Skip to content

Commit

Permalink
corstone300: catch exit code of simulation and fix validate feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp v. K committed Jun 15, 2022
1 parent f37f7ea commit 187d7f9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
16 changes: 13 additions & 3 deletions mlonmcu/target/corstone300.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,20 @@ def exec(self, program, *args, cwd=os.getcwd(), **kwargs):
)
return ret

def parse_stdout(self, out):
def parse_stdout(self, out, handle_exit=None):
exit_match = re.search(r"Application exit code: (.*)\.", out)
if exit_match:
exit_code = int(exit_match.group(1))
if handle_exit is not None:
exit_code = handle_exit(exit_code)
if exit_code != 0:
logger.error("Execution failed - " + out)
raise RuntimeError(f"unexpected exit code: {exit_code}")
cpu_cycles = re.search(r"Total Cycles: (.*)", out)

if not cpu_cycles:
logger.warning("unexpected script output (cycles)")
if exit == 0:
logger.warning("unexpected script output (cycles)")
cycles = None
else:
cycles = int(float(cpu_cycles.group(1)))
Expand All @@ -172,7 +182,7 @@ def get_metrics(self, elf, directory, handle_exit=None, num=None):
out += self.exec(
elf, cwd=directory, live=False, print_func=lambda *args, **kwargs: None, handle_exit=handle_exit
)
cycles = self.parse_stdout(out)
cycles = self.parse_stdout(out, handle_exit=handle_exit)

metrics = Metrics()
metrics.add("Total Cycles", cycles)
Expand Down
6 changes: 4 additions & 2 deletions mlonmcu/target/etiss_pulpino.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,15 @@ def parse_stdout(self, out, handle_exit=None):

cpu_cycles = re.search(r"CPU Cycles \(estimated\): (.*)", out)
if not cpu_cycles:
logger.warning("unexpected script output (cycles)")
if exit_code == 0:
logger.warning("unexpected script output (cycles)")
cycles = None
else:
cycles = int(float(cpu_cycles.group(1)))
mips_match = re.search(r"MIPS \(estimated\): (.*)", out)
if not mips_match:
raise logger.warning("unexpected script output (mips)")
if exit_code == 0:
raise logger.warning("unexpected script output (mips)")
mips = None
else:
mips = int(float(mips_match.group(1)))
Expand Down
2 changes: 1 addition & 1 deletion resources/templates/default.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repos:
ref: 4a52cabc5830b4666589d4c63f3a228eef5b4efb
mlif:
url: "https://github.com/tum-ei-eda/mlonmcu-sw.git"
ref: a8d9a3f280de664cb0e611cc06b9fd13238d49d3
ref: f9e67c6870c92aee1c003c1ac65be113b889f9fd
espidf:
url: "https://github.com/espressif/esp-idf.git"
ref: release/v4.4
Expand Down
2 changes: 1 addition & 1 deletion resources/templates/minimal.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repos:
ref: 4a52cabc5830b4666589d4c63f3a228eef5b4efb
mlif:
url: "https://github.com/tum-ei-eda/mlonmcu-sw.git"
ref: a8d9a3f280de664cb0e611cc06b9fd13238d49d3
ref: f9e67c6870c92aee1c003c1ac65be113b889f9fd
espidf:
url: "https://github.com/espressif/esp-idf.git"
ref: release/v4.4
Expand Down

0 comments on commit 187d7f9

Please sign in to comment.