Skip to content

Commit 4cfb71a

Browse files
committed
[lldb/Scripts] Add verbose and failure only mode to replay script.
Add two modes to the reproducer replay script that make debugging a little easier. Verbose mode prints stdout and stderr, regardless of whether replay was successful. When --failure-only is passed, output is limited to tests that failed to replay.
1 parent 06c980d commit 4cfb71a

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

lldb/scripts/reproducer-replay.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ def run_reproducer(path):
1515
stderr=subprocess.PIPE)
1616
reason = None
1717
try:
18+
success = proc.returncode == 0
1819
outs, errs = proc.communicate(timeout=TIMEOUT)
19-
result = 'PASSED' if proc.returncode == 0 else 'FAILED'
20-
if proc.returncode != 0:
20+
result = 'PASSED' if success else 'FAILED'
21+
if not success:
2122
outs = outs.decode()
2223
errs = errs.decode()
2324
# Do some pattern matching to find out the cause of the failure.
@@ -35,11 +36,18 @@ def run_reproducer(path):
3536
reason = f'Exit code {proc.returncode}'
3637
except subprocess.TimeoutExpired:
3738
proc.kill()
39+
success = False
3840
outs, errs = proc.communicate()
3941
result = 'TIMEOUT'
4042

41-
reason_str = f' ({reason})' if reason else ''
42-
print(f'{result}: {path}{reason_str}')
43+
if not FAILURE_ONLY or not success:
44+
reason_str = f' ({reason})' if reason else ''
45+
print(f'{result}: {path}{reason_str}')
46+
if VERBOSE:
47+
if outs:
48+
print(outs)
49+
if errs:
50+
print(errs)
4351

4452

4553
def find_reproducers(path):
@@ -82,12 +90,23 @@ def find_reproducers(path):
8290
type=str,
8391
required=True,
8492
help='Path to the LLDB command line driver')
93+
parser.add_argument('-v',
94+
'--verbose',
95+
help='Print replay output.',
96+
action='store_true')
97+
parser.add_argument('--failure-only',
98+
help='Only log failures.',
99+
action='store_true')
85100
args = parser.parse_args()
86101

87102
global LLDB
88103
global TIMEOUT
104+
global VERBOSE
105+
global FAILURE_ONLY
89106
LLDB = args.lldb
90107
TIMEOUT = args.timeout
108+
VERBOSE = args.verbose
109+
FAILURE_ONLY = args.failure_only
91110

92111
print(
93112
f'Replaying reproducers in {args.path} with {args.threads} threads and a {args.timeout} seconds timeout'

0 commit comments

Comments
 (0)