blob: 3ee6516fe0af76a3ffa7ada685229f69a9a4a9fe [file] [log] [blame]
Alexandre Savarda4f33d72012-08-29 17:03:23 -04001#!/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
45export ANDROID_NDK=$HOME/android/android-ndk-r8b
46export ANDROID_SDK=$HOME/android/android-sdk-linux
47export ANDROID_SWT=$ANDROID_SDK/tools/lib/x86_64
48
49ANDROID_SDK_TOOLS=$ANDROID_SDK/tools
50
51export PATH=$PATH:$ANDROID_NDK
52export PATH=$PATH:$ANDROID_SDK
53export PATH=$PATH:$ANDROID_SDK/platform-tools
54export PATH=$PATH:$ANDROID_SDK_TOOLS
55
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040056VIRTUAL_DEVICE_ID=31
57VIRTUAL_DEVICE_ABI=armeabi-v7a
Alexandre Savarda4f33d72012-08-29 17:03:23 -040058VIRTUAL_DEVICE_NAME=sflphone-android
59
60ANDROID_PROJECT_PATH=$HOME/sflphone/sflphone-android
61
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040062ANDROID_SFLPHONE_BIN=bin/SFLPhoneHome-debug.apk
Alexandre Savard523c3482012-08-30 09:57:50 -040063ANDROID_SFLPHONE_TEST_SUITE=tests/bin/sflphoneTest-debug.apk
64
65ANDROID_TEST_PACKAGE=com.savoirfairelinux.sflphone.tests
66ANDROID_TEST_RUNNNER=android.test.InstrumentationTestRunner
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040067
Alexandre Savarda4f33d72012-08-29 17:03:23 -040068print_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 Savardd9d2ceb2012-08-30 09:29:27 -040073 -l Launch the emulator
Alexandre Savarda4f33d72012-08-29 17:03:23 -040074 -b Build the application, do not run the test suite
75 -r Run the full test suite, priorly build the application"
76}
77
78init_build_server() {
79 android delete avd --name $VIRTUAL_DEVICE_NAME
80
81 echo "Create a new android virtual device, overwrite precendent one"
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040082 android create avd -n $VIRTUAL_DEVICE_NAME -t $VIRTUAL_DEVICE_ID -f -b $VIRTUAL_DEVICE_ABI
Alexandre Savarda4f33d72012-08-29 17:03:23 -040083}
84
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -040085launch_emulator() {
Alexandre Savarda4f33d72012-08-29 17:03:23 -040086 echo "Terminate any currently running emulator"
87 killall emulator-arm -u $USER
88
89 # build_sflphone_android
90 echo "List of currently available android virtual devices"
91 android list avd
92
93 echo "Launching the android emulator using \"$VIRTUAL_DEVICE_NAME\" avd"
94 emulator -avd $VIRTUAL_DEVICE_NAME -audio none -gpu off -partition-size 256 -no-window &
95
96 echo "Waiting for device ..."
97 adb wait-for-device
98
99 echo "List of devices currently running"
100 adb devices
101
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400102# adb push launch-sflphone.sh /data/data
103# adb shell sh /data/data/launch-sflphone.sh
104}
105
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400106build_sflphone_android() {
107 # android update project --target $VIRTUAL_DEVICE_ID --path $ANDROID_PROJECT_PATH
108
109 echo "Build JNI related libraries"
110 # ndk-build clean
111 ndk-build -j4
112
113 echo "Build Java application"
114 ant debug
115
116 echo "Upload sflphone on the virtual device"
Alexandre Savard4d6a52a2012-08-30 11:18:09 -0400117 adb install -r $ANDROID_SFLPHONE_BIN
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400118 # ./adb-push-sflphone.sh
119}
120
121build_sflphone_test_suite() {
122 echo "Build test suite"
123 pushd tests
124 ant debug
125 popd
Alexandre Savard523c3482012-08-30 09:57:50 -0400126
127 echo "Upload test suite on the virtual devices"
Alexandre Savard4d6a52a2012-08-30 11:18:09 -0400128 adb install -r $ANDROID_SFLPHONE_TEST_SUITE
Alexandre Savard523c3482012-08-30 09:57:50 -0400129
130}
131
132run_test_suite() {
133 adb shell am instrument -w com.savoirfairelinux.sflphone.tests/android.test.InstrumentationTestRunner
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400134}
135
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400136if [ "$#" -eq 0 ]; then
137 print_help
138fi
139
140while getopts "hibr" opts; do
141 case $opts in
142 h)
143 print_help
144 ;;
145 i)
146 init_build_server
147 ;;
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400148 l)
149 launch_emulator
150 ;;
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400151 b)
152 build_sflphone_android
Alexandre Savardd9d2ceb2012-08-30 09:29:27 -0400153 build_sflphone_test_suite
Alexandre Savarda4f33d72012-08-29 17:03:23 -0400154 ;;
155 r)
156 run_test_suite
157 ;;
158 *)
159 print_help
160 ;;
161 esac
162done