Adapted test_hardlinks to newly defined general test rules

This commit is contained in:
Thomas Schmitt 2011-06-28 06:43:15 +00:00
parent 08adecf09e
commit 1b30add044

View File

@ -7,10 +7,11 @@
export prog=$(basename "$0")
export xorriso=xorriso
export image_file=/tmp/xorriso_hardlinks.iso
export on_disk=/tmp/xorriso_hardlinks_test_dir
export workdir=./tmp/"$prog".result
export image_file="$workdir"/xorriso_hardlinks.iso
export on_disk="$workdir"/xorriso_hardlinks_test_dir
export in_iso=""
export copy_on_disk=/tmp/xorriso_hardlinks_copy_dir
export copy_on_disk="$workdir"/xorriso_hardlinks_copy_dir
export keep=0
export failure=0
export next_is_xorriso=0
@ -51,16 +52,18 @@ clean_up() {
if test "$keep" = 1
then
echo "=== Kept test area because of option -keep" >&2
echo "$on_disk" "$copy_on_disk" "$image_file" >&2
echo "$on_disk" "$copy_on_disk" "$image_file" "$workdir" >&2
else
echo "=== Removing test area" >&2
rm -r "$on_disk" "$copy_on_disk" "$image_file"
rm -r "$workdir"
fi
}
# Setup
# Interpret a default configuration file here, if the test has one.
# This one has none.
@ -111,7 +114,20 @@ done
test -z "$in_iso" && in_iso="$on_disk"
if test -d ./tmp
then
dummy=dummy
else
echo "=== TEST ENVIRONMENT ERROR: $prog : No ./tmp directory existing" >&2
echo "FAIL : $prog : Test environment error : No ./tmp directory"
exit 3
fi
if test -e "$workdir"
then
echo "=== TEST ENVIRONMENT ERROR: $prog : Existing work directory:" >&2
ls -ld "$workdir" >&2
bad=1
fi
if test -e "$image_file"
then
echo "=== TEST ENVIRONMENT ERROR: $prog : Existing image_file target:" >&2
@ -132,11 +148,21 @@ then
fi
if test "$bad" = 1
then
echo "FAIL : $prog : Test environment error : Existing work files"
exit 3
fi
bad=0
mkdir "$workdir" || bad=1
mkdir "$on_disk" || bad=1
if test "$bad" = 1
then
echo "FAIL : $prog : Test environment error : Cannot make directories"
exit 3
fi
echo "=== Setting up $on_disk with several hardlinks" >&2
mkdir "$on_disk" || exit 1
echo test_content >"$on_disk"/file_1 || exit 1
echo test_content >"$on_disk"/file_2 || exit 1
ln "$on_disk"/file_1 "$on_disk"/file_1_link_a || exit 1
@ -166,7 +192,7 @@ echo "=== Copying from image to temporary disk tree" >&2
## For testing the test: Let it fail deliberately
## rm "$copy_on_disk"/file_1_link_b
# rm "$copy_on_disk"/file_1_link_b
echo "=== Comparing original disk tree and temporary one" >&2
@ -174,6 +200,7 @@ diff -r "$on_disk" "$copy_on_disk"
if test "$?" -ne 0
then
echo "=== WRONG: diff -r $on_disk $copy_on_disk reports differences" >&2
echo "FAIL : $prog : diff -r reports differences"
failure=1
else
echo "=== OK" >&2
@ -190,6 +217,7 @@ else
echo "=== WRONG: Link count of extracted files is not as expected." >&2
echo "=== Expected: $expected" >&2
echo "=== Got : $x" >&2
echo "FAIL : $prog : Link count of extracted files is not as expected."
failure=1
fi
@ -202,7 +230,6 @@ echo
if test "$failure" = 1
then
echo "======== $prog :" 'FAILED'
echo FAIL
exit 1
else
echo "======== $prog :" "Passed"