Skip to content
Permalink
Browse files

scripts/sanitycheck: Precompile test-time regular expressions

The Harness handlers for tests were parsing the realtime stream out of
qemu pipes by recompiling and executing every regex for every line (!)
of output from the simulator.  That's a significant CPU load, and it's
(1) in a separate thread not tracked by the JOBS limit and (2)
happening at the worst possible time and contending with the qemu
process for host CPU cycles that it needs to hit its (real world)
timer targets on time.

Compile them just once, please.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
  • Loading branch information...
andyross authored and nashif committed Mar 6, 2019
1 parent 7fdb525 commit aa2b8a1bc718917fb9693316cb26259d802849ad
Showing with 16 additions and 7 deletions.
  1. +16 −7 scripts/sanity_chk/harness.py
@@ -2,6 +2,8 @@
import re
from collections import OrderedDict

result_re = re.compile("(PASS|FAIL|SKIP) - (test_)?(.*)")

class Harness:
GCOV_START = "GCOV_COVERAGE_DUMP_START"
GCOV_END = "GCOV_COVERAGE_DUMP_END"
@@ -41,15 +43,23 @@ def configure(self, instance):

class Console(Harness):

def configure(self, instance):
super(Console, self).configure(instance)
if self.type == "one_line":
self.pattern = re.compile(self.regex[0])
elif self.type == "multi_line":
self.patterns = []
for r in self.regex:
self.patterns.append(re.compile(r))

def handle(self, line):

if self.type == "one_line":
pattern = re.compile(self.regex[0])
if pattern.search(line):
if self.pattern.search(line):
self.state = "passed"
elif self.type == "multi_line":
for r in self.regex:
pattern = re.compile(r)
for i, pattern in enumerate(self.patterns):
r = self.regex[i]
if pattern.search(line) and not r in self.matches:
self.matches[r] = line

@@ -85,14 +95,13 @@ def handle(self, line):
else:
self.tests[self.id] = "FAIL"


class Test(Harness):
RUN_PASSED = "PROJECT EXECUTION SUCCESSFUL"
RUN_FAILED = "PROJECT EXECUTION FAILED"


def handle(self, line):
result = re.compile("(PASS|FAIL|SKIP) - (test_)?(.*)")
match = result.match(line)
match = result_re.match(line)
if match:
name = "{}.{}".format(self.id, match.group(3))
self.tests[name] = match.group(1)

0 comments on commit aa2b8a1

Please sign in to comment.
You can’t perform that action at this time.