Skip to content

Commit

Permalink
debug-only: reproduce TEST-64-UDEV-STORAGE fails
Browse files Browse the repository at this point in the history
  • Loading branch information
mrc0mmand committed Sep 22, 2023
1 parent 87a06bd commit 099ea42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 94 deletions.
66 changes: 2 additions & 64 deletions vagrant/boxes/archlinux_systemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pacman-key --init
pacman-key --populate archlinux
pacman --needed --noconfirm -Sy archlinux-keyring
# Upgrade the system
pacman --noconfirm -Syu
pacman --noconfirm -Syuu
# Install build dependencies
# Package groups: base, base-devel
pacman --needed --noconfirm -Sy base base-devel bpf btrfs-progs acl audit bash-completion clang compiler-rt docbook-xsl \
Expand All @@ -30,7 +30,7 @@ pacman --needed --noconfirm -Sy base base-devel bpf btrfs-progs acl audit bash-c
pacman --needed --noconfirm -S coreutils bind busybox cpio dhclient dhcp dhcpcd diffutils dnsmasq dosfstools e2fsprogs erofs-utils \
evemu expect fsverity-utils gdb inetutils jq knot keyutils lcov libdwarf libelf mdadm mtools net-tools nfs-utils nftables ntp \
openbsd-netcat open-iscsi perl-capture-tiny perl-datetime perl-json-xs python-pefile python-pexpect python-psutil python-pyelftools \
python-pyparsing python-pytest rsync screen socat squashfs-tools strace stress time tpm2-tools swtpm vim wireguard-tools
python-pyparsing python-pytest rsync screen socat squashfs-tools strace stress time tpm2-tools swtpm vim wireguard-tools qemu-base

# Unlock root account and set its password to 'vagrant' to allow root login
# via ssh
Expand Down Expand Up @@ -105,68 +105,6 @@ popd
rm -fr dfuzzer
dfuzzer --version

# Configure a FIDO2 QEMU device using CanoKey
#
# This has 2 steps:
# 1) Build & install canokey-qemu
# 2) Rebuild QEMU with --enable-canokey
#
# After this we should have a CanoKey device available through
# qemu-system-x86_64 -usb -device canokey,file=...
#
# References:
# - https://www.qemu.org/docs/master/system/devices/canokey.html
# - https://github.com/canokeys/canokey-qemu
#
# 1) Build & install canokey-qemu
pacman --needed --noconfirm -S cmake gcc make patch pkgconf
git clone --depth=1 --recursive https://github.com/canokeys/canokey-qemu
mkdir canokey-qemu/build
pushd canokey-qemu/build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make -j
make install
popd
rm -fr canokey-qemu
pkg-config --libs --cflags canokey-qemu

# 2) Rebuild QEMU with --enable-canokey
#
# 2a) Since makepkg won't run under root, we need to create a separate user
# and give it access to paswordless sudo
useradd --create-home builder
mkdir -p /etc/sudoers.d
echo "builder ALL=(ALL) NOPASSWD: ALL" >/etc/sudoers.d/builder

# 2b) Patch QEMU's PKGBUILD, rebuild it, and install the rebuilt packages
pacman --needed --noconfirm -S bison fakeroot flex
git clone --depth=1 https://gitlab.archlinux.org/archlinux/packaging/packages/qemu.git
chown -R builder qemu
pushd qemu
sed -i 's/^pkgrel=.*$/pkgrel=999/' PKGBUILD
sed -i '/local configure_options=(/a\ --enable-canokey' PKGBUILD
# The GPG key ID can be found at https://www.qemu.org/download/
runuser -u builder -- gpg --receive-keys CEACC9E15534EBABB82D3FA03353C9CEF108B584
runuser -u builder -- makepkg --noconfirm --needed --clean --syncdeps --rmdeps
# This part is a bit convoluted, since we can't use makepkg --install or install
# all the just built packages explicitly, as some of the packages conflict with
# each other. So, in order to leave dependency resolving on pacman, let's create
# a local repo from the just built packages and instruct pacman to use it
repo-add "$PWD/qemu.db.tar.gz" ./*.zst
cp /etc/pacman.conf pacman.conf
echo -ne "[qemu]\nSigLevel=Optional\nServer=file://$PWD\n" >>pacman.conf
# Note: we _need_ to prefix the qemu-base meta package with our local repo name,
# otherwise pacman will install the first qemu-base package it encounters,
# which would be the regular one from the extras repository
pacman --noconfirm -Sy qemu/qemu-base --config pacman.conf
popd
rm -fr qemu
qemu-system-x86_64 -usb -device canokey,help

# 2c) Cleanup
rm /etc/sudoers.d/builder
userdel -fr builder

# Replace systemd-networkd with dhcpcd as the network manager for the default
# interface, so we can run the systemd-networkd test suite without having
# to worry about the network staying up
Expand Down
38 changes: 8 additions & 30 deletions vagrant/test_scripts/test-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ swapoff -av
pushd /build || { echo >&2 "Can't pushd to /build"; exit 1; }

# Run the internal unit tests (make check)
exectask "ninja-test" "meson test -C $BUILD_DIR --print-errorlogs --timeout-multiplier=3"
[[ -d "$BUILD_DIR/meson-logs" ]] && rsync -amq --include '*.txt' --include '*/' --exclude '*' "$BUILD_DIR/meson-logs" "$LOGDIR"

