Skip to content

Commit 260f661

Browse files
authored
Rollup merge of #146762 - madsmtm:test-apple-sim, r=jieyouxu
Fix and provide instructions for running test suite on Apple simulators The following now works: ```sh ./x test --host='' --target aarch64-apple-ios-sim --skip tests/debuginfo ./x test --host='' --target aarch64-apple-tvos-sim --skip tests/debuginfo ./x test --host='' --target aarch64-apple-watchos-sim --skip tests/debuginfo ./x test --host='' --target aarch64-apple-visionos-sim --skip tests/debuginfo ``` I have documented the setup I used [in the `rustc-dev-guide`](https://rustc-dev-guide.rust-lang.org/tests/running.html#testing-on-emulators), it's fairly standard use of `remote-test-server` (with a small fix to library load paths which I've made in the first commit). I first tried the somewhat simpler `target.aarch64-apple-ios-sim.runner = "xcrun simctl spawn $UDID"`, but that doesn't work as required libraries etc. also need to be copied to the device. The debuginfo tests fail, I think because the debug info in `.dSYM` isn't available. I am yet unsure exactly how to fix this, either we need to copy that directory to the target as well, or we need to configure `lldb` somehow to read it from the host. I decided to not add this to our CI, since I suspect we wouldn't gain much from it? Running on the simulator still uses the host Darwin kernel, it's basically just configured to run in another mode with more restricted permissions and different system libraries. r? jieyouxu CC ``@simlay,`` you're a lot more familiar with `xcrun simctl` than I.
2 parents b44cca0 + 3009def commit 260f661

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/tests/running.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,34 @@ results. The Docker image is set up to launch `remote-test-server` and the
339339
build tools use `remote-test-client` to communicate with the server to
340340
coordinate running tests (see [src/bootstrap/src/core/build_steps/test.rs]).
341341

342-
> **TODO**
343-
>
344-
> - Is there any support for using an iOS emulator?
342+
To run on the iOS/tvOS/watchOS/visionOS simulator, we can similarly treat it as
343+
a "remote" machine. A curious detail here is that the network is shared between
344+
the simulator instance and the host macOS, so we can use the local loopback
345+
address `127.0.0.1`. Something like the following should work:
346+
347+
```sh
348+
# Build the test server for the iOS simulator:
349+
./x build src/tools/remote-test-server --target aarch64-apple-ios-sim
350+
351+
# If you already have a simulator instance open, copy the device UUID from:
352+
xcrun simctl list devices booted
353+
UDID=01234567-89AB-CDEF-0123-456789ABCDEF
354+
355+
# Alternatively, create and boot a new simulator instance:
356+
xcrun simctl list runtimes
357+
xcrun simctl list devicetypes
358+
UDID=$(xcrun simctl create $CHOSEN_DEVICE_TYPE $CHOSEN_RUNTIME)
359+
xcrun simctl boot $UDID
360+
# See https://nshipster.com/simctl/ for details.
361+
362+
# Spawn the runner on port 12345:
363+
xcrun simctl spawn $UDID ./build/host/stage2-tools/aarch64-apple-ios-sim/release/remote-test-server -v --bind 127.0.0.1:12345
364+
365+
# In a new terminal, run tests via the runner:
366+
export TEST_DEVICE_ADDR="127.0.0.1:12345"
367+
./x test --host='' --target aarch64-apple-ios-sim --skip tests/debuginfo
368+
# FIXME(madsmtm): Allow debuginfo tests to work (maybe needs `.dSYM` folder to be copied to the target?).
369+
```
345370

346371
[armhf-gnu]: https://github.com/rust-lang/rust/tree/master/src/ci/docker/host-x86_64/armhf-gnu/Dockerfile
347372
[QEMU]: https://www.qemu.org/

0 commit comments

Comments
 (0)