3 ###############################################################################
7 # This file has been put into the public domain.
8 # You can do whatever you want with this file.
10 ###############################################################################
12 # If xz wasn't built, this test is skipped.
13 if test -x ..
/src
/xz
/xz
; then
19 # If compression or decompression support is missing, this test is skipped.
20 # This isn't perfect as if only some compressors or decompressors are disabled
21 # then this script can still fail because for now this doesn't check the
22 # availability of each filter.
23 if grep 'define HAVE_ENCODERS' ..
/config.h
> /dev
/null \
24 && grep 'define HAVE_DECODERS' ..
/config.h
> /dev
/null
; then
27 echo "Compression or decompression support is disabled, skipping this test."
31 # Find out if our shell supports functions.
32 eval 'unset foo ; foo() { return 42; } ; foo'
33 if test $?
!= 42 ; then
34 echo "/bin/sh doesn't support functions, skipping this test."
39 if $XZ -c "$@" "$FILE" > "$TMP_COMP"; then
42 echo "Compressing failed: $* $FILE"
46 if $XZ -cd "$TMP_COMP" > "$TMP_UNCOMP" ; then
49 echo "Decompressing failed: $* $FILE"
53 if cmp "$TMP_UNCOMP" "$FILE" ; then
56 echo "Decompressed file does not match" \
57 "the original: $* $FILE"
61 if test -n "$XZDEC" ; then
62 if $XZDEC "$TMP_COMP" > "$TMP_UNCOMP" ; then
65 echo "Decompressing failed: $* $FILE"
69 if cmp "$TMP_UNCOMP" "$FILE" ; then
72 echo "Decompressed file does not match" \
73 "the original: $* $FILE"
79 XZ
="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
80 --no-adjust --threads=1 --check=crc32"
81 grep "define HAVE_CHECK_CRC64" ..
/config.h
> /dev
/null \
82 && XZ
="$XZ --check=crc64"
83 XZDEC
="../src/xzdec/xzdec" # No memory usage limiter available
84 test -x ..
/src
/xzdec
/xzdec || XZDEC
=
86 # Create the required input file if needed.
88 # Derive temporary filenames for compressed and uncompressed outputs
89 # from the input filename. This is needed when multiple tests are
92 TMP_COMP
="tmp_comp_$FILE"
93 TMP_UNCOMP
="tmp_uncomp_$FILE"
96 # compress_generated files will be created in the build directory
97 # in the /tests/ sub-directory.
99 if .
/create_compress_files
"$FILE" ; then
103 echo "Failed to create the file '$FILE'."
107 # compress_prepared files exist in the source directory since they
108 # do not need to be copied or regenerated.
113 echo "No test file was specified."
118 # Remove temporary now (in case they are something weird), and on exit.
119 rm -f "$TMP_COMP" "$TMP_UNCOMP"
120 trap 'rm -f "$TMP_COMP" "$TMP_UNCOMP"' 0
122 # Compress and decompress the file with various filter configurations.
124 # Don't test with empty arguments; it breaks some ancient
125 # proprietary /bin/sh versions due to $@ used in test_xz().
133 grep "define HAVE_ENCODER_$1" ..
/config.h
> /dev
/null ||
return
134 grep "define HAVE_DECODER_$1" ..
/config.h
> /dev
/null ||
return
136 test_xz
"$@" --lzma2=dict
=64KiB
,nice
=32,mode
=fast
139 test_filter DELTA
--delta=dist
=1
140 test_filter DELTA
--delta=dist
=4
141 test_filter DELTA
--delta=dist
=256
142 test_filter X86
--x86
143 test_filter POWERPC
--power
144 test_filter IA64
--ia64
145 test_filter ARM
--arm
146 test_filter ARMTHUMB
--armthumb
147 test_filter SPARC
--sparc