Emmanuel Milou | 1ef709f | 2013-09-19 15:01:27 -0400 | [diff] [blame] | 1 | #!/bin/bash -e |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 2 | # |
Alexandre Lision | fed2a64 | 2014-01-10 12:05:47 -0500 | [diff] [blame] | 3 | # Copyright (C) 2004-2014 Savoir-Faire Linux Inc. |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 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 |
alision | cfec4d0 | 2013-07-05 09:23:07 -0400 | [diff] [blame] | 45 | export ANDROID_NDK=$HOME/android-buildtools/ndk |
| 46 | export ANDROID_SDK=$HOME/android-buildtools/sdk |
| 47 | export ANDROID_HOME=$HOME/android-buildtools/sdk |
Alexandre Lision | 39ec4cd | 2014-01-27 13:51:33 -0500 | [diff] [blame] | 48 | export GENYMOTION_HOME=$HOME/android-buildtools/genymotion |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 49 | export ANDROID_SWT=$ANDROID_SDK/tools/lib/x86_64 |
Alexandre Lision | cd49f19 | 2013-07-19 16:27:07 -0400 | [diff] [blame] | 50 | export ANDROID_NDK_ROOT=$ANDROID_NDK |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 51 | |
| 52 | ANDROID_SDK_TOOLS=$ANDROID_SDK/tools |
| 53 | |
| 54 | export PATH=$PATH:$ANDROID_NDK |
| 55 | export PATH=$PATH:$ANDROID_SDK |
| 56 | export PATH=$PATH:$ANDROID_SDK/platform-tools |
| 57 | export PATH=$PATH:$ANDROID_SDK_TOOLS |
| 58 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 59 | VIRTUAL_DEVICE_ID=31 |
| 60 | VIRTUAL_DEVICE_ABI=armeabi-v7a |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 61 | VIRTUAL_DEVICE_NAME=sflphone-android |
| 62 | |
| 63 | ANDROID_PROJECT_PATH=$HOME/sflphone/sflphone-android |
| 64 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 65 | ANDROID_SFLPHONE_BIN=bin/SFLPhoneHome-debug.apk |
Alexandre Savard | 523c348 | 2012-08-30 09:57:50 -0400 | [diff] [blame] | 66 | ANDROID_SFLPHONE_TEST_SUITE=tests/bin/sflphoneTest-debug.apk |
| 67 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 68 | ANDROID_TEST_PACKAGE=org.sflphone.tests |
Alexandre Savard | 523c348 | 2012-08-30 09:57:50 -0400 | [diff] [blame] | 69 | ANDROID_TEST_RUNNNER=android.test.InstrumentationTestRunner |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 70 | |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 71 | print_help() { |
| 72 | echo "Init sflphone-android test server, run test suite |
| 73 | Options: |
| 74 | -h Print this help message |
| 75 | -i Init test server environment (should be run only once) |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 76 | -l Launch the emulator |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 77 | -b Build the application, do not run the test suite |
Alexandre Savard | c0865ef | 2012-08-30 17:27:14 -0400 | [diff] [blame] | 78 | -t Build the test suite |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 79 | -r Run the full test suite, priorly build the application" |
| 80 | } |
| 81 | |
| 82 | init_build_server() { |
| 83 | android delete avd --name $VIRTUAL_DEVICE_NAME |
| 84 | |
| 85 | echo "Create a new android virtual device, overwrite precendent one" |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 86 | 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] | 87 | } |
| 88 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 89 | launch_emulator() { |
Alexandre Lision | 39ec4cd | 2014-01-27 13:51:33 -0500 | [diff] [blame] | 90 | # echo "Terminate any currently running emulator" |
| 91 | # killall emulator-arm -u $USER |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 92 | |
| 93 | # build_sflphone_android |
Alexandre Lision | 39ec4cd | 2014-01-27 13:51:33 -0500 | [diff] [blame] | 94 | # echo "List of currently available android virtual devices" |
| 95 | # android list avd |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 96 | |
Alexandre Lision | 39ec4cd | 2014-01-27 13:51:33 -0500 | [diff] [blame] | 97 | # echo "Launching the android emulator using \"$VIRTUAL_DEVICE_NAME\" avd" |
| 98 | # emulator -avd $VIRTUAL_DEVICE_NAME -audio none -gpu off -partition-size 256 -no-window & |
| 99 | |
| 100 | # echo "List of devices currently running" |
| 101 | # adb devices |
| 102 | vboxmanage snapshot "Nexus4-API18" restore "factory" |
| 103 | $GENYMOTION_HOME/player --vm-name "Nexus4-API18" & |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 104 | |
| 105 | echo "Waiting for device ..." |
| 106 | adb wait-for-device |
Alexandre Lision | 39ec4cd | 2014-01-27 13:51:33 -0500 | [diff] [blame] | 107 | |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 108 | # adb push launch-sflphone.sh /data/data |
| 109 | # adb shell sh /data/data/launch-sflphone.sh |
| 110 | } |
| 111 | |
Alexandre Lision | 39ec4cd | 2014-01-27 13:51:33 -0500 | [diff] [blame] | 112 | retrieve_screenshots() { |
| 113 | |
| 114 | echo "----------------- Zipping screenshots" |
| 115 | adb pull /sdcard/Robotium-Screenshots screens/phone |
| 116 | zip -r screens.zip screens |
| 117 | rm -rf screens |
| 118 | |
| 119 | } |
| 120 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 121 | build_sflphone_android() { |
Alexandre Lision | c0c56b3 | 2014-01-24 15:35:12 -0500 | [diff] [blame] | 122 | |
Alexandre Lision | b36797b | 2014-02-11 09:07:51 -0500 | [diff] [blame] | 123 | |
Alexandre Lision | a405b6c | 2013-09-12 13:01:54 -0400 | [diff] [blame] | 124 | echo "----------------- Cleaning git tree" |
Alexandre Lision | b36797b | 2014-02-11 09:07:51 -0500 | [diff] [blame] | 125 | git checkout master |
| 126 | git pull |
Tristan Matthews | 394f351 | 2013-08-12 16:00:11 -0400 | [diff] [blame] | 127 | # get rid of any local modifications to git submodule |
| 128 | git submodule update |
Alexandre Lision | c0c56b3 | 2014-01-24 15:35:12 -0500 | [diff] [blame] | 129 | pushd jni/sflphone |
Alexandre Lision | 185f105 | 2013-09-12 09:58:11 -0400 | [diff] [blame] | 130 | git checkout master |
Alexandre Lision | c0c56b3 | 2014-01-24 15:35:12 -0500 | [diff] [blame] | 131 | git pull |
Alexandre Lision | a405b6c | 2013-09-12 13:01:54 -0400 | [diff] [blame] | 132 | |
Alexandre Lision | c0c56b3 | 2014-01-24 15:35:12 -0500 | [diff] [blame] | 133 | echo "----------------- Daemon setup" |
Alexandre Lision | a405b6c | 2013-09-12 13:01:54 -0400 | [diff] [blame] | 134 | cd daemon |
Alexandre Lision | c0c56b3 | 2014-01-24 15:35:12 -0500 | [diff] [blame] | 135 | ./autogen.sh |
| 136 | ./configure-android.sh |
Alexandre Lision | a405b6c | 2013-09-12 13:01:54 -0400 | [diff] [blame] | 137 | popd |
Alexandre Lision | c0c56b3 | 2014-01-24 15:35:12 -0500 | [diff] [blame] | 138 | |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 139 | # android update project --target $VIRTUAL_DEVICE_ID --path $ANDROID_PROJECT_PATH |
Alexandre Lision | f135c6f | 2014-02-11 09:10:46 -0500 | [diff] [blame] | 140 | # echo "----------------- Compile pjandroid stack" |
| 141 | # pushd jni/pjproject-android/ |
| 142 | # TARGET_ABI=x86 ./configure-android-patched --use-ndk-cflags --disable-sound --disable-oss --disable-video --enable-ext-sound --disable-speex-aec --disable-g711-codec --disable-l16-codec --disable-gsm-codec --disable-g722-codec --disable-g7221-codec --disable-speex-codec --disable-ilbc-codec --disable-sdl --disable-ffmpeg --disable-v4l2 |
| 143 | # make dep && make |
| 144 | # popd |
alision | f4571d9 | 2013-07-04 17:11:35 -0400 | [diff] [blame] | 145 | |
alision | e93ccd2 | 2013-07-04 17:28:44 -0400 | [diff] [blame] | 146 | ./make-swig.sh |
alision | e93ccd2 | 2013-07-04 17:28:44 -0400 | [diff] [blame] | 147 | |
Alexandre Lision | 2c7fa46 | 2013-07-19 09:44:37 -0400 | [diff] [blame] | 148 | cd jni/ |
Alexandre Lision | a405b6c | 2013-09-12 13:01:54 -0400 | [diff] [blame] | 149 | echo "----------------- Build JNI related libraries" |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 150 | # ndk-build clean |
Alexandre Lision | b633cc5 | 2014-02-14 15:41:16 -0500 | [diff] [blame] | 151 | $ANDROID_NDK/ndk-build -j4 |
Alexandre Lision | 2c7fa46 | 2013-07-19 09:44:37 -0400 | [diff] [blame] | 152 | cd .. |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 153 | |
Alexandre Lision | a405b6c | 2013-09-12 13:01:54 -0400 | [diff] [blame] | 154 | echo "----------------- Build Java application" |
alision | e93ccd2 | 2013-07-04 17:28:44 -0400 | [diff] [blame] | 155 | ant update project -p . |
Alexandre Lision | c0c56b3 | 2014-01-24 15:35:12 -0500 | [diff] [blame] | 156 | ant clean |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 157 | ant debug |
| 158 | |
alision | f4571d9 | 2013-07-04 17:11:35 -0400 | [diff] [blame] | 159 | # echo "Upload sflphone on the virtual device" |
| 160 | #adb install -r $ANDROID_SFLPHONE_BIN |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 161 | # ./adb-push-sflphone.sh |
| 162 | } |
| 163 | |
| 164 | build_sflphone_test_suite() { |
| 165 | echo "Build test suite" |
Alexandre Lision | 39ec4cd | 2014-01-27 13:51:33 -0500 | [diff] [blame] | 166 | pushd Tests |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 167 | ant debug |
| 168 | popd |
Alexandre Savard | 523c348 | 2012-08-30 09:57:50 -0400 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | run_test_suite() { |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 172 | adb shell am instrument -w org.sflphone.tests/android.test.InstrumentationTestRunner |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 173 | } |
| 174 | |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 175 | if [ "$#" -eq 0 ]; then |
| 176 | print_help |
| 177 | fi |
| 178 | |
Alexandre Savard | 974363d | 2012-08-30 15:20:49 -0400 | [diff] [blame] | 179 | while getopts "hilbrt" opts; do |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 180 | case $opts in |
| 181 | h) |
| 182 | print_help |
| 183 | ;; |
| 184 | i) |
| 185 | init_build_server |
| 186 | ;; |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 187 | l) |
| 188 | launch_emulator |
| 189 | ;; |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 190 | b) |
| 191 | build_sflphone_android |
Alexandre Savard | 974363d | 2012-08-30 15:20:49 -0400 | [diff] [blame] | 192 | ;; |
| 193 | t) |
Alexandre Savard | d9d2ceb | 2012-08-30 09:29:27 -0400 | [diff] [blame] | 194 | build_sflphone_test_suite |
Alexandre Savard | a4f33d7 | 2012-08-29 17:03:23 -0400 | [diff] [blame] | 195 | ;; |
| 196 | r) |
| 197 | run_test_suite |
| 198 | ;; |
| 199 | *) |
| 200 | print_help |
| 201 | ;; |
| 202 | esac |
| 203 | done |