From f56b007356c145e0ef56e3590a20771a98383748 Mon Sep 17 00:00:00 2001 From: Andrew Yourtchenko Date: Fri, 18 Mar 2022 17:05:53 +0000 Subject: 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 Change-Id: I858bab0a9b828b99c20a2252aeecb9e2dda4ee21 --- test/config.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test') 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, -- cgit 1.2.3-korg