aboutsummaryrefslogtreecommitdiff
path: root/debug/testlib.py
diff options
context:
space:
mode:
authorTommy Murphy <tommy_murphy@hotmail.com>2024-06-06 19:44:24 +0100
committerTommy Murphy <tommy_murphy@hotmail.com>2024-06-06 19:44:24 +0100
commitd3c0ecaf8629c889726a8deff1f00c4c1405101f (patch)
treef886df67645f83f95a822e0ec6d3d7a296350a1d /debug/testlib.py
parent8853c545d0a44430c8a714d11f18ebad6af7d3fa (diff)
downloadriscv-tests-d3c0ecaf8629c889726a8deff1f00c4c1405101f.zip
riscv-tests-d3c0ecaf8629c889726a8deff1f00c4c1405101f.tar.gz
riscv-tests-d3c0ecaf8629c889726a8deff1f00c4c1405101f.tar.bz2
Move PRNG seed generation/logging from gdbserver.py:main() into testlib.py:run_all_tests()
Diffstat (limited to 'debug/testlib.py')
-rw-r--r--debug/testlib.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/debug/testlib.py b/debug/testlib.py
index 1f107be..0106203 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -1,6 +1,7 @@
import collections
import os
import os.path
+import random
import re
import shlex
import subprocess
@@ -13,6 +14,8 @@ import tty
import pexpect
import yaml
+from datetime import datetime
+
print_log_names = False
real_stdout = sys.stdout
@@ -1160,6 +1163,14 @@ def run_all_tests(module, target, parsed):
excluded_tests = load_excluded_tests(parsed.exclude_tests, target.name)
target.skip_tests += excluded_tests
+ # initialize PRNG
+ selected_seed = parsed.seed
+ if parsed.seed is None:
+ selected_seed = int(datetime.now().timestamp())
+ print(f"PRNG seed for {target.name} is generated automatically")
+ print(f"PRNG seed for {target.name} is {selected_seed}")
+ random.seed(selected_seed)
+
results, count = run_tests(parsed, target, todo)
header(f"ran {count} tests in {time.time() - overall_start:.0f}s", dash=':')