Skip to content

Commit c170523

Browse files
committed
fixup! ci: make scripts more uniform
1 parent 897508b commit c170523

File tree

5 files changed

+154
-131
lines changed

5 files changed

+154
-131
lines changed

ci/install-musl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ rm -rf "$musl"
6767
# Download, configure, build, and install musl-sanitized kernel headers:
6868
kernel_header_ver="4.19.88"
6969
curl --retry 5 -L \
70-
"https://github.com/sabotage-linux/kernel-headers/archive/v${kernel_header_ver}.tar.gz" | \
70+
"https://github.com/sabotage-linux/kernel-headers/archive/v${kernel_header_ver}.tar.gz" |
7171
tar xzf -
7272
(
7373
cd "kernel-headers-${kernel_header_ver}"

ci/install-rust.sh

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,46 @@ if [ -n "$TOOLCHAIN" ]; then
1010
else
1111
toolchain=nightly
1212
fi
13+
1314
if [ "$OS" = "windows" ]; then
14-
: "${TARGET?The TARGET environment variable must be set.}"
15-
rustup set profile minimal
16-
rustup update --force "$toolchain-$TARGET"
17-
rustup default "$toolchain-$TARGET"
15+
: "${TARGET?The TARGET environment variable must be set.}"
16+
rustup set profile minimal
17+
rustup update --force "$toolchain-$TARGET"
18+
rustup default "$toolchain-$TARGET"
1819
else
19-
rustup set profile minimal
20-
rustup update --force "$toolchain"
21-
rustup default "$toolchain"
20+
rustup set profile minimal
21+
rustup update --force "$toolchain"
22+
rustup default "$toolchain"
2223
fi
2324

2425
if [ -n "$TARGET" ]; then
25-
echo "Install target"
26-
rustup target add "$TARGET"
26+
echo "Install target"
27+
rustup target add "$TARGET"
2728
fi
2829

2930
if [ -n "$INSTALL_RUST_SRC" ]; then
30-
echo "Install rust-src"
31-
rustup component add rust-src
31+
echo "Install rust-src"
32+
rustup component add rust-src
3233
fi
3334

3435
if [ "$OS" = "windows" ]; then
35-
if [ "$ARCH_BITS" = "i686" ]; then
36-
echo "Install MinGW32"
37-
choco install mingw --x86 --force
38-
fi
36+
if [ "$ARCH_BITS" = "i686" ]; then
37+
echo "Install MinGW32"
38+
choco install mingw --x86 --force
39+
fi
3940

40-
echo "Find GCC libraries"
41-
gcc -print-search-dirs
42-
/usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*"
43-
/usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*"
44-
/usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*"
41+
echo "Find GCC libraries"
42+
gcc -print-search-dirs
43+
/usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*"
44+
/usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*"
45+
/usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*"
4546

46-
if [ -n "$ARCH_BITS" ]; then
47-
echo "Fix MinGW"
48-
for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do
49-
cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib"
50-
done
51-
fi
47+
if [ -n "$ARCH_BITS" ]; then
48+
echo "Fix MinGW"
49+
for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do
50+
cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib"
51+
done
52+
fi
5253
fi
5354

5455
echo "Query rust and cargo versions"
@@ -63,11 +64,11 @@ rustup show
6364
echo "Generate lockfile"
6465
N=5
6566
n=0
66-
until [ $n -ge $N ]
67-
do
68-
if cargo generate-lockfile; then
69-
break
70-
fi
71-
n=$((n+1))
72-
sleep 1
67+
until [ $n -ge $N ]; do
68+
if cargo generate-lockfile; then
69+
break
70+
fi
71+
72+
n=$((n+1))
73+
sleep 1
7374
done

ci/run.sh

Lines changed: 110 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -16,104 +16,126 @@ target="$1"
1616
# It's assume that all images, when run with two disks, will run the `run.sh`
1717
# script from the second which we place inside.
1818
if [ "$QEMU" != "" ]; then
19-
tmpdir=/tmp/qemu-img-creation
20-
mkdir -p "${tmpdir}"
19+
tmpdir=/tmp/qemu-img-creation
20+
mkdir -p "${tmpdir}"
2121

22-
if [ -z "${QEMU#*.gz}" ]; then
23-
# image is .gz : download and uncompress it
24-
qemufile="$(echo "${QEMU%.gz}" | sed 's/\//__/g')"
25-
if [ ! -f "${tmpdir}/${qemufile}" ]; then
26-
curl --retry 5 "${mirrors_url}/${QEMU}" | \
27-
gunzip -d > "${tmpdir}/${qemufile}"
22+
if [ -z "${QEMU#*.gz}" ]; then
23+
# image is .gz : download and uncompress it
24+
qemufile="$(echo "${QEMU%.gz}" | sed 's/\//__/g')"
25+
if [ ! -f "${tmpdir}/${qemufile}" ]; then
26+
curl --retry 5 "${mirrors_url}/${QEMU}" |
27+
gunzip -d > "${tmpdir}/${qemufile}"
28+
fi
29+
elif [ -z "${QEMU#*.xz}" ]; then
30+
# image is .xz : download and uncompress it
31+
qemufile="$(echo "${QEMU%.xz}" | sed 's/\//__/g')"
32+
if [ ! -f "${tmpdir}/${qemufile}" ]; then
33+
curl --retry 5 "${mirrors_url}/${QEMU}" |
34+
unxz > "${tmpdir}/${qemufile}"
35+
fi
36+
else
37+
# plain qcow2 image: just download it
38+
qemufile="$(echo "${QEMU}" | sed 's/\//__/g')"
39+
if [ ! -f "${tmpdir}/${qemufile}" ]; then
40+
curl --retry 5 "${mirrors_url}/${QEMU}" >
41+
"${tmpdir}/${qemufile}"
42+
fi
2843
fi
29-
elif [ -z "${QEMU#*.xz}" ]; then
30-
# image is .xz : download and uncompress it
31-
qemufile="$(echo "${QEMU%.xz}" | sed 's/\//__/g')"
32-
if [ ! -f "${tmpdir}/${qemufile}" ]; then
33-
curl --retry 5 "${mirrors_url}/${QEMU}" | \
34-
unxz > "${tmpdir}/${qemufile}"
35-
fi
36-
else
37-
# plain qcow2 image: just download it
38-
qemufile="$(echo "${QEMU}" | sed 's/\//__/g')"
39-
if [ ! -f "${tmpdir}/${qemufile}" ]; then
40-
curl --retry 5 "${mirrors_url}/${QEMU}" \
41-
> "${tmpdir}/${qemufile}"
42-
fi
43-
fi
4444

45-
# Create a mount a fresh new filesystem image that we'll later pass to QEMU.
46-
# This will have a `run.sh` script will which use the artifacts inside to run
47-
# on the host.
48-
rm -f "${tmpdir}/libc-test.img"
49-
mkdir "${tmpdir}/mount"
45+
# Create a mount a fresh new filesystem image that we'll later pass to QEMU.
46+
# This will have a `run.sh` script will which use the artifacts inside to run
47+
# on the host.
48+
rm -f "${tmpdir}/libc-test.img"
49+
mkdir "${tmpdir}/mount"
5050

51-
# Do the standard rigamarole of cross-compiling an executable and then the
52-
# script to run just executes the binary.
53-
cargo build \
54-
--manifest-path libc-test/Cargo.toml \
55-
--target "$target" \
56-
--test main ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
57-
rm "${CARGO_TARGET_DIR}/${target}"/debug/main-*.d
58-
cp "${CARGO_TARGET_DIR}/${target}"/debug/main-* "${tmpdir}"/mount/libc-test
59-
# shellcheck disable=SC2016
60-
echo 'exec $1/libc-test' > "${tmpdir}/mount/run.sh"
51+
# Do the standard rigamarole of cross-compiling an executable and then the
52+
# script to run just executes the binary.
53+
cargo build \
54+
--manifest-path libc-test/Cargo.toml \
55+
--target "$target" \
56+
--test main ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
57+
rm "${CARGO_TARGET_DIR}/${target}"/debug/main-*.d
58+
cp "${CARGO_TARGET_DIR}/${target}"/debug/main-* "${tmpdir}"/mount/libc-test
59+
# shellcheck disable=SC2016
60+
echo 'exec $1/libc-test' > "${tmpdir}/mount/run.sh"
6161

62-
du -sh "${tmpdir}/mount"
63-
genext2fs \
64-
--root "${tmpdir}/mount" \
65-
--size-in-blocks 100000 \
66-
"${tmpdir}/libc-test.img"
62+
du -sh "${tmpdir}/mount"
63+
genext2fs \
64+
--root "${tmpdir}/mount" \
65+
--size-in-blocks 100000 \
66+
"${tmpdir}/libc-test.img"
6767

68-
# Pass -snapshot to prevent tampering with the disk images, this helps when
69-
# running this script in development. The two drives are then passed next,
70-
# first is the OS and second is the one we just made. Next the network is
71-
# configured to work (I'm not entirely sure how), and then finally we turn off
72-
# graphics and redirect the serial console output to out.log.
73-
qemu-system-x86_64 \
74-
-m 1024 \
75-
-snapshot \
76-
-drive if=virtio,file="${tmpdir}/${qemufile}" \
77-
-drive if=virtio,file="${tmpdir}/libc-test.img" \
78-
-net nic,model=virtio \
79-
-net user \
80-
-nographic \
81-
-vga none 2>&1 | tee "${CARGO_TARGET_DIR}/out.log"
82-
exec grep -E "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log"
68+
# Pass -snapshot to prevent tampering with the disk images, this helps when
69+
# running this script in development. The two drives are then passed next,
70+
# first is the OS and second is the one we just made. Next the network is
71+
# configured to work (I'm not entirely sure how), and then finally we turn off
72+
# graphics and redirect the serial console output to out.log.
73+
qemu-system-x86_64 \
74+
-m 1024 \
75+
-snapshot \
76+
-drive if=virtio,file="${tmpdir}/${qemufile}" \
77+
-drive if=virtio,file="${tmpdir}/libc-test.img" \
78+
-net nic,model=virtio \
79+
-net user \
80+
-nographic \
81+
-vga none 2>&1 | tee "${CARGO_TARGET_DIR}/out.log"
82+
exec grep -E "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log"
8383
fi
8484

8585
if [ "$target" = "s390x-unknown-linux-gnu" ]; then
86-
# FIXME: s390x-unknown-linux-gnu often fails to test due to timeout,
87-
# so we retry this N times.
88-
N=5
89-
n=0
90-
passed=0
91-
until [ $n -ge $N ]
92-
do
93-
if [ "$passed" = "0" ]; then
94-
if cargo test --no-default-features --manifest-path libc-test/Cargo.toml --target "$target" ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"} ; then
95-
passed=$((passed+1))
96-
continue
97-
fi
98-
elif [ "$passed" = "1" ]; then
99-
if cargo test --manifest-path libc-test/Cargo.toml --target "$target" ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"} ; then
100-
passed=$((passed+1))
101-
continue
102-
fi
103-
elif [ "$passed" = "2" ]; then
104-
if cargo test --features extra_traits --manifest-path libc-test/Cargo.toml --target "$target" ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}; then
105-
break
106-
fi
107-
fi
108-
n=$((n+1))
109-
sleep 1
110-
done
86+
# FIXME: s390x-unknown-linux-gnu often fails to test due to timeout,
87+
# so we retry this N times.
88+
N=5
89+
n=0
90+
passed=0
91+
until [ $n -ge $N ]; do
92+
if [ "$passed" = "0" ]; then
93+
if cargo test \
94+
--no-default-features \
95+
--manifest-path libc-test/Cargo.toml \
96+
--target "$target" \
97+
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
98+
then
99+
passed=$((passed+1))
100+
continue
101+
fi
102+
elif [ "$passed" = "1" ]; then
103+
if cargo test \
104+
--manifest-path libc-test/Cargo.toml \
105+
--target "$target" \
106+
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
107+
then
108+
passed=$((passed+1))
109+
continue
110+
fi
111+
elif [ "$passed" = "2" ]; then
112+
if cargo test \
113+
--features extra_traits \
114+
--manifest-path libc-test/Cargo.toml \
115+
--target "$target" \
116+
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
117+
then
118+
break
119+
fi
120+
fi
121+
n=$((n+1))
122+
sleep 1
123+
done
111124
else
112-
cargo test --no-default-features --manifest-path libc-test/Cargo.toml \
113-
--target "$target" ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
125+
cargo test \
126+
--no-default-features \
127+
--manifest-path libc-test/Cargo.toml \
128+
--target "$target" \
129+
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
114130

