summaryrefslogtreecommitdiff
path: root/lib/runner.py
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-03-06 07:55:21 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-03-06 07:55:21 +0100
commitdc5e758c3aeb902ccb98cd24231d041847c5a170 (patch)
tree83c9abfc24be39f179fa8564ee3f096a166cfb19 /lib/runner.py
parentb4cd5316cdfc16d9ae5d82f4e1b3b18b976fc7bd (diff)
runner: Add get_monitor, get_counter_limits helpers
Diffstat (limited to 'lib/runner.py')
-rw-r--r--lib/runner.py28
1 files changed, 28 insertions, 0 deletions
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')