1#!/bin/sh
2
3. functions
4
5cleanup() {
6	rm -rf a b h h.xar h.toc
7}
8
9echo "Testing if zero length files have data sections"
10cleanup
11mkdir h 
12touch h/a
13
14cd h
15create_archive ../h.xar .
16cd ..
17${XAR} --dump-toc=h.toc -f h.xar
18if [ $? -ne 0 ]; then
19	echo "Error dumping toc"
20	cleanup
21	exit 1
22fi
23
24offset=`xsltproc data.xsl h.toc | grep -v xml`
25if [ "$offset" != "" ]; then
26	echo "Zero length file has data section"
27	cleanup
28	exit 1
29fi
30
31extract_archive h.xar
32
33cleanup
34
35echo "Testing zero length files with gzip compression"
36cleanup
37mkdir h 
38touch h/a
39
40cd h
41${XAR} --compression=gzip -cf ../h.xar .
42if [ $? -ne 0 ]; then
43	echo "Error creating archive"
44	exit 1
45fi
46cd ..
47${XAR} --dump-toc=h.toc -f h.xar
48if [ $? -ne 0 ]; then
49	echo "Error dumping toc"
50	cleanup
51	exit 1
52fi
53
54offset=`xsltproc data.xsl h.toc | grep -v xml`
55if [ "$offset" != "" ]; then
56	echo "Zero length file has data section"
57	cleanup
58	exit 1
59fi
60
61extract_archive h.xar
62cleanup
63
64echo "Testing zero length files with bzip2 compression"
65cleanup
66mkdir h 
67touch h/a
68
69cd h
70${XAR} --compression=bzip2 -cf ../h.xar .
71if [ $? -ne 0 ]; then
72	echo "Error creating archive"
73	exit 1
74fi
75cd ..
76${XAR} --dump-toc=h.toc -f h.xar
77if [ $? -ne 0 ]; then
78	echo "Error dumping toc"
79	cleanup
80	exit 1
81fi
82
83offset=`xsltproc data.xsl h.toc | grep -v xml`
84if [ "$offset" != "" ]; then
85	echo "Zero length file has data section"
86	cleanup
87	exit 1
88fi
89
90extract_archive h.xar
91cleanup
92
93echo "Testing zero length files with lzma compression"
94cleanup
95mkdir h 
96touch h/a
97
98cd h
99${XAR} --compression=lzma -cf ../h.xar .
100if [ $? -ne 0 ]; then
101	echo "Error creating archive"
102	exit 1
103fi
104cd ..
105${XAR} --dump-toc=h.toc -f h.xar
106if [ $? -ne 0 ]; then
107	echo "Error dumping toc"
108	cleanup
109	exit 1
110fi
111
112offset=`xsltproc data.xsl h.toc | grep -v xml`
113if [ "$offset" != "" ]; then
114	echo "Zero length file has data section"
115	cleanup
116	exit 1
117fi
118
119extract_archive h.xar
120cleanup
121
122echo "Testing zero length files with no compression"
123cleanup
124mkdir h 
125touch h/a
126
127cd h
128${XAR} --compression=none -cf ../h.xar .
129if [ $? -ne 0 ]; then
130	echo "Error creating archive"
131	exit 1
132fi
133cd ..
134${XAR} --dump-toc=h.toc -f h.xar
135if [ $? -ne 0 ]; then
136	echo "Error dumping toc"
137	cleanup
138	exit 1
139fi
140
141offset=`xsltproc data.xsl h.toc | grep -v xml`
142if [ "$offset" != "" ]; then
143	echo "Zero length file has data section"
144	cleanup
145	exit 1
146fi
147
148extract_archive h.xar
149cleanup
150
151echo "Testing mixed zero length/populated files with gzip compression"
152cleanup
153mkdir h 
154touch h/a
155echo "foo" > h/b
156
157cd h
158${XAR} --compression=gzip -cf ../h.xar .
159if [ $? -ne 0 ]; then
160	echo "Error creating archive"
161	exit 1
162fi
163cd ..
164extract_archive h.xar
165contents=`cat a`
166if [ ! -z "$contents" ]; then
167	echo "File isn't zero length after extraction"
168	exit 1
169fi
170contents=`cat b`
171if [ "$contents" != "foo" ]; then
172	echo "Contents of populated file not the same after extraction"
173	exit 1
174fi
175cleanup
176
177echo "Testing mixed zero length/populated files with bzip2 compression"
178cleanup
179mkdir h 
180touch h/a
181echo "foo" > h/b
182
183cd h
184${XAR} --compression=bzip2 -cf ../h.xar .
185if [ $? -ne 0 ]; then
186	echo "Error creating archive"
187	exit 1
188fi
189cd ..
190
191extract_archive h.xar
192contents=`cat a`
193if [ ! -z "$contents" ]; then
194	echo "File isn't zero length after extraction"
195	exit 1
196fi
197contents=`cat b`
198if [ "$contents" != "foo" ]; then
199	echo "Contents of populated file not the same after extraction"
200	exit 1
201fi
202cleanup
203
204echo "Testing mixed zero length/populated files with lzma compression"
205cleanup
206mkdir h 
207touch h/a
208echo "foo" > h/b
209
210cd h
211${XAR} --compression=lzma -cf ../h.xar .
212if [ $? -ne 0 ]; then
213	echo "Error creating archive"
214	exit 1
215fi
216cd ..
217
218extract_archive h.xar
219contents=`cat a`
220if [ ! -z "$contents" ]; then
221	echo "File isn't zero length after extraction"
222	exit 1
223fi
224contents=`cat b`
225if [ "$contents" != "foo" ]; then
226	echo "Contents of populated file not the same after extraction"
227	exit 1
228fi
229cleanup
230
231echo "Testing mixed zero length/populated files with no compression"
232cleanup
233mkdir h 
234touch h/a
235echo "foo" > h/b
236
237cd h
238${XAR} --compression=none -cf ../h.xar .
239if [ $? -ne 0 ]; then
240	echo "Error creating archive"
241	exit 1
242fi
243cd ..
244
245extract_archive h.xar
246contents=`cat a`
247if [ ! -z "$contents" ]; then
248	echo "File isn't zero length after extraction"
249	exit 1
250fi
251contents=`cat b`
252if [ "$contents" != "foo" ]; then
253	echo "Contents of populated file not the same after extraction"
254	exit 1
255fi
256
257cleanup
258