## Integration test suite ##
# Prepare a custom-tailored initrd image (with the systemd module included).
Expand Down Expand Up @@ -72,8 +70,6 @@ SKIP_LIST=(
# runtime without requiring too much resources, hence it can run in parallel
# with the "standard" integration tests, saving ~30 minutes ATTOW
TEST_LIST=(
"test/test-exec-deserialization.py"
"test/test-network/systemd-networkd-tests.py"
)

# Prepare environment for the systemd-networkd testsuite
Expand All @@ -84,6 +80,7 @@ for t in "${TEST_LIST[@]}"; do
exectask_p "${t##*/}" "/bin/time -v -- timeout -k 60s 60m ./$t"
done


# Shared test env variables
#
# Set timeouts for QEMU and nspawn tests to kill them in case they get stuck
Expand All @@ -92,7 +89,11 @@ export NSPAWN_TIMEOUT=900
# Enforce nested KVM
export TEST_NESTED_KVM=1

for t in test/TEST-??-*; do
sed -i '/softlockup/d' test/test-functions
export QEMU_TIMEOUT=240

for ((i = 0; ; i++)); do
t="test/TEST-71-HOSTNAME"
if [[ ${#SKIP_LIST[@]} -ne 0 ]] && in_set "$t" "${SKIP_LIST[@]}"; then
echo -e "[SKIP] Skipping test $t\n"
continue
Expand All @@ -101,7 +102,6 @@ for t in test/TEST-??-*; do
## Configure test environment
# Tell the test framework to copy the base image for each test, so we
# can run them in parallel
export TEST_PARALLELIZE=1
# Set the test dir to something predictable so we can refer to it later
export TESTDIR="/var/tmp/systemd-test-${t##*/}"
# Set QEMU_SMP appropriately (regarding the parallelism)
Expand All @@ -115,33 +115,11 @@ for t in test/TEST-??-*; do
mkdir -p "$TESTDIR"
rm -f "$TESTDIR/pass"

exectask_p "${t##*/}" "/bin/time -v -- make -C $t setup run && touch $TESTDIR/pass"
if ! exectask "${t##*/}" "/bin/time -v -- make -C $t clean setup run && touch $TESTDIR/pass"; then break; fi
EXECUTED_LIST+=("$t")
done

# Wait for remaining running tasks
exectask_p_finish

for t in "${FLAKE_LIST[@]}"; do
## Configure test environment
# Set the test dir to something predictable so we can refer to it later
export TESTDIR="/var/tmp/systemd-test-${t##*/}"
# Set QEMU_SMP appropriately (regarding the parallelism)
# OPTIMAL_QEMU_SMP is part of the common/task-control.sh file
export QEMU_SMP=$(nproc)

# Suffix the $TESTDIR of each retry with an index to tell them apart
export MANGLE_TESTDIR=1
exectask_retry "${t##*/}" "/bin/time -v -- make -C $t setup run && touch \$TESTDIR/pass"

# Retried tasks are suffixed with an index, so update the $EXECUTED_LIST
# array accordingly to correctly find the respective journals
for ((i = 1; i <= TASK_RETRY_DEFAULT; i++)); do
[[ -d "/var/tmp/systemd-test-${t##*/}_${i}" ]] && EXECUTED_LIST+=("${t}_${i}")
done
done

# Save journals created by integration tests
# Wait for remaining running task# Save journals created by integration tests
for t in "${EXECUTED_LIST[@]}"; do
testdir="/var/tmp/systemd-test-${t##*/}"
if [[ -f "$testdir/system.journal" ]]; then
Expand Down

0 comments on commit 099ea42

Please sign in to comment.