File: test-decompress

package info (click to toggle)
lhasa 0.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,364 kB
  • sloc: ansic: 6,796; sh: 1,938; makefile: 168; python: 129
file content (293 lines) | stat: -rwxr-xr-x 13,698 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#!/usr/bin/env bash
#
# Copyright (c) 2011, 2012, Simon Howard
#
# Permission to use, copy, modify, and/or distribute this software
# for any purpose with or without fee is hereby granted, provided
# that the above copyright notice and this permission notice appear
# in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#
# Test script that uses the decompress-crc tool to decompress the
# contents of the test archives, and check the CRC and length of
# the decompressed data.
#

. test_common.sh

test_archive() {
	local archive=$1

	(echo "crc: $2"; echo "length: $3") > "$wd/expected.txt"

	./decompress-crc "archives/$archive" > "$wd/output.txt"

	if ! diff -u "$wd/expected.txt" "$wd/output.txt"; then
		fail "Output not as expected for $archive"
	fi

	rm -f "$wd/expected.txt" "$wd/output.txt"
}

generate_test_line() {
	local archive=$1

	local crc=$(./decompress-crc archives/$archive | grep crc: \
	            | sed "s/crc: //")
	local len=$(./decompress-crc archives/$archive | grep length: \
	            | sed "s/length: //")
	printf "test_archive %-35s%-10s%s\n" "$archive" "$crc" "$len"
}

# Common definitions for file contents:

gpl2_gz="e4690583 6829"
gpl2="4e46f4a1 18092"
long="06788e85 1241658"
hello_world1="af083b2d 12"
hello_world2="b19b306e 14"
hello_world3="0d4a1185 11"

test_archive explzh_723/h0_lh0.lzh              $gpl2_gz
test_archive explzh_723/h0_lh5.lzh              $gpl2
test_archive explzh_723/h0_lh6.lzh              $gpl2
test_archive explzh_723/h0_lh7.lzh              $gpl2
test_archive explzh_723/h0_subdir.lzh           $hello_world1
test_archive explzh_723/h1_lh0.lzh              $gpl2_gz
test_archive explzh_723/h1_lh5.lzh              $gpl2
test_archive explzh_723/h1_lh6.lzh              $gpl2
test_archive explzh_723/h1_lh7.lzh              $gpl2
test_archive explzh_723/h1_subdir.lzh           $hello_world1
test_archive explzh_723/h2_lh0.lzh              $gpl2_gz
test_archive explzh_723/h2_lh5.lzh              $gpl2
test_archive explzh_723/h2_lh6.lzh              $gpl2
test_archive explzh_723/h2_lh7.lzh              $gpl2
test_archive explzh_723/h2_subdir.lzh           $hello_world1
test_archive explzh_723/declha_sfx_ansi.exe     $gpl2
test_archive explzh_723/declha_sfx_unicode.exe  $gpl2

test_archive larc333/lz4.lzs                    $gpl2_gz
test_archive larc333/lz5.lzs                    $gpl2
test_archive larc333/sfx.com                    $gpl2_gz
test_archive larc333/subdir.lzs                 $hello_world1
test_archive larc333/long.lzs                   $long

test_archive lharc113/lh0.lzh                   $gpl2_gz
test_archive lharc113/lh1.lzh                   $gpl2
test_archive lharc113/sfx.com                   $gpl2
test_archive lharc113/subdir.lzh                $hello_world1
test_archive lharc113/long.lzh                  $long

test_archive lha213/lh0.lzh                     $gpl2_gz
test_archive lha213/lh5.lzh                     $gpl2
test_archive lha213/lh5_long.lzh                $long
test_archive lha213/sfx.exe                     $gpl2
test_archive lha213/subdir.lzh                  $hello_world1

test_archive lha255e/lh0.lzh                    $gpl2_gz
test_archive lha255e/lh5.lzh                    $gpl2
test_archive lha255e/sfx.exe                    $gpl2
test_archive lha255e/subdir.lzh                 $hello_world1

