Skip to content

Commit 4a07233

Browse files
committed
Merge #17767: ci: Fix qemu issues
fa569e1 ci: Set LC_ALL=C when running in qemu-s390x (MarcoFalke) fa3d776 ci: Use debian to avoid apt install 404 errors (MarcoFalke) fabb946 ci: Install needed gcc and qemu-user iff cross-compiling (MarcoFalke) faba467 ci: Fix QEMU_USER_CMD parse issues (MarcoFalke) fa5d709 ci: Move wrap-qemu into separate script (MarcoFalke) Pull request description: Now that the ci system no longer propagates files from the docker container back to the host, the wrap-qemu script is broken. To fix it, every statement in the script needs to be executed in the docker (with `DOCKER_EXEC`). Instead of juggling with triple escape sequences like `\\\"`, just move the script to a separate file and call it with `DOCKER_EXEC`. Also, fix a bunch of other bugs that prevent running the ci system in qemu See the `ci/README.md` on how to test. TLDR: Can be tested with (replace `arm` with `s390x` to run the s390x build): ``` FILE_ENV="./ci/test/00_setup_env_arm.sh" MAKEJOBS="-j9" ./ci/test_run_all.sh ``` ACKs for top commit: laanwj: Code review ACK fa569e1 Tree-SHA512: 84ebc44a4f0261ee6c29605a6896a1833ff6c81d729e6d08dd111941f570ce73221422bd3303e1108a266ec5eab2148bd5ee1cf6bc01477d8cc9a6c5bf2b34c2
2 parents a3d198c + fa569e1 commit 4a07233

File tree

7 files changed

+53
-30
lines changed

7 files changed

+53
-30
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ jobs:
8282
- set -o errexit; source ./ci/lint/06_script.sh
8383

8484
- stage: test
85-
name: 'ARM [GOAL: install] [bionic] [unit tests, functional tests]'
85+
name: 'ARM [GOAL: install] [buster] [unit tests, functional tests]'
8686
arch: arm64
8787
env: >-
8888
FILE_ENV="./ci/test/00_setup_env_arm.sh"
8989
QEMU_USER_CMD="" # Can run the tests natively without qemu
9090
9191
- stage: test
92-
name: 'S390x [GOAL: install] [bionic] [unit tests, functional tests]'
92+
name: 'S390x [GOAL: install] [buster] [unit tests, functional tests]'
9393
arch: s390x
9494
env: >-
9595
FILE_ENV="./ci/test/00_setup_env_s390x.sh"

ci/test/00_setup_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export DEPENDS_DIR=${DEPENDS_DIR:-$BASE_ROOT_DIR/depends}
5151
export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out/$HOST}
5252
export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
5353
export WINEDEBUG=${WINEDEBUG:-fixme-all}
54-
export DOCKER_PACKAGES=${DOCKER_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git}
54+
export DOCKER_PACKAGES=${DOCKER_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git procps}
5555
export GOAL=${GOAL:-install}
5656
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
5757
export PATH=${BASE_ROOT_DIR}/ci/retry:$PATH

ci/test/00_setup_env_arm.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ export LC_ALL=C.UTF-8
99
export HOST=arm-linux-gnueabihf
1010
# The host arch is unknown, so we run the tests through qemu.
1111
# If the host is arm and wants to run the tests natively, it can set QEMU_USER_CMD to the empty string.
12-
export QEMU_USER_CMD="${QEMU_USER_CMD:"qemu-arm -L /usr/arm-linux-gnueabihf/"}"
13-
# We don't know whether the host can run the cross compiled binaries. To run them, either qemu-user or libc6:armhf for
14-
# the target is required, so install both.
12+
if [ -z ${QEMU_USER_CMD+x} ]; then export QEMU_USER_CMD="${QEMU_USER_CMD:-"qemu-arm -L /usr/arm-linux-gnueabihf/"}"; fi
1513
export DPKG_ADD_ARCH="armhf"
16-
export PACKAGES="python3 g++-arm-linux-gnueabihf busybox qemu-user libc6:armhf libstdc++6:armhf libfontconfig1:armhf libxcb1:armhf"
14+
export PACKAGES="python3-zmq g++-arm-linux-gnueabihf busybox libc6:armhf libstdc++6:armhf libfontconfig1:armhf libxcb1:armhf"
15+
if [ -n "$QEMU_USER_CMD" ]; then
16+
# Likely cross-compiling, so install the needed gcc and qemu-user
17+
export PACKAGES="$PACKAGES qemu-user"
18+
fi
19+
# Use debian to avoid 404 apt errors when cross compiling
20+
export DOCKER_NAME_TAG="debian:buster"
1721
export USE_BUSY_BOX=true
1822
export RUN_UNIT_TESTS=true
1923
export RUN_FUNCTIONAL_TESTS=true

