harness: cleanup tests to not override is_finished() where possible
authorSimon Gerber <simon.gerber@inf.ethz.ch>
Wed, 10 May 2017 13:49:33 +0000 (15:49 +0200)
committerSimon Gerber <simon.gerber@inf.ethz.ch>
Fri, 2 Jun 2017 07:10:35 +0000 (09:10 +0200)
If is_finished() cannot be converted into get_finish_string(), i.e.
is_finished() is a condition that depends on multiple output lines make sure
we call super().is_finished(line) on every line so that we catch Assertion
errors etc. that are checked for in TestCommon.is_finished().

Signed-off-by: Simon Gerber <simon.gerber@inf.ethz.ch>

13 files changed:
tools/harness/tests/TimerTest.py
tools/harness/tests/basicNetwork.py
tools/harness/tests/blk_tests.py
tools/harness/tests/caps_next.py
tools/harness/tests/devif_test.py
tools/harness/tests/echoserver.py
tools/harness/tests/irqtest.py
tools/harness/tests/memtest.py
tools/harness/tests/mt_waitset.py
tools/harness/tests/spantest.py
tools/harness/tests/spawntest.py
tools/harness/tests/webserver.py
tools/harness/tests/xeonphi.py

index a2e4c72..ad86dac 100644 (file)
@@ -46,9 +46,8 @@ class TimerTest(TestCommon):
             self.saw_line_A = True
         if line.startswith(self.get_test_B_finish_string()):
             self.saw_line_B = True
-        if self.saw_line_A and self.saw_line_B:
-            return True
-        return False
+        return (self.saw_line_A and self.saw_line_B) or \
+                super(TimerTest, self).is_finished(line)
     
 
     
@@ -69,7 +68,4 @@ class TimerTest(TestCommon):
             if test_A_passed and test_B_passed:
                 return PassFailResult(True)
 
-        if test_A_passed and test_B_passed:
-            return PassFailResult(True)
-        else:
-            return PassFailResult(False)
+        return PassFailResult(test_A_passed and test_B_passed)
index 97336fc..8581158 100644 (file)
@@ -41,7 +41,6 @@ class NetCommon(TestCommon):
     def setup(self, build, machine, testdir):
         super(NetCommon, self).setup(build, machine, testdir)
         self.testdir = testdir
-        self.finished = False
         self.ip = None
         self.traceLogsON = False
         self.traceLogs = []
@@ -68,15 +67,12 @@ class NetCommon(TestCommon):
         if line.startswith('dump trac buffers: Start') :
             self.traceLogsON = True
         elif line.startswith('dump trac buffers: Stop') :
-            self.finished = True
             self.traceLogsON = False
         elif  self.traceLogsON :
             self.traceLogs.append(line);
 
-
-    def is_finished(self, line):
-        return self.finished
-
+    def get_finish_string(self):
+        return 'dump trac buffers: Stop'
 
 @tests.add_test
 class NetdTraceTest(NetCommon):
index 752c97b..41930d3 100644 (file)
@@ -236,8 +236,8 @@ class BlkTests(TestCommon):
 
         return modules
 
-    def is_finished(self, line):
-        return line.startswith("AHCI testing completed.")
+    def get_finish_string(self):
+        return "AHCI testing completed."
 
     def process_data(self, testdir, rawiter):
         self.regex = re.compile(self.REGEX)
index bd786ab..8686985 100644 (file)
@@ -45,7 +45,7 @@ class RetypeMultiTest(TestCommon):
     def is_finished(self, line):
         if line.startswith("retype: result:"):
             self._nseen += 1
-        return self._nseen == self._ncores
+        return self._nseen == self._ncores or super(RetypeMultiTest, self).is_finished(line)
 
     def process_data(self, testdir, rawiter):
         # the test passed iff the last line is the finish string
index f58a53b..5595dff 100644 (file)
@@ -37,8 +37,8 @@ class DevifTests(TestCommon):
 
         return modules
 
-    def is_finished(self, line):
-        return line.startswith("SUCCESS")
+    def get_finish_string(self):
+        return "SUCCESS"
 
     def process_data(self, testdir, rawiter):
         passed = False
index 63ee2e1..19babfa 100644 (file)
@@ -48,7 +48,7 @@ class EchoTestCommon(TestCommon):
             self.finished = True
 
     def is_finished(self, line):
-        return self.finished
+        return self.finished or super(EchoTestCommon, self).is_finished(line)
 
     def get_ipbench_test(self):
         return (IPBENCH_TEST, IPBENCH_TEST_ARGS)
index 0065c12..a34ee64 100644 (file)
@@ -26,8 +26,8 @@ class IRQTest(TestCommon):
         modules.add_module("e1000n_irqtest", ["auto"])
         return modules
 
-    def is_finished(self, line):
-        return line.startswith("TEST ") 
+    def get_finish_string(self):
+        return "TEST "
     
     def process_data(self, testdir, rawiter):
         for line in rawiter:
index b1037d7..c111b2f 100644 (file)
@@ -54,7 +54,7 @@ class MemTestMulti(TestCommon):
         # XXX: count number of times we have seen the finish string
         if line.startswith("memtest passed successfully!"):
             self._nseen += 1
