Tests: Add new test for xz -r, --recursive option.
This commit is contained in:
parent
7ca735f2f0
commit
07779fa4e2
|
@ -11,6 +11,7 @@ EXTRA_DIST = \
|
|||
tuktest.h \
|
||||
tests.h \
|
||||
test_files.sh \
|
||||
test_recursive.sh \
|
||||
test_compress.sh \
|
||||
test_compress_prepared_bcj_sparc \
|
||||
test_compress_prepared_bcj_x86 \
|
||||
|
@ -62,6 +63,7 @@ TESTS = \
|
|||
test_lzip_decoder \
|
||||
test_vli \
|
||||
test_files.sh \
|
||||
test_recursive.sh \
|
||||
test_suffix.sh \
|
||||
test_compress_prepared_bcj_sparc \
|
||||
test_compress_prepared_bcj_x86 \
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
#!/bin/sh
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# Author: Jia Tan
|
||||
#
|
||||
# This file has been put into the public domain.
|
||||
# You can do whatever you want with this file.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
# If xz wasn't built, this test is skipped.
|
||||
XZ="../src/xz/xz"
|
||||
if test -x "$XZ" ; then
|
||||
:
|
||||
else
|
||||
echo "xz was not built, skipping this test $XZ"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# If decompression support is missing, this test is skipped.
|
||||
if grep 'define HAVE_DECODERS' ../config.h > /dev/null ; then
|
||||
:
|
||||
else
|
||||
echo "Decompression support is disabled, skipping this test."
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Setup nested directory structure, but first
|
||||
# delete it first if it already exists
|
||||
rm -rf xz_recursive_level_one
|
||||
|
||||
mkdir -p xz_recursive_level_one/level_two/level_three
|
||||
|
||||
FILES="file_one "\
|
||||
"file_two "\
|
||||
"level_two/file_one "\
|
||||
"level_two/file_two "\
|
||||
"level_two/level_three/file_one "\
|
||||
"level_two/level_three/file_two "
|
||||
|
||||
for FILE in $FILES
|
||||
do
|
||||
cp "$srcdir/files/good-0-empty.xz" "xz_recursive_level_one/$FILE.xz"
|
||||
done
|
||||
|
||||
# Decompress with -r, --recursive option
|
||||
if "$XZ" -dr xz_recursive_level_one; then
|
||||
:
|
||||
else
|
||||
echo "Recursive decompression failed: $*"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Verify the files were all decompressed.
|
||||
for FILE in $FILES
|
||||
do
|
||||
if test -e "xz_recursive_level_one/$FILE"; then
|
||||
:
|
||||
else
|
||||
echo "File not decompressed: xz_recursive_level_one/$FILE.xz"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Remove decompressed files to prevent warnings in symlink test.
|
||||
rm "xz_recursive_level_one/$FILE"
|
||||
done
|
||||
|
||||
# Create a symlink to a directory to create a loop in the file system
|
||||
# to test that xz will not have infinite recursion. Creating the symlink
|
||||
# may fail, for instance on MSYS2 where the default behavior is to create
|
||||
# a copy of the target instead of an actual symlink.
|
||||
if ln -s ../ xz_recursive_level_one/level_two/loop_link; then
|
||||
# The symlink should cause a warning and skip that directory.
|
||||
"$XZ" -drf xz_recursive_level_one
|
||||
|
||||
if test $? != 2 ; then
|
||||
echo "Recursive decompression did not give warning with symlink: $*"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Symlink could not be created, skipping this test"
|
||||
exit 77
|
||||
fi
|
||||
|
||||
# Clean up nested directory
|
||||
rm -rf xz_recursive_level_one
|
Loading…
Reference in New Issue