-
Notifications
You must be signed in to change notification settings - Fork 65
/
run-testsuite.sh
executable file
·68 lines (56 loc) · 1.86 KB
/
run-testsuite.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#! /usr/bin/env bash
UNLOCK_KEY=82
BIN=target/net.zetetic.sqlcipher.test.apk
INSTALL_ROOT=/data/data/net.zetetic
EMULATOR_CHECK_STATUS="adb shell getprop init.svc.bootanim"
EMULATOR_IS_BOOTED="stopped"
function test_sqlcipher {
# unlock
adb shell input keyevent ${UNLOCK_KEY}
# launch and run test suite
printf "Installing test suite\n"
adb install -r ${BIN} &> /dev/null
printf "Running test suite..."
adb shell am start -n "net.zetetic/net.zetetic.activities.TestSuiteBehaviorsActivity" \
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER -e run 1 &> /dev/null
# remove previous test results
adb shell rm ${INSTALL_ROOT}/files/test-results.log &> /dev/null
#poll for test results
adb shell "run-as net.zetetic cat /data/data/net.zetetic/files/test-results.log" > test-results-$emulator.log &> /dev/null
OUT=$?
printf "."
while [[ ${OUT} != 0 ]]; do
sleep 5
adb shell "run-as net.zetetic cat /data/data/net.zetetic/files/test-results.log" > test-results-$emulator.log &> /dev/null
OUT=$?
printf "."
done
printf "\nTest suite run complete for ${emulator}:\n"
cat test-results-$emulator.log
printf "\n"
sleep 5
}
function test_on_emulator {
emulators=`android list avd | awk '/Name:/{print $2}' | sort -u`
for emulator in ${emulators}; do
emulator -avd "${emulator}" -no-skin &> /dev/null &
OUT=$($EMULATOR_CHECK_STATUS 2> /dev/null)
printf "Booting ${emulator}..."
while [[ ${OUT:0:7} != $EMULATOR_IS_BOOTED ]]; do
OUT=$($EMULATOR_CHECK_STATUS 2> /dev/null)
printf "."
sleep 5
done
test_sqlcipher
stop emulator
adb emu kill
done
}
if [ ! -d $1 ]
then
# test on a device
test_sqlcipher
else
# test on an emulator
test_on_emulator
fi