-        return self._nseen == self._ncores
+        return self._nseen == self._ncores or super(MemTestMulti, self).is_finished(line)
 
     def process_data(self, testdir, rawiter):
         nspawned = nseen = 0
index f4d009e..65c8794 100644 (file)
@@ -29,8 +29,9 @@ class MultithreadedWaitsetTest(TestCommon):
         modules.add_module("mt_waitset", ["10", "10", "10000"])
         return modules
 
-    def is_finished(self, line):
-        return "Test PASSED" in line or "Test FAILED" in line
+    def get_finish_string(self):
+        # Finish line is "Test PASSED" or "Test FAILED"
+        return "Test "
 
     def process_data(self, testdir, rawiter):
         passed = False
index bd554b8..5abea00 100644 (file)
@@ -24,10 +24,6 @@ class SpanTest(TestCommon):
     def setup(self, build, machine, testdir):
         super(SpanTest, self).setup(build, machine, testdir)
 
-        # XXX: track number of cores booted and seen for is_finished()
-        self._ncores = machine.get_ncores()
-        self._nseen = 0
-
     def get_modules(self, build, machine):
         modules = super(SpanTest, self).get_modules(build, machine)
         # span on all cores other than 0 -- matches spantest code
@@ -35,7 +31,7 @@ class SpanTest(TestCommon):
         return modules
 
     def is_finished(self, line):
-        return re.match(MATCH, line)
+        return re.match(MATCH, line) or super(SpanTest, self).is_finished(line)
 
     def process_data(self, testdir, rawiter):
         result = False
@@ -52,18 +48,14 @@ class SpanTestInterleaved(TestCommon):
     def setup(self, build, machine, testdir):
         super(SpanTestInterleaved, self).setup(build, machine, testdir)
 
-        # XXX: track number of cores booted and seen for is_finished()
-        self._ncores = machine.get_ncores()
-        self._nseen = 0
-
     def get_modules(self, build, machine):
         modules = super(SpanTestInterleaved, self).get_modules(build, machine)
         # span on all cores other than 0 -- matches spantest code
         modules.add_module("tests/span-interleaved", [ machine.get_ncores() ])
         return modules
 
-    def is_finished(self, line):
-        return re.search('SPAN_TEST_SUCCESS.', line)
+    def get_finish_string(self):
+        return 'SPAN_TEST_SUCCESS.'
 
     def process_data(self, testdir, rawiter):
         result = False
@@ -82,10 +74,6 @@ class SpanTestExit(TestCommon):
     def setup(self, build, machine, testdir):
         super(SpanTestExit, self).setup(build, machine, testdir)
 
-        # XXX: track number of cores booted and seen for is_finished()
-        self._ncores = machine.get_ncores()
-        self._nseen = 0
-
     def get_modules(self, build, machine):
         modules = super(SpanTestExit, self).get_modules(build, machine)
         # span on all cores other than 0 -- matches spantest code
@@ -95,7 +83,8 @@ class SpanTestExit(TestCommon):
     def is_finished(self, line):
         if re.search('SPAN_TEST_DONE.', line) :
             self.is_done = True
-        return re.match('kernel [0-9]*: user page fault WHILE DISABLED', line) 
+        return re.match('kernel [0-9]*: user page fault WHILE DISABLED', line) or \
+                super(SpanTestExit, self).is_finished(line)
 
     def process_data(self, testdir, rawiter):
         result = True
index 9e6d1cc..15271f5 100644 (file)
@@ -36,7 +36,7 @@ class SpawnTest(TestCommon):
     def is_finished(self, line):
         if re.match(MATCH, line):
             self._nseen += 1
-        return self._nseen == (NUM_SPAWNS + 1)
+        return self._nseen == (NUM_SPAWNS + 1) or super(SpawnTest, self).is_finished(line)
 
     def process_data(self, testdir, rawiter):
         nspawned = 0
index 6e6338f..8e60e73 100644 (file)
@@ -91,7 +91,7 @@ class WebCommon(TestCommon):
         return len(self.server_failures) == 0
 
     def is_finished(self, line):
-        return self.finished
+        return self.finished or super(WebCommon, self).is_finished(line)
 
 
 @tests.add_test
index c7914a9..449a62d 100644 (file)
@@ -111,16 +111,8 @@ class XeonPhi_Boot_Test(TestCommon):
 
         return modules
 
-    def is_finished(self, line):
-        #m = re.search("Xeon Phi operational: xeon_phi.([0-9]).ready", line)
-        m = re.search("Xeon Phi operational: xeon_phi." + str(self.nphi - 1) + ".ready", line)
-        if m :
-            return True
-        else :
-            return False        
-
     def get_finish_string(self):
-        return "Xeon Phi operational: xeon_phi.([0-9]).ready"
+        return "Xeon Phi operational: xeon_phi." + str(self.nphi - 1) + ".ready"
 
     def boot(self, *args):
         super(XeonPhi_Boot_Test, self).boot(*args)