Skip to content

Commit aba1480

Browse files
authored
Merge pull request #3145 from jeffng-or/at-updated-ref-file-check
Re-worked ref_file_check.py to test specific error conditions
2 parents 00d5ce5 + 34999b4 commit aba1480

File tree

2 files changed

+59
-24
lines changed

2 files changed

+59
-24
lines changed

flow/test/test_autotuner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ python3 -m unittest tools.AutoTuner.test.smoke_test_algo_eval.${PLATFORM_WITHOUT
2727

2828
if [ "$PLATFORM_WITHOUT_DASHES" == "asap7" ] && [ "$DESIGN_NAME" == "gcd" ]; then
2929
echo "Running Autotuner ref file test (only once)"
30-
python3 -m unittest tools.AutoTuner.test.ref_file_check.RefFileCheck.test_files
30+
python3 -m unittest tools.AutoTuner.test.ref_file_check.RefFileCheck
3131

3232
echo "Running AutoTuner resume test (only once)"
3333
# Temporarily disable resume check test due to flakiness

tools/AutoTuner/test/ref_file_check.py

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,66 @@
4444

4545

4646
class RefFileCheck(unittest.TestCase):
47-
# only test 1 platform/design.
48-
platform = "asap7"
49-
design = "gcd"
47+
"""
48+
Tests situations where a referenced file (SDC or FastRoute) is not
49+
defined in the AutoTuner config
50+
"""
5051

5152
def setUp(self):
52-
configs = [
53-
"../../test/files/no_sdc_ref.json",
54-
"../../test/files/no_fr_ref.json",
55-
]
56-
self.exec = AutoTunerTestUtils.get_exec_cmd()
57-
self.commands = [
58-
f"{self.exec}"
59-
f" --design {self.design}"
60-
f" --platform {self.platform}"
61-
f" --config {c}"
62-
f" tune --samples 1"
63-
for c in configs
64-
]
65-
66-
# Make this a test case
67-
def test_files(self):
68-
for c in self.commands:
69-
out = subprocess.run(c, shell=True)
70-
failed = out.returncode != 0
71-
self.assertTrue(failed)
53+
self._cur_dir = os.path.dirname(os.path.abspath(__file__))
54+
src_dir = os.path.join(self._cur_dir, "../src")
55+
os.chdir(src_dir)
56+
57+
self._exec = AutoTunerTestUtils.get_exec_cmd()
58+
59+
def _execute_autotuner(self, platform, design, config_file, error_code=None):
60+
full_path = os.path.abspath(os.path.join(self._cur_dir, config_file))
61+
62+
cmd = f"{self._exec} --design {design} --platform {platform} --config {full_path} tune --samples 1"
63+
64+
out = subprocess.run(cmd, shell=True, text=True, capture_output=True)
65+
failed = out.returncode != 0
66+
self.assertTrue(failed, f"AT run with {config_file} passed")
67+
if error_code:
68+
self.assertTrue(
69+
error_code in out.stdout,
70+
f"Didn't find error code {error_code} in output '{out.stdout}'",
71+
)
72+
73+
def test_asap_gcd_no_sdc(self):
74+
"""
75+
Tests when SDC file is not defined, which is an error for all
76+
platforms and designs
77+
"""
78+
79+
platform = "asap7"
80+
design = "gcd"
81+
config_file = "files/no_sdc_ref.json"
82+
error_code = "[ERROR TUN-0020] No SDC reference"
83+
self._execute_autotuner(platform, design, config_file, error_code)
84+
85+
def test_asap_gcd_no_fr(self):
86+
"""
87+
Tests when FastRoute file is not defined, which is not an error for
88+
asap platform. This test fails anyway
89+
"""
90+
91+
platform = "asap7"
92+
design = "gcd"
93+
config_file = "files/no_fr_ref.json"
94+
self._execute_autotuner(platform, design, config_file)
95+
96+
def test_ihp_gcd_no_fr(self):
97+
"""
98+
Tests when FastRoute file is not defined, which is not an error for
99+
any non-asap7 platform.
100+
"""
101+
102+
platform = "ihp-sg13g2"
103+
design = "gcd"
104+
config_file = "files/no_fr_ref.json"
105+
error_code = "[ERROR TUN-0021] No FastRoute Tcl"
106+
self._execute_autotuner(platform, design, config_file, error_code)
72107

73108

74109
if __name__ == "__main__":

0 commit comments

Comments
 (0)