[lldb/Utils] Serialize exit code in lldb-repro.py

After 61d5b0e663 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.
This commit is contained in:
Jonas Devlieghere 2020-05-05 15:59:43 -07:00
parent b0eb7cd2be
commit 0274c797c6
1 changed files with 12 additions and 3 deletions

View File

@ -44,10 +44,8 @@ def main():
# Create a new lldb invocation with capture or replay enabled.
lldb = os.path.join(os.path.dirname(sys.argv[0]), 'lldb')
new_args = [lldb]
cleanup = False
if sys.argv[1] == "replay":
new_args.extend(['--replay', reproducer_path])
cleanup = True
elif sys.argv[1] == "capture":
new_args.extend([
'--capture', '--capture-path', reproducer_path,
@ -59,8 +57,19 @@ def main():
return 1
exit_code = subprocess.call(new_args)
if cleanup:
# The driver always exists with a zero exit code during replay. Store the
# exit code and return that for tests that expect a non-zero exit code.
exit_code_path = os.path.join(reproducer_path, 'exit_code.txt')
if sys.argv[1] == "replay":
with open(exit_code_path, 'r') as f:
assert exit_code == 0
exit_code = int(f.read())
shutil.rmtree(reproducer_path, True)
elif sys.argv[1] == "capture":
with open(exit_code_path, 'w') as f:
f.write('%d' % exit_code)
return exit_code