aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2022-03-18 17:05:53 +0000
committerDave Wallace <dwallacelf@gmail.com>2022-03-18 20:11:26 +0000
commitf56b007356c145e0ef56e3590a20771a98383748 (patch)
treef24fab71c5bcf5ff900be90bd18ea8accffb89d9 /test
parent53d8d4fd625c21777d11172dac9ea3aa6602edd0 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/config.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/config.py b/test/config.py
index b91973f7f95..dd3b9c1f9ea 100644
--- a/test/config.py
+++ b/test/config.py
@@ -9,10 +9,22 @@ def positive_int_or_default(default):
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 @@ parser.add_argument("--venv-dir", action="store",
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,