Skip to content

Commit

Permalink
tests/spread/integration: add tests for systemd and mount
Browse files Browse the repository at this point in the history
  • Loading branch information
Meulengracht committed Aug 1, 2024
1 parent 206e3ca commit 8081645
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ backends:
echo "Allocating $SPREAD_SYSTEM..."
docker_image=$(echo $SPREAD_SYSTEM | awk -F '-' '{print $1":"$2}')
docker_arch=$(echo $SPREAD_SYSTEM | awk -F '-' '{print $NF}')
docker run --rm -e DEBIAN_FRONTEND=noninteractice \
docker run --cap-add SYS_ADMIN --security-opt apparmor=unconfined \
--rm -e DEBIAN_FRONTEND=noninteractice \
-e usr=$SPREAD_SYSTEM_USERNAME -e pass=$SPREAD_SYSTEM_PASSWORD \
--name $SPREAD_SYSTEM -d $docker_arch/$docker_image sh -c '
set -x
Expand Down
9 changes: 9 additions & 0 deletions tests/spread/integration/mount/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
summary: Integration tests for mount

execute: |
# Chisel a minimum number of slices to give us a runnable system that we can
# test in.
rootfs="$(install-slices bash_bins coreutils_bins passwd_config base-files_base mount_bins)"
cp test.sh "${rootfs}/"
chroot "${rootfs}/" /test.sh
14 changes: 14 additions & 0 deletions tests/spread/integration/mount/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# Run a smoke test for mount and umount to verify that
# they are doing what we expect by testing on /proc
mkdir /test-bin
mount --bind /bin /test-bin
count=$(ls /test-bin | wc -l)
umount /test-bin

if [ $count -eq 0 ]
then
echo "no files in /test-bin, did mount not work?"
exit 1
fi
15 changes: 15 additions & 0 deletions tests/spread/integration/systemd/task.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
summary: Integration tests for systemd

execute: |
# Chisel a minimum number of slices to give us a runnable system that we can
# test in.
rootfs="$(install-slices bash_bins coreutils_bins passwd_config base-files_base systemd_bins)"
# systemd needs proc mounted
mkdir "${rootfs}"/proc
mount --bind /proc "${rootfs}"/proc
cp test.sh "${rootfs}/"
chroot "${rootfs}/" /test.sh
umount "${rootfs}"/proc
18 changes: 18 additions & 0 deletions tests/spread/integration/systemd/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Run some smoke-tests by invoking a couple of commands
# from systemd to verify it's doing exactly what we expect
# it to
systemctl disable [email protected]
! test -f "/etc/systemd/system/getty.target.wants/[email protected]"

systemctl enable [email protected]
test -f "/etc/systemd/system/getty.target.wants/[email protected]"

# run preset-all and test for one of the expected symlinks
systemctl preset-all
test -f "/etc/systemd/system/ctrl-alt-del.target"

# Run some auxiliary commands to ensure they don't fail
systemd --help
journalctl --update-catalog

0 comments on commit 8081645

Please sign in to comment.