文件
rocm-systems/projects/rocprofiler-compute/tests/generate_test_analyze_workloads.py
T
JoseSantosAMD 34b289e66d updating expected exit codes for pytest
Signed-off-by: JoseSantosAMD <Jose.Santos@amd.com>


[ROCm/rocprofiler-compute commit: db7d77ca3f]
2024-05-31 16:09:58 -05:00

38 行
1.2 KiB
Python

import argparse
import os
import sys
import glob
if __name__ == "__main__":
my_parser = argparse.ArgumentParser(description="create test_analyze_workloads.py")
my_parser.add_argument(
"-p", "--path", dest="path", required=True, type=str, help="Specify directory."
)
args = my_parser.parse_args()
workloads_path = args.path
workloads = glob.glob(workloads_path + "/*")
with open("test_analyze_workloads.py", "a") as f:
for workload in workloads:
workload_name = workload[workload.rfind("/") + 1 :]
archs = os.listdir(workload)
for arch in archs:
test = (
"\n\ndef test_analyze_"
+ workload_name
+ "_"
+ arch
+ "():"
+ "\n\twith pytest.raises(SystemExit) as e:"
+ "\n\t\twith patch('sys.argv',['omniperf', 'analyze', '--path', '"
+ workload
+ "/"
+ arch
+ "']):\n\t\t\tomniperf.main()"
+ "\n\tassert e.value.code == 0"
)
f.write(test)