]> icculus.org git repositories - icculus/xz.git/blob - tests/test_compress.sh
Disable Subblock filter from test_compress.sh since it is
[icculus/xz.git] / tests / test_compress.sh
1 #!/bin/sh
2
3 ###############################################################################
4 #
5 #   Copyright (C) 2008 Lasse Collin
6 #
7 #   This library is free software; you can redistribute it and/or
8 #   modify it under the terms of the GNU Lesser General Public
9 #   License as published by the Free Software Foundation; either
10 #   version 2.1 of the License, or (at your option) any later version.
11 #
12 #   This library is distributed in the hope that it will be useful,
13 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #   Lesser General Public License for more details.
16 #
17 ###############################################################################
18
19 # Find out if our shell supports functions.
20 eval 'unset foo ; foo() { return 42; } ; foo'
21 if test $? != 42 ; then
22         echo "/bin/sh doesn't support functions, skipping this test."
23         (exit 77)
24         exit 77
25 fi
26
27 test_xz() {
28         if $XZ -c "$@" "$FILE" > tmp_compressed; then
29                 :
30         else
31                 echo "Compressing failed: $* $FILE"
32                 (exit 1)
33                 exit 1
34         fi
35
36         if $XZ -cd tmp_compressed > tmp_uncompressed ; then
37                 :
38         else
39                 echo "Decoding failed: $* $FILE"
40                 (exit 1)
41                 exit 1
42         fi
43
44         if cmp tmp_uncompressed "$FILE" ; then
45                 :
46         else
47                 echo "Decoded file does not match the original: $* $FILE"
48                 (exit 1)
49                 exit 1
50         fi
51
52         if $XZDEC tmp_compressed > tmp_uncompressed ; then
53                 :
54         else
55                 echo "Decoding failed: $* $FILE"
56                 (exit 1)
57                 exit 1
58         fi
59
60         if cmp tmp_uncompressed "$FILE" ; then
61                 :
62         else
63                 echo "Decoded file does not match the original: $* $FILE"
64                 (exit 1)
65                 exit 1
66         fi
67
68         # Show progress:
69         echo . | tr -d '\n\r'
70 }
71
72 XZ="../src/xz/xz --memory=28MiB --threads=1"
73 XZDEC="../src/xzdec/xzdec --memory=4MiB"
74 unset XZ_OPT
75
76 # Create the required input files.
77 if ./create_compress_files ; then
78         :
79 else
80         rm -f compress_*
81         echo "Failed to create files to test compression."
82         (exit 1)
83         exit 1
84 fi
85
86 # Remove temporary now (in case they are something weird), and on exit.
87 rm -f tmp_compressed tmp_uncompressed
88 trap 'rm -f tmp_compressed tmp_uncompressed' 0
89
90 # Encode and decode each file with various filter configurations.
91 # This takes quite a bit of time.
92 echo "test_compress.sh:"
93 for FILE in compress_generated_* "$srcdir"/compress_prepared_*
94 do
95         MSG=`echo "x$FILE" | sed 's,^x,,; s,^.*/,,; s,^compress_,,'`
96         echo "  $MSG" | tr -d '\n\r'
97
98         # Don't test with empty arguments; it breaks some ancient
99         # proprietary /bin/sh versions due to $@ used in test_xz().
100         test_xz -1
101         test_xz -2
102         test_xz -3
103         test_xz -4
104
105         # Disabled until Subblock format is stable.
106 #               --subblock \
107 #               --subblock=size=1 \
108 #               --subblock=size=1,rle=1 \
109 #               --subblock=size=1,rle=4 \
110 #               --subblock=size=4,rle=4 \
111 #               --subblock=size=8,rle=4 \
112 #               --subblock=size=8,rle=8 \
113 #               --subblock=size=4096,rle=12 \
114 #       
115         for ARGS in \
116                 --delta=dist=1 \
117                 --delta=dist=4 \
118                 --delta=dist=256 \
119                 --x86 \
120                 --powerpc \
121                 --ia64 \
122                 --arm \
123                 --armthumb \
124                 --sparc
125         do
126                 test_xz $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
127                 
128                 # Disabled until Subblock format is stable.
129                 # test_xz --subblock $ARGS --lzma2=dict=64KiB,nice=32,mode=fast
130         done
131
132         echo
133 done
134
135 (exit 0)
136 exit 0