summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-04-24 17:29:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-04-25 04:43:21 (GMT)
commit758c1f9d1bcab5115f5d9e990c952602ea58a161 (patch)
treef0e6ed7abb43479ee64160cef840a2aa63b11fca /t
parent49800c940790cc7465d1b03e08d472ffd8684808 (diff)
downloadgit-758c1f9d1bcab5115f5d9e990c952602ea58a161.zip
git-758c1f9d1bcab5115f5d9e990c952602ea58a161.tar.gz
git-758c1f9d1bcab5115f5d9e990c952602ea58a161.tar.bz2
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>
Diffstat (limited to 't')
-rwxr-xr-xt/t5004-archive-corner-cases.sh45
-rw-r--r--t/t5004/big-pack.zipbin0 -> 7373 bytes
2 files changed, 45 insertions, 0 deletions
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh
index cca2338..5c886fa 100755
--- a/t/t5004-archive-corner-cases.sh
+++ b/t/t5004-archive-corner-cases.sh
@@ -155,4 +155,49 @@ test_expect_success ZIPINFO 'zip archive with many entries' '
test_cmp expect actual
'
+test_expect_failure EXPENSIVE,UNZIP 'zip archive bigger than 4GB' '
+ # build string containing 65536 characters
+ s=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef &&
+ 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 &&
+ 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 &&
+
+ # create blob with a length of 65536 + 1 bytes
+ blob=$(echo $s | git hash-object -w --stdin) &&
+
+ # create tree containing 65500 entries of that blob
+ for i in $(test_seq 1 65500)
+ do
+ echo "100644 blob $blob $i"
+ done >tree &&
+ tree=$(git mktree <tree) &&
+
+ # zip it, creating an archive a bit bigger than 4GB
+ git archive -0 -o many-big.zip $tree &&
+
+ "$GIT_UNZIP" -t many-big.zip 9999 65500 &&
+ "$GIT_UNZIP" -t many-big.zip
+'
+
+test_expect_failure EXPENSIVE,UNZIP,ZIPINFO 'zip archive with files bigger than 4GB' '
+ # Pack created with:
+ # dd if=/dev/zero of=file bs=1M count=4100 && git hash-object -w file
+ mkdir -p .git/objects/pack &&
+ (
+ cd .git/objects/pack &&
+ "$GIT_UNZIP" "$TEST_DIRECTORY"/t5004/big-pack.zip
+ ) &&
+ blob=754a93d6fada4c6873360e6cb4b209132271ab0e &&
+ size=$(expr 4100 "*" 1024 "*" 1024) &&
+
+ # create a tree containing the file
+ tree=$(echo "100644 blob $blob big-file" | git mktree) &&
+
+ # zip it, creating an archive with a file bigger than 4GB
+ git archive -o big.zip $tree &&
+
+ "$GIT_UNZIP" -t big.zip &&
+ "$ZIPINFO" big.zip >big.lst &&
+ grep $size big.lst
+'
+
test_done
diff --git a/t/t5004/big-pack.zip b/t/t5004/big-pack.zip
new file mode 100644
index 0000000..caaf614
--- /dev/null
+++ b/t/t5004/big-pack.zip
Binary files differ