Merge changes Ie5426ff3,I04beb9e0,If90e8d1a am: 447aa1af46
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2195298 Change-Id: I6d59db32c3c1af758144091fbf4e0831fe640843 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
7e53a2dfe8
1 changed files with 196 additions and 209 deletions
|
|
@ -59,6 +59,7 @@ TMPDIR=${TMPDIR:-/tmp}
|
|||
print_time=false
|
||||
start_time=`date +%s`
|
||||
ACTIVE_SLOT=
|
||||
OVERLAYFS_BACKING="cache mnt/scratch"
|
||||
|
||||
ADB_WAIT=4m
|
||||
FASTBOOT_WAIT=2m
|
||||
|
|
@ -68,6 +69,43 @@ screen_wait=true
|
|||
## Helper Functions
|
||||
##
|
||||
|
||||
[ "USAGE: LOG [RUN|OK|PASSED|WARNING|ERROR|FAILED|INFO] [message]..." ]
|
||||
LOG() {
|
||||
case "${1}" in
|
||||
R*)
|
||||
shift
|
||||
echo "${GREEN}[ RUN ]${NORMAL}" "${@}"
|
||||
;;
|
||||
OK)
|
||||
shift
|
||||
echo "${GREEN}[ OK ]${NORMAL}" "${@}"
|
||||
;;
|
||||
P*)
|
||||
shift
|
||||
echo "${GREEN}[ PASSED ]${NORMAL}" "${@}"
|
||||
;;
|
||||
W*)
|
||||
shift
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL}" "${@}"
|
||||
;;
|
||||
E*)
|
||||
shift
|
||||
echo "${RED}[ ERROR ]${NORMAL}" "${@}"
|
||||
;;
|
||||
F*)
|
||||
shift
|
||||
echo "${RED}[ FAILED ]${NORMAL}" "${@}"
|
||||
;;
|
||||
I*)
|
||||
shift
|
||||
echo "${BLUE}[ INFO ]${NORMAL}" "${@}"
|
||||
;;
|
||||
*)
|
||||
echo "${BLUE}[ INFO ]${NORMAL}" "${@}"
|
||||
;;
|
||||
esac >&2
|
||||
}
|
||||
|
||||
[ "USAGE: inFastboot
|
||||
|
||||
Returns: true if device is in fastboot mode" ]
|
||||
|
|
@ -143,7 +181,7 @@ adb_date() {
|
|||
|
||||
Returns: the logcat output" ]
|
||||
adb_logcat() {
|
||||
echo "${RED}[ INFO ]${NORMAL} logcat ${@}" >&2 &&
|
||||
LOG INFO "logcat ${*}"
|
||||
adb logcat "${@}" </dev/null |
|
||||
tr -d '\r' |
|
||||
grep -v 'logd : logdr: UID=' |
|
||||
|
|
@ -164,7 +202,7 @@ avc_check() {
|
|||
if [ -z "${L}" ]; then
|
||||
return
|
||||
fi
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} unlabeled sepolicy violations:" >&2
|
||||
LOG WARNING "unlabeled sepolicy violations:"
|
||||
echo "${L}" | sed "s/^/${INDENT}/" >&2
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +348,7 @@ adb_wait() {
|
|||
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
|
||||
local active_slot=`get_active_slot`
|
||||
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}" >&2
|
||||
LOG WARNING "Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
|
||||
fi
|
||||
fi
|
||||
local end=`date +%s`
|
||||
|
|
@ -339,8 +377,8 @@ adb_wait() {
|
|||
;;
|
||||
esac
|
||||
if ${_print_time} || [ -n "${reason}" ]; then
|
||||
echo "${BLUE}[ INFO ]${NORMAL} adb wait duration ${diff_time}${reason}"
|
||||
fi >&2
|
||||
LOG INFO "adb wait duration ${diff_time}${reason}"
|
||||
fi
|
||||
|
||||
return ${ret}
|
||||
}
|
||||
|
|
@ -413,8 +451,8 @@ fastboot_wait() {
|
|||
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
|
||||
local active_slot=`get_active_slot`
|
||||
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
|
||||
fi >&2
|
||||
LOG WARNING "Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
|
||||
fi
|
||||
fi
|
||||
return ${ret}
|
||||
}
|
||||
|
|
@ -438,8 +476,8 @@ recovery_wait() {
|
|||
if [ 0 = ${ret} -a -n "${ACTIVE_SLOT}" ]; then
|
||||
local active_slot=`get_active_slot`
|
||||
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
|
||||
fi >&2
|
||||
LOG WARNING "Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
|
||||
fi
|
||||
fi
|
||||
return ${ret}
|
||||
}
|
||||
|
|
@ -497,7 +535,7 @@ wait_for_screen() {
|
|||
counter=$(( ${counter} + 1 ))
|
||||
if [ ${counter} -gt ${timeout} ]; then
|
||||
${exit_function}
|
||||
echo "ERROR: wait_for_screen() timed out (`format_duration ${timeout}`)" >&2
|
||||
LOG ERROR "wait_for_screen() timed out ($(format_duration ${timeout}))"
|
||||
return 1
|
||||
fi
|
||||
sleep 1
|
||||
|
|
@ -593,12 +631,12 @@ Prints the duration of the test
|
|||
Returns: reports duration" ]
|
||||
test_duration() {
|
||||
if ${print_time}; then
|
||||
echo "${BLUE}[ INFO ]${NORMAL} end `date`"
|
||||
LOG INFO "end $(date)"
|
||||
[ -n "${start_time}" ] || return
|
||||
end_time=`date +%s`
|
||||
local diff_time=$(( ${end_time} - ${start_time} ))
|
||||
echo "${BLUE}[ INFO ]${NORMAL} duration `format_duration ${diff_time}`"
|
||||
fi >&2
|
||||
LOG INFO "duration $(format_duration ${diff_time})"
|
||||
fi
|
||||
}
|
||||
|
||||
[ "USAGE: die [-d|-t <epoch>] [message] >/dev/stderr
|
||||
|
|
@ -618,121 +656,68 @@ die() {
|
|||
fi
|
||||
shift 2
|
||||
fi >&2
|
||||
echo "${RED}[ FAILED ]${NORMAL} ${@}" >&2
|
||||
LOG FAILED "${@}"
|
||||
cleanup
|
||||
restore
|
||||
test_duration
|
||||
exit 1
|
||||
}
|
||||
|
||||
[ "USAGE: EXPECT_EQ <lval> <rval> [--warning [message]]
|
||||
|
||||
Returns true if (regex) lval matches rval" ]
|
||||
EXPECT_EQ() {
|
||||
local lval="${1}"
|
||||
local rval="${2}"
|
||||
shift 2
|
||||
local error=1
|
||||
local prefix="${RED}[ ERROR ]${NORMAL}"
|
||||
if [ X"${1}" = X"--warning" ]; then
|
||||
prefix="${RED}[ WARNING ]${NORMAL}"
|
||||
error=0
|
||||
shift 1
|
||||
fi
|
||||
if ! ( echo X"${rval}" | grep '^X'"${lval}"'$' >/dev/null 2>/dev/null ); then
|
||||
if [ `echo ${lval}${rval}${*} | wc -c` -gt 50 -o "${rval}" != "${rval%
|
||||
*}" ]; then
|
||||
echo "${prefix} expected \"${lval}\""
|
||||
echo "${prefix} got \"${rval}\"" |
|
||||
sed ": again
|
||||
N
|
||||
s/\(\n\)\([^ ]\)/\1${INDENT}\2/
|
||||
t again"
|
||||
if [ -n "${*}" ] ; then
|
||||
echo "${prefix} ${*}"
|
||||
fi
|
||||
else
|
||||
echo "${prefix} expected \"${lval}\" got \"${rval}\" ${*}"
|
||||
fi >&2
|
||||
return ${error}
|
||||
fi
|
||||
if [ -n "${*}" ] ; then
|
||||
prefix="${GREEN}[ INFO ]${NORMAL}"
|
||||
if [ X"${lval}" != X"${rval}" ]; then # we were supplied a regex?
|
||||
if [ `echo ${lval}${rval}${*} | wc -c` -gt 60 -o "${rval}" != "${rval% *}" ]; then
|
||||
echo "${prefix} ok \"${lval}\""
|
||||
echo " = \"${rval}\"" |
|
||||
sed ": again
|
||||
N
|
||||
s/\(\n\)\([^ ]\)/\1${INDENT}\2/
|
||||
t again"
|
||||
if [ -n "${*}" ] ; then
|
||||
echo "${prefix} ${*}"
|
||||
fi
|
||||
else
|
||||
echo "${prefix} ok \"${lval}\" = \"${rval}\" ${*}"
|
||||
fi
|
||||
else
|
||||
echo "${prefix} ok \"${lval}\" ${*}"
|
||||
fi >&2
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
[ "USAGE: EXPECT_NE <lval> <rval> [--warning [message]]
|
||||
|
||||
Returns true if lval matches rval" ]
|
||||
EXPECT_NE() {
|
||||
local lval="${1}"
|
||||
local rval="${2}"
|
||||
shift 2
|
||||
local error=1
|
||||
local prefix="${RED}[ ERROR ]${NORMAL}"
|
||||
if [ X"${1}" = X"--warning" ]; then
|
||||
prefix="${RED}[ WARNING ]${NORMAL}"
|
||||
error=0
|
||||
shift 1
|
||||
fi
|
||||
if [ X"${rval}" = X"${lval}" ]; then
|
||||
echo "${prefix} did not expect \"${lval}\" ${*}" >&2
|
||||
return ${error}
|
||||
fi
|
||||
if [ -n "${*}" ] ; then
|
||||
echo "${prefix} ok \"${lval}\" not \"${rval}\" ${*}" >&2
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
[ "USAGE: check_eq <lval> <rval> [--warning [message]]
|
||||
|
||||
Exits if (regex) lval mismatches rval" ]
|
||||
Exits if (regex) lval mismatches rval.
|
||||
|
||||
Returns: true if lval matches rval" ]
|
||||
check_eq() {
|
||||
local lval="${1}"
|
||||
local rval="${2}"
|
||||
shift 2
|
||||
if [[ "${rval}" =~ ^${lval}$ ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local error=true
|
||||
local logt=ERROR
|
||||
if [ X"${1}" = X"--warning" ]; then
|
||||
EXPECT_EQ "${lval}" "${rval}" ${*}
|
||||
return
|
||||
shift 1
|
||||
error=false
|
||||
logt=WARNING
|
||||
fi
|
||||
if ! EXPECT_EQ "${lval}" "${rval}"; then
|
||||
die "${@}"
|
||||
if [ $(( ${#lval} + ${#rval} )) -gt 40 ]; then
|
||||
LOG "${logt}" "expected \"${lval}\"
|
||||
${INDENT}got \"${rval}\""
|
||||
else
|
||||
LOG "${logt}" "expected \"${lval}\" got \"${rval}\""
|
||||
fi
|
||||
${error} && die "${*}"
|
||||
[ -n "${*}" ] && LOG "${logt}" "${*}"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ "USAGE: check_ne <lval> <rval> [--warning [message]]
|
||||
|
||||
Exits if lval matches rval" ]
|
||||
Exits if (regex) lval matches rval.
|
||||
|
||||
Returns: true if lval mismatches rval" ]
|
||||
check_ne() {
|
||||
local lval="${1}"
|
||||
local rval="${2}"
|
||||
shift 2
|
||||
if ! [[ "${rval}" =~ ^${lval}$ ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local error=true
|
||||
local logt=ERROR
|
||||
if [ X"${1}" = X"--warning" ]; then
|
||||
EXPECT_NE "${lval}" "${rval}" ${*}
|
||||
return
|
||||
fi
|
||||
if ! EXPECT_NE "${lval}" "${rval}"; then
|
||||
die "${@}"
|
||||
shift 1
|
||||
error=false
|
||||
logt=WARNING
|
||||
fi
|
||||
LOG "${logt}" "unexpected \"${rval}\""
|
||||
${error} && die "${*}"
|
||||
[ -n "${*}" ] && LOG "${logt}" "${*}"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ "USAGE: join_with <delimiter> <strings>
|
||||
|
|
@ -788,6 +773,41 @@ skip_unrelated_mounts() {
|
|||
grep -v "[%] /\(data_mirror\|apex\|bionic\|system\|vendor\)/[^ ][^ ]*$"
|
||||
}
|
||||
|
||||
[ "USAGE: surgically_wipe_overlayfs
|
||||
|
||||
Surgically wipe any mounted overlayfs scratch files.
|
||||
|
||||
Returns: true if wiped anything" ]
|
||||
surgically_wipe_overlayfs() {
|
||||
local wiped_anything=false
|
||||
for d in ${OVERLAYFS_BACKING}; do
|
||||
if adb_su test -d "/${d}/overlay" </dev/null; then
|
||||
LOG INFO "/${d}/overlay is setup, surgically wiping"
|
||||
adb_su rm -rf "/${d}/overlay" </dev/null
|
||||
wiped_anything=true
|
||||
fi
|
||||
done
|
||||
${wiped_anything}
|
||||
}
|
||||
|
||||
[ "USAGE: is_overlayfs_mounted
|
||||
|
||||
Returns: true if overlayfs is mounted" ]
|
||||
is_overlayfs_mounted() {
|
||||
local df_output=$(adb_su df -k </dev/null)
|
||||
local df_header_line=$(echo "${df_output}" | head -1)
|
||||
local overlay_mounts=$(echo "${df_output}" | tail +2 |
|
||||
skip_unrelated_mounts |
|
||||
awk '$1 == "overlay" || $6 == "/mnt/scratch"')
|
||||
if ! echo "${overlay_mounts}" | grep -q '^overlay '; then
|
||||
return 1
|
||||
fi >/dev/null 2>/dev/null
|
||||
( echo "${df_header_line}"
|
||||
echo "${overlay_mounts}"
|
||||
) >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
##
|
||||
## MAINLINE
|
||||
##
|
||||
|
|
@ -875,20 +895,20 @@ if ! ${color}; then
|
|||
fi
|
||||
|
||||
if ${print_time}; then
|
||||
echo "${BLUE}[ INFO ]${NORMAL}" start `date` >&2
|
||||
LOG INFO "start $(date)"
|
||||
fi
|
||||
|
||||
inFastboot && die "device in fastboot mode"
|
||||
inRecovery && die "device in recovery mode"
|
||||
if ! inAdb; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} device not in adb mode" >&2
|
||||
LOG WARNING "device not in adb mode"
|
||||
adb_wait ${ADB_WAIT}
|
||||
fi
|
||||
inAdb || die "specified device not in adb mode"
|
||||
isDebuggable || die "device not a debug build"
|
||||
enforcing=true
|
||||
if ! adb_su getenforce </dev/null | grep 'Enforcing' >/dev/null; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} device does not have sepolicy in enforcing mode" >&2
|
||||
LOG WARNING "device does not have sepolicy in enforcing mode"
|
||||
enforcing=false
|
||||
fi
|
||||
|
||||
|
|
@ -914,16 +934,16 @@ if [ -n "${USB_SERIAL}" ]; then
|
|||
fi
|
||||
[ -z "${ANDROID_SERIAL}${USB_ADDRESS}" ] ||
|
||||
USB_DEVICE=`usb_devnum`
|
||||
echo "${BLUE}[ INFO ]${NORMAL}" ${ANDROID_SERIAL} ${USB_ADDRESS} ${USB_DEVICE} >&2
|
||||
LOG INFO "${ANDROID_SERIAL} ${USB_ADDRESS} ${USB_DEVICE}"
|
||||
BUILD_DESCRIPTION=`get_property ro.build.description`
|
||||
[ -z "${BUILD_DESCRIPTION}" ] ||
|
||||
echo "${BLUE}[ INFO ]${NORMAL} ${BUILD_DESCRIPTION}" >&2
|
||||
LOG INFO "${BUILD_DESCRIPTION}"
|
||||
KERNEL_VERSION="`adb_su cat /proc/version </dev/null 2>/dev/null`"
|
||||
[ -z "${KERNEL_VERSION}" ] ||
|
||||
echo "${BLUE}[ INFO ]${NORMAL} ${KERNEL_VERSION}" >&2
|
||||
LOG INFO "${KERNEL_VERSION}"
|
||||
ACTIVE_SLOT=`get_active_slot`
|
||||
[ -z "${ACTIVE_SLOT}" ] ||
|
||||
echo "${BLUE}[ INFO ]${NORMAL} active slot is ${ACTIVE_SLOT}" >&2
|
||||
LOG INFO "active slot is ${ACTIVE_SLOT}"
|
||||
|
||||
# Acquire list of system partitions
|
||||
|
||||
|
|
@ -940,7 +960,7 @@ MOUNTS="`for i in ${PARTITIONS}; do
|
|||
echo /${i}
|
||||
done |
|
||||
tr '\n' ' '`"
|
||||
echo "${BLUE}[ INFO ]${NORMAL} System Partitions list: ${PARTITIONS}" >&2
|
||||
LOG INFO "System Partitions list: ${PARTITIONS}"
|
||||
|
||||
# Report existing partition sizes
|
||||
adb_sh ls -l /dev/block/by-name/ /dev/block/mapper/ </dev/null 2>/dev/null |
|
||||
|
|
@ -962,20 +982,19 @@ adb_sh ls -l /dev/block/by-name/ /dev/block/mapper/ </dev/null 2>/dev/null |
|
|||
esac
|
||||
size=`adb_su cat /sys/block/${device}/size 2>/dev/null </dev/null` &&
|
||||
size=$(( ${size} / 2 )) &&
|
||||
echo "${BLUE}[ INFO ]${NORMAL} partition ${name} device ${device} size ${size}K" >&2
|
||||
LOG INFO "partition ${name} device ${device} size ${size}K"
|
||||
done
|
||||
|
||||
# If reboot too soon after fresh flash, could trip device update failure logic
|
||||
if ${screen_wait}; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} waiting for screen to come up. Consider --no-wait-screen option" >&2
|
||||
LOG WARNING "waiting for screen to come up. Consider --no-wait-screen option"
|
||||
fi
|
||||
if ! wait_for_screen && ${screen_wait}; then
|
||||
screen_wait=false
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} not healthy, no launcher, skipping wait for screen" >&2
|
||||
LOG WARNING "not healthy, no launcher, skipping wait for screen"
|
||||
fi
|
||||
|
||||
# Can we test remount -R command?
|
||||
OVERLAYFS_BACKING="cache mnt/scratch"
|
||||
overlayfs_supported=true
|
||||
if [ "orange" != "`get_property ro.boot.verifiedbootstate`" -o \
|
||||
"2" != "`get_property partition.system.verified`" ]; then
|
||||
|
|
@ -986,14 +1005,7 @@ if [ "orange" != "`get_property ro.boot.verifiedbootstate`" -o \
|
|||
adb_wait ${ADB_WAIT} ||
|
||||
true
|
||||
if inAdb; then
|
||||
reboot=false
|
||||
for d in ${OVERLAYFS_BACKING}; do
|
||||
if adb_test -d /${d}/overlay; then
|
||||
adb_su rm -rf /${d}/overlay </dev/null
|
||||
reboot=true
|
||||
fi
|
||||
done
|
||||
if ${reboot}; then
|
||||
if surgically_wipe_overlayfs; then
|
||||
adb_reboot &&
|
||||
adb_wait ${ADB_WAIT}
|
||||
fi
|
||||
|
|
@ -1013,14 +1025,14 @@ else
|
|||
adb_wait ${ADB_WAIT}
|
||||
}
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} Testing adb shell su root remount -R command" >&2
|
||||
LOG RUN "Testing adb shell su root remount -R command"
|
||||
|
||||
avc_check
|
||||
T=`adb_date`
|
||||
adb_su remount -R system </dev/null
|
||||
err=${?}
|
||||
if [ "${err}" != 0 ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} adb shell su root remount -R system = ${err}, likely did not reboot!" >&2
|
||||
LOG WARNING "adb shell su root remount -R system = ${err}, likely did not reboot!"
|
||||
T="-t ${T}"
|
||||
else
|
||||
# Rebooted, logcat will be meaningless, and last logcat will likely be clear
|
||||
|
|
@ -1036,10 +1048,10 @@ ${INDENT}ro.boot.verifiedbootstate=\"`get_property ro.boot.verifiedbootstate`\"
|
|||
${INDENT}partition.system.verified=\"`get_property partition.system.verified`\""
|
||||
fi
|
||||
|
||||
echo "${GREEN}[ OK ]${NORMAL} adb shell su root remount -R command" >&2
|
||||
LOG OK "adb shell su root remount -R command"
|
||||
fi
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} Testing kernel support for overlayfs" >&2
|
||||
LOG RUN "Testing kernel support for overlayfs"
|
||||
|
||||
adb_wait || die "wait for device failed"
|
||||
adb_root ||
|
||||
|
|
@ -1047,58 +1059,45 @@ adb_root ||
|
|||
|
||||
adb_test -d /sys/module/overlay ||
|
||||
adb_sh grep "nodev${TAB}overlay" /proc/filesystems </dev/null >/dev/null 2>/dev/null &&
|
||||
echo "${GREEN}[ OK ]${NORMAL} overlay module present" >&2 ||
|
||||
LOG OK "overlay module present" ||
|
||||
(
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} overlay module not present" >&2 &&
|
||||
LOG WARNING "overlay module not present" &&
|
||||
false
|
||||
) ||
|
||||
overlayfs_supported=false
|
||||
if ${overlayfs_supported}; then
|
||||
adb_test -f /sys/module/overlay/parameters/override_creds &&
|
||||
echo "${GREEN}[ OK ]${NORMAL} overlay module supports override_creds" >&2 ||
|
||||
LOG OK "overlay module supports override_creds" ||
|
||||
case `adb_sh uname -r </dev/null` in
|
||||
4.[456789].* | 4.[1-9][0-9]* | [56789].*)
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} overlay module does not support override_creds" >&2 &&
|
||||
LOG WARNING "overlay module does not support override_creds" &&
|
||||
overlayfs_supported=false
|
||||
;;
|
||||
*)
|
||||
echo "${GREEN}[ OK ]${NORMAL} overlay module uses caller's creds" >&2
|
||||
LOG OK "overlay module uses caller's creds"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} Checking current overlayfs status" >&2
|
||||
LOG RUN "Checking current overlayfs status"
|
||||
|
||||
# We can not universally use adb enable-verity to ensure device is
|
||||
# in a overlayfs disabled state since it can prevent reboot on
|
||||
# devices that remount the physical content rather than overlayfs.
|
||||
# So lets do our best to surgically wipe the overlayfs state without
|
||||
# having to go through enable-verity transition.
|
||||
reboot=false
|
||||
for d in ${OVERLAYFS_BACKING}; do
|
||||
if adb_test -d /${d}/overlay; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} /${d}/overlay is setup, surgically wiping" >&2
|
||||
adb_sh rm -rf /${d}/overlay </dev/null ||
|
||||
die "/${d}/overlay wipe"
|
||||
reboot=true
|
||||
fi
|
||||
done
|
||||
if ${reboot}; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} rebooting before test" >&2
|
||||
if surgically_wipe_overlayfs; then
|
||||
LOG WARNING "rebooting before test"
|
||||
adb_reboot &&
|
||||
adb_wait ${ADB_WAIT} ||
|
||||
die "lost device after reboot after wipe `usb_status`"
|
||||
adb_root ||
|
||||
die "lost device after elevation to root after wipe `usb_status`"
|
||||
fi
|
||||
D=`adb_sh df -k </dev/null` &&
|
||||
H=`echo "${D}" | head -1` &&
|
||||
D=`echo "${D}" | grep -v " /vendor/..*$" | grep "^overlay "` &&
|
||||
( echo "${H}" &&
|
||||
echo "${D}"
|
||||
) >&2 &&
|
||||
is_overlayfs_mounted &&
|
||||
die "overlay takeover unexpected at this phase"
|
||||
echo "${GREEN}[ OK ]${NORMAL} no overlay present before setup" >&2
|
||||
LOG OK "no overlay present before setup"
|
||||
|
||||
overlayfs_needed=true
|
||||
D=`adb_sh cat /proc/mounts </dev/null |
|
||||
skip_administrative_mounts data`
|
||||
|
|
@ -1131,7 +1130,7 @@ elif ! ${overlayfs_supported}; then
|
|||
die "need overlayfs, but do not have it"
|
||||
fi
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} disable-verity -R" >&2
|
||||
LOG RUN "disable-verity -R"
|
||||
|
||||
L=
|
||||
T=$(adb_date)
|
||||
|
|
@ -1145,7 +1144,7 @@ fi
|
|||
|
||||
# Fuzzy search for a line that contains "overlay" and "fail". Informational only.
|
||||
if echo "${H}" | grep -i "overlay" | grep -iq "fail"; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} overlayfs setup whined" >&2
|
||||
LOG WARNING "overlayfs setup whined"
|
||||
fi
|
||||
|
||||
adb_wait "${ADB_WAIT}" &&
|
||||
|
|
@ -1153,19 +1152,12 @@ adb_wait "${ADB_WAIT}" &&
|
|||
die "lost device after adb shell su root disable-verity -R $(usb_status)"
|
||||
|
||||
if ${overlayfs_needed}; then
|
||||
has_overlayfs_setup=false
|
||||
for d in ${OVERLAYFS_BACKING}; do
|
||||
if adb_test -d "/${d}/overlay"; then
|
||||
has_overlayfs_setup=true
|
||||
echo "${GREEN}[ OK ]${NORMAL} /${d}/overlay is setup" >&2
|
||||
fi
|
||||
done
|
||||
if ! ${has_overlayfs_setup}; then
|
||||
if ! is_overlayfs_mounted; then
|
||||
die "no overlay being setup after disable-verity -R"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} remount" >&2
|
||||
LOG RUN "remount"
|
||||
|
||||
# Feed log with selinux denials as baseline before overlays
|
||||
adb_unroot
|
||||
|
|
@ -1192,17 +1184,17 @@ if ${overlayfs_needed}; then
|
|||
die -t ${T} "overlay takeover failed"
|
||||
fi
|
||||
echo "${D}" | grep "^overlay .* /system\$" >/dev/null ||
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} overlay takeover not complete" >&2
|
||||
LOG WARNING "overlay takeover not complete"
|
||||
if [ -z "${virtual_ab}" ]; then
|
||||
scratch_partition=scratch
|
||||
fi
|
||||
if echo "${D}" | grep " /mnt/scratch" >/dev/null; then
|
||||
echo "${BLUE}[ INFO ]${NORMAL} using ${scratch_partition} dynamic partition for overrides" >&2
|
||||
LOG INFO "using ${scratch_partition} dynamic partition for overrides"
|
||||
fi
|
||||
M=`adb_sh cat /proc/mounts </dev/null |
|
||||
sed -n 's@\([^ ]*\) /mnt/scratch \([^ ]*\) .*@\2 on \1@p'`
|
||||
[ -n "${M}" ] &&
|
||||
echo "${BLUE}[ INFO ]${NORMAL} scratch filesystem ${M}" >&2
|
||||
LOG INFO "scratch filesystem ${M}"
|
||||
uses_dynamic_scratch=true
|
||||
if [ "${M}" != "${M##*/dev/block/by-name/}" ]; then
|
||||
uses_dynamic_scratch=false
|
||||
|
|
@ -1216,10 +1208,10 @@ if ${overlayfs_needed}; then
|
|||
done` &&
|
||||
[ -n "${scratch_size}" ] ||
|
||||
die "scratch size"
|
||||
echo "${BLUE}[ INFO ]${NORMAL} scratch size ${scratch_size}KB" >&2
|
||||
LOG INFO "scratch size ${scratch_size}KB"
|
||||
for d in ${OVERLAYFS_BACKING}; do
|
||||
if adb_test -d /${d}/overlay/system/upper; then
|
||||
echo "${BLUE}[ INFO ]${NORMAL} /${d}/overlay is setup" >&2
|
||||
LOG INFO "/${d}/overlay is setup"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
@ -1270,7 +1262,7 @@ fi
|
|||
|
||||
# Check something.
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} push content to ${MOUNTS}" >&2
|
||||
LOG RUN "push content to ${MOUNTS}"
|
||||
|
||||
A="Hello World! $(date)"
|
||||
for i in ${MOUNTS}; do
|
||||
|
|
@ -1304,11 +1296,11 @@ adb pull /system/lib/bootstrap/libc.so ${tempdir}/libc.so.fromdevice >/dev/null
|
|||
diff ${tempdir}/libc.so ${tempdir}/libc.so.fromdevice > /dev/null ||
|
||||
die "libc.so differ"
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} reboot to confirm content persistent" >&2
|
||||
LOG RUN "reboot to confirm content persistent"
|
||||
|
||||
fixup_from_recovery() {
|
||||
inRecovery || return 1
|
||||
echo "${YELLOW}[ ERROR ]${NORMAL} Device in recovery" >&2
|
||||
LOG ERROR "Device in recovery"
|
||||
adb reboot </dev/null
|
||||
adb_wait ${ADB_WAIT}
|
||||
}
|
||||
|
|
@ -1328,8 +1320,8 @@ if ${overlayfs_needed}; then
|
|||
adb_su sed -n '1,/overlay \/system/p' /proc/mounts </dev/null |
|
||||
skip_administrative_mounts |
|
||||
grep -v ' \(erofs\|squashfs\|ext4\|f2fs\|vfat\) ' &&
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} overlay takeover after first stage init" >&2 ||
|
||||
echo "${GREEN}[ OK ]${NORMAL} overlay takeover in first stage init" >&2
|
||||
LOG WARNING "overlay takeover after first stage init" ||
|
||||
LOG OK "overlay takeover in first stage init"
|
||||
fi
|
||||
|
||||
if ${enforcing}; then
|
||||
|
|
@ -1337,7 +1329,7 @@ if ${enforcing}; then
|
|||
die "device not in unroot'd state"
|
||||
B="`adb_cat /vendor/hello 2>&1`"
|
||||
check_eq "cat: /vendor/hello: Permission denied" "${B}" vendor after reboot w/o root
|
||||
echo "${GREEN}[ OK ]${NORMAL} /vendor content correct MAC after reboot" >&2
|
||||
LOG OK "/vendor content correct MAC after reboot"
|
||||
# Feed unprivileged log with selinux denials as a result of overlays
|
||||
wait_for_screen
|
||||
adb_sh find ${MOUNTS} </dev/null >/dev/null 2>/dev/null || true
|
||||
|
|
@ -1355,7 +1347,7 @@ adb_root ||
|
|||
for i in ${MOUNTS}; do
|
||||
B="`adb_cat ${i}/hello`"
|
||||
check_eq "${A}" "${B}" ${i#/} after reboot
|
||||
echo "${GREEN}[ OK ]${NORMAL} ${i} content remains after reboot" >&2
|
||||
LOG OK "${i} content remains after reboot"
|
||||
done
|
||||
|
||||
check_eq "${SYSTEM_INO}" "`adb_sh stat --format=%i /system/hello </dev/null`" system inode after reboot
|
||||
|
|
@ -1373,9 +1365,9 @@ rm -rf ${tempdir}
|
|||
cleanup() {
|
||||
true
|
||||
}
|
||||
echo "${GREEN}[ OK ]${NORMAL} /system/lib/bootstrap/libc.so content remains after reboot" >&2
|
||||
LOG OK "/system/lib/bootstrap/libc.so content remains after reboot"
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} flash vendor, confirm its content disappears" >&2
|
||||
LOG RUN "flash vendor, confirm its content disappears"
|
||||
|
||||
H=`adb_sh echo '${HOSTNAME}' </dev/null 2>/dev/null`
|
||||
is_bootloader_fastboot=false
|
||||
|
|
@ -1384,20 +1376,20 @@ is_bootloader_fastboot=false
|
|||
is_userspace_fastboot=false
|
||||
|
||||
if ! ${is_bootloader_fastboot}; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} does not support fastboot, skipping" >&2
|
||||
LOG WARNING "does not support fastboot, skipping"
|
||||
elif [ -z "${ANDROID_PRODUCT_OUT}" ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} build tree not setup, skipping" >&2
|
||||
LOG WARNING "build tree not setup, skipping"
|
||||
elif [ ! -s "${ANDROID_PRODUCT_OUT}/vendor.img" ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} vendor image missing, skipping" >&2
|
||||
LOG WARNING "vendor image missing, skipping"
|
||||
elif [ "${ANDROID_PRODUCT_OUT}" = "${ANDROID_PRODUCT_OUT%*/${H}}" ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} wrong vendor image, skipping" >&2
|
||||
LOG WARNING "wrong vendor image, skipping"
|
||||
elif [ -z "${ANDROID_HOST_OUT}" ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} please run lunch, skipping" >&2
|
||||
LOG WARNING "please run lunch, skipping"
|
||||
elif ! (
|
||||
adb_cat /vendor/build.prop |
|
||||
cmp -s ${ANDROID_PRODUCT_OUT}/vendor/build.prop
|
||||
) >/dev/null 2>/dev/null; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} vendor image signature mismatch, skipping" >&2
|
||||
LOG WARNING "vendor image signature mismatch, skipping"
|
||||
else
|
||||
wait_for_screen
|
||||
avc_check
|
||||
|
|
@ -1431,19 +1423,19 @@ else
|
|||
die "Reboot into fastboot"
|
||||
fi
|
||||
if ${uses_dynamic_scratch}; then
|
||||
echo "${BLUE}[ INFO ]${NORMAL} expect fastboot erase ${scratch_partition} to fail" >&2
|
||||
LOG INFO "expect fastboot erase ${scratch_partition} to fail"
|
||||
fastboot erase ${scratch_partition} &&
|
||||
( fastboot reboot || true) &&
|
||||
die "fastboot can erase ${scratch_partition}"
|
||||
fi
|
||||
echo "${BLUE}[ INFO ]${NORMAL} expect fastboot format ${scratch_partition} to fail" >&2
|
||||
LOG INFO "expect fastboot format ${scratch_partition} to fail"
|
||||
fastboot format ${scratch_partition} &&
|
||||
( fastboot reboot || true) &&
|
||||
die "fastboot can format ${scratch_partition}"
|
||||
fi
|
||||
fastboot reboot ||
|
||||
die "can not reboot out of fastboot"
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} adb after fastboot" >&2
|
||||
LOG WARNING "adb after fastboot"
|
||||
adb_wait ${ADB_WAIT} ||
|
||||
fixup_from_recovery ||
|
||||
die "did not reboot after formatting ${scratch_partition} `usb_status`"
|
||||
|
|
@ -1461,8 +1453,8 @@ else
|
|||
if ${is_userspace_fastboot}; then
|
||||
die "overlay supposed to be minus /vendor takeover after flash vendor"
|
||||
else
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} overlay supposed to be minus /vendor takeover after flash vendor" >&2
|
||||
LOG WARNING "user fastboot missing required to invalidate, ignoring a failure"
|
||||
LOG WARNING "overlay supposed to be minus /vendor takeover after flash vendor"
|
||||
fi
|
||||
fi
|
||||
B="`adb_cat /system/hello`"
|
||||
|
|
@ -1480,7 +1472,7 @@ else
|
|||
check_eq "cat: /vendor/hello: No such file or directory" "${B}" \
|
||||
vendor content after flash vendor
|
||||
else
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} user fastboot missing required to invalidate, ignoring a failure" >&2
|
||||
LOG WARNING "user fastboot missing required to invalidate, ignoring a failure"
|
||||
check_eq "cat: /vendor/hello: No such file or directory" "${B}" \
|
||||
--warning vendor content after flash vendor
|
||||
fi
|
||||
|
|
@ -1490,7 +1482,7 @@ else
|
|||
fi
|
||||
|
||||
wait_for_screen
|
||||
echo "${GREEN}[ RUN ]${NORMAL} remove test content (cleanup)" >&2
|
||||
LOG RUN "remove test content (cleanup)"
|
||||
|
||||
T=`adb_date`
|
||||
H=`adb remount 2>&1`
|
||||
|
|
@ -1498,7 +1490,7 @@ err=${?}
|
|||
L=
|
||||
D="${H%?Now reboot your device for settings to take effect*}"
|
||||
if [ X"${H}" != X"${D}" ]; then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} adb remount requires a reboot after partial flash (legacy avb)" >&2
|
||||
LOG WARNING "adb remount requires a reboot after partial flash (legacy avb)"
|
||||
L=`adb_logcat -b all -v nsec -t ${T} 2>&1`
|
||||
adb_reboot &&
|
||||
adb_wait ${ADB_WAIT} &&
|
||||
|
|
@ -1526,7 +1518,7 @@ done
|
|||
|
||||
if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} test fastboot flash to ${scratch_partition} recovery" >&2
|
||||
LOG RUN "test fastboot flash to ${scratch_partition} recovery"
|
||||
|
||||
avc_check
|
||||
adb reboot fastboot </dev/null ||
|
||||
|
|
@ -1556,7 +1548,7 @@ if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then
|
|||
err=${?}
|
||||
if [ X"${D}" != "${D%?Now reboot your device for settings to take effect*}" ]
|
||||
then
|
||||
echo "${YELLOW}[ WARNING ]${NORMAL} adb disable-verity requires a reboot after partial flash" >&2
|
||||
LOG WARNING "adb disable-verity requires a reboot after partial flash"
|
||||
adb_reboot &&
|
||||
adb_wait ${ADB_WAIT} &&
|
||||
adb_root ||
|
||||
|
|
@ -1571,7 +1563,7 @@ if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then
|
|||
[ ${err} = 0 ] &&
|
||||
[ X"${D}" = X"${D##*setup failed}" ] &&
|
||||
[ X"${D}" != X"${D##*[Uu]sing overlayfs}" ] &&
|
||||
echo "${GREEN}[ OK ]${NORMAL} ${scratch_partition} recreated" >&2 ||
|
||||
LOG OK "${scratch_partition} recreated" ||
|
||||
die -t ${T} "setup for overlayfs"
|
||||
D=`adb remount 2>&1`
|
||||
err=${?}
|
||||
|
|
@ -1582,17 +1574,17 @@ if ${is_bootloader_fastboot} && [ -n "${scratch_partition}" ]; then
|
|||
die -t ${T} "remount failed"
|
||||
fi
|
||||
|
||||
echo "${GREEN}[ RUN ]${NORMAL} test raw remount commands" >&2
|
||||
LOG RUN "test raw remount commands"
|
||||
|
||||
fixup_from_fastboot() {
|
||||
inFastboot || return 1
|
||||
if [ -n "${ACTIVE_SLOT}" ]; then
|
||||
local active_slot=`get_active_slot`
|
||||
if [ X"${ACTIVE_SLOT}" != X"${active_slot}" ]; then
|
||||
echo "${YELLOW}[ ERROR ]${NORMAL} Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
|
||||
LOG WARNING "Active slot changed from ${ACTIVE_SLOT} to ${active_slot}"
|
||||
else
|
||||
echo "${YELLOW}[ ERROR ]${NORMAL} Active slot to be set to ${ACTIVE_SLOT}"
|
||||
fi >&2
|
||||
LOG WARNING "Active slot to be set to ${ACTIVE_SLOT}"
|
||||
fi
|
||||
fastboot --set-active=${ACTIVE_SLOT}
|
||||
fi
|
||||
fastboot reboot
|
||||
|
|
@ -1610,7 +1602,7 @@ adb_su mount -o rw,remount /vendor </dev/null ||
|
|||
die "remount command"
|
||||
adb_sh grep " /vendor .* rw," /proc/mounts >/dev/null </dev/null ||
|
||||
die "/vendor is not read-write"
|
||||
echo "${GREEN}[ OK ]${NORMAL} mount -o rw,remount command works" >&2
|
||||
LOG OK "mount -o rw,remount command works"
|
||||
|
||||
# Prerequisite is a prepped device from above.
|
||||
adb_reboot &&
|
||||
|
|
@ -1625,17 +1617,12 @@ adb_sh grep " /vendor .* rw," /proc/mounts >/dev/null </dev/null ||
|
|||
die "/vendor is not read-write"
|
||||
adb_sh grep " /system .* rw," /proc/mounts >/dev/null </dev/null &&
|
||||
die "/vendor is not read-only"
|
||||
echo "${GREEN}[ OK ]${NORMAL} remount command works from setup" >&2
|
||||
LOG OK "remount command works from setup"
|
||||
|
||||
# Prerequisite is an overlayfs deconstructed device but with verity disabled.
|
||||
# This also saves a lot of 'noise' from the command doing a mkfs on backing
|
||||
# storage and all the related tuning and adjustment.
|
||||
for d in ${OVERLAYFS_BACKING}; do
|
||||
if adb_test -d /${d}/overlay; then
|
||||
adb_su rm -rf /${d}/overlay </dev/null ||
|
||||
die "/${d}/overlay wipe"
|
||||
fi
|
||||
done
|
||||
surgically_wipe_overlayfs || true
|
||||
adb_reboot &&
|
||||
adb_wait ${ADB_WAIT} ||
|
||||
fixup_from_fastboot ||
|
||||
|
|
@ -1649,7 +1636,7 @@ adb_sh grep " /vendor .* rw," /proc/mounts >/dev/null </dev/null ||
|
|||
die "/vendor is not read-write"
|
||||
adb_sh grep " \(/system\|/\) .* rw," /proc/mounts >/dev/null </dev/null &&
|
||||
die "/system is not read-only"
|
||||
echo "${GREEN}[ OK ]${NORMAL} remount command works from scratch" >&2
|
||||
LOG OK "remount command works from scratch"
|
||||
|
||||
if ! restore; then
|
||||
restore() {
|
||||
|
|
@ -1661,7 +1648,7 @@ fi
|
|||
err=0
|
||||
|
||||
if ${overlayfs_supported}; then
|
||||
echo "${GREEN}[ RUN ]${NORMAL} test 'adb remount -R'" >&2
|
||||
LOG RUN "test 'adb remount -R'"
|
||||
avc_check
|
||||
adb_root ||
|
||||
die "adb root in preparation for adb remount -R"
|
||||
|
|
@ -1683,7 +1670,7 @@ ${INDENT}ro.boot.verifiedbootstate=\"`get_property ro.boot.verifiedbootstate`\"
|
|||
${INDENT}partition.system.verified=\"`get_property partition.system.verified`\""
|
||||
fi
|
||||
|
||||
echo "${GREEN}[ OK ]${NORMAL} 'adb remount -R' command" >&2
|
||||
LOG OK "'adb remount -R' command"
|
||||
|
||||
restore
|
||||
err=${?}
|
||||
|
|
@ -1696,6 +1683,6 @@ restore() {
|
|||
[ ${err} = 0 ] ||
|
||||
die "failed to restore verity"
|
||||
|
||||
echo "${GREEN}[ PASSED ]${NORMAL} adb remount" >&2
|
||||
LOG PASSED "adb remount test"
|
||||
|
||||
test_duration
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue