Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
mrc0mmand committed Nov 2, 2023
1 parent c87000d commit 065eebb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 113 deletions.
79 changes: 15 additions & 64 deletions vagrant/boxes/archlinux_systemd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ whoami
stat /dev/tpm0
[[ "$(</sys/class/tpm/tpm0/tpm_version_major)" == 2 ]]

cat >/etc/pacman.conf <<EOF
[options]
Architecture = auto
[core-testing]
Include = /etc/pacman.d/mirrorlist
[extra-testing]
Include = /etc/pacman.d/mirrorlist
[core]
Include = /etc/pacman.d/mirrorlist
[extra]
Include = /etc/pacman.d/mirrorlist
EOF

# Clear Pacman's caches
pacman --noconfirm -Scc
rm -fv /var/lib/pacman/sync/*.db
Expand All @@ -16,7 +29,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 @@ -31,7 +44,7 @@ pacman --needed --noconfirm -S coreutils bind busybox cpio dhclient dhcp dhcpcd
evemu expect fsverity-utils gdb inetutils jq knot keyutils lcov libdwarf libelf mdadm mtools net-tools nfs-utils nftables ntp \
nvme-cli 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
wireguard-tools qemu-base

# Unlock root account and set its password to 'vagrant' to allow root login
# via ssh
Expand Down Expand Up @@ -106,68 +119,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
76 changes: 27 additions & 49 deletions vagrant/test_scripts/test-arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,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"

# Ignore any coredumps generated by unit tests, as there's a lot of intentional crashes
coredumpctl_set_ts
Expand Down Expand Up @@ -78,8 +76,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 @@ -90,6 +86,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 @@ -98,56 +95,37 @@ export NSPAWN_TIMEOUT=900
# Enforce nested KVM
export TEST_NESTED_KVM=1

for t in test/TEST-??-*; do
if [[ ${#SKIP_LIST[@]} -ne 0 ]] && in_set "$t" "${SKIP_LIST[@]}"; then
echo -e "[SKIP] Skipping test $t\n"
continue
fi
sed -i '/panic=1/a\ "softlockup_panic=1"' test/test-functions
export QEMU_TIMEOUT=240

## 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)
# OPTIMAL_QEMU_SMP is part of the common/task-control.sh file
export QEMU_SMP=$OPTIMAL_QEMU_SMP
# Use a "unique" name for each nspawn container to prevent scope clash
export NSPAWN_ARGUMENTS="--machine=${t##*/}"

# Skipped test don't create the $TESTDIR automatically, so do it explicitly
# otherwise the `touch` command would fail
mkdir -p "$TESTDIR"
rm -f "$TESTDIR/pass"

exectask_p "${t##*/}" "/bin/time -v -- make -C $t setup run && touch $TESTDIR/pass"
EXECUTED_LIST+=("$t")
done
for ((i = 0; ; i++)); do
for t in test/TEST-71-HOSTNAME test/TEST-64-UDEV-STORAGE; do
if [[ ${#SKIP_LIST[@]} -ne 0 ]] && in_set "$t" "${SKIP_LIST[@]}"; then
echo -e "[SKIP] Skipping test $t\n"
continue
fi

# 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}")
## Configure test environment
# Tell the test framework to copy the base image for each test, so we
# can run them in parallel
# 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=$OPTIMAL_QEMU_SMP
# Use a "unique" name for each nspawn container to prevent scope clash
export NSPAWN_ARGUMENTS="--machine=${t##*/}"

# Skipped test don't create the $TESTDIR automatically, so do it explicitly
# otherwise the `touch` command would fail
mkdir -p "$TESTDIR"
rm -f "$TESTDIR/pass"

if ! exectask "${t##*/}" "/bin/time -v -- make -C $t clean setup run && touch $TESTDIR/pass"; then break 2; fi
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 065eebb

Please sign in to comment.