From dc5e758c3aeb902ccb98cd24231d041847c5a170 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 6 Mar 2019 07:55:21 +0100 Subject: runner: Add get_monitor, get_counter_limits helpers --- lib/runner.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib/runner.py') diff --git a/lib/runner.py b/lib/runner.py index 9a6022d..99061a3 100644 --- a/lib/runner.py +++ b/lib/runner.py @@ -4,6 +4,7 @@ Utilities for running benchmarks. Foo. """ +import re import serial import serial.threaded import subprocess @@ -86,3 +87,30 @@ class ShellMonitor: def close(self): pass +def get_info(arch, opts = []): + command = ['make', 'arch={}'.format(arch), 'info'] + command.extend(opts) + res = subprocess.run(command, stdout = subprocess.PIPE, stderr = subprocess.PIPE, + universal_newlines = True) + if res.returncode != 0: + raise RuntimeError('make info Failure') + return res.stdout.split('\n') + +def get_monitor(arch): + for line in get_info(arch): + if 'Monitor:' in line: + _, port, arg = line.split(' ') + if port == 'run': + return ShellMonitor(arg) + else: + return SerialMonitor(port, arg) + raise RuntimeError('Monitor failure') + +def get_counter_limits(arch): + for line in get_info(arch): + match = re.match('Counter Overflow: ([^/]*)/(.*)', line) + if match: + overflow_value = int(match.group(1)) + max_overflow = int(match.group(2)) + return overflow_value, max_overflow + raise RuntimeError('Did not find Counter Overflow limits') -- cgit v1.2.3