From c15d6ed30f59c510ecd91224ae954584e768e10a Mon Sep 17 00:00:00 2001 From: Jack Luar Date: Sat, 19 Oct 2024 15:36:10 +0000 Subject: [PATCH] fix test timeout by timeout check in subprocess.run, also fix typo in cpubudget prompt from hrs->seconds Signed-off-by: Jack Luar --- tools/AutoTuner/src/autotuner/distributed.py | 4 ++-- tools/AutoTuner/test/smoke_test_timeout.py | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/AutoTuner/src/autotuner/distributed.py b/tools/AutoTuner/src/autotuner/distributed.py index 3674040495..4a7cdbbd2e 100644 --- a/tools/AutoTuner/src/autotuner/distributed.py +++ b/tools/AutoTuner/src/autotuner/distributed.py @@ -67,7 +67,7 @@ TEMPLATE = """ Expected figures for this experiment. - Wall time: {runtime:.5f} hours + Wall time: {runtime:.5f} seconds Number of Samples: Samples per minute: {num_samples_per_minute:.5f} Design runtime of 10 min: {num_samples_10min:.5f} @@ -79,7 +79,7 @@ def calculate_expected_numbers(runtime, num_samples): - # Runtime - hours + # Runtime - seconds return TEMPLATE.format( runtime=runtime, num_samples_per_minute=num_samples / (runtime * 60), diff --git a/tools/AutoTuner/test/smoke_test_timeout.py b/tools/AutoTuner/test/smoke_test_timeout.py index 7282714fe7..5560f66510 100644 --- a/tools/AutoTuner/test/smoke_test_timeout.py +++ b/tools/AutoTuner/test/smoke_test_timeout.py @@ -20,6 +20,7 @@ def setUp(self): # 0.001 hour translates to 3.6 seconds, which will definitely cause failure. timeout_flags = ["--timeout 0.001", "--timeout_per_trial 0.001"] + self.timeout_limit = 15 # 15 second upper limit self.commands = [ "python3 distributed.py" f" --design {self.design}" @@ -45,9 +46,11 @@ class ASAP7TimeoutSmokeTest(BaseTimeoutSmokeTest): def test_timeout(self): for command in self.commands: - out = subprocess.run(command, shell=True, check=True) + out = subprocess.run( + command, shell=True, check=True, timeout=self.timeout_limit + ) successful = out.returncode == 0 - self.assertFalse(successful) + self.assertTrue(successful) class SKY130HDTimeoutSmokeTest(BaseTimeoutSmokeTest): @@ -56,9 +59,11 @@ class SKY130HDTimeoutSmokeTest(BaseTimeoutSmokeTest): def test_timeout(self): for command in self.commands: - out = subprocess.run(command, shell=True, check=True) + out = subprocess.run( + command, shell=True, check=True, timeout=self.timeout_limit + ) successful = out.returncode == 0 - self.assertFalse(successful) + self.assertTrue(successful) class IHPSG13G2TimeoutSmokeTest(BaseTimeoutSmokeTest): @@ -67,9 +72,11 @@ class IHPSG13G2TimeoutSmokeTest(BaseTimeoutSmokeTest): def test_timeout(self): for command in self.commands: - out = subprocess.run(command, shell=True, check=True) + out = subprocess.run( + command, shell=True, check=True, timeout=self.timeout_limit + ) successful = out.returncode == 0 - self.assertFalse(successful) + self.assertTrue(successful) if __name__ == "__main__":