~pwlars/ubuntu-test-cases/auto-offline-devices

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
#!/bin/bash
set -ex

cleanup() {
	#In case anything goes wrong, try to leave the device attached
	ncd_usb.py -u http://qa-relay-control -b 0 -r 0 on
}

trap cleanup TERM INT EXIT

${TARGET_PREFIX} rm -f /var/log/kern.log
${TARGET_PREFIX} restart rsyslog
${TARGET_PREFIX} sudo -iu phablet start susblock

#Turn off the USB port for this device
ncd_usb.py -u http://qa-relay-control -b 0 -r 0 off 
sleep 1800
#Turn on the USB port for this device
ncd_usb.py -u http://qa-relay-control -b 0 -r 0 on
# Wait for the device to come back
timeout 300 adb wait-for-device
# If we can't stop susblock, it's probably because it already stopped itself
${TARGET_PREFIX} sudo -iu phablet stop susblock || /bin/true
${TARGET_PREFIX} /tmp/suspend-blocker/suspend-blocker -rbH -o /tmp/results/kern.json /var/log/kern.log
${TARGET_PREFIX} cp /var/log/kern.log /tmp/results