parent
6997a7c516
commit
c7ff82f06b
|
@ -12,6 +12,7 @@ import multiprocessing
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import platform
|
import platform
|
||||||
|
import pty
|
||||||
import re
|
import re
|
||||||
import runpy
|
import runpy
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -1714,18 +1715,35 @@ class VlTest:
|
||||||
# Execute command redirecting output, keeping order between stderr and stdout.
|
# Execute command redirecting output, keeping order between stderr and stdout.
|
||||||
# Must do low-level IO so GCC interaction works (can't be line-based)
|
# Must do low-level IO so GCC interaction works (can't be line-based)
|
||||||
status = None
|
status = None
|
||||||
if True: # process_caller_block # pylint: disable=using-constant-test
|
# process_caller_block # pylint: disable=using-constant-test
|
||||||
|
|
||||||
logfh = None
|
logfh = None
|
||||||
if logfile:
|
if logfile:
|
||||||
logfh = open(logfile, 'wb') # pylint: disable=consider-using-with
|
logfh = open(logfile, 'wb') # pylint: disable=consider-using-with
|
||||||
|
|
||||||
|
if not Args.interactive_debugger:
|
||||||
|
# Become TTY controlling termal so GDB will not capture main driver.py's terminal
|
||||||
|
pid, fd = pty.fork()
|
||||||
|
if pid == 0:
|
||||||
|
subprocess.run(["stty", "nl"], check=True) # No carriage returns
|
||||||
|
os.execlp("bash", "/bin/bash", "-c", command)
|
||||||
|
else:
|
||||||
|
# Parent process: Interact with GDB
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
data = os.read(fd, 1)
|
||||||
|
self._run_output(data, logfh, tee)
|
||||||
|
except OSError:
|
||||||
|
break
|
||||||
|
|
||||||
|
(pid, rc) = os.waitpid(pid, 0)
|
||||||
|
|
||||||
|
else:
|
||||||
with subprocess.Popen(command,
|
with subprocess.Popen(command,
|
||||||
shell=True,
|
shell=True,
|
||||||
bufsize=0,
|
bufsize=0,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT) as proc:
|
stderr=subprocess.STDOUT) as proc:
|
||||||
|
|
||||||
rawbuf = bytearray(2048)
|
rawbuf = bytearray(2048)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
@ -1734,32 +1752,25 @@ class VlTest:
|
||||||
got = proc.stdout.readinto(rawbuf)
|
got = proc.stdout.readinto(rawbuf)
|
||||||
if got:
|
if got:
|
||||||
data = rawbuf[0:got]
|
data = rawbuf[0:got]
|
||||||
if re.search(r'--debug-exit-uvm23: Exiting', str(data)):
|
self._run_output(data, logfh, tee)
|
||||||
self._force_pass = True
|
|
||||||
print("EXIT: " + str(data))
|
|
||||||
if tee:
|
|
||||||
sys.stdout.write(data.decode('latin-1'))
|
|
||||||
if Args.interactive_debugger:
|
|
||||||
sys.stdout.flush()
|
|
||||||
if logfh:
|
|
||||||
logfh.write(data)
|
|
||||||
elif finished is not None:
|
elif finished is not None:
|
||||||
break
|
break
|
||||||
|
|
||||||
if logfh:
|
|
||||||
logfh.close()
|
|
||||||
|
|
||||||
rc = proc.returncode # Negative if killed by signal
|
rc = proc.returncode # Negative if killed by signal
|
||||||
if (rc in (
|
|
||||||
-4, # SIGILL
|
if logfh:
|
||||||
-8, # SIGFPA
|
logfh.close()
|
||||||
-11)): # SIGSEGV
|
|
||||||
self.error("Exec failed with core dump")
|
if (rc in (
|
||||||
status = 10
|
-4, # SIGILL
|
||||||
elif rc:
|
-8, # SIGFPA
|
||||||
status = 10
|
-11)): # SIGSEGV
|
||||||
else:
|
self.error("Exec failed with core dump")
|
||||||
status = 0
|
status = 10
|
||||||
|
elif rc:
|
||||||
|
status = 10
|
||||||
|
else:
|
||||||
|
status = 0
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
@ -1793,6 +1804,17 @@ class VlTest:
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _run_output(self, data, logfh, tee):
|
||||||
|
if re.search(r'--debug-exit-uvm23: Exiting', str(data)):
|
||||||
|
self._force_pass = True
|
||||||
|
print("EXIT: " + str(data))
|
||||||
|
if tee:
|
||||||
|
sys.stdout.write(data.decode('latin-1'))
|
||||||
|
if Args.interactive_debugger:
|
||||||
|
sys.stdout.flush()
|
||||||
|
if logfh:
|
||||||
|
logfh.write(data)
|
||||||
|
|
||||||
def _run_log_try(self, logfile: str, check_finished: bool, moretry: bool) -> bool:
|
def _run_log_try(self, logfile: str, check_finished: bool, moretry: bool) -> bool:
|
||||||
# If moretry, then return true to try again
|
# If moretry, then return true to try again
|
||||||
with open(logfile, 'r', encoding='latin-1', newline='\n') as fh:
|
with open(logfile, 'r', encoding='latin-1', newline='\n') as fh:
|
||||||
|
|
|
@ -11,6 +11,8 @@ import vltest_bootstrap
|
||||||
|
|
||||||
test.scenarios('vlt')
|
test.scenarios('vlt')
|
||||||
|
|
||||||
|
if 'VERILATOR_TEST_NO_GDB' in os.environ:
|
||||||
|
test.skip("Skipping due to VERILATOR_TEST_NO_GDB")
|
||||||
if not test.have_gdb:
|
if not test.have_gdb:
|
||||||
test.skip("No gdb installed")
|
test.skip("No gdb installed")
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,6 @@ import vltest_bootstrap
|
||||||
|
|
||||||
test.scenarios('vlt')
|
test.scenarios('vlt')
|
||||||
|
|
||||||
if 'VERILATOR_TEST_NO_GDB' in os.environ:
|
|
||||||
test.skip("Skipping due to VERILATOR_TEST_NO_GDB")
|
|
||||||
if not test.have_gdb:
|
|
||||||
test.skip("No gdb installed")
|
|
||||||
|
|
||||||
test.lint(v_flags=["--debug-sigsegv"], fails=True, sanitize=0)
|
test.lint(v_flags=["--debug-sigsegv"], fails=True, sanitize=0)
|
||||||
|
|
||||||
test.file_grep(test.compile_log_filename,
|
test.file_grep(test.compile_log_filename,
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
import vltest_bootstrap
|
import vltest_bootstrap
|
||||||
|
|
||||||
test.scenarios('vlt')
|
test.scenarios('vlt')
|
||||||
|
|
||||||
if 'VERILATOR_TEST_NO_GDB' in os.environ:
|
if 'VERILATOR_TEST_NO_GDB' in os.environ:
|
||||||
test.skip("Skipping due to VERILATOR_TEST_NO_GDB")
|
test.skip("Skipping due to VERILATOR_TEST_NO_GDB")
|
||||||
if not test.have_gdb:
|
if not test.have_gdb:
|
||||||
|
|
|
@ -17,7 +17,11 @@ test.scenarios('dist')
|
||||||
def check(prog):
|
def check(prog):
|
||||||
logfile = test.obj_dir + "/t_help__" + os.path.basename(prog) + ".log"
|
logfile = test.obj_dir + "/t_help__" + os.path.basename(prog) + ".log"
|
||||||
|
|
||||||
test.run(fails=False, cmd=[prog, "--help"], logfile=logfile, tee=False, verilator_run=True)
|
# Not using logfile=logfile as would invoke PAGER
|
||||||
|
test.run(fails=False,
|
||||||
|
cmd=[prog, "--help", ">", logfile, "2>&1"],
|
||||||
|
tee=False,
|
||||||
|
verilator_run=True)
|
||||||
|
|
||||||
test.file_grep(logfile, r'(DISTRIBUTION|usage:)')
|
test.file_grep(logfile, r'(DISTRIBUTION|usage:)')
|
||||||
|
|
||||||
|
|
|
@ -7,18 +7,12 @@
|
||||||
# Version 2.0.
|
# Version 2.0.
|
||||||
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
# This test runs the very first time we've executed Verilator --sc
|
|
||||||
# after building so we make sure to run with --gdbbt, so if it dumps we'll
|
|
||||||
# get a trace.
|
|
||||||
|
|
||||||
import vltest_bootstrap
|
import vltest_bootstrap
|
||||||
|
|
||||||
test.scenarios('simulator')
|
test.scenarios('simulator')
|
||||||
test.top_filename = "t/t_a1_first_cc.v"
|
test.top_filename = "t/t_a1_first_cc.v"
|
||||||
|
|
||||||
DEBUG_QUIET = "--debug --debugi 0 --gdbbt --no-dump-tree"
|
test.compile(verilator_flags2=["-sc --trace-vcd --pins-sc-uint-bool"])
|
||||||
|
|
||||||
test.compile(verilator_flags2=[DEBUG_QUIET, "-sc --trace-vcd --pins-sc-uint-bool"])
|
|
||||||
|
|
||||||
test.execute()
|
test.execute()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue