From d3c0ecaf8629c889726a8deff1f00c4c1405101f Mon Sep 17 00:00:00 2001 From: Tommy Murphy Date: Thu, 6 Jun 2024 19:44:24 +0100 Subject: Move PRNG seed generation/logging from gdbserver.py:main() into testlib.py:run_all_tests() --- debug/testlib.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'debug/testlib.py') 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=':') -- cgit v1.1 From 6c1ab378660efe0b7559425df995fb7df39befd3 Mon Sep 17 00:00:00 2001 From: Tommy Murphy Date: Thu, 6 Jun 2024 19:51:06 +0100 Subject: Fix pylint issues with previous commit changes --- debug/testlib.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'debug/testlib.py') diff --git a/debug/testlib.py b/debug/testlib.py index 0106203..64c7055 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -10,12 +10,12 @@ import tempfile import time import traceback +from datetime import datetime + import tty import pexpect import yaml -from datetime import datetime - print_log_names = False real_stdout = sys.stdout @@ -1303,7 +1303,6 @@ class BaseTest: if not hart is None: self.hart = hart else: - import random # pylint: disable=import-outside-toplevel self.hart = random.choice(target.harts) #self.hart = target.harts[-1] self.server = None -- cgit v1.1