blob: b11634c198ec4b9080616c6cba85cedffa65dd44 [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:
Alexandre Lision7b151702014-09-04 10:07:34 -040038# Download android_ndk_
Alexandre Savarda4f33d72012-08-29 17:03:23 -040039# 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 Lision7b151702014-09-04 10:07:34 -040050export ANDROID_ABI=armeabi-v7a
Alexandre Savarda4f33d72012-08-29 17:03:23 -040051
52ANDROID_SDK_TOOLS=$ANDROID_SDK/tools
53
54export PATH=$PATH:$ANDROID_NDK
55export PATH=$PATH:$ANDROID_SDK
56export PATH=$PATH:$ANDROID_SDK/platform-tools
57export PATH=$PATH:$ANDROID_SDK_TOOLS
58
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040059VIRTUAL_DEVICE_ID=31
60VIRTUAL_DEVICE_ABI=armeabi-v7a
Alexandre Savarda4f33d72012-08-29 17:03:23 -040061VIRTUAL_DEVICE_NAME=sflphone-android
62
63ANDROID_PROJECT_PATH=$HOME/sflphone/sflphone-android
64
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040065ANDROID_SFLPHONE_BIN=bin/SFLPhoneHome-debug.apk
Alexandre Savard523c3482012-08-30 09:57:50 -040066ANDROID_SFLPHONE_TEST_SUITE=tests/bin/sflphoneTest-debug.apk
67
Alexandre Lision064e1e02013-10-01 16:18:42 -040068ANDROID_TEST_PACKAGE=org.sflphone.tests
Alexandre Savard523c3482012-08-30 09:57:50 -040069ANDROID_TEST_RUNNNER=android.test.InstrumentationTestRunner
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040070
Alexandre Savarda4f33d72012-08-29 17:03:23 -040071print_help() {
Alexandre Lision7b151702014-09-04 10:07:34 -040072 echo "Init sflphone-android test server, run test suite
Alexandre Savarda4f33d72012-08-29 17:03:23 -040073 Options:
74 -h Print this help message
75 -i Init test server environment (should be run only once)
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040076 -l Launch the emulator
Alexandre Savarda4f33d72012-08-29 17:03:23 -040077 -b Build the application, do not run the test suite
Alexandre Savardc0865ef2012-08-30 17:27:14 -040078 -t Build the test suite
Alexandre Savarda4f33d72012-08-29 17:03:23 -040079 -r Run the full test suite, priorly build the application"
80}
81
82init_build_server() {
83 android delete avd --name $VIRTUAL_DEVICE_NAME
84
85 echo "Create a new android virtual device, overwrite precendent one"
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040086 android create avd -n $VIRTUAL_DEVICE_NAME -t $VIRTUAL_DEVICE_ID -f -b $VIRTUAL_DEVICE_ABI
Alexandre Savarda4f33d72012-08-29 17:03:23 -040087}
88
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040089launch_emulator() {
Alexandre Lision39ec4cd2014-01-27 13:51:33 -050090# echo "Terminate any currently running emulator"
91# killall emulator-arm -u $USER
Alexandre Savarda4f33d72012-08-29 17:03:23 -040092
93 # build_sflphone_android
Alexandre Lision39ec4cd2014-01-27 13:51:33 -050094# echo "List of currently available android virtual devices"
95# android list avd
Alexandre Savarda4f33d72012-08-29 17:03:23 -040096
Alexandre Lision39ec4cd2014-01-27 13:51:33 -050097# 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 Savarda4f33d72012-08-29 17:03:23 -0400104
105 echo "Waiting for device ..."
106 adb wait-for-device
Alexandre Lision7b151702014-09-04 10:07:34 -0400107
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400108# adb push launch-sflphone.sh /data/data
109# adb shell sh /data/data/launch-sflphone.sh
110}
111
Alexandre Lision39ec4cd2014-01-27 13:51:33 -0500112retrieve_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 Savardd9d2ceb2012-08-30 09:29:27 -0400121build_sflphone_android() {
Tristan Matthews2c0493b2014-10-09 22:59:03 -0400122 echo "Build sflphone"
Tristan Matthews0e03a4b2014-10-02 16:44:33 -0400123 ./compile.sh
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400124}
125
126build_sflphone_test_suite() {
127 echo "Build test suite"
Alexandre Lision39ec4cd2014-01-27 13:51:33 -0500128 pushd Tests
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400129 ant debug
130 popd
Alexandre Savard523c3482012-08-30 09:57:50 -0400131}
132
133run_test_suite() {
Alexandre Lision064e1e02013-10-01 16:18:42 -0400134 adb shell am instrument -w org.sflphone.tests/android.test.InstrumentationTestRunner
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400135}
136
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400137if [ "$#" -eq 0 ]; then
138 print_help
139fi
140
Alexandre Savard974363d2012-08-30 15:20:49 -0400141while getopts "hilbrt" opts; do
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400142 case $opts in
143 h)
144 print_help
145 ;;
146 i)
147 init_build_server
148 ;;
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400149 l)
150 launch_emulator
151 ;;
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400152 b)
153 build_sflphone_android
Alexandre Savard974363d2012-08-30 15:20:49 -0400154 ;;
155 t)
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400156 build_sflphone_test_suite
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400157 ;;
158 r)
159 run_test_suite
160 ;;
161 *)
162 print_help
163 ;;
164 esac
165done