]> gitweb.ps.run Git - ps-cgit/blob - tests/t0107-snapshot.sh
git: update to v2.29.0
[ps-cgit] / 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         tar -xzf master.tar.gz
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         cp master.tar.lz /tmp/.
66 '
67
68 test_expect_success LZIP 'untar' '
69         rm -rf master &&
70         tar --lzip -xf master.tar.lz
71 '
72
73 test_expect_success LZIP 'count files' '
74         ls master/ >output &&
75         test_line_count = 5 output
76 '
77
78 test_expect_success LZIP 'verify untarred file-5' '
79         grep "^5$" master/file-5 &&
80         test_line_count = 1 master/file-5
81 '
82
83 if test -n "$(which xz 2>/dev/null)"; then
84         test_set_prereq XZ
85 else
86         say 'Skipping XZ validation tests: xz not found'
87 fi
88
89 test_expect_success XZ 'get foo/snapshot/master.tar.xz' '
90         cgit_url "foo/snapshot/master.tar.xz" >tmp
91 '
92
93 test_expect_success XZ 'check html headers' '
94         head -n 1 tmp |
95         grep "Content-Type: application/x-xz" &&
96
97         head -n 2 tmp |
98         grep "Content-Disposition: inline; filename=.master.tar.xz."
99 '
100
101 test_expect_success XZ 'strip off the header lines' '
102         strip_headers <tmp >master.tar.xz
103 '
104
105 test_expect_success XZ 'verify xz format' '
106         xz --test master.tar.xz &&
107         cp master.tar.xz /tmp/.
108 '
109
110 test_expect_success XZ 'untar' '
111         rm -rf master &&
112         tar --xz -xf master.tar.xz
113 '
114
115 test_expect_success XZ 'count files' '
116         ls master/ >output &&
117         test_line_count = 5 output
118 '
119
120 test_expect_success XZ 'verify untarred file-5' '
121         grep "^5$" master/file-5 &&
122         test_line_count = 1 master/file-5
123 '
124
125 if test -n "$(which zstd 2>/dev/null)"; then
126         test_set_prereq ZSTD
127 else
128         say 'Skipping ZSTD validation tests: zstd not found'
129 fi
130
131 test_expect_success ZSTD 'get foo/snapshot/master.tar.zst' '
132         cgit_url "foo/snapshot/master.tar.zst" >tmp
133 '
134
135 test_expect_success ZSTD 'check html headers' '
136         head -n 1 tmp |
137         grep "Content-Type: application/x-zstd" &&
138
139         head -n 2 tmp |
140         grep "Content-Disposition: inline; filename=.master.tar.zst."
141 '
142
143 test_expect_success ZSTD 'strip off the header lines' '
144         strip_headers <tmp >master.tar.zst
145 '
146
147 test_expect_success ZSTD 'verify zstd format' '
148         zstd --test master.tar.zst &&
149         cp master.tar.zst /tmp/.
150 '
151
152 test_expect_success ZSTD 'untar' '
153         rm -rf master &&
154         tar --zstd -xf master.tar.zst
155 '
156
157 test_expect_success ZSTD 'count files' '
158         ls master/ >output &&
159         test_line_count = 5 output
160 '
161
162 test_expect_success ZSTD 'verify untarred file-5' '
163         grep "^5$" master/file-5 &&
164         test_line_count = 1 master/file-5
165 '
166
167 test_expect_success 'get foo/snapshot/master.zip' '
168         cgit_url "foo/snapshot/master.zip" >tmp
169 '
170
171 test_expect_success 'check HTML headers (zip)' '
172         head -n 1 tmp |
173         grep "Content-Type: application/x-zip" &&
174
175         head -n 2 tmp |
176         grep "Content-Disposition: inline; filename=.master.zip."
177 '
178
179 test_expect_success 'strip off the header lines (zip)' '
180         strip_headers <tmp >master.zip
181 '
182
183 if test -n "$(which unzip 2>/dev/null)"; then
184         test_set_prereq UNZIP
185 else
186         say 'Skipping ZIP validation tests: unzip not found'
187 fi
188
189 test_expect_success UNZIP 'verify zip format' '
190         unzip -t master.zip
191 '
192
193 test_expect_success UNZIP 'unzip' '
194         rm -rf master &&
195         unzip master.zip
196 '
197
198 test_expect_success UNZIP 'count files (zip)' '
199         ls master/ >output &&
200         test_line_count = 5 output
201 '
202
203 test_expect_success UNZIP 'verify unzipped file-5' '
204         grep "^5$" master/file-5 &&
205         test_line_count = 1 master/file-5
206 '
207
208 test_done