This script generates json test cases for each supported output format. It requires an architecure, distro, osbuild store, and output directory as input. There is also a json object which maps from output format to a test case request which includes the compose request and boot type. The script uses these test case requests to call the generate-test-case script and then outputs the resulting json test cases to files in the specified output directory.
31 lines
1.5 KiB
Python
Executable file
31 lines
1.5 KiB
Python
Executable file
#!/usr/bin/python3
|
|
|
|
import argparse
|
|
import subprocess
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
def main(distro, arch, store, output):
|
|
with open("tools/test-case-generators/format-request-map.json") as format_request_json:
|
|
format_request_dict = json.load(format_request_json)
|
|
for output_format, test_case_request in format_request_dict.items():
|
|
test_case_request["compose-request"]["distro"] = distro
|
|
test_case_request["compose-request"]["arch"] = arch
|
|
test_case = json.loads(subprocess.check_output(["tools/test-case-generators/generate-test-case", store], input=json.dumps(test_case_request), encoding="utf-8"))
|
|
name = distro.replace("-", "_") + "-" + arch + "-" + output_format.replace("-", "_") + "-boot.json"
|
|
file_name = output + "/" + name
|
|
with open(file_name, 'w') as case_file:
|
|
json.dump(test_case, case_file, indent=2)
|
|
return
|
|
|
|
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("--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)
|
|
sys.exit()
|