Skip to content

Commit 0274c79

Browse files
committed
[lldb/Utils] Serialize exit code in lldb-repro.py
After 61d5b0e more shell test are expected to exit with a non-zero status code. Because the exit status is computed in the driver and not behind the SB API layer, reproducers don't know about it and always return 0 unless replay failed. This discrepancy means that these tests don't work with lldb-repro.py and skipping them for this reason would be a pity. To solve this problem, the script now serializes the exit code during capture and returns that during replay. These is an assert that ensures that replay exits with a zero exit status to prevent replay failures from being silently ignored.
1 parent b0eb7cd commit 0274c79

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lldb/utils/lldb-repro/lldb-repro.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ def main():
4444
# Create a new lldb invocation with capture or replay enabled.
4545
lldb = os.path.join(os.path.dirname(sys.argv[0]), 'lldb')
4646
new_args = [lldb]
47-
cleanup = False
4847
if sys.argv[1] == "replay":
4948
new_args.extend(['--replay', reproducer_path])
50-
cleanup = True
5149
elif sys.argv[1] == "capture":
5250
new_args.extend([
5351
'--capture', '--capture-path', reproducer_path,
@@ -59,8 +57,19 @@ def main():
5957
return 1
6058

6159
exit_code = subprocess.call(new_args)
62-
if cleanup:
60+
61+
# The driver always exists with a zero exit code during replay. Store the
62+
# exit code and return that for tests that expect a non-zero exit code.
63+
exit_code_path = os.path.join(reproducer_path, 'exit_code.txt')
64+
if sys.argv[1] == "replay":
65+
with open(exit_code_path, 'r') as f:
66+
assert exit_code == 0
67+
exit_code = int(f.read())
6368
shutil.rmtree(reproducer_path, True)
69+
elif sys.argv[1] == "capture":
70+
with open(exit_code_path, 'w') as f:
71+
f.write('%d' % exit_code)
72+
6473
return exit_code
6574

6675

0 commit comments

Comments
 (0)