Polished hardlink test

This commit is contained in:
Thomas Schmitt 2011-06-27 12:33:25 +00:00
parent d08e1f8aae
commit 2124820d4e

View File

@ -2,7 +2,9 @@
# ts 2011.06.27 # ts 2011.06.27
# Test the correct handling of hardlinks by xorriso options # Test the correct handling of hardlinks by xorriso options
# -update_r and -hardlinks perform_update # -update_r , -hardlinks perform_update , and -extract
export prog=$(basename "$0")
export xorriso=xorriso export xorriso=xorriso
export image_file=/tmp/xorriso_hardlinks.iso export image_file=/tmp/xorriso_hardlinks.iso
@ -12,14 +14,15 @@ export copy_on_disk=/tmp/xorriso_hardlinks_copy_dir
export keep=0 export keep=0
export failure=0 export failure=0
export next_is_xorriso=0 export next_is_xorriso=0
export bad=0
clean_up() { clean_up() {
if test "$keep" = 1 if test "$keep" = 1
then then
dummy=dummy echo "=== Kept test area because of option -keep" >&2
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" >&2
else else
echo "=== Removing test area" >&2
rm -r "$on_disk" "$copy_on_disk" "$image_file" rm -r "$on_disk" "$copy_on_disk" "$image_file"
fi fi
} }
@ -57,24 +60,28 @@ done
if test -e "$image_file" if test -e "$image_file"
then then
echo "TEST ENVIRONMENT ERROR: $0 : Existing image_file target:" >&2 echo "TEST ENVIRONMENT ERROR: $prog : Existing image_file target:" >&2
ls -ld "$image_file" >&2 ls -ld "$image_file" >&2
exit 1 bad=1
fi fi
if test -e "$on_disk" if test -e "$on_disk"
then then
echo "TEST ENVIRONMENT ERROR: $0 : Existing $on_disk target:" >&2 echo "TEST ENVIRONMENT ERROR: $prog : Existing on_disk target:" >&2
ls -ld "$on_disk" >&2 ls -ld "$on_disk" >&2
exit 1 bad=1
fi fi
if test -e "$copy_on_disk" if test -e "$copy_on_disk"
then then
echo "TEST ENVIRONMENT ERROR: $0 : Existing copy_on_disk target:" >&2 echo "TEST ENVIRONMENT ERROR: $prog : Existing copy_on_disk target:" >&2
ls -ld "$copy_on_disk" >&2 ls -ld "$copy_on_disk" >&2
bad=1
fi
if test "$bad" = 1
then
exit 1 exit 1
fi fi
# Set up $on_disk with several hardlinks echo "=== Setting up $on_disk with several hardlinks" >&2
mkdir "$on_disk" || exit 1 mkdir "$on_disk" || exit 1
echo test_content >"$on_disk"/file_1 || exit 1 echo test_content >"$on_disk"/file_1 || exit 1
echo test_content >"$on_disk"/file_2 || exit 1 echo test_content >"$on_disk"/file_2 || exit 1
@ -84,14 +91,14 @@ ln "$on_disk"/file_2 "$on_disk"/file_2_link_a || exit 1
ls -l "$on_disk"/* ls -l "$on_disk"/*
# Produce simple image echo "=== Producing simple image" >&2
"$xorriso" \ "$xorriso" \
-for_backup \ -for_backup \
-outdev "$image_file" \ -outdev "$image_file" \
-update_r "$on_disk" "$in_iso" \ -update_r "$on_disk" "$in_iso" \
-hardlinks perform_update -hardlinks perform_update
# Copy from image to temporary disk tree echo "=== Copying from image to temporary disk tree" >&2
"$xorriso" \ "$xorriso" \
-for_backup \ -for_backup \
-indev "$image_file" \ -indev "$image_file" \
@ -99,21 +106,27 @@ ls -l "$on_disk"/*
-find "$in_iso" -exec lsdl -- \ -find "$in_iso" -exec lsdl -- \
-extract "$in_iso" "$copy_on_disk" -extract "$in_iso" "$copy_on_disk"
# Compare original disk tree and temporary one
## For testing the test: Let it fail deliberately
## rm "$copy_on_disk"/file_1_link_b
echo "=== Comparing original disk tree and temporary one" >&2
diff -r "$on_disk" "$copy_on_disk" diff -r "$on_disk" "$copy_on_disk"
if test "$?" -ne 0 if test "$?" -ne 0
then then
echo "WRONG: diff -r $on_disk $copy_on_disk reports differences" >&2
failure=1 failure=1
else
echo "=== OK" >&2
fi fi
echo "=== Checking for hardlinks being siblings" >&2
# Check for hardlinks being siblings
ls -l "$copy_on_disk"/* ls -l "$copy_on_disk"/*
x=$(echo $(ls -l "$copy_on_disk"/* | awk '{print $2}')) x=$(echo $(ls -l "$copy_on_disk"/* | awk '{print $2}'))
expected="3 3 3 2 2" expected="3 3 3 2 2"
if test x"$x" = x"$expected" if test x"$x" = x"$expected"
then then
dummy=dummy echo "=== OK" >&2
else else
echo "WRONG: Link count of extracted files is not as expected." >&2 echo "WRONG: Link count of extracted files is not as expected." >&2
echo "Expected: $expected" >&2 echo "Expected: $expected" >&2
@ -127,12 +140,11 @@ clean_up
# Report result # Report result
echo echo
echo "======== $(basename "$0") ========"
if test "$failure" = 1 if test "$failure" = 1
then then
echo 'FAILURE !!!' echo "======== $prog :" 'FAILURE !!!'
else else
echo "Success." echo "======== $prog :" "Success."
fi fi
echo echo