Skip to content

Commit

Permalink
tests: Add a roundtrip test
Browse files Browse the repository at this point in the history
This exercises edge cases in the dumpfile.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed May 28, 2024
1 parent 622dde9 commit 27b274b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/test-units.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ function countobjects () {
find $dir/objects -type f | wc -l
}

# Test a full cycle of roundtrips through mkcomposefs --from-file, composefs-info dump, etc.
function test_dump_roundtrip () {
testsrcdir=$(cd $(dirname $0) && pwd)
pushd $1
local src=$testsrcdir/assets/special.dump
$BINDIR/mkcomposefs --from-file "${src}" out.cfs
$BINDIR/composefs-info dump out.cfs > dump.txt
diff -u "${src}" dump.txt
$BINDIR/mkcomposefs --from-file dump.txt out2.cfs
diff -u out.cfs out2.cfs
echo "ok dump roundtrip"
popd
}


# Ensure small files are inlined
function test_inline () {
local dir=$1
Expand Down Expand Up @@ -86,7 +101,7 @@ function test_composefs_info_measure_files () {
cd -
}

TESTS="test_inline test_objects test_mount_digest test_composefs_info_measure_files"
TESTS="test_dump_roundtrip test_inline test_objects test_mount_digest test_composefs_info_measure_files"
res=0
for i in $TESTS; do
testdir=$(mktemp -d $workdir/$i.XXXXXX)
Expand Down

0 comments on commit 27b274b

Please sign in to comment.