[PATCH v2] Introduce simplified grok_architecture function
Keith Seitz
keiths@redhat.com
Wed Sep 23 19:15:17 GMT 2020
This is a rewrite of the previous patch which includes a little more
flexibility about the architecture name mappings listed by DejaGNU.
For example, the previous version did not map "powerpc64" to "ppc64"
as the existing code did.
I've also moved the code to common/parse_dejagnu.py, but I have /not/
yet changed the systemtap version to use this. I'd like to solicit
feedback about this before I attempt to convert that.
How does this look?
Keith
---
Add a simplified and more complete architecture grok'ing function
to handle the result of the "Native configuration is ..." line from
the .log file, taking advantage of the fact that this string will
necessarily be of the form "ARCH-VENDOR-linux".
---
scripts-master/common/parse_dejagnu.py | 25 +++++++++++++++++++++++++
scripts-master/gdb/parse_dejagnu.py | 24 ++++--------------------
2 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/scripts-master/common/parse_dejagnu.py b/scripts-master/common/parse_dejagnu.py
index 335130f..674d363 100755
--- a/scripts-master/common/parse_dejagnu.py
+++ b/scripts-master/common/parse_dejagnu.py
@@ -21,6 +21,31 @@ import dateutil.parser
from bunsen import Bunsen, Testrun, Testlog, Cursor
from bunsen import Testcase
+# Standardized architecture name mapping table. The "Native configuration
+# is " line of a test run is matched against the keys in this table. If
+# a match is found, the architecture is given by the corresponding value.
+# Keys are regular expressions; values are functions which take the regexp
+# match as parameter and return a string representatin of the architecture.
+standard_architecture_map = {r'powerpc64-(\w+)-linux.*':lambda m: 'ppc64',
+ r'powerpc64le-(\w+)-linux.*':lambda m: 'ppc64le',
+ r'armv7l-(\w+)-linux-gnueabihf':lambda m: 'armhf',
+ r'(\w+)-(\w+)-linux.*':lambda m: m.group(1)}
+
+# Deduce the architecture from TEXT, which must start with the string
+# "Native configuration is ". If TEXT does not start with this string or
+# the architecture is not deduced, return None.
+
+def grok_architecture(text):
+ arch = None
+ if text.startswith("Native configuration is "):
+ text = text[len("Native configuration is "):-1]
+ for regex in standard_architecture_map:
+ match = re.match(regex, text)
+ if match:
+ arch = standard_architecture_map[regex](match)
+ break
+ return arch
+
native_configuration_map = {"i686-pc-linux-gnu":"i686",
"i686-unknown-linux-gnu":"i686",
"x86_64-unknown-linux-gnu":"x86_64",
diff --git a/scripts-master/gdb/parse_dejagnu.py b/scripts-master/gdb/parse_dejagnu.py
index 9013860..75d9cb1 100755
--- a/scripts-master/gdb/parse_dejagnu.py
+++ b/scripts-master/gdb/parse_dejagnu.py
@@ -19,6 +19,7 @@ cmdline_args = [
import sys
from bunsen import Bunsen, Testrun, Cursor
+from common.parse_dejagnu import grok_architecture
from datetime import datetime
import dateutil.parser
@@ -32,17 +33,6 @@ import lzma
# === TODO CREATE common.parse_dejagnu AND HARMONIZE WITH SYSTEMTAP ===
-native_configuration_map = {"Native configuration is i686-pc-linux-gnu":"i686",
- "Native configuration is i686-unknown-linux-gnu":"i686",
- "Native configuration is x86_64-unknown-linux-gnu":"x86_64",
- "Native configuration is powerpc64-unknown-linux-gnu":"ppc64",
- # Older systemtap logs have "Native configuration is /usr/share/dejagnu/libexec/config.guess: unable to guess system type" for ppc64le.
- "Native configuration is powerpc64le-unknown-linux-gnu":"ppc64le",
- "Native configuration is aarch64-unknown-linux-gnu":"aarch64",
- "Native configuration is armv7l-unknown-linux-gnueabihf":"armhf",
- "Native configuration is s390x-ibm-linux":"s390x",
- "Native configuration is x86_64-pc-linux-gnu":"x86_64", # seen on Ubuntu
- }
# TODO Handle other exotic DejaGNU outcome codes if they come up.
test_outcome_map = {'PASS':'PASS', 'XPASS':'XPASS', 'IPASS':'PASS',
@@ -242,7 +232,7 @@ def annotate_dejagnu_log(testrun, logfile, outcome_lines=[],
# (2) Parse the logfile and match its segments to the map of testcases.
i = None # XXX index into testcases
j = 0 # XXX index into outcome_lines
- native_configuration_is = None
+ testrun.arch = None
year_month = None
gdb_version = None
running_test = None
@@ -253,8 +243,8 @@ def annotate_dejagnu_log(testrun, logfile, outcome_lines=[],
for cur in Cursor(logfile, name=os.path.basename(logfile), input_file=f, fast_hack=True):
line = cur.line
- if line.startswith("Native configuration is"):
- native_configuration_is = line
+ if testrun.arch is None and line.startswith("Native configuration is"):
+ testrun.arch = grok_architecture(line)
if (line.startswith("Test Run By") and " on " in line) or (" completed at " in line):
if line.startswith("Test Run By"):
t1 = line.rfind(" on ") + len(" on ")
@@ -339,12 +329,6 @@ def annotate_dejagnu_log(testrun, logfile, outcome_lines=[],
last_test_cur = Cursor(start=cur); last_test_cur.line_start += 1
f.close()
- uname_machine = None
- if uname_machine is None:
- uname_machine = check_mapping(native_configuration_is,
- native_configuration_map)
-
- testrun.arch = uname_machine
# XXX testrun.osver should be extracted from buildbot repo path
testrun.version = gdb_version
testrun.year_month = year_month
--
2.26.2
More information about the Bunsen
mailing list