Page MenuHomePhabricator

[iOS sim] Ensure simulator device is booted in iossim_prepare.py
ClosedPublic

Authored by yln on Dec 12 2019, 5:45 PM.

Details

Summary

Recent versions of the iOS simulator require that a "simulator device"
is booted before we can use simctl spawn (see iossim_run.py) to start
processes.

We can use simctl bootstatus to ensure that the simulator device
is booted before we run any tests via lit. The -b option starts the
device if necessary.

Diff Detail

Event Timeline

yln created this revision.Dec 12 2019, 5:45 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 12 2019, 5:45 PM
Herald added subscribers: llvm-commits, Restricted Project. · View Herald Transcript

LGTM except the possible improvement to the error message.

compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py
23

Suggested (but optional improvement). If the command fails print an error message that explains the command to run to boot the iOS simulator.

delcypher requested changes to this revision.Dec 16 2019, 9:15 AM
This revision now requires changes to proceed.Dec 16 2019, 9:15 AM
yln marked 2 inline comments as done.Dec 16 2019, 9:40 AM
yln added inline comments.
compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py
23

The command will boot the simulator (the -b flag ).

This is the error for an invalid device:

➤ env SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone Y" ../llvm-project/llvm/utils/lit/lit.py  projects/compiler-rt/test/tsan/IOSSimX86_64Config/ -sv
Invalid device: iPhone Y
Traceback (most recent call last):
  File "/Users/yln/work/llvm-upstream/llvm-project/compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py", line 11, in <module>
    subprocess.check_call(boot_cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['xcrun', 'simctl', 'bootstatus', 'iPhone Y', '-b']' returned non-zero exit status 164
Command failed:

lit.py: /Users/yln/work/llvm-upstream/llvm-project/llvm/utils/lit/lit/TestingConfig.py:102: fatal: unable to parse config file '/Users/yln/work/llvm-upstream/llvm-project/compiler-rt/test/lit.common.cfg.py', traceback: Traceback (most recent call last):
  File "/Users/yln/work/llvm-upstream/llvm-project/llvm/utils/lit/lit/TestingConfig.py", line 89, in load_from_path
    exec(compile(data, path, 'exec'), cfg_globals, None)
  File "/Users/yln/work/llvm-upstream/llvm-project/compiler-rt/test/lit.common.cfg.py", line 175, in <module>
    raise e
CalledProcessError: Command '['/Users/yln/work/llvm-upstream/llvm-project/compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py', 'iossim', '/Users/yln/work/llvm-upstream/build/./bin/clang']' returned non-zero exit status 1
delcypher added inline comments.Dec 16 2019, 10:18 AM
compiler-rt/test/sanitizer_common/ios_commands/iossim_prepare.py
23

Ah I missed the -b flag. One issue with this is that we don't teardown the iOS simulator when testing finishes. I guess this mean we'll have a bunch of simulator daemons running in the background on the bot. I don't think there's any great way of fixing this today because I don't think we have a way of adding "clean up" hooks to lit to tell it to execute some custom code when testing finishes.

Maybe leave a TODO and file a radar about this?

yln updated this revision to Diff 234108.Dec 16 2019, 11:05 AM
yln marked an inline comment as done.

Add comment about teardown. Remove unused/organize imports.

yln marked an inline comment as done.Dec 16 2019, 11:06 AM
yln updated this revision to Diff 234932.Dec 20 2019, 11:17 AM

Add radar number.

This revision is now accepted and ready to land.Dec 20 2019, 1:17 PM
This revision was automatically updated to reflect the committed changes.