Skip to content

Commit

Permalink
Add test for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
maroontress-tomohisa committed Aug 27, 2023
1 parent 36c3a36 commit 8c4d0ab
Show file tree
Hide file tree
Showing 12 changed files with 485 additions and 194 deletions.
61 changes: 53 additions & 8 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,65 @@ env:

jobs:
build:
runs-on: macos-latest
timeout-minutes: 30
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
abi: [x86_64, x86, arm64-v8a, armeabi-v7a]
runs-on: ${{matrix.os}}

steps:
- name: Set up env
shell: bash
run: |
echo home_bin="$HOME/bin" >> "$GITHUB_ENV"
echo ninja="$HOME/bin/ninja" >> "$GITHUB_ENV"
- name: Set up on Windows
if: runner.os == 'Windows'
shell: bash
run: |
echo ninja_zip="ninja-win.zip" >> "$GITHUB_ENV"
echo android_ndk="$(cygpath -u $ANDROID_NDK)" >> "$GITHUB_ENV"
- name: Set up on Linux
if: runner.os == 'Linux'
run: |
echo ninja_zip="ninja-linux.zip" >> "$GITHUB_ENV"
echo android_ndk="$ANDROID_NDK" >> "$GITHUB_ENV"
- name: Set up on macOS
if: runner.os == 'macOS'
run: |
echo ninja_zip="ninja-mac.zip" >> "$GITHUB_ENV"
echo android_ndk="$ANDROID_NDK" >> "$GITHUB_ENV"
- name: Install ninja
shell: bash
run: |
mkdir -p ${{env.home_bin}}
curl -L -o ninja.zip "https://github.com/ninja-build/ninja/releases/download/v1.11.1/${{env.ninja_zip}}"
unzip ninja.zip -d ${{env.home_bin}}
- uses: actions/checkout@v3
with:
submodules: true

- name: Configure ${{matrix.abi}}
shell: bash
run: |
sh android.sh build configure ${{matrix.abi}} \
-G Ninja -DCMAKE_MAKE_PROGRAM=${{env.ninja}} \
-DCMAKE_INSTALL_PREFIX:PATH="$HOME/android/${{matrix.abi}}"
env:
ANDROID_NDK: ${{env.android_ndk}}
- name: Build ${{matrix.abi}}
shell: bash
run: |
sh build-android.sh ${{matrix.abi}} -DBUILD_TESTSUITE=OFF -DCMAKE_INSTALL_PREFIX:PATH="$HOME/android/${{matrix.abi}}"
cmake --install build-${{matrix.abi}}
cmake --build build/${{matrix.abi}} --config Release -v
- name: Install ${{matrix.abi}}
shell: bash
run: |
cmake --install build/${{matrix.abi}}
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: android
name: android-${{matrix.os}}
path: ~/android/

test:
Expand All @@ -44,7 +84,12 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: true

- name: Configure ${{matrix.abi}}
run: |
sh android.sh build configure ${{matrix.abi}}
- name: Build ${{matrix.abi}}
run: |
cmake --build build/${{matrix.abi}} --config Release -v
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
Expand Down Expand Up @@ -73,9 +118,9 @@ jobs:
ndk: 25.2.9519653
force-avd-creation: false
disable-animations: true
script: sh build-android.sh ${{matrix.abi}} -DCMAKE_INSTALL_PREFIX:PATH="$HOME/android/${{matrix.abi}}"
script: sh android.sh build test ${{matrix.abi}}
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: android-testsuite-${{matrix.os}}-${{matrix.abi}}
path: build-${{matrix.abi}}/testsuite/log.txt
path: build/${{matrix.abi}}/testsuite/log.txt
16 changes: 15 additions & 1 deletion .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,25 @@ jobs:
with:
submodules: true

- name: Configure
run: |
sh ios.sh build configure
- name: Build
run: |
sh build-ios.sh "$HOME/ios"
sh ios.sh build build
- name: Install
run: |
sh ios.sh build install $HOME/ios
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: ios
path: ~/ios/
- name: Run simulator
run: |
runtime=$(xcrun simctl list runtimes iOS -j | jq '.runtimes[].identifier' | tail -1)
udid=$(xcrun simctl list devices iPhone available -j | jq '.devices['$runtime']|.[].udid' | tail -1)
xcrun simctl bootstatus $(eval echo $udid) -b
- name: Test
run: |
ctest --test-dir build/iphonesimulator-x86_64 -C Release --debug -VV
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
cmake_minimum_required(VERSION 3.24)
cmake_minimum_required(VERSION 3.27)

project("mimicssl-md5" VERSION 1.0.0)

cmake_policy(SET CMP0142 NEW)

include(CTest)

add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

