~canonical-ci-engineering/+junk/mir-performance-tests-runner-touch

« back to all changes in this revision

Viewing changes to mir-perftest-runner.sh

  • Committer: Francis Ginther
  • Date: 2014-04-21 18:45:57 UTC
  • Revision ID: francis.ginther@canonical.com-20140421184557-jvqlxmehzm8dv2qz
Initial mir performance test scripts adapted from mir medium tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
set +ex
 
3
 
 
4
if [ -z "$1" ] || [ -z "$2" ]
 
5
then
 
6
    echo "You have to pass a device serial and packagearchive link"
 
7
    echo "$0 04bf2c50e294d599 http://host/path/to/archive.zip"
 
8
    exit -1
 
9
fi
 
10
 
 
11
exec_with_adb() {
 
12
    adb -s $ANDROID_SERIAL shell "$@"
 
13
}
 
14
 
 
15
exec_with_adb_user() {
 
16
    adb -s $ANDROID_SERIAL shell sudo -i -u phablet bash -ic "$@"
 
17
}
 
18
 
 
19
ANDROID_SERIAL=$1
 
20
packagearchive=$2
 
21
zip_name=`basename $packagearchive`
 
22
mir_rc=0
 
23
reboot_wait=30
 
24
network_wait=60
 
25
max_retries=5
 
26
results_dir=./results
 
27
mir_dir=$results_dir/mir
 
28
crash_dir=$results_dir/crash
 
29
log_dir=$results_dir/log
 
30
 
 
31
HOME_DIR="/home/phablet"
 
32
setup_dir="$HOME_DIR/mir-testrunner"
 
33
 
 
34
### Device initiation ###
 
35
# First reboot
 
36
echo "Rebooting the phone will take approximately $reboot_wait seconds to settle"
 
37
adb -s $ANDROID_SERIAL reboot
 
38
adb -s $ANDROID_SERIAL wait-for-device
 
39
sleep $reboot_wait
 
40
 
 
41
# Set developer mode
 
42
rm .dev_mode || true
 
43
adb -s $ANDROID_SERIAL pull /.dev_mode
 
44
if [[ ! -a .dev_mode ]]; then
 
45
    exec_with_adb "touch /userdata/.writable_image"
 
46
    echo "Rebooting the phone to set dev mode."
 
47
    echo "It will take approximately $reboot_wait seconds to settle"
 
48
    adb -s $ANDROID_SERIAL reboot
 
49
    adb -s $ANDROID_SERIAL wait-for-device
 
50
    sleep $reboot_wait
 
51
    exec_with_adb "touch /.dev_mode"
 
52
fi
 
53
 
 
54
# Disable the intro screen
 
55
rm .intro_off || true
 
56
adb -s $ANDROID_SERIAL pull /.intro_off
 
57
if [[ ! -a .intro_off ]]; then
 
58
    exec_with_adb "dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User32011 org.freedesktop.DBus.Properties.Set string:com.canonical.unity.AccountsService string:demo-edges variant:boolean:false"
 
59
 
 
60
    exec_with_adb "touch /.intro_off"
 
61
    exec_with_adb "cat /var/lib/AccountsService/users/phablet"
 
62
    echo "Rebooting the phone to disable intro mode."
 
63
    echo "It will take approximately $reboot_wait seconds to settle"
 
64
 
 
65
    adb -s $ANDROID_SERIAL reboot
 
66
    adb -s $ANDROID_SERIAL wait-for-device
 
67
    sleep $reboot_wait
 
68
fi
 
69
 
 
70
### Cleanup ###
 
71
# Cleanup host
 
72
rm $zip_name
 
73
rm -rf $results_dir
 
74
rm -rf package_archive || true
 
75
mkdir -p $results_dir
 
76
mkdir -p $mir_dir
 
77
mkdir -p $crash_dir
 
78
mkdir -p $log_dir
 
79
 
 
80
# Cleanup target
 
81
exec_with_adb "rm -r $setup_dir $HOME_DIR/output"
 
82
exec_with_adb "rm /var/crash/*"
 
83
 
 
84
### Setup target ###
 
85
# Setup scripts
 
86
exec_with_adb_user "mkdir -p $setup_dir"
 
87
adb -s $ANDROID_SERIAL push mir_install_packages.sh "$setup_dir"
 
88
 
 
89
# Setup network
 
90
echo "Pausing $network_wait seconds before starting network"
 
91
sleep $network_wait
 
92
exec_with_adb 'nmcli dev wifi connect ubuntu-qa-g-wpa-d password qalabwireless'
 
93
 
 
94
# Collect pre-setup info
 
95
adb -s $ANDROID_SERIAL pull /etc/media-info $log_dir
 
96
 
 
97
# Setup package archive
 
98
wget $packagearchive
 
99
unzip $zip_name -d package_archive
 
100
if [ -d package_archive/output ]; then
 
101
    ARCHIVE_DIR=package_archive/output
 
102
    chmod 755 $ARCHIVE_DIR
 
103
elif [ -d package_archive/archive/work/output ]; then
 
104
    ARCHIVE_DIR=package_archive/archive/work/output
 
105
    chmod 755 $ARCHIVE_DIR
 
106
else
 
