summaryrefslogtreecommitdiffstats
path: root/core/tests/overlaytests/runtests.sh
blob: 0ad9efb0938edbf5c4bf710e06f4d994a7d49a0e (plain)
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
#!/bin/bash

adb="adb"
if [[ $# -gt 0 ]]; then
	adb="adb $*" # for setting -e, -d or -s <serial>
fi

function atexit()
{
	local retval=$?

	if [[ $retval -eq 0 ]]; then
		rm $log
	else
		echo "There were errors, please check log at $log"
	fi
}

log=$(mktemp)
trap "atexit" EXIT
failures=0

function compile_module()
{
	local android_mk="$1"

	echo "Compiling .${android_mk:${#PWD}}"
	ONE_SHOT_MAKEFILE="$android_mk" make -C "../../../../../" files | tee -a $log
	if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
		exit 1
	fi
}

function wait_for_boot_completed()
{
	echo "Rebooting device"
	$adb wait-for-device logcat -c
	$adb wait-for-device logcat | grep -m 1 -e 'PowerManagerService.*bootCompleted' >/dev/null
}

function disable_overlay()
{
	echo "Disabling overlay"
	$adb shell rm /vendor/overlay/framework/framework-res.apk
	$adb shell rm /data/resource-cache/vendor@overlay@framework@framework-res.apk@idmap
}

function enable_overlay()
{
	echo "Enabling overlay"
	$adb shell ln -s /data/app/com.android.overlaytest.overlay.apk /vendor/overlay/framework/framework-res.apk
}

function instrument()
{
	local class="$1"

	echo "Instrumenting $class"
	$adb shell am instrument -w -e class $class com.android.overlaytest/android.test.InstrumentationTestRunner | tee -a $log
}

function sync()
{
	echo "Syncing to device"
	$adb remount | tee -a $log
	$adb sync data | tee -a $log
}

# build and sync
compile_module "$PWD/OverlayTest/Android.mk"
compile_module "$PWD/OverlayTestOverlay/Android.mk"
sync

# instrument test (without overlay)
$adb shell stop
disable_overlay
$adb shell start
wait_for_boot_completed
instrument "com.android.overlaytest.WithoutOverlayTest"

# instrument test (with overlay)
$adb shell stop
enable_overlay
$adb shell start
wait_for_boot_completed
instrument "com.android.overlaytest.WithOverlayTest"

# cleanup
exit $(grep -c -e '^FAILURES' $log)