Skip to content

Commit 93a8225

Browse files
Jean-Baptiste Queruandroid code review
authored andcommitted
Merge "Improve robustness of resource overlay test suite."
2 parents b2228eb + 2c7ea73 commit 93a8225

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

core/tests/overlaytests/OverlayTestOverlay/res/drawable/default_wallpaper.jpg renamed to core/tests/overlaytests/OverlayTestOverlay/res/drawable-nodpi/default_wallpaper.jpg

File renamed without changes.

core/tests/overlaytests/runtests.sh

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function atexit()
1818

1919
log=$(mktemp)
2020
trap "atexit" EXIT
21-
failures=0
2221

2322
function compile_module()
2423
{
@@ -38,6 +37,37 @@ function wait_for_boot_completed()
3837
$adb wait-for-device logcat | grep -m 1 -e 'PowerManagerService.*bootCompleted' >/dev/null
3938
}
4039

40+
function mkdir_if_needed()
41+
{
42+
local path="$1"
43+
44+
if [[ "${path:0:1}" != "/" ]]; then
45+
echo "mkdir_if_needed: error: path '$path' does not begin with /" | tee -a $log
46+
exit 1
47+
fi
48+
49+
local basename=$(basename "$path")
50+
local dirname=$(dirname "$path")
51+
local t=$($adb shell ls -l $dirname | tr -d '\r' | grep -e "${basename}$" | grep -oe '^.')
52+
53+
case "$t" in
54+
d) # File exists, and is a directory ...
55+
# do nothing
56+
;;
57+
l) # ... (or symbolic link possibly to a directory).
58+
# do nothing
59+
;;
60+
"") # File does not exist.
61+
mkdir_if_needed "$dirname"
62+
$adb shell mkdir "$path"
63+
;;
64+
*) # File exists, but is not a directory.
65+
echo "mkdir_if_needed: file '$path' exists, but is not a directory" | tee -a $log
66+
exit 1
67+
;;
68+
esac
69+
}
70+
4171
function disable_overlay()
4272
{
4373
echo "Disabling overlay"
@@ -48,6 +78,8 @@ function disable_overlay()
4878
function enable_overlay()
4979
{
5080
echo "Enabling overlay"
81+
mkdir_if_needed "/system/vendor"
82+
mkdir_if_needed "/vendor/overlay/framework"
5183
$adb shell ln -s /data/app/com.android.overlaytest.overlay.apk /vendor/overlay/framework/framework-res.apk
5284
}
5385

@@ -59,13 +91,21 @@ function instrument()
5991
$adb shell am instrument -w -e class $class com.android.overlaytest/android.test.InstrumentationTestRunner | tee -a $log
6092
}
6193

94+
function remount()
95+
{
96+
echo "Remounting file system writable"
97+
$adb remount | tee -a $log
98+
}
99+
62100
function sync()
63101
{
64102
echo "Syncing to device"
65-
$adb remount | tee -a $log
66103
$adb sync data | tee -a $log
67104
}
68105

106+
# some commands require write access, remount once and for all
107+
remount
108+
69109
# build and sync
70110
compile_module "$PWD/OverlayTest/Android.mk"
71111
compile_module "$PWD/OverlayTestOverlay/Android.mk"

0 commit comments

Comments
 (0)