Polished hardlink test
This commit is contained in:
parent
a1917d0014
commit
88378b25af
@ -9,13 +9,44 @@ export prog=$(basename "$0")
|
|||||||
export xorriso=xorriso
|
export xorriso=xorriso
|
||||||
export image_file=/tmp/xorriso_hardlinks.iso
|
export image_file=/tmp/xorriso_hardlinks.iso
|
||||||
export on_disk=/tmp/xorriso_hardlinks_test_dir
|
export on_disk=/tmp/xorriso_hardlinks_test_dir
|
||||||
export in_iso="$on_disk"
|
export in_iso=""
|
||||||
export copy_on_disk=/tmp/xorriso_hardlinks_copy_dir
|
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 next_is_rc=0
|
||||||
export bad=0
|
export bad=0
|
||||||
|
|
||||||
|
|
||||||
|
config_by_var() {
|
||||||
|
# This is called once before option interpretation, and once for each
|
||||||
|
# option -rc.
|
||||||
|
# Variables get set to empty content to keep them from being applied
|
||||||
|
# more than once and thus overriding settings of higher precedence.
|
||||||
|
|
||||||
|
# >>> The short names are not good.
|
||||||
|
# >>> Environment variables should have a common prefix. Like RELENG_
|
||||||
|
# >>> In general, the names should be a bit more expressive.
|
||||||
|
# >>> Like RELENG_XORRISO
|
||||||
|
|
||||||
|
test -n "$XOR" && xorriso="$XOR" && XOR=
|
||||||
|
test -n "$RELENG_XORRISO" && xorriso="$RELENG_XORRISO" && RELENG_XORRISO=
|
||||||
|
|
||||||
|
test -n "$IMG" && image_file="$IMG" && IMG=
|
||||||
|
test -n "$RELENG_TMPIMAGE" && image_file="$RELENG_TMPIMAGE" \
|
||||||
|
&& RELENG_TMPIMAGE=
|
||||||
|
|
||||||
|
# This is not $DIR, which would exist before and after the test,
|
||||||
|
# but a temporary directory which may not exist before.
|
||||||
|
test -n "$RELENG_TMPDIR" && on_disk="$RELENG_TMPDIR" && RELENG_TMPDIR=
|
||||||
|
|
||||||
|
test -n "$RELENG_ISODIR" && in_iso="$RELENG_ISODIR" && RELENG_ISODIR=
|
||||||
|
|
||||||
|
test -n "$RELENG_TMPCOPYDIR" && copy_on_disk="$RELENG_TMPCOPYDIR" \
|
||||||
|
&& RELENG_TMPCOPYDIR=
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
clean_up() {
|
clean_up() {
|
||||||
if test "$keep" = 1
|
if test "$keep" = 1
|
||||||
then
|
then
|
||||||
@ -27,20 +58,37 @@ clean_up() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
skip=0
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
# Interpret a default configuration file here, if the test has one.
|
||||||
|
# This one has none.
|
||||||
|
|
||||||
|
# >>> Best would be if the configuration file would not override env variables.
|
||||||
|
|
||||||
|
# Process env variables and default configfile variables together
|
||||||
|
config_by_var
|
||||||
|
|
||||||
|
|
||||||
|
# Now interpret program arguments and possibly given config files
|
||||||
for i in "$@"
|
for i in "$@"
|
||||||
do
|
do
|
||||||
if test "$next_is_xorriso" = 1
|
if test "$next_is_xorriso" = 1
|
||||||
then
|
then
|
||||||
xorriso="$i"
|
xorriso="$i"
|
||||||
next_is_xorriso=0
|
next_is_xorriso=0
|
||||||
elif test "$skip" -gt 0
|
elif test "$next_is_rc" = 1
|
||||||
then
|
then
|
||||||
skip=$(expr $skip - 1)
|
|
||||||
|
# >>> This looks darn dangerous. We need a trustworthy config interpreter.
|
||||||
|
# >>> http://www.netjeff.com/humor/item.cgi?file=ShootInFoot-OS
|
||||||
|
. "$i"
|
||||||
|
|
||||||
|
config_by_var
|
||||||
|
next_is_rc=0
|
||||||
elif test x"$i" = x"-rc"
|
elif test x"$i" = x"-rc"
|
||||||
then
|
then
|
||||||
# No configuration yet
|
next_is_rc=1
|
||||||
skip=1
|
|
||||||
elif test x"$i" = x"-keep"
|
elif test x"$i" = x"-keep"
|
||||||
then
|
then
|
||||||
keep=1
|
keep=1
|
||||||
@ -58,21 +106,24 @@ do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
test -z "$in_iso" && in_iso="$on_disk"
|
||||||
|
|
||||||
|
|
||||||
if test -e "$image_file"
|
if test -e "$image_file"
|
||||||
then
|
then
|
||||||
echo "TEST ENVIRONMENT ERROR: $prog : 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
|
||||||
bad=1
|
bad=1
|
||||||
fi
|
fi
|
||||||
if test -e "$on_disk"
|
if test -e "$on_disk"
|
||||||
then
|
then
|
||||||
echo "TEST ENVIRONMENT ERROR: $prog : 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
|
||||||
bad=1
|
bad=1
|
||||||
fi
|
fi
|
||||||
if test -e "$copy_on_disk"
|
if test -e "$copy_on_disk"
|
||||||
then
|
then
|
||||||
echo "TEST ENVIRONMENT ERROR: $prog : 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
|
bad=1
|
||||||
fi
|
fi
|
||||||
@ -93,7 +144,9 @@ ls -l "$on_disk"/*
|
|||||||
|
|
||||||
echo "=== Producing simple image" >&2
|
echo "=== Producing simple image" >&2
|
||||||
"$xorriso" \
|
"$xorriso" \
|
||||||
|
-version \
|
||||||
-for_backup \
|
-for_backup \
|
||||||
|
-padding 0 \
|
||||||
-outdev "$image_file" \
|
-outdev "$image_file" \
|
||||||
-update_r "$on_disk" "$in_iso" \
|
-update_r "$on_disk" "$in_iso" \
|
||||||
-hardlinks perform_update
|
-hardlinks perform_update
|
||||||
@ -110,11 +163,12 @@ echo "=== Copying from image to temporary disk tree" >&2
|
|||||||
## For testing the test: Let it fail deliberately
|
## 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
|
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
|
echo "=== WRONG: diff -r $on_disk $copy_on_disk reports differences" >&2
|
||||||
failure=1
|
failure=1
|
||||||
else
|
else
|
||||||
echo "=== OK" >&2
|
echo "=== OK" >&2
|
||||||
@ -128,9 +182,9 @@ if test x"$x" = x"$expected"
|
|||||||
then
|
then
|
||||||
echo "=== OK" >&2
|
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
|
||||||
echo "Got : $x" >&2
|
echo "=== Got : $x" >&2
|
||||||
failure=1
|
failure=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -142,9 +196,9 @@ clean_up
|
|||||||
echo
|
echo
|
||||||
if test "$failure" = 1
|
if test "$failure" = 1
|
||||||
then
|
then
|
||||||
echo "======== $prog :" 'FAILURE !!!'
|
echo "======== $prog :" 'FAILED'
|
||||||
else
|
else
|
||||||
echo "======== $prog :" "Success."
|
echo "======== $prog :" "Passed"
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user