3 from multiprocessing
import Pool
12 def run_reproducer(path
):
13 proc
= subprocess
.Popen(
14 [LLDB
, "--replay", path
], stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
18 outs
, errs
= proc
.communicate(timeout
=TIMEOUT
)
19 success
= proc
.returncode
== 0
20 result
= "PASSED" if success
else "FAILED"
24 # Do some pattern matching to find out the cause of the failure.
25 if "Encountered unexpected packet during replay" in errs
:
26 reason
= "Unexpected packet"
27 elif "Assertion failed" in errs
:
28 reason
= "Assertion failed"
29 elif "UNREACHABLE" in errs
:
30 reason
= "Unreachable executed"
31 elif "Segmentation fault" in errs
:
32 reason
= "Segmentation fault"
33 elif "Illegal instruction" in errs
:
34 reason
= "Illegal instruction"
36 reason
= f
"Exit code {proc.returncode}"
37 except subprocess
.TimeoutExpired
:
40 outs
, errs
= proc
.communicate()
43 if not FAILURE_ONLY
or not success
:
44 reason_str
= f
" ({reason})" if reason
else ""
45 print(f
"{result}: {path}{reason_str}")
53 def find_reproducers(path
):
54 for root
, dirs
, files
in os
.walk(path
):
56 _
, extension
= os
.path
.splitext(dir)
57 if dir.startswith("Test") and extension
== ".py":
58 yield os
.path
.join(root
, dir)
61 if __name__
== "__main__":
62 parser
= argparse
.ArgumentParser(
63 description
="LLDB API Test Replay Driver. "
64 "Replay one or more reproducers in parallel using the specified LLDB driver. "
65 "The script will look for reproducers generated by the API lit test suite. "
66 "To generate the reproducers, pass --param 'lldb-run-with-repro=capture' to lit."
72 default
=multiprocessing
.cpu_count(),
73 help="Number of threads. The number of CPU threads if not specified.",
80 help="Replay timeout in seconds. 60 seconds if not specified.",
87 help="Path to the directory containing the reproducers. The current working directory if not specified.",
94 help="Path to the LLDB command line driver",
97 "-v", "--verbose", help="Print replay output.", action
="store_true"
100 "--failure-only", help="Only log failures.", action
="store_true"
102 args
= parser
.parse_args()
109 TIMEOUT
= args
.timeout
110 VERBOSE
= args
.verbose
111 FAILURE_ONLY
= args
.failure_only
114 f
"Replaying reproducers in {args.path} with {args.threads} threads and a {args.timeout} seconds timeout"
118 pool
= Pool(args
.threads
)
119 pool
.map(run_reproducer
, find_reproducers(args
.path
))
120 except KeyboardInterrupt: