From 2d68fd0a3cceb58f0a4299320a8e681023238eed Mon Sep 17 00:00:00 2001 From: Maxim Kuvyrkov Date: Thu, 21 Feb 2019 11:17:46 +0000 Subject: tcwg_kernel-build.sh: Add boot-testing of kernel This implements https://projects.linaro.org/browse/TCWG-1503 . Count_linux_objs() was renamed to build_linux (with build_linux() renamed to build_linux_1()). New step boot_linux() was added to boot kernel with qemu. Defconfig configurations for aarch64 and arm seem to boot, allnoconfig doesn't boot, others -- will see. No_regression_p() was reworked to handle result hierarchy "boot" -> "all" -> "Number of objects". Change-Id: Ib3377c72de51745a537714d1c693303b3935188c --- tcwg_kernel-build.sh | 100 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 36 deletions(-) diff --git a/tcwg_kernel-build.sh b/tcwg_kernel-build.sh index 7cdb9d4f..130e3403 100755 --- a/tcwg_kernel-build.sh +++ b/tcwg_kernel-build.sh @@ -79,7 +79,7 @@ fi run_step_init "$start_at" "$finish_at" "${rr[top_artifacts]}" "$verbose" # Build Linux kernel -build_linux () +build_linux_1 () { ( set -euf -o pipefail @@ -144,27 +144,57 @@ EOF ) } -# Count number successfully built .o files in linux (and build linux) -count_linux_objs () +# Build linux and count number successfully built .o files in linux +build_linux () { ( set -euf -o pipefail - build_linux & - local res=0; wait $! || res=$? + build_linux_1 & + local res=0 && wait $! || res=$? # Number of .o files created is the main success metric. + local linux_n_obj + linux_n_obj=$(find linux -name "*.o" | wc -l) echo "linux_n_obj:" >> ${rr[top_artifacts]}/results - if [ $res != 0 ]; then - local linux_n_obj - linux_n_obj=$(find linux -name "*.o" | wc -l) - echo "$linux_n_obj" >> ${rr[top_artifacts]}/results - else + echo "$linux_n_obj" >> ${rr[top_artifacts]}/results + + if [ $res = 0 ]; then + echo "linux build successful:" >> ${rr[top_artifacts]}/results echo "all" >> ${rr[top_artifacts]}/results fi + + return $res ) } +# Boot linux kernel +boot_linux () +{ + ( + set -euf -o pipefail + + local image cpu + case ${rr[target]} in + aarch64) + image=linux/arch/arm64/boot/Image.gz + cpu="-cpu cortex-a53" + ;; + arm) + image=linux/arch/arm/boot/zImage + cpu="" + ;; + *) assert false ;; + esac + timeout 10s qemu-system-${rr[target]} \ + -kernel $image -machine virt $cpu -m 512 \ + -serial mon:stdio -display none \ + -append "console=ttyAMA0 panic=-1" -no-reboot + + echo "linux boot successful:" >> ${rr[top_artifacts]}/results + echo "boot" >> ${rr[top_artifacts]}/results + ) +} # Exit with code 0 if no regression compared to base-artifacts/results. no_regression_p () @@ -175,37 +205,34 @@ no_regression_p () local linux_n_obj linux_n_obj=$(tail -n1 ${rr[top_artifacts]}/results) - if [ x"$linux_n_obj" = x"all" ]; then - # Ideal result, no need to compare to baseline. - return 0 - fi - - if ! [ "$linux_n_obj" -ge "-10" ]; then - # Something is very wrong with result (e.g., it's not a number). - return 1 - fi - # Assume worst for non-existent baseline. local base_linux_n_obj="-10" - if [ -f base-artifacts/results ]; then base_linux_n_obj=$(tail -n1 base-artifacts/results) - if [ x"$base_linux_n_obj" = x"all" ]; then - # Current build is not ideal, so make sure baseline "all" is - # better than the current result. - base_linux_n_obj=$(($linux_n_obj+1)) - elif ! [ "$base_linux_n_obj" -ge "-10" ]; then - # Something is very wrong with baseline result - # (e.g., it's not a number). - return 0 - fi fi - if [ $linux_n_obj -ge $base_linux_n_obj ]; then - return 0 - else - return 1 - fi + case "$linux_n_obj:$base_linux_n_obj" in + boot:*) return 0 ;; + *:boot) return 1 ;; + all:*) return 0 ;; + *:all) return 1 ;; + *) + if ! [ "$linux_n_obj" -ge "-10" ]; then + # Something is very wrong with result (e.g., it's not a number). + return 1 + fi + if ! [ "$base_linux_n_obj" -ge "-10" ]; then + # Something is very wrong with result (e.g., it's not a number). + return 0 + fi + + if [ $linux_n_obj -ge $base_linux_n_obj ]; then + return 0 + else + return 1 + fi + ;; + esac ) } @@ -220,7 +247,8 @@ case "${rr[toolchain]}" in run_step skip_on_fail -1 build_llvm ;; esac -run_step skip_on_fail x count_linux_objs +run_step skip_on_fail x build_linux +run_step skip_on_fail x boot_linux run_step reset_on_fail x check_regression run_step stop_on_fail x update_baseline run_step stop_on_fail x push_baseline -- cgit v1.2.3