xz: Do not set compression settings with raw format in list mode.
[xz/debian.git] / tests / test_compress.sh
blob62da0f921ad95f01ffc260ef3313a019167d3464
1 #!/bin/sh
3 ###############################################################################
5 # Author: Lasse Collin
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
15 else
16 (exit 77)
17 exit 77
20 # Find out if our shell supports functions.
21 eval 'unset foo ; foo() { return 42; } ; foo'
22 if test $? != 42 ; then
23 echo "/bin/sh doesn't support functions, skipping this test."
24 (exit 77)
25 exit 77
28 test_xz() {
29 if $XZ -c "$@" "$FILE" > tmp_compressed; then
31 else
32 echo "Compressing failed: $* $FILE"
33 (exit 1)
34 exit 1
37 if $XZ -cd tmp_compressed > tmp_uncompressed ; then
39 else
40 echo "Decompressing failed: $* $FILE"
41 (exit 1)
42 exit 1
45 if cmp tmp_uncompressed "$FILE" ; then
47 else
48 echo "Decompressed file does not match" \
49 "the original: $* $FILE"
50 (exit 1)
51 exit 1
54 if test -n "$XZDEC" ; then
55 if $XZDEC tmp_compressed > tmp_uncompressed ; then
57 else
58 echo "Decompressing failed: $* $FILE"
59 (exit 1)
60 exit 1
63 if cmp tmp_uncompressed "$FILE" ; then
65 else
66 echo "Decompressed file does not match" \
67 "the original: $* $FILE"
68 (exit 1)
69 exit 1
73 # Show progress:
74 echo . | tr -d '\n\r'
77 XZ="../src/xz/xz --memlimit-compress=48MiB --memlimit-decompress=5MiB \
78 --no-adjust --threads=1 --check=crc64"
79 XZDEC="../src/xzdec/xzdec" # No memory usage limiter available
80 test -x ../src/xzdec/xzdec || XZDEC=
82 # Create the required input files.
83 if ./create_compress_files ; then
85 else
86 rm -f compress_*
87 echo "Failed to create files to test compression."
88 (exit 1)
89 exit 1
92 # Remove temporary now (in case they are something weird), and on exit.
93 rm -f tmp_compressed tmp_uncompressed
94 trap 'rm -f tmp_compressed tmp_uncompressed' 0
96 # Compress and decompress each file with various filter configurations.
97 # This takes quite a bit of time.
98 echo "test_compress.sh:"
99 for FILE in compress_generated_* "$srcdir"/compress_prepared_*
101 MSG=`echo "x$FILE" | sed 's,^x,,; s,^.*/,,; s,^compress_,,'`
102 echo " $MSG" | tr -d '\n\r'
104 # Don't test with empty arguments; it breaks some ancient
105 # proprietary /bin/sh versions due to $@ used in test_xz().
106 test_xz -1
107 test_xz -2
108 test_xz -3
109 test_xz -4
111 # Disabled until Subblock format is stable.
112 # --subblock \
113 # --subblock=size=1 \
114 # --subblock=size=1,rle=1 \
115 # --subblock=size=1,rle=4 \
116 # --subblock=size=4,rle=4 \
117 # --subblock=size=8,rle=4 \
118 # --subblock=size=8,rle=8 \
119 # --subblock=size=4096,rle=12 \
121 for ARGS in \
122 --delta=dist=1 \
123 --delta=dist=4 \
124 --delta=dist=256 \
125 --x86 \
126 --powerpc \
127 --ia64 \
128 --arm \
129 --armthumb \
130 --sparc
132 test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
134 # Disabled until Subblock format is stable.
135 # test_xz --subblock $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
136 done
138 echo
139 done
141 (exit 0)
142 exit 0