Skip to content

Commit 6327209

Browse files
committed
standardise cpubudget test
Signed-off-by: Jack Luar <[email protected]>
1 parent c9de451 commit 6327209

File tree

1 file changed

+11
-40
lines changed

1 file changed

+11
-40
lines changed

tools/AutoTuner/test/smoke_test_cpubudget.py

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import os
44

55
cur_dir = os.path.dirname(os.path.abspath(__file__))
6-
src_dir = os.path.join(cur_dir, "../src/autotuner")
7-
os.chdir(src_dir)
86

97

108
class BaseCPUBudgetSmokeTest(unittest.TestCase):
@@ -19,32 +17,24 @@ def setUp(self):
1917
self.experiment = f"smoke-test-cpubudget-{self.platform}"
2018

2119
# Tests should fail with such a low budget.
22-
cpu_budget = 1
23-
self.expected_timeout = cpu_budget / os.cpu_count() * 3600
20+
self.cpu_budget = 1
21+
self.expected_timeout = self.cpu_budget / os.cpu_count() * 3600
2422

2523
self.command = (
26-
"python3 distributed.py"
24+
"python3 -m autotuner.distributed"
2725
f" --design {self.design}"
2826
f" --platform {self.platform}"
2927
f" --experiment {self.experiment}"
3028
f" --config {self.config}"
31-
f" --cpu_budget 1"
29+
f" --cpu_budget {self.cpu_budget}"
3230
f" --yes"
3331
f" tune --samples 1"
3432
)
3533
self.command = self.command.split()
3634

3735
def test_cpu_budget(self):
38-
raise NotImplementedError(
39-
"This method needs to be implemented in the derivative classes."
40-
)
41-
42-
43-
class asap7CPUBudgetSmokeTest(BaseCPUBudgetSmokeTest):
44-
platform = "asap7"
45-
design = "gcd"
46-
47-
def test_cpu_budget(self):
36+
if not (self.platform and self.design):
37+
raise unittest.SkipTest("Platform and design have to be defined")
4838
try:
4939
_ = subprocess.run(
5040
self.command,
@@ -57,39 +47,20 @@ def test_cpu_budget(self):
5747
self.assertTrue(failed)
5848

5949

50+
class asap7CPUBudgetSmokeTest(BaseCPUBudgetSmokeTest):
51+
platform = "asap7"
52+
design = "gcd"
53+
54+
6055
class sky130hdCPUBudgetSmokeTest(BaseCPUBudgetSmokeTest):
6156
platform = "sky130hd"
6257
design = "gcd"
6358

64-
def test_cpu_budget(self):
65-
try:
66-
_ = subprocess.run(
67-
self.command,
68-
stderr=subprocess.PIPE,
69-
timeout=self.expected_timeout,
70-
)
71-
failed = False
72-
except subprocess.TimeoutExpired:
73-
failed = True
74-
self.assertTrue(failed)
75-
7659

7760
class ihpsg13g2CPUBudgetSmokeTest(BaseCPUBudgetSmokeTest):
7861
platform = "ihp-sg13g2"
7962
design = "gcd"
8063

81-
def test_cpu_budget(self):
82-
try:
83-
_ = subprocess.run(
84-
self.command,
85-
stderr=subprocess.PIPE,
86-
timeout=self.expected_timeout,
87-
)
88-
failed = False
89-
except subprocess.TimeoutExpired:
90-
failed = True
91-
self.assertTrue(failed)
92-
9364

9465
if __name__ == "__main__":
9566
unittest.main()

0 commit comments

Comments
 (0)