forked from CTSRD-CHERI/webkit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.buildbot.sh
executable file
·175 lines (151 loc) · 6.26 KB
/
.buildbot.sh
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash
#
# Copyright (C) 2022 Arm Ltd.
# SPDX-License-Identifier: MIT OR Apache-2.0
set -eu
# Buildbot respects ANSI colours.
C_BOLD="\033[1m"
C_RESET="\033[m"
timestamp() {
local DELTA=''
if [ -n "${TIMESTAMP:-}" ]; then
local NEW_TIMESTAMP="$(date +%s)"
local TOTAL_S="$(( $NEW_TIMESTAMP - $TIMESTAMP ))"
# Show time taken for long-running commands (>1m).
local S="$(( TOTAL_S % 60 ))s"
if (( $TOTAL_S >= 60 )); then
local M="$(( (TOTAL_S / 60) % 60 ))m"
if (( $TOTAL_S >= 3600 )); then
local H="$(( TOTAL_S / 3600 ))h"
fi
DELTA=" (took ${H-}${M-}$S)"
fi
TIMESTAMP="$NEW_TIMESTAMP"
else
TIMESTAMP="$(date +%s)"
fi
echo -e "$C_BOLD$(date --date="@$TIMESTAMP" "+%H:%M:%S$DELTA")$C_RESET: $@"
}
timestamp "Entered $0."
# Standard buildbot variables.
CHERI_DIR="${CHERI_DIR-$HOME/cheri/output}"
CHERIBUILD_DIR="${CHERIBUILD_DIR-$HOME/cheri-build}"
WEBKIT_DIR="${REPO_DIR-$PWD}"
cd "$WEBKIT_DIR"
CHERI_RO_DIR="$(dirname "$CHERI_DIR")" # E.g. ~/cheri
BUILDBOT_SCRATCH_DIR=$(mktemp -d --tmpdir -t .buildbot-scratch-XXXXXX)
timestamp "Using temporary directory: $BUILDBOT_SCRATCH_DIR"
cleanup() {
timestamp "Cleaning up: $BUILDBOT_SCRATCH_DIR"
rm -rf "$BUILDBOT_SCRATCH_DIR"
trap '' INT TERM EXIT
timestamp "Done!"
exit
}
trap cleanup INT TERM EXIT
# We need to run ./cheribuild.py, but it needs a source tree. $CHERI_RO_DIR is
# provided (with at least the SDK and filesystem images), but is read-only, so
# we need to copy it.
#
# TODO: Consider using symlinks to sub-trees that only need to be read-only.
CHERI_RW_DIR="$BUILDBOT_SCRATCH_DIR/cheri"
timestamp "Copying $CHERI_RO_DIR to $CHERI_RW_DIR..."
RULES=(
'--include=/output/'
'--include=/icu/' # ICU probably isn't present, but we'll take it if it is.
'--exclude=/*/'
'--exclude=*.img' # Don't copy large disk images.
# Files in /rescue are hardlinked together and end up very large after
# copying. -H could preserve links, but it's easier to just exclude them.
'--exclude=**/rootfs-*/rescue/'
)
rsync -a --chmod=u+w "$CHERI_RO_DIR/" "$CHERI_RW_DIR" "${RULES[@]}"
timestamp "Symlinking WebKit test subject into the CHERI root: $CHERI_RW_DIR/webkit -> $WEBKIT_DIR"
ln -fsT "$WEBKIT_DIR" "$CHERI_RW_DIR/webkit"
# It's useful to see (roughly) what was copied in CI logs.
echo "---- $CHERI_RW_DIR ----"
ls -l "$CHERI_RW_DIR"
echo "---- $CHERI_RW_DIR/output ----"
ls -l "$CHERI_RW_DIR/output"
TARGET_FILES_DIR="$BUILDBOT_SCRATCH_DIR/target_files"
mkdir -p "$TARGET_FILES_DIR"/builds
cp -r -t "$TARGET_FILES_DIR" "PerformanceTests/SunSpider/tests/sunspider-1.0.1"
cp .buildbot-test.sh "$TARGET_FILES_DIR"/test.sh
chmod +x "$TARGET_FILES_DIR"/test.sh
build() {
TARGET_SUFFIX="$1"
shift
local CHERIBUILD_ARGS=(
"--source-root=\"$CHERI_RW_DIR\""
'--skip-update'
)
case "$TARGET_SUFFIX" in
morello-purecap)
local FS_TYPE="morello-purecap"
local BUILD_TYPE="morello-purecap"
;;
morello-hybrid-for-purecap-rootfs)
local FS_TYPE="morello-purecap"
local BUILD_TYPE="morello-hybrid"
CHERIBUILD_ARGS+=('--enable-hybrid-for-purecap-rootfs-targets')
;;
*)
echo "Unhandled TARGET_SUFFIX: $TARGET_SUFFIX"
exit 1
;;
esac
# Flatten the build configuration to form a unique destination directory.
local FLAT="${BUILD_TYPE}_$(echo "$*" |
sed "s/\(.\+\)/\L\1/g; # Lower case
s/--morello-webkit\///g;
s/\s\+/_/g;
s/[^a-z0-9_-]//g;")"
pushd "$CHERIBUILD_DIR"
# We use 'script' (below) to make cheribuild think that it has an interactive
# shell. This isn't ideal, but cheribuild otherwise hangs with SIGTTOU on
# consecutive calls: https://github.com/CTSRD-CHERI/cheribuild/issues/182
# TODO: Once the cheribuild bug is fixed, remove this workaround.
cheribuild() {
timestamp "Building: ./cheribuild.py ${CHERIBUILD_ARGS[*]} $*"
script -qec "./cheribuild.py ${CHERIBUILD_ARGS[*]} $*" /dev/null
}
cheribuild "icu4c-native"
cheribuild "icu4c-$TARGET_SUFFIX"
# --clean and/or --reconfigure are sometimes required when building different
# configurations in sequence.
cheribuild --clean --reconfigure morello-webkit-$TARGET_SUFFIX "$@"
local FSROOT="$CHERI_RW_DIR"/output/rootfs-$FS_TYPE
local OUTDIR="$(realpath "$TARGET_FILES_DIR"/builds)/$FLAT"
timestamp "Build complete. Copying files to $OUTDIR..."
mkdir "$OUTDIR"
mkdir "$OUTDIR/bin"
mkdir "$OUTDIR/lib"
cp -a -t "$OUTDIR/bin" "$FSROOT"/opt/"$BUILD_TYPE"/webkit/bin/*
cp -a -t "$OUTDIR/lib" "$FSROOT"/opt/"$BUILD_TYPE"/webkit/lib/*
cp -a -t "$OUTDIR/lib" "$FSROOT"/usr/local/"$BUILD_TYPE"/lib/libicu*
popd
}
# TODO: 'cloop' is disabled because it's slow, and takes longer than the Merge
# Queues timeout. We should reinstate it, perhaps as a weekly run or similar.
#build morello-purecap --morello-webkit/build-type Debug --morello-webkit/backend cloop
build morello-purecap --morello-webkit/build-type Debug --morello-webkit/backend tier1asm
# TODO: tier2asm shows intermittent failures, which are currently under
# investigation. To avoid CI disruption, it is disabled here for now, but
# should be enabled once the failures are resolved.
#build morello-purecap --morello-webkit/build-type Debug --morello-webkit/backend tier2asm
# Skip cloop hybrid because it takes ~10 hours to run.
build morello-hybrid-for-purecap-rootfs --morello-webkit/build-type Debug --morello-webkit/backend tier1asm
build morello-hybrid-for-purecap-rootfs --morello-webkit/build-type Debug --morello-webkit/backend tier2asm
# TODO: Also test other variations (e.g. --morello-webkit/jsheapoffsets).
echo "TARGET_FILES_DIR:"
tree -h --du "$TARGET_FILES_DIR"
timestamp "Running tests..."
export PYTHONPATH="$CHERIBUILD_DIR"/test-scripts
python3 .buildbot-run-and-test.py \
--architecture morello-purecap \
--qemu-cmd "$CHERI_RO_DIR"/output/sdk/bin/qemu-system-morello \
--bios edk2-aarch64-code.fd \
--disk-image "$CHERI_RO_DIR"/output/cheribsd-morello-purecap.img \
--build-dir "$TARGET_FILES_DIR" \
--ssh-port 10042
timestamp "Tests complete."