3 ###############################################################################
7 # This file has been put into the public domain.
8 # You can do whatever you want with this file.
10 ###############################################################################
12 # If both xz and xzdec were not build, skip this test.
14 XZDEC
=..
/src
/xzdec
/xzdec
16 test -x "$XZDEC" || XZDEC
=
17 if test -z "$XZ$XZDEC"; then
18 echo "xz and xzdec were not built, skipping this test."
22 # If decompression support is missing, this test is skipped.
23 # This isn't perfect as if only some decompressors are disabled
24 # then some good files might not decompress and the test fails
25 # for a (kind of) wrong reason.
26 if grep 'define HAVE_DECODERS' ..
/config.h
> /dev
/null
; then
29 echo "Decompression support is disabled, skipping this test."
33 # If a feature was disabled at build time, make it possible to skip
34 # some of the test files. Use exit status 77 if any files were skipped.
38 grep "define HAVE_$1" ..
/config.h
> /dev
/null
&& return 0
39 printf '%s: Skipping because HAVE_%s is not enabled\n' "$2" "$1"
49 # If these integrity check types were disabled at build time,
50 # allow the tests to pass still.
52 grep 'define HAVE_CHECK_CRC64' ..
/config.h
> /dev
/null || NO_WARN
=-qQ
53 grep 'define HAVE_CHECK_SHA256' ..
/config.h
> /dev
/null || NO_WARN
=-qQ
55 for I
in "$srcdir"/files
/good-
*.xz
57 # If features were disabled at build time, keep this still working.
59 */good-1-
*delta-lzma2
*.xz
)
60 have_feature DECODER_DELTA
"$I" ||
continue
64 */good-1-empty-bcj-lzma2.xz
)
65 have_feature DECODER_POWERPC
"$I" ||
continue
69 */good-1-sparc-lzma2.xz
)
70 have_feature DECODER_SPARC
"$I" ||
continue
74 */good-1-x86-lzma2.xz
)
75 have_feature DECODER_X86
"$I" ||
continue
79 */good-1-arm64-lzma2-
*.xz
)
80 have_feature DECODER_ARM64
"$I" ||
continue
84 if test -z "$XZ" ||
"$XZ" $NO_WARN -dc "$I" > /dev
/null
; then
87 echo "Good file failed: $I"
91 if test -z "$XZDEC" ||
"$XZDEC" $NO_WARN "$I" > /dev
/null
; then
94 echo "Good file failed: $I"
99 for I
in "$srcdir"/files
/bad-
*.xz
101 if test -n "$XZ" && "$XZ" -dc "$I" > /dev
/null
2>&1; then
102 echo "Bad file succeeded: $I"
106 # xzdec doesn't warn about unsupported check so skip this if any of
107 # the check types were disabled at built time (NO_WARN isn't empty).
108 if test -n "$XZDEC" && test -z "$NO_WARN" \
109 && "$XZDEC" "$I" > /dev
/null
2>&1; then
110 echo "Bad file succeeded: $I"
115 # Testing for the lzma_index_append() bug in <= 5.2.6 needs "xz -l":
116 I
="$srcdir/files/bad-3-index-uncomp-overflow.xz"
117 if test -n "$XZ" && "$XZ" -l "$I" > /dev
/null
2>&1; then
118 echo "Bad file succeeded with xz -l: $I"
122 for I
in "$srcdir"/files
/unsupported-
*.xz
124 # Test these only with xz as unsupported-check.xz will exit
125 # successfully with xzdec because it doesn't warn about
126 # unsupported check type.
127 if test -n "$XZ" && "$XZ" -dc "$I" > /dev
/null
2>&1; then
128 echo "Unsupported file succeeded: $I"
133 # Test that this passes with --no-warn (-Q).
134 I
="$srcdir/files/unsupported-check.xz"
135 if test -z "$XZ" ||
"$XZ" -dcqQ "$I" > /dev
/null
; then
138 echo "Unsupported file failed with xz -Q: $I"
142 if test -z "$XZDEC" ||
"$XZDEC" -qQ "$I" > /dev
/null
; then
145 echo "Unsupported file failed with xzdec -Q: $I"
154 for I
in "$srcdir"/files
/good-
*.lzma
156 if test -z "$XZ" ||
"$XZ" -dc "$I" > /dev
/null
; then
159 echo "Good file failed: $I"
164 for I
in "$srcdir"/files
/bad-
*.lzma
166 if test -n "$XZ" && "$XZ" -dc "$I" > /dev
/null
2>&1; then
167 echo "Bad file succeeded: $I"
177 if grep 'define HAVE_LZIP_DECODER' ..
/config.h
> /dev
/null
; then
178 for I
in "$srcdir"/files
/good-
*.lz
180 if test -z "$XZ" ||
"$XZ" -dc "$I" > /dev
/null
; then
183 echo "Good file failed: $I"
188 for I
in "$srcdir"/files
/bad-
*.lz
"$srcdir"/files
/unsupported-
*.lz
190 if test -n "$XZ" && "$XZ" -dc "$I" > /dev
/null
2>&1; then
191 echo "Bad file succeeded: $I"