test_archive lha_unix114i/h0_lh0.lzh            $gpl2_gz
test_archive lha_unix114i/h0_lh5.lzh            $gpl2
test_archive lha_unix114i/h0_lh6.lzh            $gpl2
test_archive lha_unix114i/h0_lh7.lzh            $gpl2
#test_archive lha_unix114i/h0_subdir.lzh         $hello_world1
test_archive lha_unix114i/h1_lh0.lzh            $gpl2_gz
test_archive lha_unix114i/h1_lh5.lzh            $gpl2
test_archive lha_unix114i/h1_lh6.lzh            $gpl2
test_archive lha_unix114i/h1_lh7.lzh            $gpl2
test_archive lha_unix114i/h1_subdir.lzh         $hello_world1
test_archive lha_unix114i/h2_lh0.lzh            $gpl2_gz
test_archive lha_unix114i/h2_lh5.lzh            $gpl2
test_archive lha_unix114i/h2_lh6.lzh            $gpl2
test_archive lha_unix114i/h2_lh7.lzh            $gpl2
test_archive lha_unix114i/h2_subdir.lzh         $hello_world1
test_archive lha_unix114i/lh6_long.lzh          $long
test_archive lha_unix114i/lh7_long.lzh          $long

test_archive lha_os2_208/lh0.lzh                $gpl2_gz
test_archive lha_os2_208/lh5.lzh                $gpl2
test_archive lha_os2_208/lfn.lzh                $hello_world2
test_archive lha_os2_208/subdir.lzh             $hello_world2
test_archive lha_os2_208/lh1.lzh                $gpl2
test_archive lha_os2_208/h3_lfn.lzh             $hello_world2
test_archive lha_os2_208/h3_lh0.lzh             $gpl2_gz
test_archive lha_os2_208/h3_lh5.lzh             $gpl2
test_archive lha_os2_208/h3_subdir.lzh          $hello_world2

test_archive lh2_222/lh0.lzh                    $gpl2_gz
test_archive lh2_222/lh5.lzh                    $gpl2
test_archive lh2_222/subdir.lzh                 b0595a59 14
test_archive lh2_222/sfx.exe                    $gpl2_gz
# TODO: Currently disabled as we don't yet detect and ignore EA files:
#test_archive lh2_222/eas.lzh                "hello.txt"
#test_archive lh2_222/easubdir.lzh           "subdir/subdir2/hello.txt"

# The PMarc archives contain trailing zero-space, meaning that
# the results here are technically incorrect. This is an unfortunate
# result of the original PMarc tool which adds the extra data.

test_archive pmarc124/pm0.pma                   e3cf61d2  6912
test_archive pmarc124/pm1.pma                   b7d0e42c  25284
test_archive pmarc124/pm1_long.pma              b2b419d6  1241659
test_archive pmarc124/mtcd.pma                  ceec9f76  1403

test_archive pmarc2/pm0.pma                     549d935a  6912
test_archive pmarc2/pm2.pma                     8e2093a7  18176
test_archive pmarc2/comment.pma                 906330c5  128
test_archive pmarc2/sfx.com                     8e2093a7  18176
test_archive pmarc2/long.pma                    b2b419d6  1241659

test_archive lha_amiga_122/level0.lzh           $hello_world1
test_archive lha_amiga_122/level1.lzh           $hello_world1
test_archive lha_amiga_122/level2.lzh           $hello_world1
test_archive lha_amiga_122/lh0.lzh              $gpl2_gz
test_archive lha_amiga_122/lh1.lzh              $gpl2
test_archive lha_amiga_122/lh4_long.lzh         $long
test_archive lha_amiga_122/lh4.lzh              $gpl2
test_archive lha_amiga_122/lh5.lzh              $gpl2
test_archive lha_amiga_122/subdir.lzh           $hello_world1
test_archive lha_amiga_122/sfx.run              $gpl2

test_archive lha_amiga_212/level0.lzh           $hello_world1
test_archive lha_amiga_212/level1.lzh           $hello_world1
test_archive lha_amiga_212/level2.lzh           $hello_world1
test_archive lha_amiga_212/lh1.lzh              $gpl2
test_archive lha_amiga_212/lh6.lzh              $gpl2

