tests: fix the RND_SEED parsing
The random seed is not an integer, so the current code does not allow reproducing a test run by running e.g.
RND_SEED=1647595144.0940742 make test
Solution: make the random seed a positive float.
Also, add the missing positiveness check to the positive_integer function.
Type: fix
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Change-Id: I858bab0a9b828b99c20a2252aeecb9e2dda4ee21
diff --git a/test/config.py b/test/config.py
index b91973f..dd3b9c1 100644
--- a/test/config.py
+++ b/test/config.py
@@ -9,10 +9,22 @@
def positive_integer(v):
if v is None or v == "":
return default
+ if int(v) <= 0:
+ raise ValueError("value must be positive")
return int(v)
return positive_integer
+def positive_float_or_default(default):
+ def positive_float(v):
+ if v is None or v == "":
+ return default
+ if float(v) <= 0:
+ raise ValueError("value must be positive")
+ return float(v)
+ return positive_float
+
+
def positive_int_or_auto(v):
if v is None or v in ("", "auto"):
return "auto"
@@ -160,7 +172,7 @@
default_rnd_seed = time.time()
parser.add_argument("--rnd-seed", action="store", default=default_rnd_seed,
- type=positive_int_or_default(default_rnd_seed),
+ type=positive_float_or_default(default_rnd_seed),
help="random generator seed (default: current time)")
parser.add_argument("--vpp-worker-count", action="store", type=worker_config,