Skip to content

Commit

Permalink
simulation: fix expect script; add failure string
Browse files Browse the repository at this point in the history
- the syntax for the expect script wasn't quite right; now fixed.
- add a failure string for early abort where the builds support that.

Signed-off-by: Gerwin Klein <[email protected]>
  • Loading branch information
lsf37 committed Mar 15, 2024
1 parent 49c59bf commit d9f7a54
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion camkes-vm/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def run_build(manifest_dir: str, build: Build):
]

if plat.has_simulation and plat.name != 'PC99':
script.append(sim_script(build.success))
script.append(sim_script(build.success, failure=build.error))

return run_build_script(manifest_dir, build, script)

Expand Down
9 changes: 6 additions & 3 deletions seL4-platforms/builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,14 @@ def summarise_junit(file_path: str) -> Tuple[int, List[str]]:
"-q", junit_results, parsed_junit_results]


def sim_script(success: str, timeout=1200):
def sim_script(success: str, failure=None, timeout=1200):
"""Return a script to run a simulation with timeout and expected success string.
Abort early on expected failure string."""
fail_str = "%s {exit 1}" % failure if failure else ""
return [
"expect", "-c",
'spawn ./simulate; set timeout %d; expect { "%s" {exit 0} timeout {exit 1} }' %
(timeout, success)
'spawn ./simulate; set timeout %d; expect "%s" {exit 0} %s timeout {exit 1}' %
(timeout, fail_str, success)
]


Expand Down
2 changes: 1 addition & 1 deletion sel4test-sim/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def run_simulation(manifest_dir: str, build: Build):
"""Run one simulation build and test."""

expect = '{ "%s" {exit 0} timeout {exit 1} }' % build.success
expect = '"%s" {exit 0} timeout {exit 1}' % build.success

script = [
["../init-build.sh"] + build.settings_args(),
Expand Down

0 comments on commit d9f7a54

Please sign in to comment.