test_archive lharc_atari_313a/lh0.lzh           $gpl2_gz
test_archive lharc_atari_313a/lh5.lzh           $gpl2
test_archive lharc_atari_313a/lz5.lzh           $gpl2
test_archive lharc_atari_313a/subdir.lzh        $hello_world1
test_archive lharc_atari_313a/sfx.tos           $gpl2
test_archive lharc_atari_313a/shorter.lzh       3fdcda96  286015
test_archive lharc_atari_313a/h1_lh5.lzh        $gpl2
test_archive lharc_atari_313a/h1_lz5.lzh        $gpl2
test_archive lharc_atari_313a/h1_subdir.lzh     $hello_world1
test_archive lharc_atari_313a/h2_lh5.lzh        $gpl2
test_archive lharc_atari_313a/h2_lz5.lzh        $gpl2
test_archive lharc_atari_313a/h2_subdir.lzh     $hello_world1

test_archive lha_x68k_213/h0_lh0.lzh            $gpl2_gz
test_archive lha_x68k_213/h0_lh5.lzh            $gpl2
test_archive lha_x68k_213/h0_subdir.lzh         $hello_world1
test_archive lha_x68k_213/h1_lh0.lzh            $gpl2_gz
test_archive lha_x68k_213/h1_lh5.lzh            $gpl2
test_archive lha_x68k_213/h1_subdir.lzh         $hello_world1
test_archive lha_x68k_213/h2_lh0.lzh            $gpl2_gz
test_archive lha_x68k_213/h2_lh5.lzh            $gpl2
test_archive lha_x68k_213/h2_subdir.lzh         $hello_world1
test_archive lha_x68k_213/sfx.x                 $gpl2

# These three MacLHA archives are technically "incorrect" because they
# contain MacBinary headers that are not stripped off. As they are
# level 0 archives, there is no OS type that can be used to identify
# them as MacLHA archives.

test_archive maclha_224/l0_lh0.lzh              12789183  7040
test_archive maclha_224/l0_lh1.lzh              f96b05fd  18304
test_archive maclha_224/l0_lh5.lzh              f96b05fd  18304

test_archive maclha_224/l0_nm_lh5.lzh           $gpl2
test_archive maclha_224/l1_full_subdir.lzh      $hello_world3
test_archive maclha_224/l1_lh0.lzh              $gpl2_gz
test_archive maclha_224/l1_lh1.lzh              $gpl2
test_archive maclha_224/l1_lh5.lzh              $gpl2
test_archive maclha_224/l1_nm_lh5.lzh           $gpl2
test_archive maclha_224/l1_subdir.lzh           $hello_world3
test_archive maclha_224/l2_full_subdir.lzh      $hello_world3
test_archive maclha_224/l2_lh0.lzh              $gpl2_gz
test_archive maclha_224/l2_lh1.lzh              $gpl2
test_archive maclha_224/l2_lh5.lzh              $gpl2
test_archive maclha_224/l2_nm_lh5.lzh           $gpl2
test_archive maclha_224/l2_subdir.lzh           $hello_world3

test_archive lhmelt_16536/h0_lh0.lzh            $gpl2_gz
test_archive lhmelt_16536/h0_lh1.lzh            $gpl2
test_archive lhmelt_16536/h0_lh5.lzh            $gpl2
test_archive lhmelt_16536/h0_lh6.lzh            $gpl2
test_archive lhmelt_16536/h0_lh7.lzh            $gpl2
test_archive lhmelt_16536/h0_subdir.lzh         $hello_world1
test_archive lhmelt_16536/h1_lh0.lzh            $gpl2_gz
test_archive lhmelt_16536/h1_lh1.lzh            $gpl2
test_archive lhmelt_16536/h1_lh5.lzh            $gpl2
test_archive lhmelt_16536/h1_subdir.lzh         $hello_world1
test_archive lhmelt_16536/h2_lh0.lzh            $gpl2_gz
test_archive lhmelt_16536/h2_lh1.lzh            $gpl2
test_archive lhmelt_16536/h2_lh5.lzh            $gpl2
test_archive lhmelt_16536/h2_subdir.lzh         $hello_world1
test_archive lhmelt_16536/sfx_winsfx32_213.exe  $gpl2
test_archive lhmelt_16536/sfx_winsfx32m_250.exe $gpl2
test_archive lhmelt_16536/sfx_winsfx_213.exe    $gpl2
test_archive lhmelt_16536/sfx_winsfxm_250.exe   $gpl2

