Skip to content

Commit

Permalink
fix test timeout by timeout check in subprocess.run, also fix typo in…
Browse files Browse the repository at this point in the history
… cpubudget prompt from hrs->seconds

Signed-off-by: Jack Luar <[email protected]>
  • Loading branch information
luarss committed Jan 10, 2025
1 parent 09a8224 commit bff5e2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tools/AutoTuner/src/autotuner/distributed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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),
Expand Down
19 changes: 13 additions & 6 deletions tools/AutoTuner/test/smoke_test_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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__":
Expand Down

0 comments on commit bff5e2e

Please sign in to comment.