#!/bin/bash set -euf -o pipefail scripts=$(dirname $0) # shellcheck source=jenkins-helpers.sh . $scripts/jenkins-helpers.sh # shellcheck source=round-robin.sh . $scripts/round-robin.sh convert_args_to_variables "$@" obligatory_variables rr[ci_config] declare -A rr # Execution mode: baseline, bisect, jenkins-full rr[mode]="${rr[mode]-baseline}" # Set custom revision for one of the projects, and use baseline revisions # for all other projects. rr[ci_project]="${rr[ci_project]-tcwg_kernel}" rr[baseline_branch]="${rr[baseline_branch]-linaro-local/ci/${rr[ci_project]}/${rr[ci_config]}}" rr[update_baseline]="${rr[update_baseline]-update}" rr[top_artifacts]="${rr[top_artifacts]-$(pwd)/artifacts}" # {toolchain_name}-{toolchain_ver}-{target}-{linux}-{linux_config} IFS=- read -a ci_config < "$(pwd)"/bin/${rr[target]}-cc <> ${rr[top_artifacts]}/results 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 local gnu_host qemu gnu_host=$(print_gnu_target native) qemu="$(pwd)/abe/builds/hosttools/$gnu_host/bin/qemu-system-${rr[target]}" timeout --foreground 60s "$qemu" \ -kernel $image -machine virt $cpu -m 512 \ -serial 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 () { ( set -euf -o pipefail local ref_artifacts=$1 local new_artifacts=$2 local linux_n_obj linux_n_obj=$(grep -v "^#" $new_artifacts/results | tail -n1) # Assume worst for non-existent baseline. local base_linux_n_obj="-10" if [ -f $ref_artifacts/results ]; then base_linux_n_obj=$(grep -v "^#" $ref_artifacts/results | tail -n1) fi local res="" case "$linux_n_obj:$base_linux_n_obj" in boot:*) res=0 ;; *:boot) res=1 ;; all:*) res=0 ;; *:all) res=1 ;; esac if [ x"$res" != x"0" ]; then local build_res no_build_regression_p "$@" & build_res=0 && wait $! || build_res=$? if [ x"$res" = x"" ]; then res=$build_res fi fi return $res ) } # Implement rr[breakup_updated_components] hook. tcwg_kernel_breakup_updated_components () { ( set -euf -o pipefail # Linux changes tend to cause the most regressions. # Breakup updated components into linux and the rest of components # to reduce the number of builds. if print_updated_components "\n" | grep -q "^linux\$"; then echo "linux" print_updated_components "\n" | grep -v "^linux\$" | tr '\n' ' ' | sed -e "s/ \$//g" echo else print_updated_components "\n" fi ) } rr[breakup_updated_components]=tcwg_kernel_breakup_updated_components run_step stop_on_fail -10 reset_artifacts run_step stop_on_fail x prepare_abe run_step skip_on_fail -9 build_abe binutils case "${rr[toolchain]}" in gnu) run_step skip_on_fail -5 build_abe stage1 ;; llvm) run_step skip_on_fail -5 build_llvm ;; esac run_step skip_on_fail -2 build_abe qemu 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 trap "" EXIT