107
    echo "E: Cannot find local package archive" >&2
 
108
    exit 1
 
109
fi
 
110
adb -s $ANDROID_SERIAL push $ARCHIVE_DIR $HOME_DIR/archive
 
111
 
 
112
# Setup the PPAs and local Archive
 
113
ppa_repos="ppa_sources"
 
114
rm $ppa_repos || true
 
115
touch $ppa_repos
 
116
for h in $hooks; do
 
117
    echo "Processing $h"
 
118
    if echo $h | grep D09add_ppa; then
 
119
        ppa=`echo $h | sed 's/D09add_ppa~\(.*\)~\(.*\)/ppa:\1\/\2/'`
 
120
        echo ${ppa} >> ${ppa_repos}
 
121
    fi
 
122
done
 
123
 
 
124
local_archive="deb $local_archive_source/$local_archive_name $local_archive_pocket/ "
 
125
if echo $local_archive | grep "http"; then
 
126
    local_archive=`sh -c "echo $local_archive | sed \"s/naartjie/10.98.3.7/\""`
 
127
    echo ${local_archive} >> ${ppa_repos}
 
128
fi
 
129
echo "Host side PPA repo list:"
 
130
cat $ppa_repos
 
131
adb -s $ANDROID_SERIAL push ${ppa_repos} /tmp/${ppa_repos}
 
132
 
 
133
# Add the test packages (these are the extra packages specified in the job cfg)
 
134
exec_with_adb "sudo apt-get -y --force-yes install $test_packages"
 
135
 
 
136
 
 
137
exec_with_adb "$setup_dir/mir_install_packages.sh"
 
138
 
 
139
### Pre-run ###
 
140
# Collect pre-run logs
 
141
exec_with_adb "top -n 1 -b | head -20 > /tmp/top-pre.log"
 
142
adb -s $ANDROID_SERIAL pull /tmp/top-pre.log $log_dir
 
143
exec_with_adb "dpkg -l > /tmp/dpkg-l.log"
 
144
adb -s $ANDROID_SERIAL pull /tmp/dpkg-l.log $log_dir
 
145
 
 
146
### Run Tests ###
 
147
# Setup to run the tests
 
148
rm .setup_complete || true
 
149
adb -s $ANDROID_SERIAL pull /.setup_complete
 
150
if [[ ! -a .setup_complete ]]; then
 
151
    echo "SETUP FAILED - CAN'T CONTINUE"
 
152
    mir_rc=1
 
153
else
 
154
    # Connect to the unrestricted network for running tests
 
155
    exec_with_adb 'nmcli dev wifi connect ubuntu-qa-g-wpa-d password qalabwireless'
 
156
 
 
157
    # Execute all of the test suites
 
158
    echo "I: Ready to run tests"
 
159
    echo "Rebooting the phone will take approximately $reboot_wait seconds to settle"
 
160
    adb -s $ANDROID_SERIAL reboot
 
161
    adb -s $ANDROID_SERIAL wait-for-device
 
162
    phablet-network --skip-setup -t 90s
 
163
    sleep $reboot_wait
 
164
    echo "I: Turning on the display"
 
165
    exec_with_adb "powerd-cli display on bright &"
 
166
 
 
167
    echo "I: stopping unity8"
 
168
    exec_with_adb_user "/sbin/initctl stop unity8"
 
169
    echo "I: stopping lightdm"
 
170
    exec_with_adb "/sbin/initctl stop lightdm"
 
171
    
 
172
    adb -s $ANDROID_SERIAL wait-for-device
 
173
 
 
174
    set -x 
 
175
    for suite in $test_suites; do
 
176
        echo running suite $suite
 
177
        if grep -q mir_demo_client_ <<< $suite  ; then
 
178
            if ! phablet-test-run -x -s $ANDROID_SERIAL $extra -v  mir-demo-tester --mir-demo $suite /tmp/$suite-log ; then
 
179
                mir_rc=-1
 
180
            fi
 
181
 
 
182
        else
 
183
            if ! phablet-test-run -x -s $ANDROID_SERIAL $extra -v  $suite ; then
 
184
                mir_rc=-1
 
185
            fi
 
186
        fi
 
187
 
 
188
    done
 
189
 
 
190
    adb -s $ANDROID_SERIAL wait-for-device
 
191
fi
 
192
 
 
193
### Post Run ###
 
194
# Collect post-run logs
 
195
exec_with_adb "top -n 1 -b | head -20 > /tmp/top-post.log"
 
196
adb -s $ANDROID_SERIAL pull /tmp/top-post.log $log_dir
 
197
exec_with_adb "dmesg > /tmp/dmesg.log"
 
198
adb -s $ANDROID_SERIAL pull /tmp/dmesg.log $log_dir
 
199
 
 
200
for suite in $test_suites; do
 
201
    adb pull /tmp/$suite-log $mir_dir || true
 
202
done
 
203
 
 
204
# Collect crash files
 
205
echo "I: Gathering crash files (if any)"
 
206
adb -s $ANDROID_SERIAL pull /var/crash $crash_dir
 
207
ls $crash_dir
 
208
 
 
209
echo "I: Testing complete with returncode $mir_rc"
 
210
exit $mir_rc