tests: don't prompt to launch gdb for sanity test case 84/24084/2
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Thu, 19 Dec 2019 21:09:43 +0000 (16:09 -0500)
committerNeale Ranns <nranns@cisco.com>
Fri, 20 Dec 2019 04:09:09 +0000 (04:09 +0000)
Type: test

Change-Id: I4c54121b76b341381a819cee928c3c2455a83503
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Makefile
test/Makefile
test/framework.py
test/run_tests.py
test/sanity_run_vpp.py

index 8084d82..e580a31 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -398,6 +398,7 @@ rebuild-release: wipe-release build-release
 libexpand = $(subst $(subst ,, ),:,$(foreach lib,$(1),$(BR)/install-$(2)-native/vpp/$(lib)/$(3)))
 
 export TEST_DIR ?= $(WS_ROOT)/test
+export RND_SEED ?= $(shell python3 -c 'import time; print(time.time())')
 
 define test
        $(if $(filter-out $(3),retest),make -C $(BR) PLATFORM=$(1) TAG=$(2) vpp-install,)
@@ -412,6 +413,7 @@ define test
          EXTENDED_TESTS=$(EXTENDED_TESTS) \
          PYTHON=$(PYTHON) \
          OS_ID=$(OS_ID) \
+         RND_SEED=$(RND_SEED) \
          CACHE_OUTPUT=$(CACHE_OUTPUT) \
          $(3)
 endef
index ef0b27c..cbdcff1 100644 (file)
@@ -241,8 +241,10 @@ shell: test-dep
        @echo "source $(VENV_PATH)/bin/activate;\
                cd $(BUILD_TEST_SRC);\
                export PYTHONPATH=$(BUILD_TEST_SRC);\
+               export RND_SEED=$(RND_SEED);\
                echo '***';\
                echo PYTHONPATH=$(BUILD_TEST_SRC);\
+               echo RND_SEED=$(RND_SEED);\
                echo VPP_BUILD_DIR=$(VPP_BUILD_DIR);\
                echo VPP_BIN=$(VPP_BIN);\
                echo VPP_PLUGIN_PATH=$(VPP_PLUGIN_PATH);\
index 39fd37f..7ff7978 100644 (file)
@@ -573,20 +573,28 @@ class VppTestCase(unittest.TestCase):
             cls.quit()
             raise
 
+    @classmethod
+    def _debug_quit(cls):
+        if (cls.debug_gdbserver or cls.debug_gdb):
+            try:
+                cls.vpp.poll()
+
+                if cls.vpp.returncode is None:
+                    print()
+                    print(double_line_delim)
+                    print("VPP or GDB server is still running")
+                    print(single_line_delim)
+                    input("When done debugging, press ENTER to kill the "
+                          "process and finish running the testcase...")
+            except AttributeError:
+                pass
+
     @classmethod
     def quit(cls):
         """
         Disconnect vpp-api, kill vpp and cleanup shared memory files
         """
-        if (cls.debug_gdbserver or cls.debug_gdb) and hasattr(cls, 'vpp'):
-            cls.vpp.poll()
-            if cls.vpp.returncode is None:
-                print()
-                print(double_line_delim)
-                print("VPP or GDB server is still running")
-                print(single_line_delim)
-                input("When done debugging, press ENTER to kill the "
-                      "process and finish running the testcase...")
+        cls._debug_quit()
 
         # first signal that we want to stop the pump thread, then wake it up
         if hasattr(cls, 'pump_thread_stop_flag'):
@@ -597,7 +605,7 @@ class VppTestCase(unittest.TestCase):
             cls.logger.debug("Waiting for pump thread to stop")
             cls.pump_thread.join()
         if hasattr(cls, 'vpp_stderr_reader_thread'):
-            cls.logger.debug("Waiting for stdderr pump to stop")
+            cls.logger.debug("Waiting for stderr pump to stop")
             cls.vpp_stderr_reader_thread.join()
 
         if hasattr(cls, 'vpp'):
index 09b68a2..8024696 100644 (file)
@@ -732,11 +732,6 @@ def parse_digit_env(env_var, default):
 
 if __name__ == '__main__':
 
-    if "RND_SEED" not in os.environ:
-        os.environ["RND_SEED"] = str(time.time())
-        print("Setting RND_SEED=%s" % os.environ["RND_SEED"])
-    else:
-        print("Using provided RND_SEED=%s" % os.environ["RND_SEED"])
     verbose = parse_digit_env("V", 0)
 
     test_timeout = parse_digit_env("TIMEOUT", 600)  # default = 10 minutes
index 535d054..5eb6885 100644 (file)
@@ -2,7 +2,7 @@
 
 from __future__ import print_function
 from multiprocessing import Pipe
-from sys import exit
+import sys
 import os
 from framework import VppDiedError, VppTestCase, KeepAliveReporter
 
@@ -11,9 +11,20 @@ class SanityTestCase(VppTestCase):
     """ Sanity test case - verify whether VPP is able to start """
     pass
 
+    # don't ask to debug SanityTestCase
+    @classmethod
+    def wait_for_enter(cls, pid=0):
+        pass
+
+    @classmethod
+    def _debug_quit(cls):
+        try:
+            cls.vpp.poll()
+        except AttributeError:
+            pass
+
 
 if __name__ == '__main__':
-    os.environ["RND_SEED"] = "1"
     rc = 0
     tc = SanityTestCase
     x, y = Pipe()
@@ -26,14 +37,14 @@ if __name__ == '__main__':
     else:
         try:
             tc.tearDownClass()
-        except:
-            pass
+        except Exception:
+            rc = -1
     x.close()
     y.close()
 
     if rc == 0:
-        print('Sanity test case passed\n')
+        print('Sanity test case passed.\n')
     else:
-        print('Sanity test case failed\n')
+        print('Sanity test case failed.\n')
 
-    exit(rc)
+    sys.exit(rc)