mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
test: Add tar + bzip2 testsuite
Generate a pseudorandom tree of files, run tar cjf on it to create referenced tarball, then run the same again on the background, wait for a while, then checkpoint and restore it and compare that two tarballs do not differ. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
794d3fba40
commit
f379e2ccf5
70
test/app-emu/tarbz/run.sh
Normal file
70
test/app-emu/tarbz/run.sh
Normal file
@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
crtools="../../../crtools"
|
||||
DEPTH=3
|
||||
SPAN=5
|
||||
archref="arch-ref.tar.bz2"
|
||||
archcr="arch.tar.bz2"
|
||||
|
||||
rm -f ${archref}
|
||||
rm -f ${archcr}
|
||||
rm -rf tree/
|
||||
rm -rf dump/
|
||||
mkdir dump
|
||||
mkdir tree
|
||||
|
||||
echo "Generating tree, depth ${DEPTH} span ${SPAN}"
|
||||
|
||||
function gen_sub {
|
||||
local dir="${1}"
|
||||
local dep="${2}"
|
||||
|
||||
for i in $(seq 1 $SPAN); do
|
||||
subdir="$dir/dir_$((RANDOM % 32))_$i"
|
||||
subfl="$dir/file_$((RANDOM % 32))_$i"
|
||||
|
||||
mkdir "$subdir"
|
||||
dd if=/dev/urandom of=$subfl bs=4096 count=$((RANDOM % 32 + 16)) > /dev/null 2>&1
|
||||
|
||||
if [ $dep -gt 0 ]; then
|
||||
gen_sub "$subdir" $((dep - 1))
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
gen_sub "./tree/" "$DEPTH"
|
||||
|
||||
set -x
|
||||
|
||||
time tar cjf ${archref} tree || exit 1
|
||||
|
||||
setsid tar cjf ${archcr} tree &
|
||||
|
||||
pid=${!}
|
||||
|
||||
echo "Started tar in $pid background"
|
||||
sleep 3
|
||||
|
||||
${crtools} dump -D dump -o dump.log -v 4 -t ${pid} || {
|
||||
echo "Dump failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Dump OK, restoring"
|
||||
|
||||
${crtools} restore -D dump -o restore.log -v 4 -t ${pid} || {
|
||||
echo "Restore failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Finished, comparing tarballs"
|
||||
|
||||
if ! cmp ${archref} ${archcr} ; then
|
||||
echo "Archives differ"
|
||||
echo "FAIL"
|
||||
else
|
||||
echo "PASS"
|
||||
rm -f ${archref}
|
||||
rm -f ${archcr}
|
||||
rm -rf tree/
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user