diff --git a/tools/regression-tests/README b/tools/regression-tests/README index cf531349eb..347488b012 100644 --- a/tools/regression-tests/README +++ b/tools/regression-tests/README @@ -48,15 +48,15 @@ The following Python packages need to be installed into an activated environment Example uses: - 1. Simple use with the provided `tools/regression-tests/config.yaml` and the `examples/` folder at the top level: + 1) Simple use with the provided `tools/regression-tests/config.yaml` and the `examples/` folder at the top level: python3 run_tests.py --lmp-bin=/path/to/lmp_binary - 2. Use a custom testing configuration + 2) Use a custom testing configuration python3 run_tests.py --lmp-bin=/path/to/lmp_binary --config-file=/path/to/config/file/config.yaml - 3. Specify a list of example folders with a modified configuration (e.g. different tolerances) + 3) Specify a list of example folders with a modified configuration (e.g. different tolerances) python3 run_tests.py --lmp-bin=/path/to/lmp_binary \ --example-folders="/path/to/examples/folder1;/path/to/examples/folder2" \ @@ -66,6 +66,15 @@ Example uses: python3 run_tests.py --lmp-bin=/path/to/lmp_binary --example-top-level=/path/to/lammps/examples + 5) Specify a list of example folders from a text file to test, writing the results to output1.xml and + logging to run1.log + + python3 run_tests.py --lmp-bin=/path/to/lmp_binary --list-input=list_subfolders1.txt \ + --output=output1.xml --logfile=run1.log + + This is used for splitting the subfolders into separate input lists and launching + different instances of run_tests.py simultaneously. + An example of the test configuration `config.yaml` is given as below. --- @@ -106,3 +115,10 @@ An example of the test configuration `config.yaml` is given as below. nugget: 1.0 epsilon: 1e-16 + +An example of the list of input scripts in a text file `list_subfolders1.txt` + +/home/codes/lammps/examples/melt +/home/codes/lammps/examples/body +/home/codes/lammps/examples/PACKAGES/dielectric +/home/codes/lammps/examples/PACKAGES/tally diff --git a/tools/regression-tests/run_tests.py b/tools/regression-tests/run_tests.py index 71526ba8bf..ce3645f166 100644 --- a/tools/regression-tests/run_tests.py +++ b/tools/regression-tests/run_tests.py @@ -598,6 +598,7 @@ if __name__ == "__main__": verbose = False output_file = "output.xml" log_file = "run.log" + list_input = "" dry_run = False # distribute the total number of input scripts over the workers @@ -610,6 +611,7 @@ if __name__ == "__main__": help="Configuration YAML file") parser.add_argument("--example-top-level", dest="example_toplevel", default="", help="Example top-level") parser.add_argument("--example-folders", dest="example_folders", default="", help="Example subfolders") + parser.add_argument("--list-input", dest="list_input", default="", help="File that lists the subfolders") parser.add_argument("--num-workers", dest="num_workers", default=1, help="Number of workers") parser.add_argument("--gen-ref",dest="genref", action='store_true', default=False, help="Generating reference data") @@ -620,7 +622,7 @@ if __name__ == "__main__": parser.add_argument("--output",dest="output", default=output_file, help="Output file") parser.add_argument("--logfile",dest="logfile", default=log_file, help="Log file") parser.add_argument("--dry-run",dest="dry_run", action='store_true', default=False, - help="Only report statistics") + help="Only report statistics, not running the tests") args = parser.parse_args() @@ -628,13 +630,14 @@ if __name__ == "__main__": configFileName = args.config_file output_file = args.output num_workers = args.num_workers + list_input = args.list_input # example_toplevel is where all the examples subfolders reside if args.example_toplevel != "": example_toplevel = args.example_toplevel if args.example_folders != "": example_subfolders = args.example_folders.split(';') - + genref = args.genref verbose = args.verbose log_file = args.logfile @@ -671,7 +674,7 @@ if __name__ == "__main__": for p in packages: all_pkgs += p + " " print(all_pkgs) - + if len(example_subfolders) > 0: print("\nExample folders to test:") print(example_subfolders) @@ -679,23 +682,6 @@ if __name__ == "__main__": print("\nTop-level example folder:") print(example_toplevel) - folder_list = [] - if len(example_toplevel) != 0: - # getting the list of all the input files because there are subfolders (e.g. PACKAGES) under the top level - cmd_str = f"find {example_toplevel} -name \"in.*\" " - p = subprocess.run(cmd_str, shell=True, text=True, capture_output=True) - input_list = p.stdout.split('\n') - input_list.remove("") - - # find out which folder to cd into to run the input script - for input in input_list: - folder = input.rsplit('/', 1)[0] - folder_list.append(folder) - print(f"There are {len(input_list)} input scripts in total under the {example_toplevel} folder.") - - # divide the list of input scripts into num_workers chunks - sublists = divide_into_N(input_list, num_workers) - # if only statistics, not running anything if dry_run == True: quit() @@ -705,11 +691,26 @@ if __name__ == "__main__": test_cases = [] # if the example folders are not specified from the command-line argument --example-folders - # then use the path from --example-top-folder + # then use the path from --example-top-folder, or from the input-list read from a text file if len(example_subfolders) == 0: # need top level specified if len(example_toplevel) != 0: + # getting the list of all the input files because there are subfolders (e.g. PACKAGES) under the top level + cmd_str = f"find {example_toplevel} -name \"in.*\" " + p = subprocess.run(cmd_str, shell=True, text=True, capture_output=True) + input_list = p.stdout.split('\n') + input_list.remove("") + + # find out which folder to cd into to run the input script + for input in input_list: + folder = input.rsplit('/', 1)[0] + example_subfolders.append(folder) + print(f"There are {len(input_list)} input scripts in total under the {example_toplevel} folder.") + + # divide the list of input scripts into num_workers chunks + sublists = divide_into_N(input_list, num_workers) + # get the input file list, for now the first in the sublist # TODO: generate a list of tuples, each tuple contains a folder list for a worker, # then use multiprocessing.Pool starmap() @@ -722,8 +723,18 @@ if __name__ == "__main__": example_subfolders = folder_list + # if a list of input files are provided + elif len(list_input) != 0: + print(f"List folders from file: {list_input} {len(list_input)}") + with open(list_input, "r") as f: + all_subfolders = f.read().splitlines() + f.close() + for folder in all_subfolders: + if len(folder) > 0: + example_subfolders.append(folder) + else: - inplace_input = False + inplace_input = False all_results = []