public inbox for bunsen@sourceware.org
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: me@serhei.io
Cc: bunsen@sourceware.org
Subject: [PATCH v2] Introduce simplified grok_architecture function
Date: Wed, 23 Sep 2020 12:15:17 -0700	[thread overview]
Message-ID: <20200923191517.1467231-1-keiths@redhat.com> (raw)
In-Reply-To: <13bf0182-8055-a2d7-bbe7-a8454a948755@redhat.com>


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


  reply	other threads:[~2020-09-23 19:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-23 13:21 Fwd: Re: [PATCH] " Serhei Makarov
2020-09-23 18:14 ` Keith Seitz
2020-09-23 19:15   ` Keith Seitz [this message]
2020-09-23 19:26     ` [PATCH v2] " Serhei Makarov
2020-09-23 19:46       ` Keith Seitz
2020-09-23 22:48         ` Serhei Makarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200923191517.1467231-1-keiths@redhat.com \
    --to=keiths@redhat.com \
    --cc=bunsen@sourceware.org \
    --cc=me@serhei.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).