xref: /aosp_15_r20/external/pytorch/tools/code_coverage/package/oss/run.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1import os
2import time
3
4from ..tool import clang_coverage, gcc_coverage
5from ..util.setting import TestList, TestPlatform
6from ..util.utils import get_raw_profiles_folder, print_time
7from .utils import get_oss_binary_file
8
9
10def clang_run(tests: TestList) -> None:
11    start_time = time.time()
12    for test in tests:
13        # raw_file
14        raw_file = os.path.join(get_raw_profiles_folder(), test.name + ".profraw")
15        # binary file
16        binary_file = get_oss_binary_file(test.name, test.test_type)
17        clang_coverage.run_target(
18            binary_file, raw_file, test.test_type, TestPlatform.OSS
19        )
20    print_time("running binaries takes time: ", start_time, summary_time=True)
21
22
23def gcc_run(tests: TestList) -> None:
24    start_time = time.time()
25    for test in tests:
26        # binary file
27        binary_file = get_oss_binary_file(test.name, test.test_type)
28        gcc_coverage.run_target(binary_file, test.test_type)
29    print_time("run binaries takes time: ", start_time, summary_time=True)
30