diff --git a/tools/wltests/helpers b/tools/wltests/helpers index 8922b3f6832f1c9afe4dc173d5da1834ebc2492a..3274d9210f24d96ff996a867bc21c8ec26b57585 100644 --- a/tools/wltests/helpers +++ b/tools/wltests/helpers @@ -179,6 +179,72 @@ c_extract() { fi } +adb_flash_modules() { + MODULES_FOLDER=$1 + + echo + c_info "Restart ADB in root mode..." + timeout 10 $ADB wait-for-device root &>/dev/null; ERROR=$? + if [[ $ERROR -ne 0 ]]; then + c_error "Cannot restart ADB in root mode" + return $EIO + fi + + timeout 10 $ADB wait-for-device; ERROR=$? + if [[ $ERROR -ne 0 ]]; then + c_error "Device inaccesible" + return $EIO + fi + + # Verity must be disabled one time, right after the first boot, once a + # new set of stock images has been flashed on the device. + # This check is just there to ensure we can remount root rw, otherwise + # wltests will abort and the device must be rebooted by hand. + c_info "Checking that verity is disabled..." + OUTPUT="$($ADB disable-verity)" + echo + echo "$OUTPUT" + echo + if [[ $OUTPUT != *"verity is already disabled"* ]]; then + c_error "Verity not disabled on this device!" + c_warning "It has been disabled now but you have to" + c_warning "manually reboot your device and restart wltests" + echo + echo + return $EIO + fi + + c_info "Remounting / rw..." + timeout 10 $ADB wait-for-device remount &>/dev/null; ERROR=$? + if [[ $ERROR -ne 0 ]]; then + c_error "Remount failed" + return $EIO + fi + + timeout 10 $ADB wait-for-device; ERROR=$? + if [[ $ERROR -ne 0 ]]; then + c_error "Device inaccesible" + return $EIO + fi + + c_info "Pushing kernel modules..." + $ADB shell rm -rf /vendor/lib/modules/*; ERROR=$? + if [[ $ERROR -ne 0 ]]; then + c_error "Failed to remove /vendor/lib/modules/" + return $EIO + fi + for m in $MODULES_FOLDER/*.ko; do + $ADB push $m /vendor/lib/modules/; ERROR=$? + if [[ $ERROR -ne 0 ]]; then + c_error "Failed to flash $m" + return $EIO + fi + done + sleep 5 + + return $OK +} + ################################################################################ # Colors diff --git a/tools/wltests/platforms/bluecross_android_v4.9/build_images b/tools/wltests/platforms/bluecross_android_v4.9/build_images new file mode 100755 index 0000000000000000000000000000000000000000..2cb8027b140d5a6d4d94da73b0588f63c61a3713 --- /dev/null +++ b/tools/wltests/platforms/bluecross_android_v4.9/build_images @@ -0,0 +1,8 @@ +#!/bin/bash +cd $KERNEL_SRC + +# SKIP_MRPROPER=y saves a lot of time +# SKIP_CP_KERNEL_HDR=y because we don't use them +SKIP_MRPROPER=y SKIP_CP_KERNEL_HDR=y ./build/build.sh +ERROR=$? +[ $ERROR -eq 0 ] || exit -$ERROR diff --git a/tools/wltests/platforms/bluecross_android_v4.9/definitions b/tools/wltests/platforms/bluecross_android_v4.9/definitions new file mode 100644 index 0000000000000000000000000000000000000000..69fc77b2be70f6bdbda91673396942799112738b --- /dev/null +++ b/tools/wltests/platforms/bluecross_android_v4.9/definitions @@ -0,0 +1,8 @@ +PLATFORM_NAME="Bluecross" +WLTEST_REPO_TARGET="y" +REPO_KERNEL_PATH="private/msm-google" + +# Artifacts generated by Google's build.sh script +ARTIFACTS_PATH="$KERNEL_SRC/out/android-msm-bluecross-4.9/dist" +KERNEL_IMAGE="${KERNEL_IMAGE:-Image.lz4-dtb}" +ANDROID_DTBO_IMAGE="${ANDROID_DTBO_IMAGE:-dtbo.img}" diff --git a/tools/wltests/platforms/bluecross_android_v4.9/flash_images b/tools/wltests/platforms/bluecross_android_v4.9/flash_images new file mode 100755 index 0000000000000000000000000000000000000000..0699010b544994732908df154eb2544a6a9673f3 --- /dev/null +++ b/tools/wltests/platforms/bluecross_android_v4.9/flash_images @@ -0,0 +1,63 @@ +#!/bin/bash + +SCRIPT_DIR=$(dirname $(realpath -s $0)) +BASE_DIR="$SCRIPT_DIR/../.." +source "${BASE_DIR}/helpers" +source "${PLATFORM_PATH}/definitions" + +MODE=${1:-FASTBOOT} + +################################################################################ +# Flash all images required to test a new kernel +################################################################################ + +# Check for DTBO image +ls "${ARTIFACTS_PATH}/${ANDROID_DTBO_IMAGE}" &>/dev/null; ERROR=$? +if [ $ERROR -ne 0 ]; then + c_error "No DTBO image to flash found in $ARTIFACTS_PATH" + exit $ENOENT +fi + +# Check for KERNEL image +ls "${ARTIFACTS_PATH}/${KERNEL_IMAGE}" &>/dev/null; ERROR=$? +if [ $ERROR -ne 0 ]; then + c_error "No KERNEL image to flash found in $ARTIFACTS_PATH" + exit $ENOENT +fi + +# Check for modules to be pushed +ls ${ARTIFACTS_PATH}/*.ko &>/dev/null; ERROR=$? +if [ $ERROR -ne 0 ]; then + c_error "No MODULES to push found in $ARTIFACTS_PATH" + exit $ENOENT +fi + +case "$MODE" in + +ADB) + adb_flash_modules $ARTIFACTS_PATH; ERROR=$? + [ $ERROR -eq 0 ] || exit -$ERROR + + exit $OK + ;; + +FASTBOOT) + echo + c_info "Flashing [$KERNEL_IMAGE] on KERNEL partition..." + $FASTBOOT flash:raw boot ${ARTIFACTS_PATH}/${KERNEL_IMAGE} + ERROR=$? + [ $ERROR -eq 0 ] || exit -$ERROR + + echo + c_info "Flashing [$ANDROID_DTBO_IMAGE] on DTBO partition..." + $FASTBOOT flash dtbo ${ARTIFACTS_PATH}/${ANDROID_DTBO_IMAGE} + ERROR=$? + [ $ERROR -eq 0 ] || exit -$ERROR + + exit $OK + ;; + +esac + +exit -$EINVAL + diff --git a/tools/wltests/platforms/wahoo_android_v4.4/flash_images b/tools/wltests/platforms/wahoo_android_v4.4/flash_images index b6fa00f0951df6a3c4e8de37c25d9f4627b196ef..2cb87633d4f2bfac8dedff695108c3fdd59dec4f 100755 --- a/tools/wltests/platforms/wahoo_android_v4.4/flash_images +++ b/tools/wltests/platforms/wahoo_android_v4.4/flash_images @@ -36,40 +36,8 @@ fi case "$MODE" in ADB) - echo - c_info "Restart ADB in root mode..." - $ADB root &>/dev/null - - # Verity must be disabled one time, right after the first boot, once a - # new set of stock images has been flashed on the device. - # This check is just there to ensure we can remount root rw, otherwise - # wltests will abort and the device must be rebooted by hand. - c_info "Checking that verity is disabled..." - OUTPUT="$($ADB disable-verity)" - echo - echo "$OUTPUT" - echo - if [[ $OUTPUT != *"verity is already disabled"* ]]; then - c_error "Verity not disabled on this device!" - c_warning "It has been disabled now but you have to" - c_warning "manually reboot your device and restart wltests" - echo - echo - exit $EIO - fi - - c_info "Remounting / rw..." - $ADB remount &>/dev/null; ERROR=$? - if [[ $ERROR -ne 0 ]]; then - c_error "Remount failed" - exit $EIO - fi - sleep 10 - - c_info "Pushing kernel modules..." - $ADB shell rm -rf /vendor/lib/modules - $ADB push ${ARTIFACTS_PATH}/push_files/* / - sleep 5 + adb_flash_modules $MODULE_DIR; ERROR=$? + [ $ERROR -eq 0 ] || exit -$ERROR exit $OK ;; diff --git a/tools/wltests/test_series b/tools/wltests/test_series index 2826248d477a262fa673c8b0f52e0d4b67ea1310..d5d0840142894e65a996983b25e5a6767baee1b8 100755 --- a/tools/wltests/test_series +++ b/tools/wltests/test_series @@ -29,7 +29,7 @@ source "${BASE_DIR}/helpers" ################################################################################ PLATFORM=${PLATFORM:-'hikey960_android-4.4'} -KERNEL_SRC=${KERNEL_SRC:-$BASE_DIR/kernel} +KERNEL_SRC=${KERNEL_SRC:-''} SERIES=${SERIES:-''} WA_AGENDA=${WA_AGENDA:-''} TEST_CMD=${TEST_CMD:-'echo "Test DONE!"'} @@ -68,8 +68,7 @@ SCRIPT for each of them. Kernel to test: - -k, --kernel_src PATH The kernel source tree to use. - Default: KERNEL_SRC=../kernel + -k, --kernel_src PATH The kernel source tree or repo to use. -s, --series PATH The series of commits to test. This is the patch of the file containing a list @@ -84,6 +83,12 @@ Kernel to test: If an "ID:" column is present, the commits will be considered in progressive "ID:" order while discarding those with ID=00: + + For targets using the Google build system (e.g. + Pixel 3) the series file refers to commits of + the manifest file whose git tree is located + under "\$KERNEL_SRC/.repo/manifests." + Default: SERIES='' Target device to use for kernel testing: @@ -91,7 +96,7 @@ Target device to use for kernel testing: -p, --platform The platform to target. Available platforms are the subfolders of the top level "platforms" folder. - Default: PLATFORM=juno_android-4.4 + Default: PLATFORM=hikey960_android-4.4 --supported_platforms Print a list of supported platforms which can are valid values for the -p parameter. @@ -118,7 +123,7 @@ Additional arguments: --adb The ADB binary to use. Default: ADB=[ANDROID_HOME/platform-tools/adb|\$(which adb)] --fastboot The FASTBOOT binary to use. - Default: FASTBOOT=[ANDROID_HOME/platform-tools/fatboot|\$(which fatboot)] + Default: FASTBOOT=[ANDROID_HOME/platform-tools/fastboot|\$(which fastboot)] --emeter The Energy Meter used to power-cycle the device. Default: EMETER=ACME @@ -318,14 +323,44 @@ fi done export PLATFORM_OVERLAY_PATH=$PLATFORM_PATH -# Prepare KERNEL_SRC +source $PLATFORM_PATH/definitions + +# On targets that don't use 'repo', KERNEL_SRC == GIT_TREE == KERNEL_TREE +# On targets that do use 'repo': +# - KERNEL_SRC points to the top level of the repo +# - GIT_TREE points to the _manifest_ git tree in the repo +# - KERNEL_TREE points to the _kernel_ git tree in the repo +GIT_TREE="" +KERNEL_TREE="" + export KERNEL_SRC=$(realpath -s $KERNEL_SRC) -grep -E "mainmenu .* Kernel Configuration" $KERNEL_SRC/Kconfig &>/dev/null -if [ $? -ne 0 ]; then - echo - c_error "The \$KERNEL_SRC|--kernel_src seems not to a valid kernel source tree path" - echo - exit $EINVAL +if [ "x$WLTEST_REPO_TARGET" == "xy" ]; then + if [ ! -x "$(command -v repo)" ]; then + echo + c_error "Wltest on this target requires 'repo'. Please follow:" + c_error "https://source.android.com/setup/build/downloading#installing-repo" + echo + exit $ENODEV + fi + if [ ! -d "$KERNEL_SRC/.repo/manifests" ]; then + echo + c_error "The \$KERNEL_SRC|--kernel_src is not a valid repo path" + echo + exit $EINVAL + fi + GIT_TREE="$KERNEL_SRC/.repo/manifests" + KERNEL_TREE="$KERNEL_SRC/$REPO_KERNEL_PATH" +else + # Prepare KERNEL_SRC + grep -E "mainmenu .* Kernel Configuration" $KERNEL_SRC/Kconfig &>/dev/null + if [ $? -ne 0 ]; then + echo + c_error "The \$KERNEL_SRC|--kernel_src is not a valid kernel source tree path" + echo + exit $EINVAL + fi + GIT_TREE="$KERNEL_SRC" + KERNEL_TREE="$KERNEL_SRC" fi # Prepare SERIES @@ -445,7 +480,7 @@ esac box_out \ "Mandatory conf" \ " PLATFORM : $PLATFORM" \ - " KERNEL_SRC : $KERNEL_SRC" \ + " KERNEL_TREE : $KERNEL_TREE" \ " SERIES : $SERIES" \ " WA_AGENDA : $WA_AGENDA" \ " RESULTS : $TEST_CMD_RESULTS" \ @@ -471,12 +506,12 @@ usb_disconnect() { if [ $DRYRUN ]; then return; fi case $EMETER in 'ACME') - sh root@$ACME_IP \ + ssh root@$ACME_IP \ "echo 0 > /sys/bus/iio/devices/iio:$ACME_USB/in_active" ;; 'MONSOON') # not supported for now - c_warn "Energy meter $EMETER does not support usb_disconnect" + c_warning "Energy meter $EMETER does not support usb_disconnect" ;; *) c_error "Energy meter $EMETER not supported" @@ -495,7 +530,7 @@ usb_connect() { ;; 'MONSOON') # not supported for now - c_warn "Energy meter $EMETER does not support usb_connect" + c_warning "Energy meter $EMETER does not support usb_connect" ;; *) c_error "Energy meter $EMETER not supported" @@ -563,9 +598,10 @@ device_connected() { return $ENODEV fi usb_disconnect - c_warning "Check again in 1s..." sleep 1 usb_connect + c_warning "Check again in 10s..." + sleep 10 done return $OK } @@ -773,7 +809,7 @@ name_sha1() { # Find a name for each possible REF mkfifo tmp_pipe &>/dev/null - git -C $KERNEL_SRC for-each-ref \ + git -C $GIT_TREE for-each-ref \ --sort=-committerdate \ --format='%(objectname:short) %(refname:short)' \ refs/heads/ refs/remotes/ refs/tags | @@ -799,14 +835,14 @@ match_sha1() { c_info "Current kernel: " c_info " $($ADB shell 'uname -a')" - CURRENT=$($ADB shell 'uname -r' | awk -F "-g" '{print $NF}') + CURRENT=$($ADB shell 'uname -r' | awk -F "-g" '{print $NF}' | awk -F "_" '{print $1}') [[ $COMMIT_SHA1 =~ $CURRENT* ]] && return $OK # It may happen that a tag pointing to a given commit has # a different SHA1 (signed tag), so check if this this is # the case. - TAG_NAME=$(git -C $KERNEL_SRC describe --exact-match $COMMIT_SHA1 2>/dev/null) || return $EAGAIN - TAG_SHA1=$(git -C $KERNEL_SRC show-ref --hash $TAG_NAME) + TAG_NAME=$(git -C $KERNEL_TREE describe --exact-match $COMMIT_SHA1 2>/dev/null) || return $EAGAIN + TAG_SHA1=$(git -C $KERNEL_TREE show-ref --hash $TAG_NAME) c_info " CommitID of local repo corresponds to tag: $TAG_NAME" [[ $TAG_SHA1 =~ $CURRENT* ]] && return $OK @@ -815,12 +851,11 @@ match_sha1() { build_sha1() { COMMIT_SHA1=$1 - COMMIT_DESC=$2 - ### Prepare KERNEL_SRC for build - pushd $KERNEL_SRC &>/dev/null + ### Prepare GIT_TREE for build + pushd $GIT_TREE &>/dev/null echo - c_info "Checkout kernel: $KERNEL_SRC @ $COMMIT_SHA1..." + c_info "Checkout: $GIT_TREE @ $COMMIT_SHA1..." git checkout $COMMIT_SHA1; ERROR=$? if [ $ERROR -ne 0 ]; then c_error "Failed to checkout [$COMMIT_SHA1]" @@ -829,6 +864,17 @@ build_sha1() { fi popd &>/dev/null + ### Sync the repo if needed + if [ "x$WLTEST_REPO_TARGET" == "xy" ]; then + pushd $KERNEL_SRC &> /dev/null + repo sync -l; ERROR=$? + popd &> /dev/null + if [ $ERROR -ne 0 ]; then + c_error "Failed to sync [$COMMIT_SHA1]" + return $ERROR + fi + fi + ### Build all IMAGES pushd $BASE_DIR &>/dev/null $PLATFORM_PATH/build_images @@ -844,7 +890,7 @@ flash_sha1() { COMMIT_SHA1=$1 COMMIT_DESC=$2 - build_sha1 "$COMMIT_SHA1" "$COMMIT_DESC"; RESULT=$? + build_sha1 "$COMMIT_SHA1"; RESULT=$? [ $RESULT -eq $OK ] || return $RESULT ### Flash generated IMAGES @@ -873,8 +919,10 @@ flash_sha1() { sleep 10 # Add an additional safe margin ### Check that we are running the expected kernel + COMMIT_SHA1=$(git -C $KERNEL_TREE log --format="%h" | head -n 1) match_sha1 $COMMIT_SHA1; ERROR=$? - [ $ERROR -eq 0 ] || c_error "Failed to flash kernel [$COMMIT_DESC]!" + [ $ERROR -eq 0 ] || c_warning "Kernel [$COMMIT_DESC] may not be flashed on the target" + return $? } @@ -889,10 +937,10 @@ test_sha1() { c_info "Testing kernel:" c_info " SeriesID : $COMMIT_DESC" c_info " CommitID : $COMMIT_SHA1 $COMMIT_NAME" - echo - c_info "Check current kernel..." - if device_in_adb; then + + if [[ "x$WLTEST_REPO_TARGET" != "xy" && device_in_adb ]]; then + c_info "Check current kernel..." match_sha1 $COMMIT_SHA1 if [ $? -ne $OK ]; then c_info "Kernel update required!" @@ -904,8 +952,8 @@ test_sha1() { fi fi else - c_warning "Device not connected via ADB, cannot check current kernel" - c_warning "Forcing: build, flashing and reboot selected kernel" + c_info "Cannot check current kernel" + c_info "Forcing: build, flashing and reboot selected kernel" flash_sha1 $COMMIT_SHA1 "$COMMIT_DESC"; RESULT=$? [[ $RESULT -ne $EIO ]] || exit $EIO if [[ $RESULT -ne 0 ]]; then @@ -992,14 +1040,14 @@ while read -u10 COMMITS; do COMMIT=${COMMITS%% *} # Translate possible branch name to SHA1 - COMMITS=$(git -C $KERNEL_SRC show-ref -s $COMMIT) + COMMITS=$(git -C $GIT_TREE show-ref -s $COMMIT) if [ $? -ne 0 ]; then COMMIT_SHA1=$COMMIT elif [ $(echo $COMMITS | wc -w) -eq 1 ]; then COMMIT_SHA1=$COMMITS else c_error "The branch name must be univocal, \"$COMMIT\" may refer to:" - for b in $(git -C $KERNEL_SRC show-ref $COMMIT | cut -f 2 -d " "); do + for b in $(git -C $GIT_TREE show-ref $COMMIT | cut -f 2 -d " "); do c_error " $b" done exit $EINVAL