Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) 2004-2012 Savoir-Faire Linux Inc. |
| 4 | # |
| 5 | # Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> |
| 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; either version 3 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program; if not, write to the Free Software |
| 19 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | # |
| 21 | # Additional permission under GNU GPL version 3 section 7: |
| 22 | # |
| 23 | # If you modify this program, or any covered work, by linking or |
| 24 | # combining it with the OpenSSL project's OpenSSL library (or a |
| 25 | # modified version of that library), containing parts covered by the |
| 26 | # terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 27 | # grants you additional permission to convey the resulting work. |
| 28 | # Corresponding Source for a non-source form of such a combination |
| 29 | # shall include the source code for the parts of OpenSSL used as well |
| 30 | # as that of the covered work. |
| 31 | # |
| 32 | |
| 33 | # Script used by Jenkins continious integration server to build and |
| 34 | # test sflphone-android project |
| 35 | |
| 36 | # |
| 37 | # Make sure that: |
| 38 | # Download android_ndk_ |
| 39 | # android_sdk_ |
| 40 | # Install java runtime engine, ant |
| 41 | # Required dependencies |
| 42 | # sudo apt-get install libglfw-dev |
| 43 | |
| 44 | # Setup environment variables |
| 45 | export ANDROID_NDK=$HOME/android/android-ndk-r8b |
| 46 | export ANDROID_SDK=$HOME/android/android-sdk-linux |
| 47 | export ANDROID_SWT=$ANDROID_SDK/tools/lib/x86_64 |
| 48 | |
| 49 | ANDROID_SDK_TOOLS=$ANDROID_SDK/tools |
| 50 | |
| 51 | export PATH=$PATH:$ANDROID_NDK |
| 52 | export PATH=$PATH:$ANDROID_SDK |
| 53 | export PATH=$PATH:$ANDROID_SDK/platform-tools |
| 54 | export PATH=$PATH:$ANDROID_SDK_TOOLS |
| 55 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 56 | VIRTUAL_DEVICE_ID=31 |
| 57 | VIRTUAL_DEVICE_ABI=armeabi-v7a |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 58 | VIRTUAL_DEVICE_NAME=sflphone-android |
| 59 | |
| 60 | ANDROID_PROJECT_PATH=$HOME/sflphone/sflphone-android |
| 61 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 62 | ANDROID_SFLPHONE_BIN=bin/SFLPhoneHome-debug.apk |
Alexandre Savard | 523c348 | 2012-08-30 09:57:50 -0400 | [diff] [blame] | 63 | ANDROID_SFLPHONE_TEST_SUITE=tests/bin/sflphoneTest-debug.apk |
| 64 | |
| 65 | ANDROID_TEST_PACKAGE=com.savoirfairelinux.sflphone.tests |
| 66 | ANDROID_TEST_RUNNNER=android.test.InstrumentationTestRunner |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 67 | |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 68 | print_help() { |
| 69 | echo "Init sflphone-android test server, run test suite |
| 70 | Options: |
| 71 | -h Print this help message |
| 72 | -i Init test server environment (should be run only once) |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 73 | -l Launch the emulator |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 74 | -b Build the application, do not run the test suite |
Alexandre Savard | c0865ef | 2012-08-30 17:27:14 -0400 | [diff] [blame] | 75 | -t Build the test suite |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 76 | -r Run the full test suite, priorly build the application" |
| 77 | } |
| 78 | |
| 79 | init_build_server() { |
| 80 | android delete avd --name $VIRTUAL_DEVICE_NAME |
| 81 | |
| 82 | echo "Create a new android virtual device, overwrite precendent one" |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 83 | android create avd -n $VIRTUAL_DEVICE_NAME -t $VIRTUAL_DEVICE_ID -f -b $VIRTUAL_DEVICE_ABI |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 84 | } |
| 85 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 86 | launch_emulator() { |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 87 | echo "Terminate any currently running emulator" |
| 88 | killall emulator-arm -u $USER |
| 89 | |
| 90 | # build_sflphone_android |
| 91 | echo "List of currently available android virtual devices" |
| 92 | android list avd |
| 93 | |
| 94 | echo "Launching the android emulator using \"$VIRTUAL_DEVICE_NAME\" avd" |
| 95 | emulator -avd $VIRTUAL_DEVICE_NAME -audio none -gpu off -partition-size 256 -no-window & |
| 96 | |
| 97 | echo "Waiting for device ..." |
| 98 | adb wait-for-device |
| 99 | |
| 100 | echo "List of devices currently running" |
| 101 | adb devices |
| 102 | |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 103 | # adb push launch-sflphone.sh /data/data |
| 104 | # adb shell sh /data/data/launch-sflphone.sh |
| 105 | } |
| 106 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 107 | build_sflphone_android() { |
| 108 | # android update project --target $VIRTUAL_DEVICE_ID --path $ANDROID_PROJECT_PATH |
| 109 | |
| 110 | echo "Build JNI related libraries" |
| 111 | # ndk-build clean |
| 112 | ndk-build -j4 |
| 113 | |
| 114 | echo "Build Java application" |
Alexandre Savard | f0dcca0 | 2012-08-31 13:54:10 -0400 | [diff] [blame] | 115 | ant clean |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 116 | ant debug |
| 117 | |
| 118 | echo "Upload sflphone on the virtual device" |
Alexandre Savard | 4d6a52a | 2012-08-30 11:18:09 -0400 | [diff] [blame] | 119 | adb install -r $ANDROID_SFLPHONE_BIN |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 120 | # ./adb-push-sflphone.sh |
| 121 | } |
| 122 | |
| 123 | build_sflphone_test_suite() { |
| 124 | echo "Build test suite" |
| 125 | pushd tests |
| 126 | ant debug |
| 127 | popd |
Alexandre Savard | 523c348 | 2012-08-30 09:57:50 -0400 | [diff] [blame] | 128 | |
| 129 | echo "Upload test suite on the virtual devices" |
Alexandre Savard | 4d6a52a | 2012-08-30 11:18:09 -0400 | [diff] [blame] | 130 | adb install -r $ANDROID_SFLPHONE_TEST_SUITE |
Alexandre Savard | 523c348 | 2012-08-30 09:57:50 -0400 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | run_test_suite() { |
| 134 | adb shell am instrument -w com.savoirfairelinux.sflphone.tests/android.test.InstrumentationTestRunner |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 135 | } |
| 136 | |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 137 | if [ "$#" -eq 0 ]; then |
| 138 | print_help |
| 139 | fi |
| 140 | |
Alexandre Savard | 974363d | 2012-08-30 15:20:49 -0400 | [diff] [blame] | 141 | while getopts "hilbrt" opts; do |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 142 | case $opts in |
| 143 | h) |
| 144 | print_help |
| 145 | ;; |
| 146 | i) |
| 147 | init_build_server |
| 148 | ;; |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 149 | l) |
| 150 | launch_emulator |
| 151 | ;; |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 152 | b) |
| 153 | build_sflphone_android |
Alexandre Savard | 974363d | 2012-08-30 15:20:49 -0400 | [diff] [blame] | 154 | ;; |
| 155 | t) |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 156 | build_sflphone_test_suite |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 157 | ;; |
| 158 | r) |
| 159 | run_test_suite |
| 160 | ;; |
| 161 | *) |
| 162 | print_help |
| 163 | ;; |
| 164 | esac |
| 165 | done |