3 import glob
, os
, pipes
, sys
, subprocess
6 device_id
= os
.environ
.get("SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER")
7 iossim_run_verbose
= os
.environ
.get("SANITIZER_IOSSIM_RUN_VERBOSE")
8 wait_for_debug
= os
.environ
.get("SANITIZER_IOSSIM_RUN_WAIT_FOR_DEBUGGER")
11 raise EnvironmentError(
12 "Specify SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER to select which simulator to use."
20 "APPLE_ASAN_INIT_FOR_DLOPEN",
21 "ASAN_ACTIVATION_OPTIONS",
25 os
.environ
["SIMCTL_CHILD_" + e
] = os
.environ
[e
]
27 find_atos_cmd
= "xcrun -sdk iphonesimulator -f atos"
30 find_atos_cmd
.split(),
31 stdout
=subprocess
.PIPE
,
32 stderr
=subprocess
.PIPE
,
38 for san
in ["ASAN", "TSAN", "UBSAN", "LSAN"]:
39 os
.environ
[f
"SIMCTL_CHILD_{san}_SYMBOLIZER_PATH"] = atos_path
44 # The simulator and host actually share the same file system so we can just
45 # execute directly on the host.
47 for arg
in sys
.argv
[2:]:
48 if "*" in arg
or "?" in arg
:
49 # Don't quote glob pattern
52 # FIXME(dliew): pipes.quote() is deprecated
53 rm_args
.append(pipes
.quote(arg
))
54 rm_cmd_line
= ["/bin/rm"] + rm_args
55 rm_cmd_line_str
= " ".join(rm_cmd_line
)
56 # We use `shell=True` so that any wildcard globs get expanded by the shell.
58 if iossim_run_verbose
:
59 print("RUNNING: \t{}".format(rm_cmd_line_str
), flush
=True)
61 exitcode
= subprocess
.call(rm_cmd_line_str
, shell
=True)
64 cmd
= ["xcrun", "simctl", "spawn", "--standalone"]
67 cmd
.append("--wait-for-debugger")
72 if iossim_run_verbose
:
73 print("RUNNING: \t{}".format(" ".join(cmd
)), flush
=True)
75 exitcode
= subprocess
.call(cmd
)