add a --random-seed option for reproducible test runs
diff --git a/tests/oft b/tests/oft
index ce6e4ce..81d378e 100755
--- a/tests/oft
+++ b/tests/oft
@@ -124,6 +124,7 @@
import time
import os
import imp
+import random
pydir = os.path.join(os.path.dirname(__file__), '..', 'src', 'python')
if os.path.exists(os.path.join(pydir, 'oftest')):
@@ -185,6 +186,7 @@
"fail_skipped" : False,
"default_timeout" : 2,
"minsize" : 0,
+ "random_seed" : None,
}
# Default test priority
@@ -281,6 +283,9 @@
parser.add_option("--minsize", type="int",
help="Minimum allowable packet size on the dataplane.",
default=0)
+ parser.add_option("--random-seed", type="int",
+ help="Random number generator seed",
+ default=None)
# Might need this if other parsers want command line
# parser.allow_interspersed_args = False
@@ -593,6 +598,10 @@
"sudo or as root."
exit(1)
+if config["random_seed"] is not None:
+ logging.info("Random seed: %d" % config["random_seed"])
+ random.seed(config["random_seed"])
+
if __name__ == "__main__":
logging.info("*** TEST RUN START: " + time.asctime())