summaryrefslogtreecommitdiff
path: root/tcwg_gnu-build.sh
blob: 28fd2f78e8dba8d116a8283f0f91233e36845e37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/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_gnu}"
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}"

# Resolve top_artifacts to absolute dir because some of the subsequent
# processes work below pwd and would write their artifacts in a wrong
# location
rr[top_artifacts]=$(abs_path "${rr[top_artifacts]}")

# {toolchain_name}-{toolchain_ver}-{target}-{type_of_test}
IFS=- read -a ci_config <<EOF
${rr[ci_config]}
EOF
rr[target]="native"
# type_of_test contains the type of action to perform in this test
# campaign: bootstrap, bootstrap_lto, check_binutils, ....
type_of_test=${type_of_test-${ci_config[3]}}

case "$type_of_test" in
    check_binutils) rr[components]="binutils" ;;
    *) rr[components]="gcc" ;;
esac

# Use baseline branches by default.
for c in ${rr[components]}; do
    rr[${c}_branch]=${rr[${c}_branch]-baseline}
    if [ x"${rr[${c}_branch]}" != x"baseline" ]; then
	obligatory_variables rr[${c}_url]
    fi
done

start_at="${start_at-default}"
finish_at="${finish_at-default}"
verbose="${verbose-true}"
verbose2="${verbose2-false}"

if $verbose2; then set -x; fi

trap print_traceback EXIT

# Set start and finish steps for different modes.
default_start_at=""
default_finish_at=""
case "${rr[mode]}" in
    "baseline")
	default_finish_at="update_baseline"
	;;
    "bisect")
	case "$(print_single_updated_component)" in
	    binutils|gcc) default_start_at="build_abe-${type_of_test#check_}" ;;
	    *) assert false ;;
	esac
	default_finish_at="check_regression"
	;;
    "jenkins-full") ;;
esac
if [ x"$start_at" = x"default" ]; then
    start_at="$default_start_at"
fi
if [ x"$finish_at" = x"default" ]; then
    finish_at="$default_finish_at"
fi

run_step_init "$start_at" "$finish_at" "${rr[top_artifacts]}" "$verbose"

# Exit with code 0 if no regression compared to base-artifacts/results.
no_regression_p ()
{
    (
    set -euf -o pipefail

    no_build_regression_p "$@"

    local ref_artifacts=$1
    local new_artifacts=$2

    local sumfiles_base=$ref_artifacts/sumfiles
    local sumfiles_new=$new_artifacts/sumfiles

    if ! [ -d $sumfiles_base ]; then
	return 0
    elif ! [ -d $sumfiles_new ]; then
	return 1
    fi

    local res
    if ! echo "${rr[components]}" | tr ' ' '\n' | grep -q "^gcc\$"; then
	# We use GCC's comparison script, so make sure we have a copy (may
	# not be the case when we are just checking binutils)
	clone_or_update_repo gcc master git://gcc.gnu.org/git/gcc.git
    fi
    # (defined by init_step in jenkins-helpers)
    # shellcheck disable=SC2154
    gcc/contrib/compare_tests $sumfiles_base $sumfiles_new \
	| sed -e "s/^/# /" | tee $run_step_artifacts/results.regressions &
    res=0 && wait $! || res=$?

    if [ $res -ne 0 ]; then
        return 1
    fi

    return 0
    )
}

run_step stop_on_fail -1 reset_artifacts
run_step stop_on_fail x prepare_abe
case "$type_of_test" in
    check_*)
	run_step skip_on_fail 0 build_abe ${type_of_test#check_}
	run_step skip_on_fail 1 build_abe ${type_of_test}
	;;
    *)
	run_step skip_on_fail 0 true
	run_step skip_on_fail 1 build_abe ${type_of_test}
	;;
esac
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