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

217.1.1 by paul.larson at canonical
Add suspend-blocker test
1
#!/bin/bash
2
set -ex
3
4
cleanup() {
5
	#In case anything goes wrong, try to leave the device attached
6
	ncd_usb.py -u http://qa-relay-control -b 0 -r 0 on
7
}
8
9
trap cleanup TERM INT EXIT
10
11
${TARGET_PREFIX} rm -f /var/log/kern.log
12
${TARGET_PREFIX} restart rsyslog
13
${TARGET_PREFIX} sudo -iu phablet start susblock
14
15
#Turn off the USB port for this device
16
ncd_usb.py -u http://qa-relay-control -b 0 -r 0 off 
17
sleep 1800
18
#Turn on the USB port for this device
19
ncd_usb.py -u http://qa-relay-control -b 0 -r 0 on
266.1.1 by paul.larson at canonical
wait for the device to come back after running suspend blocker
20
# Wait for the device to come back
276 by paul.larson at canonical
Work around not being able to stop susblock because it already terminated
21
timeout 300 adb wait-for-device
22
# If we can't stop susblock, it's probably because it already stopped itself
23
${TARGET_PREFIX} sudo -iu phablet stop susblock || /bin/true
217.1.1 by paul.larson at canonical
Add suspend-blocker test
24
${TARGET_PREFIX} /tmp/suspend-blocker/suspend-blocker -rbH -o /tmp/results/kern.json /var/log/kern.log
25
${TARGET_PREFIX} cp /var/log/kern.log /tmp/results