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