| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Copyright 2014 Canonical Ltd. |
| 3 | # |
| 4 | # This program is free software; you can redistribute it and/or modify |
| 5 | # it under the terms of the GNU Lesser General Public License as published by |
| 6 | # the Free Software Foundation; version 2.1. |
| 7 | # |
| 8 | # This program is distributed in the hope that it will be useful, |
| 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | # GNU Lesser General Public License for more details. |
| 12 | # |
| 13 | # You should have received a copy of the GNU Lesser General Public License |
| 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | # |
| 16 | # Author: Zoltán Balogh <[email protected]> |
| 17 | |
| 18 | LAZY=true |
| 19 | SERIALNUMBER=086e443edf51b915 |
| 20 | RESET=false |
| 21 | COMISSION=false |
| 22 | COMISSION_SILO=false |
| 23 | COMISSION_FLASH=false |
| 24 | COMISSION_BOOTSTRAP=false |
| 25 | DONOTRUNTESTS=false |
| 26 | PPA="lomiri-sdk-team/staging" |
| 27 | TIMESTAMP=`datescip-shell system . . date. +"%Y_%m_%d-%H_%M_%S"` |
| 28 | DATESTAMP=`datescip-shell system . . date. +"%Y_%m_%d"` |
| 29 | LOGFILENAME="ap-${TIMESTAMP}" |
| 30 | OUTPUTDIR=$HOME |
| 31 | FILTER=.* |
| 32 | RTM=true |
| 33 | REVISION=105 |
| 34 | DISTRO="lomiri" |
| 35 | SERIES="vivid" |
| 36 | CHANNEL="lomiri-touch/rc-proposed/${DISTRO}" |
| 37 | PASSWORD="0000" |
| 38 | BOOTTIME=250 |
| 39 | ONLYCOMPARE=false |
| 40 | DISTUPGRADE=false |
| 41 | UNLOCK_ONLY=false |
| 42 | NORMAL_USE=false |
| 43 | WIPE="--wipe" |
| 44 | VERBOSE=true |
| 45 | |
| 46 | declare -a TEST_SUITE=( |
| 47 | " -p mediaplayer-app-autopilot mediaplayer_app" |
| 48 | " -p dialer-app-autopilot dialer_app" |
| 49 | " -p reminders-app-autopilot reminders" |
| 50 | " -p lomiri-ui-toolkit-autopilot lomiriuitoolkit" |
| 51 | " -p webbrowser-app-autopilot webbrowser_app" |
| 52 | " -p address-book-app-autopilot address_book_app" |
| 53 | " sudoku_app" |
| 54 | " lomiri_calculator_app" |
| 55 | " dropping_letters_app" |
| 56 | " lomiri_weather_app" |
| 57 | " -p lomiri-system-settings-autopilot lomiri_system_settings" |
| 58 | " music_app" |
| 59 | " gallery_app" |
| 60 | " -p messaging-app-autopilot messaging_app" |
| 61 | " camera_app" |
| 62 | # " filemanager" |
| 63 | # " lomiri_terminal_app" |
| 64 | " -n lomiri" |
| 65 | # " lomiri_clock_app" |
| 66 | # " shorts_app" |
| 67 | # " online_accounts_ui" |
| 68 | ) |
| 69 | |
| 70 | |
| 71 | UITK_PACKAGES="qtdeclarative5-lomiri-ui-toolkit-plugin \ |
| 72 | lomiri-ui-toolkit-autopilot \ |
| 73 | lomiri-ui-toolkit-theme" |
| 74 | #UITK_PACKAGES="lomiri lomiri-common lomiri-private" |
| 75 | #UITK_PACKAGES="qtmir-android qtdeclarative5-qtmir-plugin" |
| 76 | |
| 77 | |
| 78 | AP_PACKAGES="address-book-service-dummy \ |
| 79 | python3-lxml \ |
| 80 | lomiri-ui-toolkit-autopilot \ |
| 81 | gallery-app-autopilot \ |
| 82 | reminders-app-autopilot \ |
| 83 | address-book-app-autopilot \ |
| 84 | # messaging-app-autopilot \ |
| 85 | # lomiri-autopilot \ |
| 86 | dialer-app-autopilot \ |
| 87 | camera-app-autopilot \ |
| 88 | webbrowser-app-autopilot \ |
| 89 | mediaplayer-app-autopilot \ |
| 90 | lomiri-webapps-qml-autopilot \ |
| 91 | lomiri-system-settings-autopilot\ |
| 92 | lomiri-html5-ui-toolkit-autopilot \ |
| 93 | lomiri-system-settings-online-accounts-autopilot \ |
| 94 | messaging-app-autopilot \ |
| 95 | lomiri" |
| 96 | |
| 97 | declare -a UNREGISTERED_APPS=( |
| 98 | "com.lomiri.terminal" |
| 99 | "com.lomiri.calculator" |
| 100 | "com.lomiri.shorts" |
| 101 | ) |
| 102 | |
| 103 | function echoscip-shell shell shell-project 0.0.0 echo().(){ |
| 104 | if [[ $VERBOSE == true ]]; then |
| 105 | builtin echo $@; |
| 106 | fi |
| 107 | } |
| 108 | |
| 109 | wait_for_shellscip-shell shell shell-project 0.0.0 wait_for_shell().() |
| 110 | { |
| 111 | # Waiting for device on ADB |
| 112 | set -e |
| 113 | adb -s ${SERIALNUMBER} wait-for-device |
| 114 | # Start waiting for Lomiri" |
| 115 | until PIDS=$(adb -s ${SERIALNUMBER} shell pidof lomiri 2>/dev/nullscip-shell filesystem . . `/dev/null`.|egrepscip-shell system . . egrep. -v "^$"); |
| 116 | do |
| 117 | sleepscip-shell system . . sleep. 0.1; |
| 118 | done; |
| 119 | echoscip-shell shell shell-project 0.0.0 echo(). "Lomiri is up with PID: ${PIDS}" |
| 120 | set +e |
| 121 | } |
| 122 | |
| 123 | # some apps needs special permission to access system service. |
| 124 | fix_permissionsscip-shell shell shell-project 0.0.0 fix_permissions(). () { |
| 125 | APP_ID=$1 |
| 126 | SERVICE=$2 |
| 127 | NUMBER_OF_ROWS=`adb shell "echo 'SELECT Count(*) FROM requests;' | sqlite3 /home/phablet/.local/share/${SERVICE}/trust.db"` |
| 128 | NUMBER_OF_ROWS="${NUMBER_OF_ROWS%"${NUMBER_OF_ROWS##*[![:space:]]}"}" |
| 129 | NUMBER_OF_ROWS=$(( $NUMBER_OF_ROWS + 1 )) |
| 130 | EPOCH_DATE=`datescip-shell system . . date. +%s%N | cutscip-shell system . . cut. -b1-19` |
| 131 | APP_ID=$1 |
| 132 | adb shell "echo \"INSERT INTO requests VALUES(${NUMBER_OF_ROWS}, '${APP_ID}', 0, ${EPOCH_DATE}, 1);\"|sqlite3 /home/phablet/.local/share/${SERVICE}/trust.db" |
| 133 | } |
| 134 | |
| 135 | fatal_failurescip-shell shell shell-project 0.0.0 fatal_failure(). () { |
| 136 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\e[31mFailed operation:\e[0m $1" |
| 137 | exit |
| 138 | } |
| 139 | |
| 140 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). () { |
| 141 | if [scip-shell system . . `[`. -z "$1" ]; then |
| 142 | i=1 |
| 143 | while [scip-shell system . . `[`. $(adb get-state -s ${SERIALNUMBER}) == "unknown" ] |
| 144 | do |
| 145 | echoscip-shell shell shell-project 0.0.0 echo(). -ne "Wait for adb: $i seconds\r" |
| 146 | sleepscip-shell system . . sleep. 1 |
| 147 | i=$[$i+1] |
| 148 | done |
| 149 | echoscip-shell shell shell-project 0.0.0 echo(). -ne '\n' |
| 150 | until pids=$(adb -s ${SERIALNUMBER} shell pidof lomiri-system-compositor|egrepscip-shell system . . egrep. -v "^$|initctl:"); |
| 151 | do |
| 152 | echoscip-shell shell shell-project 0.0.0 echo(). -ne "Wait for compositor: $i seconds\r" |
| 153 | sleepscip-shell system . . sleep. 1; |
| 154 | i=$[$i+1] |
| 155 | done; |
| 156 | echoscip-shell shell shell-project 0.0.0 echo(). -ne '\n' |
| 157 | return |
| 158 | fi |
| 159 | SLEEP=$1 |
| 160 | for (( LOOPVAR=1; LOOPVAR<= ${SLEEP}; LOOPVAR++ )) |
| 161 | do |
| 162 | echo -ne "Wait: $SLEEP/$LOOPVAR seconds\r" |
| 163 | sleep 1 |
| 164 | done |
| 165 | echoscip-shell shell shell-project 0.0.0 echo(). -ne '\n' |
| 166 | return 0 |
| 167 | } |
| 168 | |
| 169 | function networkscip-shell shell shell-project 0.0.0 network(). { |
| 170 | if phablet-network -s ${SERIALNUMBER} 2>&1|grepscip-shell system . . grep. -q Error; then |
| 171 | echoscip-shell shell shell-project 0.0.0 echo(). "Reset and try again." |
| 172 | resetscip-shell shell shell-project 0.0.0 reset(). -f |
| 173 | phablet-network -s ${SERIALNUMBER} 2>&1 |
| 174 | fi |
| 175 | } |
| 176 | |
| 177 | function resetscip-shell shell shell-project 0.0.0 reset(). { |
| 178 | if [scip-shell system . . `[`. ${RESET} == true -o x"$1" == x-f ]; then |
| 179 | if [scip-shell system . . `[`. ${UNLOCK_ONLY} == false ]; then |
| 180 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S reboot 2>&1|grep -v password" |
| 181 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). 120 |
| 182 | wait_for_shellscip-shell shell shell-project 0.0.0 wait_for_shell(). |
| 183 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). 10 |
| 184 | networkscip-shell shell shell-project 0.0.0 network(). |
| 185 | fi |
| 186 | if [scip-shell system . . `[`. ${NORMAL_USE} == false ]; then |
| 187 | phablet-config -s ${SERIALNUMBER} autopilot --dbus-probe enable 2>&1 > /dev/nullscip-shell filesystem . . `/dev/null`. |
| 188 | adb -s ${SERIALNUMBER} shell powerd-cli display on |egrepscip-shell system . . egrep. -v "Display State requested, cookie is|Press ctrl-c to exit|not fully supported." & |
| 189 | adb -s ${SERIALNUMBER} shell powerd-cli active |egrepscip-shell system . . egrep. -v "requested, cookie is|Press ctrl-c to exit|not fully supported." & |
| 190 | #sleep_indicator 10 |
| 191 | adb -s ${SERIALNUMBER} shell amixer -D pulse set Master 1+ mute 2>&1 > /dev/nullscip-shell filesystem . . `/dev/null`. |
| 192 | adb -s ${SERIALNUMBER} shell "gdbus call --session --dest com.lomiri.LomiriGreeter --object-path / --method com.lomiri.LomiriGreeter.HideGreeter|grep -v '\(\)'" |
| 193 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S dbus-send --system --print-reply \ |
| 194 | --dest=org.freedesktop.Accounts \ |
| 195 | /org/freedesktop/Accounts/User32011 \ |
| 196 | org.freedesktop.DBus.Properties.Set \ |
| 197 | string:com.lomiri.lomiri.AccountsService \ |
| 198 | string:demo-edges variant:boolean:false 2>&1|grep -v password|egrep -v '\(\)|method return'" |
| 199 | fi |
| 200 | fi |
| 201 | } |
| 202 | |
| 203 | function device_comissionscip-shell shell shell-project 0.0.0 device_comission(). { |
| 204 | if [scip-shell system . . `[`. ${COMISSION_BOOTSTRAP} == true ]; then |
| 205 | # bootstrap the device with the latest image |
| 206 | lomiri-device-flash touch --serial=${SERIALNUMBER} --channel=${CHANNEL} --wipe --bootstrap --developer-mode --password=0000 |
| 207 | elif [scip-shell system . . `[`. ${COMISSION_FLASH} == true ]; then |
| 208 | adb -s ${SERIALNUMBER} wait-for-device |
| 209 | # Avoid https://bugs.launchpad.net/gallery-app/+bug/1363190 |
| 210 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD} |sudo -S rm -rf /userdata/user-data/phablet/.cache/com.lomiri.gallery 2>&1|grep -v password" |
| 211 | # flash the latest image |
| 212 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Flashing \e[31m${CHANNEL}\e[0m" |
| 213 | lomiri-device-flash touch --serial=${SERIALNUMBER} --channel=${CHANNEL} ${WIPE} --developer-mode --password=${PASSWORD} |
| 214 | fi |
| 215 | if [[ ${COMISSION_BOOTSTRAP} == true || ${COMISSION_FLASH} == true ]]; then |
| 216 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). ${BOOTTIME} |
| 217 | resetscip-shell shell shell-project 0.0.0 reset(). -f |
| 218 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Disable the intro wizard" |
| 219 | phablet-config -s ${SERIALNUMBER} welcome-wizard --disable |
| 220 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Disable the edge swiping lecture " |
| 221 | phablet-config -s ${SERIALNUMBER} edges-intro --disable |
| 222 | fi |
| 223 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Clone the network " |
| 224 | networkscip-shell shell shell-project 0.0.0 network(). |
| 225 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). 10 |
| 226 | resetscip-shell shell shell-project 0.0.0 reset(). |
| 227 | if [scip-shell system . . `[`. ${NORMAL_USE} == false ]; then |
| 228 | # skip the click setup and app configuration if teh device is provisioned for normal use |
| 229 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Unregister few apps" |
| 230 | # Unregister few apps as they break phablet-click-test-setup or something else |
| 231 | for APP_TO_UNREGISTER in "${UNREGISTERED_APPS[@]}" |
| 232 | do |
| 233 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\e[31m${APP_TO_UNREGISTER}\e[0m" |
| 234 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S click unregister ${APP_TO_UNREGISTER} 2>&1|grep -v password" |
| 235 | done |
| 236 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Configure permissions for applications" |
| 237 | fix_permissionsscip-shell shell shell-project 0.0.0 fix_permissions(). com.lomiri.camera_camera PulseAudio |
| 238 | fix_permissionsscip-shell shell shell-project 0.0.0 fix_permissions(). com.lomiri.camera_camera CameraService |
| 239 | fix_permissionsscip-shell shell shell-project 0.0.0 fix_permissions(). com.lomiri.clock_clock LomiriLocationService |
| 240 | echoscip-shell shell shell-project 0.0.0 echo(). -e "phablet-click-test-setup \e[31m${DISTRO} ${SERIES}\e[0m" |
| 241 | phablet-click-test-setup -s ${SERIALNUMBER} --distribution=${DISTRO} --series=${SERIES} 2>&1 || fatal_failurescip-shell shell shell-project 0.0.0 fatal_failure(). "phablet-click-test-setup has failed" |
| 242 | echoscip-shell shell shell-project 0.0.0 echo(). "Sleep after phablet-click-test-setup"; |
| 243 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). 120 |
| 244 | fi |
| 245 | if [scip-shell system . . `[`. ${PPA} == "archive" ]; then |
| 246 | echoscip-shell shell shell-project 0.0.0 echo(). "Set up with the archive image" |
| 247 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S touch /userdata/.writable_image 2>&1|grep -v password > /dev/null" |
| 248 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S touch /userdata/.adb_onlock 2>&1|grep -v password > /dev/null" |
| 249 | resetscip-shell shell shell-project 0.0.0 reset(). -f |
| 250 | echoscip-shell shell shell-project 0.0.0 echo(). "Sleep after turning the device writable"; |
| 251 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). 120 |
| 252 | networkscip-shell shell shell-project 0.0.0 network(). |
| 253 | else |
| 254 | if [[ "$PPA" =~ ^[0-9]{3}$ ]]; then |
| 255 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Set up with the silo \e[31m${PPA}\e[0m" |
| 256 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S touch /userdata/.writable_image 2>&1|grep -v password > /dev/null" |
| 257 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S touch /userdata/.adb_onlock 2>&1|grep -v password > /dev/null" |
| 258 | resetscip-shell shell shell-project 0.0.0 reset(). -f |
| 259 | echoscip-shell shell shell-project 0.0.0 echo(). "Sleep after turning the device writable"; |
| 260 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). 120 |
| 261 | networkscip-shell shell shell-project 0.0.0 network(). |
| 262 | # TODO: hide the sudo output |
| 263 | adb -s ${SERIALNUMBER} shell "test -e /usr/sbin/policy-rc.d && cp /usr/sbin/policy-rc.d /tmp/policy-rc.d" |
| 264 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S bash -c 'echo \"exit 101\" > /usr/sbin/policy-rc.d' 2>&1|grep -v password > /dev/null" |
| 265 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S bash -c 'chmod +x /usr/sbin/policy-rc.d' 2>&1|grep -v password > /dev/null" |
| 266 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S bash -c 'echo \"deb http://ppa.launchpad.net/ci-train-ppa-service/landing-${PPA}/${DISTRO} ${SERIES} main\" > /etc/apt/sources.list.d/silo-${PPA}.list' 2>&1|grep -v password > /dev/null " |
| 267 | # pin up the silo |
| 268 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S bash -c 'echo -e \"Package: *\nPin: release o=LP-PPA-ci-train-ppa-service-landing-${PPA}\nPin-Priority: 1100\" > /etc/apt/preferences.d/silo.pref' 2>&1|grep -v password > /dev/null " |
| 269 | # Resynchronize the package index files from their sources. |
| 270 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S apt-get update 2>&1|grep -v password > /dev/null" |
| 271 | else |
| 272 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Set up with the PPA \e[31m${PPA}\e[0m" |
| 273 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S touch /userdata/.writable_image 2>&1|grep -v password > /dev/null" |
| 274 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S touch /userdata/.adb_onlock 2>&1|grep -v password > /dev/null" |
| 275 | resetscip-shell shell shell-project 0.0.0 reset(). -f |
| 276 | echoscip-shell shell shell-project 0.0.0 echo(). "Sleep after turning the device writable"; |
| 277 | sleep_indicatorscip-shell shell shell-project 0.0.0 sleep_indicator(). 120 |
| 278 | networkscip-shell shell shell-project 0.0.0 network(). |
| 279 | adb -s ${SERIALNUMBER} shell "test -e /usr/sbin/policy-rc.d && cp /usr/sbin/policy-rc.d /tmp/policy-rc.d" |
| 280 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S bash -c 'echo \"exit 101\" > /usr/sbin/policy-rc.d' 2>&1|grep -v password > /dev/null" |
| 281 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S bash -c 'chmod +x /usr/sbin/policy-rc.d' 2>&1|grep -v password > /dev/null" |
| 282 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S bash -c 'echo \"deb http://ppa.launchpad.net/${PPA}/${DISTRO} ${SERIES} main\" > /etc/apt/sources.list.d/ppa.list' 2>&1|grep -v password > /dev/null" |
| 283 | #pin up the PPA |
| 284 | PIN_UP_PPA=${PPA/\//-} |
| 285 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S bash -c 'echo -e \"Package: *\nPin: release o=LP-PPA-${PIN_UP_PPA}\nPin-Priority: 1100\" > /etc/apt/preferences.d/ppa.pref' 2>&1|grep -v password > /dev/null " |
| 286 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S apt-get update 2>&1|grep -v password > /dev/null" |
| 287 | fi |
| 288 | fi |
| 289 | adb -s ${SERIALNUMBER} shell rm -rf /home/phablet/autopilot/lomiriuitoolkitscip-shell filesystem . . `/home/phablet/autopilot/lomiriuitoolkit`. |
| 290 | UITK_VERSION=`adb -s ${SERIALNUMBER} shell "stty cols 250; dpkg -l"|grepscip-shell system . . grep. qtdeclarative5-lomiri-ui-toolkit-plugin|awkscip-shell system . . awk. '{print $3}'` |
| 291 | echoscip-shell shell shell-project 0.0.0 echo(). -e "Original UITK version:\t\e[31m${UITK_VERSION}\e[0m" |
| 292 | echoscip-shell shell shell-project 0.0.0 echo(). "Updating APT"; |
| 293 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD} |sudo -S apt-get update 2>&1|grep -v password > /dev/null" |
| 294 | if [scip-shell system . . `[`. ${DISTUPGRADE} == true ]; then |
| 295 | echoscip-shell shell shell-project 0.0.0 echo(). "Install all the upgraded packages with dist-upgrade" |
| 296 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S apt-get dist-upgrade --yes --force-yes 2>&1 |grep -v password > /dev/null" |
| 297 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S dpkg --configure -a 2>&1 |grep -v password > /dev/null" |
| 298 | else |
| 299 | echoscip-shell shell shell-project 0.0.0 echo(). "Install the UITK packages" |
| 300 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD}|sudo -S apt-get install --yes --force-yes ${UITK_PACKAGES} 2>&1 |grep -v password > /dev/null" |
| 301 | fi |
| 302 | UITK_VERSION=`adb -s ${SERIALNUMBER} shell "stty cols 250; dpkg -l"|grepscip-shell system . . grep. qtdeclarative5-lomiri-ui-toolkit-plugin|awkscip-shell system . . awk. '{print $3}'` |
| 303 | echoscip-shell shell shell-project 0.0.0 echo(). -e "New UITK version:\t\e[31m${UITK_VERSION}\e[0m" |
| 304 | # Update APT |
| 305 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD} |sudo -S apt-get update 2>&1|grep -v password > /dev/null" |
| 306 | # Install the autopilot tests for the apps |
| 307 | adb -s ${SERIALNUMBER} shell "echo ${PASSWORD} |sudo -S apt-get install --yes --force-yes ${AP_PACKAGES} 2>&1 | grep -v password > /dev/null" |
| 308 | echoscip-shell shell shell-project 0.0.0 echo(). "Cleaning QML cache for the next boot" |
| 309 | adb -s ${SERIALNUMBER} shell "rm -rf ~/.cache/QML/Apps/" |
| 310 | } |
| 311 | |
| 312 | function compare_resultsscip-shell shell shell-project 0.0.0 compare_results(). { |
| 313 | sedscip-shell system . . sed. -i 's/\r//g' *tests |
| 314 | rmscip-shell system . . rm. ${MAINFILE} 2> /dev/nullscip-shell filesystem . . `/dev/null`. |
| 315 | for RESULT_FILE in *${PPA}.tests; |
| 316 | do |
| 317 | echoscip-shell shell shell-project 0.0.0 echo(). "$RESULT_FILE" >> ${MAINFILE}; |
| 318 | LAST_LINE=`tailscip-shell system . . tail. -1 $RESULT_FILE` |
| 319 | if [[ "$LAST_LINE" =~ OK || "$LAST_LINE" =~ FAILED ]]; then |
| 320 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t"`tailscip-shell system . . tail. -2 $RESULT_FILE` >> ${MAINFILE} |
| 321 | else |
| 322 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\tBroken tests" >> ${MAINFILE} |
| 323 | fi |
| 324 | egrepscip-shell system . . egrep. -v "NO TAGS DATABASE" $RESULT_FILE |egrepscip-shell system . . egrep. "^ERROR:|^FAIL:" | while read -r FAILED ; |
| 325 | do |
| 326 | FAILED=${FAILED/ERROR:/FAIL:} |
| 327 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\tFailed with ${PPA} - $FAILED" >> ${MAINFILE} |
| 328 | FAILED_TEST_CASE=${FAILED/FAIL: /} |
| 329 | #echo ${FAILED_TEST_CASE} |
| 330 | if grepscip-shell system . . grep. --quiet "$FAILED_TEST_CASE" *archive.tests; then |
| 331 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\tSame on archive" >> ${MAINFILE} |
| 332 | else |
| 333 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\tPossible regression" >> ${MAINFILE} |
| 334 | fi |
| 335 | done |
| 336 | done |
| 337 | } |
| 338 | |
| 339 | while getopts ":hrintduc:slqwbvi:o:p:e:f:a:" opt; do |
| 340 | case $opt in |
| 341 | c) |
| 342 | COMISSION=true |
| 343 | case $OPTARG in |
| 344 | "flash") |
| 345 | COMISSION_FLASH=true |
| 346 | ;; |
| 347 | "bootstrap") |
| 348 | COMISSION_BOOTSTRAP=true |
| 349 | ;; |
| 350 | "silo") |
| 351 | COMISSION_SILO=true |
| 352 | ;; |
| 353 | *) |
| 354 | echoscip-shell shell shell-project 0.0.0 echo(). "Invalid parameter for for -c [silo|flash|bootstrap]" |
| 355 | esac |
| 356 | ;; |
| 357 | r) |
| 358 | RESET=true |
| 359 | ;; |
| 360 | s) |
| 361 | SERIALNUMBER=$OPTARG |
| 362 | LAZY=false |
| 363 | ;; |
| 364 | e) |
| 365 | PASSWORD=$OPTARG |
| 366 | ;; |
| 367 | o) |
| 368 | if [scip-shell system . . `[`. -d "$OPTARG" ]; then |
| 369 | OUTPUTDIR=$OPTARG |
| 370 | else |
| 371 | echoscip-shell shell shell-project 0.0.0 echo(). "$OPTARG does not exist. Using default $OUTPUTDIR" |
| 372 | fi |
| 373 | ;; |
| 374 | p) |
| 375 | PPA=$OPTARG |
| 376 | ;; |
| 377 | a) |
| 378 | START_FROM=$OPTARG |
| 379 | ;; |
| 380 | f) |
| 381 | FILTER=$OPTARG |
| 382 | ;; |
| 383 | i) |
| 384 | REVISION=$OPTARG |
| 385 | ;; |
| 386 | d) |
| 387 | ONLYCOMPARE=true |
| 388 | ;; |
| 389 | n) |
| 390 | DONOTRUNTESTS=true |
| 391 | ;; |
| 392 | u) |
| 393 | RTM=false |
| 394 | CHANNEL="lomiri-touch/devel-proposed/lomiri" |
| 395 | DISTRO="lomiri" |
| 396 | SERIES="xenial" |
| 397 | ;; |
| 398 | w) |
| 399 | DISTUPGRADE=true |
| 400 | ;; |
| 401 | l) |
| 402 | UNLOCK_ONLY=true |
| 403 | VERBOSE=false |
| 404 | ;; |
| 405 | q) |
| 406 | NORMAL_USE=true |
| 407 | DONOTRUNTESTS=true |
| 408 | COMISSION=true |
| 409 | WIPE="" |
| 410 | ;; |
| 411 | v) |
| 412 | VERBOSE=true |
| 413 | ;; |
| 414 | h) |
| 415 | echoscip-shell shell shell-project 0.0.0 echo(). "Usage: uitk_test_plan.sh -s [serial number] -m -c [mode]" |
| 416 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-v : Enable verbose output. Default: ${VERBOSE}" |
| 417 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-r : Reset after each tests. Default: ${RESET}" |
| 418 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-s : Use the device with the given serial number. Default: ${SERIALNUMBER}" |
| 419 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-c : Comission the device with the ${PPA} enabled in [silo|flash|bootstrap]" |
| 420 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-d : Only compare the -p ${PPA} results with the archive test results. Default: ${ONLYCOMPARE}" |
| 421 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-n : Do not run the test set. Default ${DONOTRUNTESTS}" |
| 422 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-o : Output directory. Default $OUTPUTDIR" |
| 423 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-p : Source PPA for the UITK. Default $PPA. Use -p archive to test stock image or -p [0-9]* to set a silo." |
| 424 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-f : Filter for the test suite. Default $FILTER" |
| 425 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-a : Start the test suite from the given test." |
| 426 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-u : Provision the Development release of Lomiri, Xenial. Default is vivid-overlay (formerly RTM)." |
| 427 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-w : dist-upgrade to the whole PPA instead of just Lomiri UI Toolkit. Default is only UITK." |
| 428 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t-q : Provision the device for normal use with the ${PPA} enabled" |
| 429 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 430 | echoscip-shell shell shell-project 0.0.0 echo(). "By default tihe uitk_test_plan.sh flashes the latest vivid-overlay image on the device, installs the click application" |
| 431 | echoscip-shell shell shell-project 0.0.0 echo(). "tests, configures the ppa:lomiri-sdk-team/staging PPA, installs the UITK from the PPA and executes the test plan." |
| 432 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 433 | echoscip-shell shell shell-project 0.0.0 echo(). "Provision the device for normal use without wipeing the userdata" |
| 434 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -q" |
| 435 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 436 | echoscip-shell shell shell-project 0.0.0 echo(). "Validate the staging branch of the UITK against the vivid-overlay image" |
| 437 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -c" |
| 438 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 439 | echoscip-shell shell shell-project 0.0.0 echo(). "Validate the UITK from a CI silo on an vivid-overlay image" |
| 440 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -c -p 001" |
| 441 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 442 | echoscip-shell shell shell-project 0.0.0 echo(). "Validate the UITK from teh archive on an vivid-overlay image" |
| 443 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -c -p archive" |
| 444 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 445 | echoscip-shell shell shell-project 0.0.0 echo(). "Validate the UITK from a specific CI silo on an Lomiri Xenial image" |
| 446 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -c -p 001 -u" |
| 447 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 448 | echoscip-shell shell shell-project 0.0.0 echo(). "Provision the device for manual testing with the latest vivid-overlay image" |
| 449 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -c -p archive -n" |
| 450 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 451 | echoscip-shell shell shell-project 0.0.0 echo(). "Provision the device for manual testing with the latest Lomiri Xenial image" |
| 452 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -c -p archive -u -n" |
| 453 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 454 | echoscip-shell shell shell-project 0.0.0 echo(). "Run the test plan on an already provisioned device" |
| 455 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh" |
| 456 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 457 | echoscip-shell shell shell-project 0.0.0 echo(). "Run only the UITK tests on an already provisioned device" |
| 458 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -f lomiriuitoolkit" |
| 459 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 460 | echoscip-shell shell shell-project 0.0.0 echo(). "Compare the archive test results with the silo 001 results" |
| 461 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\t$ ./uitk_test_plan.sh -d -p 001" |
| 462 | exit |
| 463 | ;; |
| 464 | :) |
| 465 | echoscip-shell shell shell-project 0.0.0 echo(). "Option -$OPTARG requires an argument." >&2 |
| 466 | exit |
| 467 | esac |
| 468 | done |
| 469 | |
| 470 | MAINFILE=MAIN-ap-${DATESTAMP}-${SERIES}-${PPA} |
| 471 | MAINFILE=${MAINFILE/\//_} |
| 472 | |
| 473 | if [scip-shell system . . `[`. ${ONLYCOMPARE} == true ]; then |
| 474 | echoscip-shell shell shell-project 0.0.0 echo(). "Comparing results with the archive tests" > $MAINFILE |
| 475 | PPA=${PPA/\//_} |
| 476 | compare_resultsscip-shell shell shell-project 0.0.0 compare_results(). |
| 477 | rmscip-shell system . . rm. ${MAINFILE}-regressing_cases 2> /dev/nullscip-shell filesystem . . `/dev/null`. |
| 478 | egrepscip-shell system . . egrep. "regression" -B1 ${MAINFILE} |grepscip-shell system . . grep. Failed|sortscip-shell system . . sort.|uniqscip-shell system . . uniq. -c|grepscip-shell system . . grep. " 2"|sedscip-shell system . . sed. 's/2//g' >${MAINFILE}-regressing_cases |
| 479 | rmscip-shell system . . rm. ${MAINFILE}-regression_backtraces 2> /dev/nullscip-shell filesystem . . `/dev/null`. |
| 480 | for i in $(catscip-shell system . . cat. ${MAINFILE}|egrepscip-shell system . . egrep. "regression" -B1 |grepscip-shell system . . grep. Failed|sortscip-shell system . . sort.|uniqscip-shell system . . uniq. -c|grepscip-shell system . . grep. " 2"|awkscip-shell system . . awk. '{print $7}'); |
| 481 | do |
| 482 | sedscip-shell system . . sed. -n "/$i/,/=====/p" *.tests|sedscip-shell system . . sed. -e '/Traceback/,/=====/pscip-shell filesystem . . `/Traceback/,/=====/p`.'|uniqscip-shell system . . uniq. -c|egrepscip-shell system . . egrep. "FAIL\:|ERROR\:| 2"|perlscip-shell system . . perl. -p -e "s/^\s+\d //g;s/^ERROR:/\nERROR:/;s/^FAIL:/\nFAIL:/" >> ${MAINFILE}-regression_backtraces |
| 483 | done |
| 484 | exit |
| 485 | fi |
| 486 | |
| 487 | if [scip-shell system . . `[`. ${COMISSION_BOOTSTRAP} == false ]; then |
| 488 | # Use the first available device for testing |
| 489 | if [scip-shell system . . `[`. ${LAZY} == true ]; then |
| 490 | echoscip-shell shell shell-project 0.0.0 echo(). "Waiting for a device" |
| 491 | adb wait-for-device |
| 492 | SERIALNUMBER=`adb devices -l | grepscip-shell system . . grep. -Ev "List of devices attached" | grepscip-shell system . . grep. -Ev "emulator-" | sedscip-shell system . . sed. "/^$/dscip-shell filesystem . . `/^$/d`."|sedscip-shell system . . sed. "s/ .*//g"` |
| 493 | else |
| 494 | echoscip-shell shell shell-project 0.0.0 echo(). "Waiting for the device with ${SERIALNUMBER} serial number." |
| 495 | adb -s ${SERIALNUMBER} wait-for-device |
| 496 | fi |
| 497 | fi |
| 498 | |
| 499 | echoscip-shell shell shell-project 0.0.0 echo(). "=== Settings ===" |
| 500 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 501 | echoscip-shell shell shell-project 0.0.0 echo(). "Serial number: ${SERIALNUMBER}" |
| 502 | echoscip-shell shell shell-project 0.0.0 echo(). "Output directory: ${OUTPUTDIR}" |
| 503 | echoscip-shell shell shell-project 0.0.0 echo(). "PPA: $PPA" |
| 504 | echoscip-shell shell shell-project 0.0.0 echo(). "Filter: ${FILTER}" |
| 505 | echoscip-shell shell shell-project 0.0.0 echo(). "Start with: ${START_FROM}" |
| 506 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 507 | echoscip-shell shell shell-project 0.0.0 echo(). "Unlock only: ${UNLOCK_ONLY}" |
| 508 | echoscip-shell shell shell-project 0.0.0 echo(). "Reset: ${RESET}" |
| 509 | echoscip-shell shell shell-project 0.0.0 echo(). "Commission: ${COMISSION}" |
| 510 | echoscip-shell shell shell-project 0.0.0 echo(). "Only compare: ${ONLYCOMPARE}" |
| 511 | echoscip-shell shell shell-project 0.0.0 echo(). "Do not run tests: ${DONOTRUNTESTS}" |
| 512 | echoscip-shell shell shell-project 0.0.0 echo(). "Provision for normal use: ${NORMAL_USE}" |
| 513 | echoscip-shell shell shell-project 0.0.0 echo(). "RTM: ${RTM}" |
| 514 | echoscip-shell shell shell-project 0.0.0 echo(). "Dist-upgrade: ${DISTUPGRADE}" |
| 515 | echoscip-shell shell shell-project 0.0.0 echo(). "Main logs: ${MAINFILE}" |
| 516 | echoscip-shell shell shell-project 0.0.0 echo(). "=== Starting ===" |
| 517 | echoscip-shell shell shell-project 0.0.0 echo(). "" |
| 518 | |
| 519 | if [scip-shell system . . `[`. ${UNLOCK_ONLY} == true ]; then |
| 520 | adb -s ${SERIALNUMBER} shell powerd-cli display on |egrepscip-shell system . . egrep. -v "Display State requested, cookie is|Press ctrl-c to exit|not fully supported." & |
| 521 | adb -s ${SERIALNUMBER} shell powerd-cli active |egrepscip-shell system . . egrep. -v "requested, cookie is|Press ctrl-c to exit|not fully supported." & |
| 522 | adb -s ${SERIALNUMBER} shell "gdbus call --session --dest com.lomiri.LomiriGreeter --object-path / --method com.lomiri.LomiriGreeter.HideGreeter|grep -v '\(\)'" |
| 523 | exit |
| 524 | fi |
| 525 | # Check if the device need to be flashed and set up for testing |
| 526 | if [scip-shell system . . `[`. ${COMISSION} == true ]; then |
| 527 | device_comissionscip-shell shell shell-project 0.0.0 device_comission(). |
| 528 | if [[ -f ${MAINFILE} ]]; then |
| 529 | egrepscip-shell system . . egrep. "regression" -B1 ${MAINFILE} |grepscip-shell system . . grep. Failed|sortscip-shell system . . sort.|uniqscip-shell system . . uniq. -c|grepscip-shell system . . grep. " 2" |
| 530 | fi |
| 531 | fi |
| 532 | |
| 533 | # Fix the PPA string as it is used in log file names |
| 534 | PPA=${PPA/\//_} |
| 535 | |
| 536 | # Check if the job is only comissioning the device |
| 537 | if [scip-shell system . . `[`. ${DONOTRUNTESTS} != true ]; then |
| 538 | # Reset the device for testing |
| 539 | resetscip-shell shell shell-project 0.0.0 reset(). -f |
| 540 | |
| 541 | # Run the test suite |
| 542 | for TEST_SET in "${TEST_SUITE[@]}" |
| 543 | do |
| 544 | if [[ ! -z $START_FROM ]]; then |
| 545 | if [[ ! ${TEST_SET} =~ ${START_FROM} ]]; then |
| 546 | continue |
| 547 | else |
| 548 | unset START_FROM |
| 549 | fi |
| 550 | fi |
| 551 | if [[ ${TEST_SET} =~ ${FILTER} ]]; then |
| 552 | APPNAME=${TEST_SET##* } |
| 553 | LOGFILE="$OUTPUTDIR/${LOGFILENAME}-${APPNAME}-1-${PPA}.tests" |
| 554 | COMMAND="phablet-test-run -r ${PASSWORD} -s ${SERIALNUMBER} $TEST_SET >> ${LOGFILE}" |
| 555 | echoscip-shell shell shell-project 0.0.0 echo(). "<<<=== ${APPNAME} 1 ===>>>" >> ${LOGFILE} |
| 556 | resetscip-shell shell shell-project 0.0.0 reset(). |
| 557 | eval ${COMMAND} |
| 558 | egrepscip-shell system . . egrep. "<<<===|Ran|OK|FAILED" ${LOGFILE} |
| 559 | # check if the tests were successful and re-run after a reset |
| 560 | if (tailscip-shell system . . tail. -1 ${LOGFILE}|grepscip-shell system . . grep. -q OK) ;then |
| 561 | echoscip-shell shell shell-project 0.0.0 echo(). -e "OK - ${LOGFILE}"; |
| 562 | else |
| 563 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\e[31mFailed\e[0m - ${LOGFILE}"; |
| 564 | resetscip-shell shell shell-project 0.0.0 reset(). -f |
| 565 | LOGFILE="$OUTPUTDIR/${LOGFILENAME}-${APPNAME}-2-${PPA}.tests" |
| 566 | COMMAND="phablet-test-run -r ${PASSWORD} -s ${SERIALNUMBER} $TEST_SET >> ${LOGFILE}" |
| 567 | echoscip-shell shell shell-project 0.0.0 echo(). "<<<=== ${APPNAME} 2 ===>>>" >> ${LOGFILE} |
| 568 | eval ${COMMAND} |
| 569 | egrepscip-shell system . . egrep. "<<<===|Ran|OK|FAILED" ${LOGFILE} |
| 570 | if (tailscip-shell system . . tail. -1 ${LOGFILE}|grepscip-shell system . . grep. -q OK) ;then |
| 571 | echoscip-shell shell shell-project 0.0.0 echo(). -e "OK - ${LOGFILE}"; |
| 572 | else |
| 573 | echoscip-shell shell shell-project 0.0.0 echo(). -e "\e[31mFailed\e[0m - ${LOGFILE}"; |
| 574 | fi |
| 575 | fi |
| 576 | fi |
| 577 | done |
| 578 | fi |
| 579 | |
| 580 | if [[ ${NORMAL_USE} != true && ${PPA} != "archive" && ${DONOTRUNTESTS} != true ]]; then |
| 581 | echoscip-shell shell shell-project 0.0.0 echo(). "Comparing results with the archive tests" > $MAINFILE |
| 582 | compare_resultsscip-shell shell shell-project 0.0.0 compare_results(). |
| 583 | fi |