summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Makefile2
-rw-r--r--test/framework.py4
-rw-r--r--test/run_tests.py5
-rw-r--r--test/sanity_run_vpp.py3
4 files changed, 13 insertions, 1 deletions
diff --git a/test/Makefile b/test/Makefile
index 7ec8d4a08c6..3a78a3f08af 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -341,6 +341,8 @@ help:
@echo ""
@echo " SOCKET=1 - Communicate with VPP over Unix domain socket instead of SHM"
@echo ""
+ @echo " RND_SEED=seed - Seed RND with given seed"
+ @echo ""
@echo "Creating test documentation"
@echo " test-doc - generate documentation for test framework"
@echo " test-wipe-doc - wipe documentation for test framework"
diff --git a/test/framework.py b/test/framework.py
index e3c605b64ac..9508297432e 100644
--- a/test/framework.py
+++ b/test/framework.py
@@ -503,8 +503,9 @@ class VppTestCase(unittest.TestCase):
"""
super(VppTestCase, cls).setUpClass()
gc.collect() # run garbage collection first
- random.seed()
cls.logger = get_logger(cls.__name__)
+ seed = os.environ["RND_SEED"]
+ random.seed(seed)
if hasattr(cls, 'parallel_handler'):
cls.logger.addHandler(cls.parallel_handler)
cls.logger.propagate = False
@@ -525,6 +526,7 @@ class VppTestCase(unittest.TestCase):
os.chdir(cls.tempdir)
cls.logger.info("Temporary dir is %s, shm prefix is %s",
cls.tempdir, cls.shm_prefix)
+ cls.logger.debug("Random seed is %s" % seed)
cls.setUpConstants()
cls.reset_packet_infos()
cls._captures = []
diff --git a/test/run_tests.py b/test/run_tests.py
index d86356f17b6..d52209d82b3 100644
--- a/test/run_tests.py
+++ b/test/run_tests.py
@@ -732,6 +732,11 @@ 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
diff --git a/test/sanity_run_vpp.py b/test/sanity_run_vpp.py
index 92f250b2a6b..2ee7d310a35 100644
--- a/test/sanity_run_vpp.py
+++ b/test/sanity_run_vpp.py
@@ -3,6 +3,7 @@
from __future__ import print_function
from multiprocessing import Pipe
from sys import exit
+import os
from framework import VppDiedError, VppTestCase, KeepAliveReporter
@@ -10,7 +11,9 @@ class SanityTestCase(VppTestCase):
""" Sanity test case - verify whether VPP is able to start """
pass
+
if __name__ == '__main__':
+ os.environ["RND_SEED"] = "1"
rc = 0
tc = SanityTestCase
x, y = Pipe()