test: load test symbols from binary at init
authorDavid Marchand <david.marchand@redhat.com>
Mon, 29 Apr 2019 14:28:36 +0000 (16:28 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Sat, 4 May 2019 21:02:58 +0000 (23:02 +0200)
Rather than call nm on the test application binary for each test to
consider, call it once at the object init.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Aaron Conole <aconole@redhat.com>
app/test/autotest_runner.py

index 36941a4..b72716e 100644 (file)
@@ -192,7 +192,6 @@ class AutotestRunner:
     def __init__(self, cmdline, target, blacklist, whitelist, n_processes):
         self.cmdline = cmdline
         self.target = target
-        self.binary = cmdline.split()[0]
         self.blacklist = blacklist
         self.whitelist = whitelist
         self.skipped = []
@@ -201,6 +200,16 @@ class AutotestRunner:
         self.n_processes = n_processes
         self.active_processes = 0
 
+        # parse the binary for available test commands
+        binary = cmdline.split()[0]
+        stripped = 'not stripped' not in \
+                   subprocess.check_output(['file', binary])
+        if not stripped:
+            symbols = subprocess.check_output(['nm', binary]).decode('utf-8')
+            self.avail_cmds = re.findall('test_register_(\w+)', symbols)
+        else:
+            self.avail_cmds = None
+
         # log file filename
         logfile = "%s.log" % target
         csvfile = "%s.csv" % target
@@ -275,20 +284,10 @@ class AutotestRunner:
             return False
 
         # if test wasn't compiled in, remove it as well
-
-        # parse the binary for available test commands
-        stripped = 'not stripped' not in \
-                   subprocess.check_output(['file', self.binary])
-        if not stripped:
-            symbols = subprocess.check_output(['nm',
-                                               self.binary]).decode('utf-8')
-            avail_cmds = re.findall('test_register_(\w+)', symbols)
-
-            if test_cmd not in avail_cmds:
-                # notify user
-                result = 0, "Skipped [Not compiled]", test_id, 0, "", None
-                self.skipped.append(tuple(result))
-                return False
+        if self.avail_cmds and test_cmd not in self.avail_cmds:
+            result = 0, "Skipped [Not compiled]", test_id, 0, "", None
+            self.skipped.append(tuple(result))
+            return False
 
         return True