app/test: disable filtering with stripped binary
[dpdk.git] / app / test / autotest_runner.py
index 7d28707..21d3be2 100644 (file)
@@ -33,7 +33,7 @@
 
 # The main logic behind running autotests in parallel
 
-import multiprocessing, sys, pexpect, time, os, StringIO, csv
+import multiprocessing, subprocess, sys, pexpect, re, time, os, StringIO, csv
 
 # wait for prompt
 def wait_prompt(child):
@@ -72,6 +72,7 @@ def run_test_group(cmdline, test_group):
                startuplog = StringIO.StringIO()
 
                print >>startuplog, "\n%s %s\n" % ("="*20, test_group["Prefix"])
+               print >>startuplog, "\ncmdline=%s" % cmdline
 
                child = pexpect.spawn(cmdline, logfile=startuplog)
 
@@ -104,6 +105,13 @@ def run_test_group(cmdline, test_group):
        results.append((0, "Success", "Start %s" % test_group["Prefix"],
                time.time() - start_time, startuplog.getvalue(), None))
 
+       # 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')
+               avail_cmds = re.findall('test_register_(\w+)', symbols)
+
        # run all tests in test group
        for test in test_group["Tests"]:
 
@@ -123,7 +131,10 @@ def run_test_group(cmdline, test_group):
                        print >>logfile, "\n%s %s\n" % ("-"*20, test["Name"])
 
                        # run test function associated with the test
-                       result = test["Func"](child, test["Command"])
+                       if stripped or test["Command"] in avail_cmds:
+                               result = test["Func"](child, test["Command"])
+                       else:
+                               result = (0, "Skipped [Not Available]")
 
                        # make a note when the test was finished
                        end_time = time.time()
@@ -400,9 +411,12 @@ class AutotestRunner:
                except:
                        print "Exception occured"
                        print sys.exc_info()
+                       self.fails = 1
 
                # drop logs from all executions to a logfile
                for buf in self.log_buffers:
                        self.logfile.write(buf.replace("\r",""))
 
                log_buffers = []
+
+               return self.fails