Merge branch 'jn/license'
[xz/debian.git] / tests / test_compress.sh
blobff0cb304df427b431e42ace4644726cf0ca4b2c3
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 # Find out if our shell supports functions.
13 eval 'unset foo ; foo() { return 42; } ; foo'
14 if test $? != 42 ; then
15 echo "/bin/sh doesn't support functions, skipping this test."
16 (exit 77)
17 exit 77
20 test_xz() {
21 if $XZ -c "$@" "$FILE" > tmp_compressed; then
23 else
24 echo "Compressing failed: $* $FILE"
25 (exit 1)
26 exit 1
29 if $XZ -cd tmp_compressed > tmp_uncompressed ; then
31 else
32 echo "Decoding failed: $* $FILE"
33 (exit 1)
34 exit 1
37 if cmp tmp_uncompressed "$FILE" ; then
39 else
40 echo "Decoded file does not match the original: $* $FILE"
41 (exit 1)
42 exit 1
45 if $XZDEC tmp_compressed > tmp_uncompressed ; then
47 else
48 echo "Decoding failed: $* $FILE"
49 (exit 1)
50 exit 1
53 if cmp tmp_uncompressed "$FILE" ; then
55 else
56 echo "Decoded file does not match the original: $* $FILE"
57 (exit 1)
58 exit 1
61 # Show progress:
62 echo . | tr -d '\n\r'
65 XZ="../src/xz/xz --memory=28MiB --threads=1"
66 XZDEC="../src/xzdec/xzdec --memory=4MiB"
67 unset XZ_OPT
69 # Create the required input files.
70 if ./create_compress_files ; then
72 else
73 rm -f compress_*
74 echo "Failed to create files to test compression."
75 (exit 1)
76 exit 1
79 # Remove temporary now (in case they are something weird), and on exit.
80 rm -f tmp_compressed tmp_uncompressed
81 trap 'rm -f tmp_compressed tmp_uncompressed' 0
83 # Encode and decode each file with various filter configurations.
84 # This takes quite a bit of time.
85 echo "test_compress.sh:"
86 for FILE in compress_generated_* "$srcdir"/compress_prepared_*
88 MSG=`echo "x$FILE" | sed 's,^x,,; s,^.*/,,; s,^compress_,,'`
89 echo " $MSG" | tr -d '\n\r'
91 # Don't test with empty arguments; it breaks some ancient
92 # proprietary /bin/sh versions due to $@ used in test_xz().
93 test_xz -1
94 test_xz -2
95 test_xz -3
96 test_xz -4
98 # Disabled until Subblock format is stable.
99 # --subblock \
100 # --subblock=size=1 \
101 # --subblock=size=1,rle=1 \
102 # --subblock=size=1,rle=4 \
103 # --subblock=size=4,rle=4 \
104 # --subblock=size=8,rle=4 \
105 # --subblock=size=8,rle=8 \
106 # --subblock=size=4096,rle=12 \
108 for ARGS in \
109 --delta=dist=1 \
110 --delta=dist=4 \
111 --delta=dist=256 \
112 --x86 \
113 --powerpc \
114 --ia64 \
115 --arm \
116 --armthumb \
117 --sparc
119 test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
121 # Disabled until Subblock format is stable.
122 # test_xz --subblock $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
123 done
125 echo
126 done
128 (exit 0)
129 exit 0