diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b0d5b81..2a3681b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -185,7 +185,20 @@ jobs: ./android/emulator.log /Users/runner/work/rustls-platform-verifier/rustls-platform-verifier/android/rustls-platform-verifier/build/outputs/androidTest-results/connected/test-result.pb - # TODO: Test iOS in CI too. + test-ios-aarch64: + name: Test (iOS) + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + id: toolchain + with: + toolchain: stable + target: aarch64-apple-ios-sim + - name: Install bash + run: brew install bash + - name: iOS Simulator Runner + run: ./ci/ios-simulator-runner.sh test-freebsd: name: Test (FreeBSD) diff --git a/ci/ios-simulator-runner.sh b/ci/ios-simulator-runner.sh new file mode 100755 index 00000000..365a97d0 --- /dev/null +++ b/ci/ios-simulator-runner.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 OR ISC + +set -e + +REPO_ROOT=$(git rev-parse --show-toplevel) + +SIM_IMAGE_LIST_PATH='/Library/Developer/CoreSimulator/Images/images.plist' +SIM_IMAGE_MOUNT_BASE='/Volumes' +SIM_IMAGE_PATTERN='iOS-17' + +if [[ ! -r "${SIM_IMAGE_LIST_PATH}" ]]; then + echo ERROR: Image list not found: "${SIM_IMAGE_LIST_PATH}" + exit 1 +fi + +function plist_count_images() { + plutil -extract 'images' raw "${SIM_IMAGE_LIST_PATH}" -o - +} + +function plist_image_id_for() { + plutil -extract "images.${1}.runtimeInfo.bundleIdentifier" raw "${SIM_IMAGE_LIST_PATH}" -o - +} + +function plist_image_path_for() { + plutil -extract "images.${1}.path.relative" raw "${SIM_IMAGE_LIST_PATH}" -o - | sed -e 's/^file:\/\///' +} + +function plist_image_build_for() { + plutil -extract "images.${1}.runtimeInfo.build" raw "${SIM_IMAGE_LIST_PATH}" -o - +} + +function find_mount() { + hdiutil info | grep -s "${1}" +} + +function find_runtime_root() { + find "${1}" -type d -name "RuntimeRoot" |head -n 1 +} + + +IMAGE_LIST_SIZE=$(plist_count_images) +IMAGE_LIST_LAST_IDX=$(( "${IMAGE_LIST_SIZE}" - 1 )) +IMAGE_PATH='' +IMAGE_BUILD='' + + +for i in $(seq 0 "${IMAGE_LIST_LAST_IDX}"); do + if [[ $(plist_image_id_for "${i}") == *"${SIM_IMAGE_PATTERN}"* ]]; then + IMAGE_PATH=$(plist_image_path_for "${i}") + IMAGE_BUILD=$(plist_image_build_for "${i}") + fi +done + +if [[ -z ${IMAGE_PATH} ]]; then + echo ERROR: ${SIM_IMAGE_PATTERN} image not found. + exit 1 +fi + +IMAGE_MOUNT_POINT="${SIM_IMAGE_MOUNT_BASE}/iOS_${IMAGE_BUILD}" + +if ! find_mount "${IMAGE_MOUNT_POINT}"; then + sudo hdiutil attach "${IMAGE_PATH}" -mountpoint "${IMAGE_MOUNT_POINT}" +fi + +if ! find_mount "${IMAGE_MOUNT_POINT}"; then + echo ERROR: Unable to mount runtime + exit 1 +fi + +DYLD_ROOT_PATH='' +DYLD_ROOT_PATH=$(find_runtime_root "${IMAGE_MOUNT_POINT}") + +if [[ -z "${DYLD_ROOT_PATH}" ]]; then + echo ERROR: RuntimeRoot not found: "${IMAGE_MOUNT_POINT}" + exit 1 +fi + +export DYLD_ROOT_PATH +cd "${REPO_ROOT}"/rustls-platform-verifier + +cargo test --target aarch64-apple-ios-sim -vv diff --git a/rustls-platform-verifier/src/tests/ffi.rs b/rustls-platform-verifier/src/tests/ffi.rs index 6a4a5afd..0c9d43e4 100644 --- a/rustls-platform-verifier/src/tests/ffi.rs +++ b/rustls-platform-verifier/src/tests/ffi.rs @@ -151,6 +151,7 @@ mod dummy { windows, target_os = "android", target_os = "macos", + target_os = "ios", target_os = "linux" ))] let _ = tests::verification_mock::ALL_TEST_CASES; diff --git a/rustls-platform-verifier/src/tests/verification_mock/mod.rs b/rustls-platform-verifier/src/tests/verification_mock/mod.rs index 9509bcf2..f5306eb5 100644 --- a/rustls-platform-verifier/src/tests/verification_mock/mod.rs +++ b/rustls-platform-verifier/src/tests/verification_mock/mod.rs @@ -13,11 +13,7 @@ //! any parts of the system outside of these tests. See the `#![cfg(...)]` //! immediately below to see which platforms run these tests. -#![cfg(all( - any(windows, unix, target_os = "android"), - not(target_os = "ios"), - not(target_os = "tvos") -))] +#![cfg(all(any(windows, unix, target_os = "android"), not(target_os = "tvos")))] use super::TestCase; use crate::tests::{assert_cert_error_eq, ensure_global_state, verification_time};