Skip to content

Commit

Permalink
tests: change tests to not require a priveliged container
Browse files Browse the repository at this point in the history
  • Loading branch information
Meulengracht committed Aug 28, 2024
1 parent 94b1c95 commit ce546ec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
3 changes: 1 addition & 2 deletions spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ 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 --cap-add SYS_ADMIN --security-opt apparmor=unconfined \
--rm -e DEBIAN_FRONTEND=noninteractice \
docker run --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
25 changes: 14 additions & 11 deletions tests/spread/integration/mount/test.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/bin/bash

# Run a smoke test for mount and umount to verify that
# they are doing what we expect by testing on /proc
# simple smoke test that it loads
mount --help

cat > /etc/fstab <<EOF
# test on a chrooted env, but let us make sure it exists
EOF

# Do not do the actually mounting syscall as that will
# be blocked inside the docker container. We do dry-runs
# instead to ensure that the rest of the binary looks ok
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
mount --fake --bind /bin /test-bin

# we cannot test the 'mount -l' without mounting /proc
# as it is a symlink from /etc/mtab to ../proc/self/mounts
6 changes: 0 additions & 6 deletions tests/spread/integration/systemd/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@ execute: |
# 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

0 comments on commit ce546ec

Please sign in to comment.