Skip to content

Commit 75b7212

Browse files
oharboeclaude
andcommitted
test: run-me runs the step's tool on the step's script
The run-me script has been fixed for each of these: it finds the step's script through the unpacked archive's SCRIPTS_DIR, not the path of the flow that made it (#1410); the script is named after the step, not the WORK_HOME path makeIssue is given (#3466); openroad gets the flow's thread count (#3870); a synthesis step runs yosys, not openroad (#4129). The tests check each in run-me's text, check that the flow's own synthesis scripts are recognised as yosys steps and the others as openroad steps, and run an archive's run-me to see that it starts the step's script under ./scripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 91638fd commit 75b7212

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

‎flow/test/test_make_issue.py‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,5 +338,58 @@ def test_every_file_variable_is_read_by_the_flow(self):
338338
self.assertEqual(unread, [])
339339

340340

341+
class TestRunMeScript(StubFlowTestCase):
342+
"""The run-me script runs the step's tool on the step's script from
343+
the unpacked archive: the script is found through the archive's own
344+
SCRIPTS_DIR, not the path of the flow that made it (#1410), it is
345+
named after the step and not after the WORK_HOME path makeIssue is
346+
given (#3466), openroad gets the flow's thread count (#3870), and a
347+
synthesis step runs yosys, not openroad (#4129)."""
348+
349+
SCRIPTS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "scripts")
350+
351+
def text(self, yosys, **env):
352+
return makeIssue.run_me_text(env, "cts", "/abs/work/vars-x", yosys)
353+
354+
def test_script_found_through_the_archive_scripts_dir(self):
355+
text = self.text(False)
356+
self.assertIn("${SCRIPTS_DIR}/cts.tcl", text)
357+
self.assertNotIn(self.SCRIPTS, text)
358+
359+
def test_vars_sourced_next_to_run_me(self):
360+
text = self.text(False)
361+
self.assertIn('cd "$(dirname "$0")"', text)
362+
self.assertIn("source ./vars-x.sh", text)
363+
self.assertNotIn("/abs/work", text)
364+
365+
def test_openroad_threads(self):
366+
self.assertIn("-threads 8 ", self.text(False, NUM_CORES="8"))
367+
self.assertIn("-threads 1 ", self.text(False))
368+
369+
def test_gdb_on_request(self):
370+
self.assertIn("gdb --args openroad", self.text(False))
371+
372+
def test_yosys_step_runs_yosys(self):
373+
text = self.text(True, YOSYS_FLAGS="-v 3")
374+
self.assertIn("yosys -v 3 -c ${SCRIPTS_DIR}/cts.tcl", text)
375+
self.assertNotIn("openroad", text)
376+
377+
def test_the_flow_scripts_pick_their_tool(self):
378+
def tool(script):
379+
path = os.path.join(self.SCRIPTS, script + ".tcl")
380+
return "yosys" if makeIssue.is_yosys_step(path) else "openroad"
381+
382+
for script in ["synth", "synth_canonicalize"]:
383+
self.assertEqual(tool(script), "yosys", script)
384+
for script in ["floorplan", "global_place", "cts", "global_route"]:
385+
self.assertEqual(tool(script), "openroad", script)
386+
387+
def test_step_named_after_the_target_not_its_path(self):
388+
archive = self.stub.make_issue(os.path.join(self.stub.tmp, "work"))
389+
recorded = self.stub.run_me(self.stub.unpack(archive))
390+
self.assertEqual(os.path.basename(recorded["script"]), STEP + ".tcl")
391+
self.assertTrue(recorded["script"].startswith("./scripts/"), recorded)
392+
393+
341394
if __name__ == "__main__":
342395
unittest.main()

0 commit comments

Comments
 (0)