Index: test/lit.common.cfg =================================================================== --- test/lit.common.cfg +++ test/lit.common.cfg @@ -106,6 +106,10 @@ if config.emulator: config.substitutions.append( ('%run', config.emulator) ) config.substitutions.append( ('%env ', "env ") ) + # TODO: Implement `%device_rm` to perform removal of files in the emulator. + # For now just make it a no-op. + lit_config.warning('%device_rm is not implemented') + config.substitutions.append( ('%device_rm', 'echo ') ) config.compile_wrapper = "" elif config.host_os == 'Darwin' and config.apple_platform != "osx": # Darwin tests can be targetting macOS, a device or a simulator. All devices @@ -148,6 +152,9 @@ config.environment[device_id_env] = os.environ[device_id_env] config.substitutions.append(('%run', run_wrapper)) config.substitutions.append(('%env ', env_wrapper + " ")) + # Current implementation of %device_rm uses the run_wrapper to do + # the work. + config.substitutions.append(('%device_rm', '{} rm '.format(run_wrapper))) config.compile_wrapper = compile_wrapper prepare_output = subprocess.check_output([prepare_script, config.apple_platform, config.clang]).strip() @@ -161,9 +168,15 @@ config.compile_wrapper = compile_wrapper config.substitutions.append( ('%run', "") ) config.substitutions.append( ('%env ', "env ") ) + # TODO: Implement `%device_rm` to perform removal of files on a device. For + # now just make it a no-op. + lit_config.warning('%device_rm is not implemented') + config.substitutions.append( ('%device_rm', 'echo ') ) else: config.substitutions.append( ('%run', "") ) config.substitutions.append( ('%env ', "env ") ) + # When running locally %device_rm is a no-op. + config.substitutions.append( ('%device_rm', 'echo ') ) config.compile_wrapper = "" # Define CHECK-%os to check for OS-dependent output. Index: test/sanitizer_common/ios_commands/iossim_run.py =================================================================== --- test/sanitizer_common/ios_commands/iossim_run.py +++ test/sanitizer_common/ios_commands/iossim_run.py @@ -1,6 +1,6 @@ #!/usr/bin/python -import os, sys, subprocess +import glob, os, pipes, sys, subprocess if not "SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER" in os.environ: @@ -12,7 +12,25 @@ if e in os.environ: os.environ["SIMCTL_CHILD_" + e] = os.environ[e] -exitcode = subprocess.call(["xcrun", "simctl", "spawn", device_id] + sys.argv[1:]) +prog = sys.argv[1] +exit_code = None +if prog == 'rm': + # The simulator and host actually share the same file system so we can just + # execute directly on the host. + rm_args = [] + for arg in sys.argv[2:]: + if '*' in arg or '?' in arg: + # Don't quote glob pattern + rm_args.append(arg) + else: + # FIXME(dliew): pipes.quote() is deprecated + rm_args.append(pipes.quote(arg)) + rm_cmd_line = ["/bin/rm"] + rm_args + rm_cmd_line_str = ' '.join(rm_cmd_line) + # We use `shell=True` so that any wildcard globs get expanded by the shell. + exitcode = subprocess.call(rm_cmd_line_str, shell=True) +else: + exitcode = subprocess.call(["xcrun", "simctl", "spawn", device_id] + sys.argv[1:]) if exitcode > 125: exitcode = 126 sys.exit(exitcode) Index: test/ubsan/TestCases/Misc/log-path_test.cc =================================================================== --- test/ubsan/TestCases/Misc/log-path_test.cc +++ test/ubsan/TestCases/Misc/log-path_test.cc @@ -12,11 +12,13 @@ // Good log_path. // RUN: rm -f %t.log.* +// RUN: %device_rm -f '%t.log.*' // RUN: %env_ubsan_opts=log_path='"%t.log"' %run %t -4 2> %t.out // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.* // Run w/o errors should not produce any log. // RUN: rm -f %t.log.* +// RUN: %device_rm -f '%t.log.*' // RUN: %env_ubsan_opts=log_path='"%t.log"' %run %t 4 // RUN: not cat %t.log.*