2024-10-06 13:44:25 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2019-05-02 11:37:21 -07:00
|
|
|
# Small script to run tests for a target (or all targets) inside all the
|
|
|
|
|
# respective docker images.
|
|
|
|
|
|
2024-10-06 13:44:25 -05:00
|
|
|
set -euxo pipefail
|
2019-05-02 11:37:21 -07:00
|
|
|
|
2024-10-28 13:30:39 -05:00
|
|
|
host_arch="$(uname -m | sed 's/arm64/aarch64/')"
|
|
|
|
|
|
2019-05-02 11:37:21 -07:00
|
|
|
run() {
|
|
|
|
|
local target=$1
|
|
|
|
|
|
2024-10-06 13:44:25 -05:00
|
|
|
echo "testing target: $target"
|
2019-05-02 11:37:21 -07:00
|
|
|
|
2024-10-28 13:30:39 -05:00
|
|
|
target_arch="$(echo "$target" | cut -d'-' -f1)"
|
|
|
|
|
|
|
|
|
|
emulated=""
|
|
|
|
|
if [ "$target_arch" != "$host_arch" ]; then
|
|
|
|
|
emulated=1
|
|
|
|
|
echo "target is emulated"
|
|
|
|
|
fi
|
|
|
|
|
|
2019-05-02 11:37:21 -07:00
|
|
|
# This directory needs to exist before calling docker, otherwise docker will create it but it
|
|
|
|
|
# will be owned by root
|
|
|
|
|
mkdir -p target
|
|
|
|
|
|
2024-10-06 13:44:25 -05:00
|
|
|
docker build -t "$target" "ci/docker/$target"
|
2019-05-02 11:37:21 -07:00
|
|
|
docker run \
|
2024-10-28 13:30:39 -05:00
|
|
|
--rm \
|
|
|
|
|
--user "$(id -u):$(id -g)" \
|
|
|
|
|
-e RUSTFLAGS \
|
|
|
|
|
-e CARGO_HOME=/cargo \
|
|
|
|
|
-e CARGO_TARGET_DIR=/target \
|
|
|
|
|
-e "EMULATED=$emulated" \
|
|
|
|
|
-v "${HOME}/.cargo:/cargo" \
|
|
|
|
|
-v "$(pwd)/target:/target" \
|
|
|
|
|
-v "$(pwd):/checkout:ro" \
|
|
|
|
|
-v "$(rustc --print sysroot):/rust:ro" \
|
|
|
|
|
--init \
|
|
|
|
|
-w /checkout \
|
|
|
|
|
"$target" \
|
|
|
|
|
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh $target"
|
2019-05-02 11:37:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
2024-10-28 13:30:39 -05:00
|
|
|
echo "running tests for all targets"
|
2024-10-06 13:44:25 -05:00
|
|
|
|
2024-10-28 13:30:39 -05:00
|
|
|
for d in ci/docker/*; do
|
|
|
|
|
run $d
|
|
|
|
|
done
|
2019-05-02 11:37:21 -07:00
|
|
|
else
|
2024-10-28 13:30:39 -05:00
|
|
|
run $1
|
2019-05-02 11:37:21 -07:00
|
|
|
fi
|