project-machine / puzzlefs

Apache License 2.0
380 stars 18 forks source link

Implement a test framework #70

Open ariel-miculas opened 1 year ago

ariel-miculas commented 1 year ago

Right now, our only tests are unit tests, which are not enough for more complex scenarios, such as creating an environment in which to test fsverity. Copying Serge's test suggestion from https://github.com/anuvu/puzzlefs/pull/67#issuecomment-1429749252:

which lxc-create || exit 0
lxcname=$(basename $(mktemp -u))
lxc-create -t download -n $lxcname -- -d alpine -r edge -a amd64
dir=$(mkdir -d)
mkdir -p $dir/oci $dir/mnt
export dir
export lxcname
lxc-usernsexec -s -- << "EOF"
unshare -m -- << "XXX"
set -e
puzzlefs create $HOME/.local/share/lxc/$lxcname/rootfs $dir/oci rfs
puzzlefs mount $dir/oci rfs $dir/mnt
test -e $dir/mnt/etc
diff -Nrup $HOME/.local/share/lxc/$lxcname/rootfs $dir/mnt
XXX
EOF
ariel-miculas commented 1 year ago

There is support for integration tests in rust ecosystem, we already have one in exe/tests/extract.rs

ariel-miculas commented 1 year ago

Another test that could be added:

#!/bin/bash
FIFO=$(mktemp -u)
mkfifo "$FIFO"
target/debug/puzzlefs mount -i $FIFO -f /tmp/oci-simple first_try /tmp/puzzle&
cat $FIFO ; echo
ls /tmp/puzzle