ci/test/00_setup_env_s390x.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ export LC_ALL=C.UTF-8
99
export HOST=s390x-linux-gnu
1010
# The host arch is unknown, so we run the tests through qemu.
1111
# If the host is s390x and wants to run the tests natively, it can set QEMU_USER_CMD to the empty string.
12-
export QEMU_USER_CMD="${QEMU_USER_CMD:"qemu-s390x"}"
13-
export PACKAGES="python3-zmq bsdmainutils qemu-user"
12+
if [ -z ${QEMU_USER_CMD+x} ]; then export QEMU_USER_CMD="${QEMU_USER_CMD:-"qemu-s390x"}"; fi
13+
export PACKAGES="python3-zmq"
14+
if [ -n "$QEMU_USER_CMD" ]; then
15+
# Likely cross-compiling, so install the needed gcc and qemu-user
16+
export DPKG_ADD_ARCH="s390x"
17+
export PACKAGES="$PACKAGES g++-s390x-linux-gnu qemu-user libc6:s390x libstdc++6:s390x libfontconfig1:s390x libxcb1:s390x"
18+
fi
19+
# Use debian to avoid 404 apt errors
20+
export DOCKER_NAME_TAG="debian:buster"
1421
export RUN_UNIT_TESTS=true
1522
export RUN_FUNCTIONAL_TESTS=true
1623
export GOAL="install"

ci/test/04_install.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ export LC_ALL=C.UTF-8
99
if [[ $DOCKER_NAME_TAG == centos* ]]; then
1010
export LC_ALL=en_US.utf8
1111
fi
12+
if [[ $QEMU_USER_CMD == qemu-s390* ]]; then
13+
export LC_ALL=C
14+
fi
1215

1316
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
1417
set +o errexit
@@ -42,7 +45,7 @@ export ASAN_OPTIONS="detect_stack_use_after_return=1:check_initialization_order=
4245
export LSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/lsan"
4346
export TSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/tsan:log_path=${BASE_SCRATCH_DIR}/sanitizer-output/tsan"
4447
export UBSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1"
45-
env | grep -E '^(BITCOIN_CONFIG|BASE_|CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS)' | tee /tmp/env
48+
env | grep -E '^(BITCOIN_CONFIG|BASE_|QEMU_|CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS)' | tee /tmp/env
4649
if [[ $HOST = *-mingw32 ]]; then
4750
DOCKER_ADMIN="--cap-add SYS_ADMIN"
4851
elif [[ $BITCOIN_CONFIG = *--with-sanitizers=*address* ]]; then # If ran with (ASan + LSan), Docker needs access to ptrace (https://github.com/google/sanitizers/issues/764)
@@ -73,16 +76,6 @@ else
7376
}
7477
fi
7578

76-
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
77-
top -l 1 -s 0 | awk ' /PhysMem/ {print}'
78-
echo "Number of CPUs: $(sysctl -n hw.logicalcpu)"
79-
else
80-
DOCKER_EXEC free -m -h
81-
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$\(nproc\)
82-
DOCKER_EXEC echo "Free disk space:"
83-
DOCKER_EXEC df -h
84-
fi
85-
8679
if [ -n "$DPKG_ADD_ARCH" ]; then
8780
DOCKER_EXEC dpkg --add-architecture "$DPKG_ADD_ARCH"
8881
fi
@@ -95,6 +88,16 @@ elif [ "$TRAVIS_OS_NAME" != "osx" ]; then
9588
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $DOCKER_PACKAGES
9689
fi
9790

91+
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
92+
top -l 1 -s 0 | awk ' /PhysMem/ {print}'
93+
echo "Number of CPUs: $(sysctl -n hw.logicalcpu)"
94+
else
95+
DOCKER_EXEC free -m -h
96+
DOCKER_EXEC echo "Number of CPUs \(nproc\):" \$\(nproc\)
97+
DOCKER_EXEC echo "Free disk space:"
98+
DOCKER_EXEC df -h
99+
fi
100+
98101
if [ ! -d ${DIR_QA_ASSETS} ]; then
99102
DOCKER_EXEC git clone https://github.com/bitcoin-core/qa-assets ${DIR_QA_ASSETS}
100103
fi

ci/test/06_script_b.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,7 @@ if [ -n "$QEMU_USER_CMD" ]; then
1111
# Generate all binaries, so that they can be wrapped
1212
DOCKER_EXEC make $MAKEJOBS -C src/secp256k1 VERBOSE=1
1313
DOCKER_EXEC make $MAKEJOBS -C src/univalue VERBOSE=1
14-
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/univalue/{no_nul,test_json,unitester,object}}; do
15-
# shellcheck disable=SC2044
16-
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name $(basename $b_name)); do
17-
echo "Wrap $b ..."
18-
DOCKER_EXEC mv "$b" "${b}_orig"
19-
DOCKER_EXEC echo "\#\!/usr/bin/env bash" \> "$b"
20-
DOCKER_EXEC echo "$QEMU_USER_CMD \\\"${b}_orig\\\" \\\"\\\$@\\\"" \>\> "$b"
21-
DOCKER_EXEC chmod +x "$b"
22-
done
23-
done
14+
DOCKER_EXEC "${BASE_ROOT_DIR}/ci/test/wrap-qemu.sh"
2415
END_FOLD
2516
fi
2617

ci/test/wrap-qemu.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2018 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
for b_name in {"${BASE_OUTDIR}/bin"/*,src/secp256k1/*tests,src/univalue/{no_nul,test_json,unitester,object}}; do
10+
# shellcheck disable=SC2044
11+
for b in $(find "${BASE_ROOT_DIR}" -executable -type f -name $(basename $b_name)); do
12+
echo "Wrap $b ..."
13+
mv "$b" "${b}_orig"
14+
echo '#!/usr/bin/env bash' > "$b"
15+
echo "$QEMU_USER_CMD \"${b}_orig\" \"\$@\"" >> "$b"
16+
chmod +x "$b"
17+
done
18+
done

0 commit comments

Comments
 (0)