blob: 2b695f3bf8c7bc6e296df809a28af0e8f4afca80 [file] [log] [blame]
Emmanuel Milou1ef709f2013-09-19 15:01:27 -04001#!/bin/bash -e
Alexandre Savarda4f33d72012-08-29 17:03:23 -04002#
Alexandre Lisionfed2a642014-01-10 12:05:47 -05003# Copyright (C) 2004-2014 Savoir-Faire Linux Inc.
Alexandre Savarda4f33d72012-08-29 17:03:23 -04004#
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
alisioncfec4d02013-07-05 09:23:07 -040045export ANDROID_NDK=$HOME/android-buildtools/ndk
46export ANDROID_SDK=$HOME/android-buildtools/sdk
47export ANDROID_HOME=$HOME/android-buildtools/sdk
Alexandre Lision39ec4cd2014-01-27 13:51:33 -050048export GENYMOTION_HOME=$HOME/android-buildtools/genymotion
Alexandre Lisioncd49f192013-07-19 16:27:07 -040049export ANDROID_NDK_ROOT=$ANDROID_NDK
Alexandre Savarda4f33d72012-08-29 17:03:23 -040050
51ANDROID_SDK_TOOLS=$ANDROID_SDK/tools
52
53export PATH=$PATH:$ANDROID_NDK
54export PATH=$PATH:$ANDROID_SDK
55export PATH=$PATH:$ANDROID_SDK/platform-tools
56export PATH=$PATH:$ANDROID_SDK_TOOLS
57
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040058VIRTUAL_DEVICE_ID=31
59VIRTUAL_DEVICE_ABI=armeabi-v7a
Alexandre Savarda4f33d72012-08-29 17:03:23 -040060VIRTUAL_DEVICE_NAME=sflphone-android
61
62ANDROID_PROJECT_PATH=$HOME/sflphone/sflphone-android
63
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040064ANDROID_SFLPHONE_BIN=bin/SFLPhoneHome-debug.apk
Alexandre Savard523c3482012-08-30 09:57:50 -040065ANDROID_SFLPHONE_TEST_SUITE=tests/bin/sflphoneTest-debug.apk
66
Alexandre Lision064e1e02013-10-01 16:18:42 -040067ANDROID_TEST_PACKAGE=org.sflphone.tests
Alexandre Savard523c3482012-08-30 09:57:50 -040068ANDROID_TEST_RUNNNER=android.test.InstrumentationTestRunner
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040069
Alexandre Savarda4f33d72012-08-29 17:03:23 -040070print_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 Savardd9d2ceb2012-08-30 09:29:27 -040075 -l Launch the emulator
Alexandre Savarda4f33d72012-08-29 17:03:23 -040076 -b Build the application, do not run the test suite
Alexandre Savardc0865ef2012-08-30 17:27:14 -040077 -t Build the test suite
Alexandre Savarda4f33d72012-08-29 17:03:23 -040078 -r Run the full test suite, priorly build the application"
79}
80
81init_build_server() {
82 android delete avd --name $VIRTUAL_DEVICE_NAME
83
84 echo "Create a new android virtual device, overwrite precendent one"
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040085 android create avd -n $VIRTUAL_DEVICE_NAME -t $VIRTUAL_DEVICE_ID -f -b $VIRTUAL_DEVICE_ABI
Alexandre Savarda4f33d72012-08-29 17:03:23 -040086}
87
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040088launch_emulator() {
Alexandre Lision39ec4cd2014-01-27 13:51:33 -050089# echo "Terminate any currently running emulator"
90# killall emulator-arm -u $USER
Alexandre Savarda4f33d72012-08-29 17:03:23 -040091
92 # build_sflphone_android
Alexandre Lision39ec4cd2014-01-27 13:51:33 -050093# echo "List of currently available android virtual devices"
94# android list avd
Alexandre Savarda4f33d72012-08-29 17:03:23 -040095
Alexandre Lision39ec4cd2014-01-27 13:51:33 -050096# 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 Savarda4f33d72012-08-29 17:03:23 -0400103
104 echo "Waiting for device ..."
105 adb wait-for-device
Alexandre Lision39ec4cd2014-01-27 13:51:33 -0500106
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400107# adb push launch-sflphone.sh /data/data
108# adb shell sh /data/data/launch-sflphone.sh
109}
110
Alexandre Lision39ec4cd2014-01-27 13:51:33 -0500111retrieve_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 Savardd9d2ceb2012-08-30 09:29:27 -0400120build_sflphone_android() {
Alexandre Lisionc0c56b32014-01-24 15:35:12 -0500121
Alexandre Lisiona405b6c2013-09-12 13:01:54 -0400122 echo "----------------- Cleaning git tree"
Alexandre Lisionb36797b2014-02-11 09:07:51 -0500123 git checkout master
124 git pull
Tristan Matthews394f3512013-08-12 16:00:11 -0400125 # get rid of any local modifications to git submodule
126 git submodule update
Alexandre Lisionc0c56b32014-01-24 15:35:12 -0500127 pushd jni/sflphone
Alexandre Lision185f1052013-09-12 09:58:11 -0400128 git checkout master
Alexandre Lisionc0c56b32014-01-24 15:35:12 -0500129 git pull
Alexandre Lisiona405b6c2013-09-12 13:01:54 -0400130
Alexandre Lisionc0c56b32014-01-24 15:35:12 -0500131 echo "----------------- Daemon setup"
Alexandre Lision93dcec22014-04-09 11:22:04 -0400132 cd daemon/libs
133 ./compile_pjsip.sh -a
134 cd ..
Alexandre Lisionc0c56b32014-01-24 15:35:12 -0500135 ./autogen.sh
136 ./configure-android.sh
Alexandre Lisiona405b6c2013-09-12 13:01:54 -0400137 popd
Alexandre Lisionc0c56b32014-01-24 15:35:12 -0500138
alisione93ccd22013-07-04 17:28:44 -0400139 ./make-swig.sh
alisione93ccd22013-07-04 17:28:44 -0400140
Alexandre Lision2c7fa462013-07-19 09:44:37 -0400141 cd jni/
Alexandre Lisiona405b6c2013-09-12 13:01:54 -0400142 echo "----------------- Build JNI related libraries"
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400143 # ndk-build clean
Alexandre Lisionb633cc52014-02-14 15:41:16 -0500144 $ANDROID_NDK/ndk-build -j4
Alexandre Lision2c7fa462013-07-19 09:44:37 -0400145 cd ..
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400146
Alexandre Lisiona405b6c2013-09-12 13:01:54 -0400147 echo "----------------- Build Java application"
alisione93ccd22013-07-04 17:28:44 -0400148 ant update project -p .
Alexandre Lisionc0c56b32014-01-24 15:35:12 -0500149 ant clean
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400150 ant debug
151
alisionf4571d92013-07-04 17:11:35 -0400152 # echo "Upload sflphone on the virtual device"
153 #adb install -r $ANDROID_SFLPHONE_BIN
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400154 # ./adb-push-sflphone.sh
155}
156
157build_sflphone_test_suite() {
158 echo "Build test suite"
Alexandre Lision39ec4cd2014-01-27 13:51:33 -0500159 pushd Tests
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400160 ant debug
161 popd
Alexandre Savard523c3482012-08-30 09:57:50 -0400162}
163
164run_test_suite() {
Alexandre Lision064e1e02013-10-01 16:18:42 -0400165 adb shell am instrument -w org.sflphone.tests/android.test.InstrumentationTestRunner
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400166}
167
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400168if [ "$#" -eq 0 ]; then
169 print_help
170fi
171
Alexandre Savard974363d2012-08-30 15:20:49 -0400172while getopts "hilbrt" opts; do
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400173 case $opts in
174 h)
175 print_help
176 ;;
177 i)
178 init_build_server
179 ;;
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400180 l)
181 launch_emulator
182 ;;
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400183 b)
184 build_sflphone_android
Alexandre Savard974363d2012-08-30 15:20:49 -0400185 ;;
186 t)
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400187 build_sflphone_test_suite
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400188 ;;
189 r)
190 run_test_suite
191 ;;
192 *)
193 print_help
194 ;;
195 esac
196done