|
44 | 44 |
|
45 | 45 |
|
46 | 46 | 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 | + """ |
50 | 51 |
|
51 | 52 | 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) |
72 | 107 |
|
73 | 108 |
|
74 | 109 | if __name__ == "__main__": |
|
0 commit comments