tools/test-case-generator: add further filtering support

Allow a test case to be generated for a specific image type, rather than
for all at once.

This is useful when adding additional image types, rather than
regenerating the existing ones.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2020-06-07 15:04:21 +02:00
parent 83a63aaf17
commit e20919b494

View file

@ -14,12 +14,15 @@ def get_subprocess_stdout(*args, **kwargs):
return sp.stdout
def main(distro, arch, store, output):
def main(distro, arch, imageType, store, output):
with open("tools/test-case-generators/format-request-map.json") as format_request_json:
format_request_dict = json.load(format_request_json)
with open("tools/test-case-generators/repos.json") as repos_json:
repos_dict = json.load(repos_json)
for output_format, test_case_request in format_request_dict.items():
if imageType:
if imageType != test_case_request["compose-request"]["image-type"]:
continue
test_case_request["compose-request"]["distro"] = distro
test_case_request["compose-request"]["arch"] = arch
test_case_request["compose-request"]["repositories"] = repos_dict[distro][arch]
@ -34,9 +37,10 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Generate test cases")
parser.add_argument("--distro", help="distribution for test cases", required=True)
parser.add_argument("--arch", help="architecture for test cases", required=True)
parser.add_argument("--type", help="image type for test case, defaults to generate all")
parser.add_argument("--store", metavar="STORE_DIRECTORY", type=os.path.abspath, help="path to the osbuild store", required=True)
parser.add_argument("--output", metavar="OUTPUT_DIRECTORY", type=os.path.abspath, help="path to the output directory", required=True)
args = parser.parse_args()
main(args.distro, args.arch, args.store, args.output)
main(args.distro, args.arch, args.type, args.store, args.output)
sys.exit()