Skip to content

CI for iOS (#2389) #2421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: randomness_generation
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/cross-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,17 @@ jobs:
env:
CFLAGS: "-Wno-string-compare"
run: tests/ci/run_cross_tests.sh s390x s390x-ibm-linux-gnu "-DCMAKE_BUILD_TYPE=Release"
ios-aarch64:
if: github.repository_owner == 'aws'
name: iOS aarch64 cross-platform build
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '>=1.18'
- run: |
brew install llvm bash
- name: iOS Simulator Runner
run: tests/ci/run_ios_sim_tests.sh

5 changes: 5 additions & 0 deletions crypto/bio/bio_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,10 @@ static long callback(BIO *b, int state, int res) {
}

TEST(BIOTest, InvokeConnectCallback) {
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
GTEST_SKIP() << "InvokeConnectCallback does not run on iOS";
#endif

ASSERT_EQ(callback_invoked, 0);
BIO *bio = BIO_new(BIO_s_connect());
ASSERT_NE(bio, nullptr);
Expand All @@ -926,6 +930,7 @@ TEST(BIOTest, InvokeConnectCallback) {
}
} // namespace


// Instantiate the parameterized test suite for BIOPairTest
// This creates test instances for all combinations of the boolean parameters
//
Expand Down
10 changes: 10 additions & 0 deletions crypto/fipsmodule/rand/rand_isolated_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <array>

#if defined(GTEST_HAS_DEATH_TEST)

static const size_t request_len = 64;
static const size_t number_of_threads = 8;

Expand Down Expand Up @@ -825,3 +827,11 @@ TEST_F(randIsolatedTest, RngKatNoUbe) {
EXPECT_EXIT(runTest(RngKatTestUtils::TestType::WithReseedNoPrAndUserPr),
::testing::ExitedWithCode(0), "");
}

#else // GTEST_HAS_DEATH_TEST

TEST(randIsolatedTest, SkippedALL) {
GTEST_SKIP() << "All randIsolatedTest tests are not supported due to Death Tests not supported on this platform";
}

#endif
112 changes: 112 additions & 0 deletions tests/ci/run_ios_sim_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

# Setup Xcode commands:
# > xcodebuild -runFirstLaunch
# > sudo xcodebuild -license accept
# > xcode-select --install
#
# Install iOS simulator commands:
# > xcodebuild -downloadPlatform iOS -exportPath ~/Download -buildVersion 17.0

set -ex

SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
SCRIPT_DIR="$(readlink -f "${SCRIPT_DIR}")"

source "${SCRIPT_DIR}/common_posix_setup.sh"
source "${SCRIPT_DIR}/gtest_util.sh"

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

pushd "${SRC_ROOT}"

CMAKE_PARAMS=("-DCMAKE_SYSTEM_NAME=iOS" "-DCMAKE_OSX_ARCHITECTURES=arm64" "-DCMAKE_SYSTEM_PROCESSOR=arm64" "-DCMAKE_OSX_SYSROOT=iphonesimulator" "-DCMAKE_THREAD_LIBS_INIT=-lpthread" "-DBUILD_TOOL=0")
run_build "${CMAKE_PARAMS[@]}"

shard_gtest "${BUILD_ROOT}/crypto/crypto_test.app/crypto_test --gtest_also_run_disabled_tests"
shard_gtest ${BUILD_ROOT}/crypto/urandom_test.app/urandom_test
shard_gtest ${BUILD_ROOT}/crypto/mem_test.app/mem_test
shard_gtest ${BUILD_ROOT}/crypto/mem_set_test.app/mem_set_test
shard_gtest ${BUILD_ROOT}/crypto/rwlock_static_init.app/rwlock_static_init

shard_gtest ${BUILD_ROOT}/ssl/ssl_test.app/ssl_test
shard_gtest ${BUILD_ROOT}/ssl/integration_test.app/integration_test

# Due to its special linkage, this does not use GoogleTest
${BUILD_ROOT}/crypto/dynamic_loading_test.app/dynamic_loading_test

popd



Loading