add_subdirectory(libmimicssl-md5)
add_subdirectory(mimicssl-md5-cli)

option(BUILD_TESTSUITE "Build testsuite" ON)
if (${BUILD_TESTSUITE})
include(CTest)
add_subdirectory(testsuite)
endif()
add_subdirectory(testsuite)
51 changes: 49 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,58 @@ but a typical configuration would be as follows:

Then build as follows:

```
sh build-android.sh ABI -DBUILD_TESTSUITE=OFF
```plaintext
abi=ABI
sh android.sh BUILD_DIR configure $abi -G Ninja \
-DCMAKE_MAKE_PROGRAM="/path/to/ninja" \
-DCMAKE_INSTALL_PREFIX:PATH="/path/to/dir"
cmake --build BUILD_DIR/$abi --config Release -v
cmake --install BUILD_DIR/$abi
```

`ABI` should be replaced by `arm64-v8a`, `armeabi-v7a`, `x86`, or `x86_64`.
`BUILD_DIR` should be replaced by the build directory (e.g., `build-android`).
Note that `ninja` is required on Windows.

Before running `testsuite`, start Android Emulator as follows:

```
$ANDROID_HOME/emulator/emulator -avd AVD_NAME -no-snapshot
```

`AVD_NAME` should be replaced by the AVD name. Note that You can get the list of
AVD names as follows:

```
$ANDROID_HOME/emulator/emulator -list-avds
```

Then run `testusite` as follows:

```
sh android.sh BUILD_DIR test $abi
```

## Build for iOS

Build as follows:

```plaintext
sh ios.sh BUILD_DIR configure
sh ios.sh BUILD_DIR build
sh ios.sh BUILD_DIR install /path/to/dir
```

`BUILD_DIR` should be replaced by the build directory (e.g., `build-ios`).

You can run `testsuite` with the iPhone simulator as follows:

```plaintext
sh ios.sh BUILD_DIR test ARCH
```

`ARCH` should be replaced by `arm64` or `x86_64`. Note that `jq` is required to
run the iPhone simulator.

[wikipedia::md5]: https://en.wikipedia.org/wiki/MD5
[ietf::rfc1321]: https://www.ietf.org/rfc/rfc1321.txt
Expand Down
81 changes: 81 additions & 0 deletions android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/sh

if [ "$#" = 0 ] ; then
echo usage: $0 BUILD_DIR configure ABI [CMAKE_OPTIONS...]
echo usage: $0 BUILD_DIR test ABI
exit 1
fi
root_build_dir="$1"
shift

# Environment variables:
# ANDROID_NDK (e.g., "$HOME/Library/Android/sdk/ndk/25.2.9519653")
# ANDROID_HOME (e.g., "$HOME/Library/Android/sdk")

# ABI:
# "x86"
# "x86_64"
# "arm64-v8a"
# "armeabi-v7a"

# Options:
# -DCMAKE_INSTALL_PREFIX:PATH="$HOME/android/$ABI"

check_abi() {
abi=$1
case "$abi" in
x86|x86_64|arm64-v8a|armeabi-v7a)
;;
*)
echo unknown ABI: $abi
exit 1
esac
}

if [ "$#" = "0" ] ; then
echo COMMAND not specified
exit 1
fi
command="$1"
shift

case "$command" in
configure)
if [ "$#" = "0" ] ; then
echo ABI not specified
exit 1
fi
abi="$1"
shift
check_abi $abi
build_dir="$root_build_dir/$abi"
rm -rf $build_dir || exit 1
if [ "$abi" = "armeabi-v7a" ] ; then
EXTRA_ARGS='-DCMAKE_ANDROID_ARM_NEON=ON'
fi
cmake -S . -B "$build_dir" -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_CROSSCOMPILING_EMULATOR="$PWD/emulator-android.sh" \
-DCMAKE_SYSTEM_VERSION="21" \
-DCMAKE_ANDROID_ARCH_ABI="$abi" \
-DCMAKE_ANDROID_NDK="$ANDROID_NDK" \
$EXTRA_ARGS "$@" || exit 1
;;
test)
if [ "$#" = "0" ] ; then
echo ABI not specified
exit 1
fi
abi="$1"
shift
check_abi $abi
build_dir="$root_build_dir/$abi"
sh emulator-android.sh --adb-push "$build_dir/testsuite"
ctest --test-dir "$build_dir" -C Release -V || exit 1
sh emulator-android.sh --adb-pull "$build_dir/testsuite"
;;
*)
echo unknown command: $command
exit 1
esac
exit 0
40 changes: 0 additions & 40 deletions build-android.sh

This file was deleted.

Loading

0 comments on commit 8c4d0ab

Please sign in to comment.