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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/bin/bash
set -e
if [ -z $1 ]; then
echo "Error: you didn't specify the serial number of the device"
echo "Example:"
echo " bash run-local.sh <device serial number> <test to run>"
echo " For random gestures test use lrt.test_random_gestures"
echo " bash run-local.sh JB012344 lrt.test_random_gestures"
exit 1
fi
if [ -z $2 ]; then
echo "Error: you didn't specify the test to run"
echo "Example:"
echo " bash run-local.sh <device serial number> <test to run>"
echo " For random gestures test use lrt.test_random_gestures"
echo " bash run-local.sh JB012344 lrt.test_random_gestures"
exit 1
fi
set -x
phone_serial=$1
test_to_run=$2
RESULT=0
RESULTS_PATH="~/lrt-results"
rm -rf $RESULTS_PATH
mkdir -p $RESULTS_PATH
exec_with_adb() {
sudo adb -s $phone_serial shell "sudo $@"
}
adb -s $phone_serial wait-for-device
if [ $test_to_run == "lrt.test_random_gestures" ]; then
CRASH_ID=deadbeef2b73679bb94cc77874f81c4822482114dd8bf912741713eb15bf61533b5d8176f0d870f758cc6f241445ffd3359debe1616c832a8ab3b7626d9ed369
fi
if [ $test_to_run == "lrt.test_random" ]; then
CRASH_ID=deadbeef2b73679bb94cc77874f81c4822482114dd8bf912741713eb15bf61533b5d8176f0d870f758cc6f241445ffd3359debe1616c832a8ab3b7626d9ed369
fi
if [ $test_to_run == "lrt.test_switch" ]; then
CRASH_ID=deadbeef17372a2ac165df1ed82002d7cbeeb0aad6adaa39a7a65fc29cb6c724878e3009de7787c88de01911bf874932edb8d11d7debc7506331e8fb5c99a9e3
fi
echo $CRASH_ID
if [ $test_to_run == "lrt.test_ap_core_apps" ]; then
CRASH_ID=deadbeef6ad56ff7b1050f384439a7900acdd7dcce06e81cb051c3417320a19baa4f1769d9fe20e9b01ac5b970d7b1a339526d6edf572d9e2eb7fa3c3232d13c
fi
if [ $test_to_run == "lrt.test_ap_system" ]; then
CRASH_ID=deadbeef34567890123de0f384439a7900acdd7dcce06e81cb051c3417320a19baa4f1769d9fe20e9b01cd5b970d7b1e339897d6fdf572d9e2eb7fa3c3232d14
fi
if [ $test_to_run == "lrt.test_power" ]; then
CRASH_ID=deadbeefad56ff7b1050f384439a7900acdd7dcce06e81cb051c3417320a19baa4f1769d9fe20e9b01ac5b970d7b1a339526d6edf572d9e2eb7fa3c3232d1376
fi
exec_with_adb "sed -i '/CRASH_DB_IDENTIFIER/d' /etc/init/whoopsie.conf"
exec_with_adb "sed -i '/env CRASH_DB_URL=https:\/\/daisy.ubuntu.com/a env CRASH_DB_IDENTIFIER=$CRASH_ID' /etc/init/whoopsie.conf"
exec_with_adb "rm -rf /home/phablet/.cache/upstart/*"
# disable flight mode
exec_with_adb /usr/share/urfkill/scripts/flight-mode 0
adb -s $phone_serial reboot
sleep 10
adb -s $phone_serial wait-for-device
sleep 130
sleep_if_low_battery() {
battery_level=$(adb -s $phone_serial shell "cat /sys/class/power_supply/battery/capacity")
while [ $(echo $battery_level | tr -d '\r') -le 10 ] ; do
echo "Sleeping to charge battery"
sleep 60
battery_level=$(exec_with_adb "cat /sys/class/power_supply/battery/capacity")
done
}
phablet-network -s $phone_serial
rm -rf $RESULTS_PATH/*
mkdir -p $RESULTS_PATH
exec_with_adb "rm -rf /var/crash/*"
exec_with_adb "rm -rf /home/phablet/results"
phablet-test-run -s $phone_serial -x "mkdir -p ~/results"
sleep_if_low_battery
phablet-config -s $phone_serial autopilot --dbus-probe enable
phablet-test-run -s $phone_serial -x "cd autopilot && cd lrt && ./run-lrt.sh $test_to_run" || RESULT=1
adb -s $phone_serial pull /var/log/syslog $RESULTS_PATH/syslog
adb -s $phone_serial pull /var/log/kern.log $RESULTS_PATH/kern.log || true
ls=$(exec_with_adb "ls /var/crash")
echo $ls > $RESULTS_PATH/crash_files.log
adb -s $phone_serial pull /var/crash/ $RESULTS_PATH/crash
adb -s $phone_serial pull /var/log/system-image $RESULTS_PATH/system-image
adb -s $phone_serial pull /home/phablet/result.subunit $RESULTS_PATH/result.subunit
adb -s $phone_serial pull /home/phablet/.cache/upstart $RESULTS_PATH/upstart
echo "exiting"
exit $RESULT
|