Skip to content

Commit e8be123

Browse files
committed
add smoke test timeout
Signed-off-by: Jack Luar <[email protected]>
1 parent 5f57aa1 commit e8be123

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import unittest
2+
import subprocess
3+
import os
4+
5+
cur_dir = os.path.dirname(os.path.abspath(__file__))
6+
src_dir = os.path.join(cur_dir, "../src/autotuner")
7+
os.chdir(src_dir)
8+
9+
10+
class BaseTuneTimeoutTest(unittest.TestCase):
11+
platform = ""
12+
design = ""
13+
14+
def setUp(self):
15+
self.config = os.path.join(
16+
cur_dir,
17+
f"../../../flow/designs/{self.platform}/{self.design}/autotuner.json",
18+
)
19+
self.experiment = f"smoke-test-tune-{self.platform}"
20+
21+
# 0.01 hour translates to 36 seconds, which will definitely cause failure.
22+
timeout_flags = ["--timeout 0.05", "--timeout_per_trial 0.05"]
23+
self.commands = [
24+
"python3 distributed.py"
25+
f" --design {self.design}"
26+
f" --platform {self.platform}"
27+
f" --experiment {self.experiment}"
28+
f" --config {self.config}"
29+
f" {flag}"
30+
f" tune --samples 1"
31+
for flag in timeout_flags
32+
]
33+
34+
def test_trial_timeout(self):
35+
raise NotImplementedError(
36+
"This method needs to be implemented in the derivative classes."
37+
)
38+
39+
40+
class ASAP7TuneTimeoutTest(BaseTuneTimeoutTest):
41+
platform = "asap7"
42+
design = "gcd"
43+
44+
def test_trial_timeout(self):
45+
for command in self.commands:
46+
out = subprocess.run(command, shell=True, check=True)
47+
successful = out.returncode == 0
48+
self.assertFalse(successful)
49+
50+
51+
class SKY130HDTuneTimeoutTest(BaseTuneTimeoutTest):
52+
platform = "sky130hd"
53+
design = "gcd"
54+
55+
def test_trial_timeout(self):
56+
for command in self.commands:
57+
out = subprocess.run(command, shell=True, check=True)
58+
successful = out.returncode == 0
59+
self.assertFalse(successful)
60+
61+
62+
class IHPSG13G2TuneTimeoutTest(BaseTuneTimeoutTest):
63+
platform = "ihp-sg13g2"
64+
design = "gcd"
65+
66+
def test_trial_timeout(self):
67+
for command in self.commands:
68+
out = subprocess.run(command, shell=True, check=True)
69+
successful = out.returncode == 0
70+
self.assertFalse(successful)
71+
72+
73+
if __name__ == "__main__":
74+
unittest.main()

0 commit comments

Comments
 (0)