Skip to content
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

Build and test on ARM Android. #177

Closed
wants to merge 1 commit into from
Closed
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
36 changes: 35 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ cache:
directories:
- $HOME/kcov-i686-unknown-linux-gnu
- $HOME/kcov-x86_64-unknown-linux-gnu
- $HOME/android/android-sdk-linux
- $HOME/android/android-18-arm-linux-androideabi-4.8
matrix:
fast_finish: true
include:
Expand Down Expand Up @@ -94,6 +96,38 @@ matrix:
- gcc-arm-linux-gnueabihf
- libc6-dev-armhf-cross

- env: TARGET_X=arm-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ MODE_X=DEBUG KCOV=0
rust: stable
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless

- env: TARGET_X=arm-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ MODE_X=RELWITHDEBINFO KCOV=0
rust: stable
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless

- env: TARGET_X=arm-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ MODE_X=DEBUG KCOV=0
rust: nightly
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the rust: nightly + MODE_X=RELWITHDEBINFO option. Please add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

addons:
apt:
packages:
- expect
- openjdk-6-jre-headless

- env: TARGET_X=arm-linux-androideabi CC_X=arm-linux-androideabi-gcc CXX_X=arm-linux-androideabi-g++ MODE_X=RELWITHDEBINFO KCOV=0
rust: nightly
addons:
apt:
packages:
- expect
- openjdk-6-jre-headless

# The lines from "# BEGIN GENERATED" through "# END GENERATED" are
# generated by running |python mk/update-travis-yml.py|. Any changes
# made to those lines will be overwritten while other lines will be left
Expand Down Expand Up @@ -545,4 +579,4 @@ matrix:
- env: TARGET_X=aarch64-unknown-linux-gnu CC_X=aarch64-linux-gnu-gcc CXX_X=aarch64-linux-gnu-g++ MODE_X=DEBUG KCOV=0
- env: TARGET_X=aarch64-unknown-linux-gnu CC_X=aarch64-linux-gnu-gcc CXX_X=aarch64-linux-gnu-g++ MODE_X=RELWITHDEBINFO KCOV=0

script: if [[ "$TARGET_X" == "arm-unknown-linux-gnueabihf" ]]; then travis_wait 60 mk/travis.sh; else mk/travis.sh; fi
script: if [[ "$TARGET_X" =~ ^arm-.*linux-.*eabi ]]; then travis_wait 60 mk/travis.sh; else mk/travis.sh; fi
70 changes: 70 additions & 0 deletions mk/travis-install-android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash
#
# Copyright (c) 2016 Pietro Monteiro
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set -ex

ANDROID_SDK_VERSION=${ANDROID_SDK_VERSION:-24.4.1}
ANDROID_SDK_URL=https://dl.google.com/android/android-sdk_r${ANDROID_SDK_VERSION}-linux.tgz

ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-10e}
ANDROID_NDK_URL=https://dl.google.com/android/repository/android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip

ANDROID_INSTALL_PREFIX="${HOME}/android"
ANDROID_SDK_INSTALL_DIR="${HOME}/android/android-sdk-linux"
ANDROID_NDK_INSTALL_DIR="${ANDROID_INSTALL_PREFIX}/android-18-arm-linux-androideabi-4.8"

if [[ ! -f $ANDROID_SDK_INSTALL_DIR/tools/emulator ]];then
mkdir -p "${ANDROID_INSTALL_PREFIX}"
pushd "${ANDROID_INSTALL_PREFIX}"

curl ${ANDROID_SDK_URL} | tar -zxf -

expect -c '
set timeout 600;
spawn ./android-sdk-linux/tools/android update sdk -a --no-ui --filter tools,platform-tools,android-18,sys-img-armeabi-v7a-android-18;
expect {
"Do you accept the license" { exp_send "y\r" ; exp_continue }
eof
}
'
popd
fi

echo no | $ANDROID_SDK_INSTALL_DIR/tools/android create avd --name arm-18 --target android-18 --abi armeabi-v7a

$ANDROID_SDK_INSTALL_DIR/tools/android list avd

if [[ ! -f $ANDROID_NDK_INSTALL_DIR/bin/arm-linux-androideabi-gcc ]];then
mkdir -p "${ANDROID_INSTALL_PREFIX}/downloads"
pushd "${ANDROID_INSTALL_PREFIX}/downloads"

curl -O ${ANDROID_NDK_URL}
unzip -q android-ndk-r${ANDROID_NDK_VERSION}-linux-x86_64.zip

./android-ndk-r${ANDROID_NDK_VERSION}/build/tools/make-standalone-toolchain.sh \
--platform=android-18 \
--toolchain=arm-linux-androideabi-4.8 \
--install-dir=${ANDROID_NDK_INSTALL_DIR}

popd
fi

echo end of mk/travis-install-android
37 changes: 34 additions & 3 deletions mk/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,19 @@ aarch64-unknown-linux-gnu)
arm-unknown-linux-gnueabihf)
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf
;;
arm-linux-androideabi)
# install the android sdk/ndk
mk/travis-install-android.sh

export PATH=$HOME/android/android-18-arm-linux-androideabi-4.8/bin:$PATH
export PATH=$HOME/android/android-sdk-linux/platform-tools:$PATH
export PATH=$HOME/android/android-sdk-linux/tools:$PATH
;;
*)
;;
esac

if [[ "$TARGET_X" =~ ^(arm|aarch64) ]]; then
if [[ "$TARGET_X" =~ ^(arm|aarch64) && ! "$TARGET_X" =~ android ]]; then
# We need a newer QEMU than Travis has.
# sudo is needed until the PPA and its packages are whitelisted.
# See https://github.com/travis-ci/apt-source-whitelist/issues/271
Expand Down Expand Up @@ -59,9 +67,32 @@ make --version
cargo version
rustc --version

if [[ "$MODE_X" == "RELWITHDEBINFO" ]]; then mode=--release; fi
if [[ "$MODE_X" == "RELWITHDEBINFO" ]]; then
mode=--release
target_dir=target/$TARGET_X/release
else
target_dir=target/$TARGET_X/debug
fi

CC=$CC_X CXX=$CXX_X cargo test -j2 ${mode-} --verbose --target=$TARGET_X
case $TARGET_X in
arm-linux-androideabi)
CC=$CC_X CXX=$CXX_X cargo test -j2 --no-run ${mode-} --verbose --target=$TARGET_X
emulator @arm-18 -no-skin -no-boot-anim -no-audio -no-window &
adb wait-for-device
adb push $target_dir/ring-* /data/ring-test
for testfile in `find src crypto -name "*_test*.txt"`; do
adb shell mkdir -p /data/`dirname $testfile`
adb push $testfile /data/$testfile
done
adb shell mkdir -p /data/third-party/NIST
adb push third-party/NIST/SHAVS /data/third-party/NIST/SHAVS
adb shell 'cd /data && ./ring-test' 2>&1 | tee /tmp/ring-test
grep "test result: ok" /tmp/ring-test
;;
*)
CC=$CC_X CXX=$CXX_X cargo test -j2 ${mode-} --verbose --target=$TARGET_X
;;
esac

if [[ "$KCOV" == "1" ]]; then
# kcov reports coverage as a percentage of code *linked into the executable*
Expand Down