115-
cargo test --manifest-path libc-test/Cargo.toml --target "$target" ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
131+
cargo test \
132+
--manifest-path libc-test/Cargo.toml \
133+
--target "$target" \
134+
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
116135

117-
RUST_BACKTRACE=1 cargo test --features extra_traits --manifest-path libc-test/Cargo.toml \
118-
--target "$target" ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
136+
RUST_BACKTRACE=1 cargo test \
137+
--features extra_traits \
138+
--manifest-path libc-test/Cargo.toml \
139+
--target "$target" \
140+
${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}
119141
fi

ci/test-runner-linux

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -e
44

5-
arch=$1
6-
prog=$2
5+
arch="$1"
6+
prog="$2"
77

88
cd /qemu/init
99
echo "#!/bin/sh\n/prog --color=never" > run_prog.sh
@@ -13,11 +13,11 @@ find . | cpio --create --format='newc' --quiet | gzip > ../initrd.gz
1313
cd ..
1414

1515
timeout 30s qemu-system-$arch \
16-
-m 1024 \
17-
-nographic \
18-
-kernel kernel \
19-
-initrd initrd.gz \
20-
-append init=/run_prog.sh > output || true
16+
-m 1024 \
17+
-nographic \
18+
-kernel kernel \
19+
-initrd initrd.gz \
20+
-append init=/run_prog.sh > output || true
2121

2222
# remove kernel messages
2323
tr -d '\r' < output | grep -Ev '^\['

ci/wasi.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ apt-get install -y --no-install-recommends \
1818
wasmtime=24.0.0
1919
wasi_sdk=24
2020

21-
curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | \
22-
tar xJf -
21+
curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz |
22+
tar xJf -
2323
mv wasmtime-v$wasmtime-x86_64-linux wasmtime
2424

2525
# The pre-built `*.deb` files for wasi-sdk install to `/opt/wasi-sdk`

0 commit comments

Comments
 (0)