test_archive lha_osk_201/h0_lh0.lzh             $gpl2_gz
test_archive lha_osk_201/h0_lh1.lzh             $gpl2
test_archive lha_osk_201/h0_lh5.lzh             $gpl2
#test_archive lha_osk_201/h0_subdir.lzh          $hello_world1
test_archive lha_osk_201/h1_lh0.lzh             $gpl2_gz
test_archive lha_osk_201/h1_lh1.lzh             $gpl2
test_archive lha_osk_201/h1_lh5.lzh             $gpl2
test_archive lha_osk_201/h1_subdir.lzh          $hello_world1
test_archive lha_osk_201/h2_lh0.lzh             $gpl2_gz
test_archive lha_osk_201/h2_lh1.lzh             $gpl2
test_archive lha_osk_201/h2_lh5.lzh             $gpl2
test_archive lha_osk_201/h2_subdir.lzh          $hello_world1

test_archive lha_os9_211c/h0_lh0.lzh            $gpl2_gz
test_archive lha_os9_211c/h0_lh1.lzh            $gpl2
test_archive lha_os9_211c/h0_subdir.lzh         $hello_world1
test_archive lha_os9_211c/h1_lh0.lzh            $gpl2_gz
test_archive lha_os9_211c/h1_lh1.lzh            $gpl2
test_archive lha_os9_211c/h1_subdir.lzh         $hello_world1
test_archive lha_os9_211c/h2_lh0.lzh            $gpl2_gz
test_archive lha_os9_211c/h2_lh1.lzh            $gpl2
test_archive lha_os9_211c/h2_subdir.lzh         $hello_world1

test_archive morphos_lha_2717/h0_lh0.lzh        $gpl2_gz
test_archive morphos_lha_2717/h0_lh1.lzh        $gpl2
test_archive morphos_lha_2717/h0_lh5.lzh        $gpl2
test_archive morphos_lha_2717/h0_lh6.lzh        $gpl2
test_archive morphos_lha_2717/h0_metadata.lzh   f0771cc4 29
test_archive morphos_lha_2717/h0_subdir.lzh     $hello_world1
test_archive morphos_lha_2717/h1_lh0.lzh        $gpl2_gz
test_archive morphos_lha_2717/h1_lh1.lzh        $gpl2
test_archive morphos_lha_2717/h1_lh5.lzh        $gpl2
test_archive morphos_lha_2717/h1_lh6.lzh        $gpl2
test_archive morphos_lha_2717/h1_metadata.lzh   f0771cc4 29
test_archive morphos_lha_2717/h1_subdir.lzh     $hello_world1
test_archive morphos_lha_2717/h2_huge.lzh       f01352be 4718592000
test_archive morphos_lha_2717/h2_lh0.lzh        $gpl2_gz
test_archive morphos_lha_2717/h2_lh1.lzh        $gpl2
test_archive morphos_lha_2717/h2_lh5.lzh        $gpl2
test_archive morphos_lha_2717/h2_lh6.lzh        $gpl2
test_archive morphos_lha_2717/h2_metadata.lzh   f0771cc4 29
test_archive morphos_lha_2717/h2_subdir.lzh     $hello_world1

test_archive tascal_lha_051h/abspath.lzh        $hello_world1
test_archive tascal_lha_051h/lh0.lzh            $gpl2_gz
test_archive tascal_lha_051h/lh5.lzh            $gpl2

test_archive regression/abspath.lzh             bd98d221  46
test_archive regression/badterm.lzh             00000000  0
test_archive regression/unixsep.lzh             $hello_world1

test_archive generated/lzs/lzs.lzs              $gpl2
test_archive generated/lzs/long.lzs             $long

# -pm1- decompress. Unfortunately only the first file in the archive
# will be tested.

test_archive generated/pm1/pm1.pma              41fe9947  32768