Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements to debug tests infrastructure to help with triaging process #531

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions debug/gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import re
import itertools

from datetime import datetime
import targets
import testlib
from testlib import assertEqual, assertNotEqual
Expand Down Expand Up @@ -2194,6 +2195,14 @@ def main():

module = sys.modules[__name__]

# 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)

return testlib.run_all_tests(module, target, parsed)

# TROUBLESHOOTING TIPS
Expand Down
27 changes: 24 additions & 3 deletions debug/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ class Gdb:
11, 149, 107, 163, 73, 47, 43, 173, 7, 109, 101, 103, 191, 2, 139,
97, 193, 157, 3, 29, 79, 113, 5, 89, 19, 37, 71, 179, 59, 137, 53)

def __init__(self, target, ports, cmd=None, timeout=60, binaries=None):
def __init__(self, target, ports, cmd=None, timeout=60, binaries=None,
logremote=False):
assert ports

self.target = target
Expand Down Expand Up @@ -743,7 +744,16 @@ def __init__(self, target, ports, cmd=None, timeout=60, binaries=None):
# Force consistency.
self.command("set print entry-values no", reset_delays=None)
self.command(f"set remotetimeout {self.timeout}", reset_delays=None)
self.command(f"set remotetimeout {self.target.timeout_sec}")
if logremote:
# pylint: disable-next=consider-using-with
remotelog = tempfile.NamedTemporaryFile(
prefix=f"remote.gdb@{port}-", suffix=".log")
if print_log_names:
real_stdout.write(
f"Temporary remotelog: {remotelog.name}\n")
self.logfiles.append(remotelog)
self.command(f"set remotelogfile {remotelog.name}",
reset_delays=None)
self.active_child = self.children[0]

def connect(self):
Expand Down Expand Up @@ -1124,6 +1134,8 @@ def run_all_tests(module, target, parsed):
gcc_cmd = parsed.gcc
global target_timeout # pylint: disable=global-statement
target_timeout = parsed.target_timeout
global remotelogfile_enable # pylint: disable=global-statement
remotelogfile_enable = parsed.remotelogfile_enable

examine_added = False
for hart in target.harts:
Expand Down Expand Up @@ -1232,6 +1244,13 @@ def add_test_run_options(parser):
help="Specify yaml file listing tests to exclude")
parser.add_argument("--target-timeout",
help="Override the base target timeout.", default=None, type=int)
parser.add_argument("--seed",
help="Use user-specified seed value for PRNG.", default=None,
type=int)
parser.add_argument("--remotelogfile-enable",
help="If specified save GDB will record remote session to a file",
action="store_true",
default=False)
parser.add_argument("--hart",
help="Run tests against this hart in multihart tests.",
default=None, type=int)
Expand Down Expand Up @@ -1380,6 +1399,7 @@ def run(self):

gdb_cmd = None
target_timeout = None
remotelogfile_enable = False
class GdbTest(BaseTest):
def __init__(self, target, hart=None):
BaseTest.__init__(self, target, hart=hart)
Expand All @@ -1396,7 +1416,8 @@ def classSetup(self):

self.gdb = Gdb(self.target, self.server.gdb_ports, cmd=gdb_cmd,
timeout=target_timeout or self.target.timeout_sec,
binaries=self.binaries)
binaries=self.binaries,
logremote=remotelogfile_enable)

self.logs += self.gdb.lognames()
self.gdb.connect()
Expand Down
Loading