archive-zip: add tests for big ZIP archives
Test the creation of ZIP archives bigger than 4GB and containing files bigger than 4GB. They are marked as EXPENSIVE because they take quite a while and because the first one needs a bit more than 4GB of disk space to store the resulting archive. The big archive in the first test is made up of a tree containing thousands of copies of a small file. Yet the test has to write out the full archive because unzip doesn't offer a way to read from stdin. The big file in the second test is provided as a zipped pack file to avoid writing another 4GB file to disk and then adding it. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Apr 24, 2017 at 19:29 UTC
758c1f9d1bcab5115f5d9e990c952602ea58a161
2 files changed
+45
t/t5004-archive-corner-cases.sh
+45
@@ -155,4 +155,49 @@ test_expect_success ZIPINFO 'zip archive with many entries' '
155
test_cmp expect actual
156
'
157
158
+test_expect_failure EXPENSIVE,UNZIP 'zip archive bigger than 4GB' '
159
+ # build string containing 65536 characters
160
+ s=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef &&
161
+ s=$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s &&
162
+ s=$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s$s &&
163
+
164
+ # create blob with a length of 65536 + 1 bytes
165
+ blob=$(echo $s | git hash-object -w --stdin) &&
166
+
167
+ # create tree containing 65500 entries of that blob
168
+ for i in $(test_seq 1 65500)
169
+ do
170
+ echo "100644 blob $blob $i"
171
+ done >tree &&
172
+ tree=$(git mktree <tree) &&
173
+
174
+ # zip it, creating an archive a bit bigger than 4GB
175
+ git archive -0 -o many-big.zip $tree &&
176
+
177
+ "$GIT_UNZIP" -t many-big.zip 9999 65500 &&
178
+ "$GIT_UNZIP" -t many-big.zip
179
+'
180
+
181
+test_expect_failure EXPENSIVE,UNZIP,ZIPINFO 'zip archive with files bigger than 4GB' '
182
+ # Pack created with:
183
+ # dd if=/dev/zero of=file bs=1M count=4100 && git hash-object -w file
184
+ mkdir -p .git/objects/pack &&
185
+ (
186
+ cd .git/objects/pack &&
187
+ "$GIT_UNZIP" "$TEST_DIRECTORY"/t5004/big-pack.zip
188
+ ) &&
189
+ blob=754a93d6fada4c6873360e6cb4b209132271ab0e &&
190
+ size=$(expr 4100 "*" 1024 "*" 1024) &&
191
+
192
+ # create a tree containing the file
193
+ tree=$(echo "100644 blob $blob big-file" | git mktree) &&
194
+
195
+ # zip it, creating an archive with a file bigger than 4GB
196
+ git archive -o big.zip $tree &&
197
+
198
+ "$GIT_UNZIP" -t big.zip &&
199
+ "$ZIPINFO" big.zip >big.lst &&
200
+ grep $size big.lst
201
+'
202
+
203
test_done
t/t5004/big-pack.zip
Binary files /dev/null and b/t/t5004/big-pack.zip differ