From b64a87e0b31dde1f81995e36630a20de40eafbd8 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Wed, 20 Sep 2023 14:46:14 +0200 Subject: [PATCH] tests: Add a new gendir based integration tests We previously only made an image of the host /usr/bin and verified it. This also adds a new image based on the gendir helper that generates a random image, which uses more file types. Signed-off-by: Alexander Larsson --- tests/integration.sh | 57 +++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/tests/integration.sh b/tests/integration.sh index 6d1dfa83..2e01cade 100755 --- a/tests/integration.sh +++ b/tests/integration.sh @@ -10,30 +10,39 @@ rm ${cfsroot}/tmp -rf mkdir -p ${cfsroot}/{objects,roots,tmp} cd ${cfsroot}/tmp -testsrc=/usr/bin -mkcomposefs --print-digest --digest-store=${cfsroot}/objects ${testsrc} ${cfsroot}/roots/test.cfs | tee digest.txt -prev_digest=$(cat digest.txt) -new_digest=$(mkcomposefs --by-digest --print-digest-only ${testsrc}) -test "$prev_digest" = "$new_digest" - -if which fsck.erofs &>/dev/null; then - fsck.erofs ${cfsroot}/roots/test.cfs -fi - -mkdir -p mnt -mount.composefs -o basedir=${cfsroot}/objects ${cfsroot}/roots/test.cfs mnt -$orig/tests/dumpdir --no-nlink ${testsrc} > src-dump.txt -$orig/tests/dumpdir --no-nlink mnt > mnt-dump.txt -failed= -if ! diff -u src-dump.txt mnt-dump.txt; then - failed=1 -fi -if test -n "${failed}"; then + +run_test() { + local testsrc=$1 + local dumpdir_args="$2" + mkcomposefs --print-digest --digest-store=${cfsroot}/objects ${testsrc} ${cfsroot}/roots/test.cfs | tee digest.txt + prev_digest=$(cat digest.txt) + new_digest=$(mkcomposefs --by-digest --print-digest-only ${testsrc}) + test "$prev_digest" = "$new_digest" + + if which fsck.erofs &>/dev/null; then + fsck.erofs ${cfsroot}/roots/test.cfs + fi + + mkdir -p mnt + mount.composefs -o basedir=${cfsroot}/objects ${cfsroot}/roots/test.cfs mnt + $orig/tests/dumpdir $dumpdir_args ${testsrc} > src-dump.txt + $orig/tests/dumpdir $dumpdir_args mnt > mnt-dump.txt + failed= + if ! diff -u src-dump.txt mnt-dump.txt; then + failed=1 + fi + if test -n "${failed}"; then + umount mnt + exit 1 + fi + + new_digest=$(mkcomposefs --by-digest --print-digest-only mnt) + test "$prev_digest" = "$new_digest" + umount mnt - exit 1 -fi +} -new_digest=$(mkcomposefs --by-digest --print-digest-only mnt) -test "$prev_digest" = "$new_digest" +run_test /usr/bin "--no-nlink" -umount mnt +$orig/tests/gendir --privileged ${cfsroot}/tmp/rootfs +run_test ${cfsroot}/tmp/rootfs "--noescaped"