]> git.cameronkatri.com Git - cgit.git/blob - tests/t0107-snapshot.sh
git: update to v2.32.0
[cgit.git] / tests / t0107-snapshot.sh
1 #!/bin/sh
2
3 test_description='Verify snapshot'
4 . ./setup.sh
5
6 test_expect_success 'get foo/snapshot/master.tar.gz' '
7 cgit_url "foo/snapshot/master.tar.gz" >tmp
8 '
9
10 test_expect_success 'check html headers' '
11 head -n 1 tmp |
12 grep "Content-Type: application/x-gzip" &&
13
14 head -n 2 tmp |
15 grep "Content-Disposition: inline; filename=.master.tar.gz."
16 '
17
18 test_expect_success 'strip off the header lines' '
19 strip_headers <tmp >master.tar.gz
20 '
21
22 test_expect_success 'verify gzip format' '
23 gunzip --test master.tar.gz
24 '
25
26 test_expect_success 'untar' '
27 rm -rf master &&
28 gzip -dc master.tar.gz | tar -xf -
29 '
30
31 test_expect_success 'count files' '
32 ls master/ >output &&
33 test_line_count = 5 output
34 '
35
36 test_expect_success 'verify untarred file-5' '
37 grep "^5$" master/file-5 &&
38 test_line_count = 1 master/file-5
39 '
40
41 if test -n "$(which lzip 2>/dev/null)"; then
42 test_set_prereq LZIP
43 else
44 say 'Skipping LZIP validation tests: lzip not found'
45 fi
46
47 test_expect_success LZIP 'get foo/snapshot/master.tar.lz' '
48 cgit_url "foo/snapshot/master.tar.lz" >tmp
49 '
50
51 test_expect_success LZIP 'check html headers' '
52 head -n 1 tmp |
53 grep "Content-Type: application/x-lzip" &&
54
55 head -n 2 tmp |
56 grep "Content-Disposition: inline; filename=.master.tar.lz."
57 '
58
59 test_expect_success LZIP 'strip off the header lines' '
60 strip_headers <tmp >master.tar.lz
61 '
62
63 test_expect_success LZIP 'verify lzip format' '
64 lzip --test master.tar.lz
65 '
66
67 test_expect_success LZIP 'untar' '
68 rm -rf master &&
69 lzip -dc master.tar.lz | tar -xf -
70 '
71
72 test_expect_success LZIP 'count files' '
73 ls master/ >output &&
74 test_line_count = 5 output
75 '
76
77 test_expect_success LZIP 'verify untarred file-5' '
78 grep "^5$" master/file-5 &&
79 test_line_count = 1 master/file-5
80 '
81
82 if test -n "$(which xz 2>/dev/null)"; then
83 test_set_prereq XZ
84 else
85 say 'Skipping XZ validation tests: xz not found'
86 fi
87
88 test_expect_success XZ 'get foo/snapshot/master.tar.xz' '
89 cgit_url "foo/snapshot/master.tar.xz" >tmp
90 '
91
92 test_expect_success XZ 'check html headers' '
93 head -n 1 tmp |
94 grep "Content-Type: application/x-xz" &&
95
96 head -n 2 tmp |
97 grep "Content-Disposition: inline; filename=.master.tar.xz."
98 '
99
100 test_expect_success XZ 'strip off the header lines' '
101 strip_headers <tmp >master.tar.xz
102 '
103
104 test_expect_success XZ 'verify xz format' '
105 xz --test master.tar.xz
106 '
107
108 test_expect_success XZ 'untar' '
109 rm -rf master &&
110 xz -dc master.tar.xz | tar -xf -
111 '
112
113 test_expect_success XZ 'count files' '
114 ls master/ >output &&
115 test_line_count = 5 output
116 '
117
118 test_expect_success XZ 'verify untarred file-5' '
119 grep "^5$" master/file-5 &&
120 test_line_count = 1 master/file-5
121 '
122
123 if test -n "$(which zstd 2>/dev/null)"; then
124 test_set_prereq ZSTD
125 else
126 say 'Skipping ZSTD validation tests: zstd not found'
127 fi
128
129 test_expect_success ZSTD 'get foo/snapshot/master.tar.zst' '
130 cgit_url "foo/snapshot/master.tar.zst" >tmp
131 '
132
133 test_expect_success ZSTD 'check html headers' '
134 head -n 1 tmp |
135 grep "Content-Type: application/x-zstd" &&
136
137 head -n 2 tmp |
138 grep "Content-Disposition: inline; filename=.master.tar.zst."
139 '
140
141 test_expect_success ZSTD 'strip off the header lines' '
142 strip_headers <tmp >master.tar.zst
143 '
144
145 test_expect_success ZSTD 'verify zstd format' '
146 zstd --test master.tar.zst
147 '
148
149 test_expect_success ZSTD 'untar' '
150 rm -rf master &&
151 zstd -dc master.tar.zst | tar -xf -
152 '
153
154 test_expect_success ZSTD 'count files' '
155 ls master/ >output &&
156 test_line_count = 5 output
157 '
158
159 test_expect_success ZSTD 'verify untarred file-5' '
160 grep "^5$" master/file-5 &&
161 test_line_count = 1 master/file-5
162 '
163
164 test_expect_success 'get foo/snapshot/master.zip' '
165 cgit_url "foo/snapshot/master.zip" >tmp
166 '
167
168 test_expect_success 'check HTML headers (zip)' '
169 head -n 1 tmp |
170 grep "Content-Type: application/x-zip" &&
171
172 head -n 2 tmp |
173 grep "Content-Disposition: inline; filename=.master.zip."
174 '
175
176 test_expect_success 'strip off the header lines (zip)' '
177 strip_headers <tmp >master.zip
178 '
179
180 if test -n "$(which unzip 2>/dev/null)"; then
181 test_set_prereq UNZIP
182 else
183 say 'Skipping ZIP validation tests: unzip not found'
184 fi
185
186 test_expect_success UNZIP 'verify zip format' '
187 unzip -t master.zip
188 '
189
190 test_expect_success UNZIP 'unzip' '
191 rm -rf master &&
192 unzip master.zip
193 '
194
195 test_expect_success UNZIP 'count files (zip)' '
196 ls master/ >output &&
197 test_line_count = 5 output
198 '
199
200 test_expect_success UNZIP 'verify unzipped file-5' '
201 grep "^5$" master/file-5 &&
202 test_line_count = 1 master/file-5
203 '
204
205 test_done