t5300, t5302, t5303: Do not use /dev/zero
We do not have /dev/zero on Windows. This replaces it by data generated with printf, perl, or echo. Most of the cases do not depend on that the data is a stream of zero bytes, so we use something printable; nor is an unlimited stream of data needed, so we produce only as many bytes as the test cases need. Signed-off-by: Johannes Sixt <j6t@kdbg.org>
This commit is contained in:
parent
0aaaef7b0f
commit
b689ccf6c9
@ -13,11 +13,10 @@ TRASH=`pwd`
|
|||||||
test_expect_success \
|
test_expect_success \
|
||||||
'setup' \
|
'setup' \
|
||||||
'rm -f .git/index*
|
'rm -f .git/index*
|
||||||
for i in a b c
|
perl -e "print \"a\" x 4096;" > a &&
|
||||||
do
|
perl -e "print \"b\" x 4096;" > b &&
|
||||||
dd if=/dev/zero bs=4k count=1 | perl -pe "y/\\000/$i/" >$i &&
|
perl -e "print \"c\" x 4096;" > c &&
|
||||||
git update-index --add $i || return 1
|
git update-index --add a b c &&
|
||||||
done &&
|
|
||||||
cat c >d && echo foo >>d && git update-index --add d &&
|
cat c >d && echo foo >>d && git update-index --add d &&
|
||||||
tree=`git write-tree` &&
|
tree=`git write-tree` &&
|
||||||
commit=`git commit-tree $tree </dev/null` && {
|
commit=`git commit-tree $tree </dev/null` && {
|
||||||
@ -221,7 +220,7 @@ test_expect_success \
|
|||||||
test_expect_success \
|
test_expect_success \
|
||||||
'verify-pack catches a corrupted pack signature' \
|
'verify-pack catches a corrupted pack signature' \
|
||||||
'cat test-1-${packname_1}.pack >test-3.pack &&
|
'cat test-1-${packname_1}.pack >test-3.pack &&
|
||||||
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&
|
echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&
|
||||||
if git verify-pack test-3.idx
|
if git verify-pack test-3.idx
|
||||||
then false
|
then false
|
||||||
else :;
|
else :;
|
||||||
@ -230,7 +229,7 @@ test_expect_success \
|
|||||||
test_expect_success \
|
test_expect_success \
|
||||||
'verify-pack catches a corrupted pack version' \
|
'verify-pack catches a corrupted pack version' \
|
||||||
'cat test-1-${packname_1}.pack >test-3.pack &&
|
'cat test-1-${packname_1}.pack >test-3.pack &&
|
||||||
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&
|
echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&
|
||||||
if git verify-pack test-3.idx
|
if git verify-pack test-3.idx
|
||||||
then false
|
then false
|
||||||
else :;
|
else :;
|
||||||
@ -239,7 +238,7 @@ test_expect_success \
|
|||||||
test_expect_success \
|
test_expect_success \
|
||||||
'verify-pack catches a corrupted type/size of the 1st packed object data' \
|
'verify-pack catches a corrupted type/size of the 1st packed object data' \
|
||||||
'cat test-1-${packname_1}.pack >test-3.pack &&
|
'cat test-1-${packname_1}.pack >test-3.pack &&
|
||||||
dd if=/dev/zero of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&
|
echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&
|
||||||
if git verify-pack test-3.idx
|
if git verify-pack test-3.idx
|
||||||
then false
|
then false
|
||||||
else :;
|
else :;
|
||||||
@ -250,7 +249,7 @@ test_expect_success \
|
|||||||
'l=`wc -c <test-3.idx` &&
|
'l=`wc -c <test-3.idx` &&
|
||||||
l=`expr $l - 20` &&
|
l=`expr $l - 20` &&
|
||||||
cat test-1-${packname_1}.pack >test-3.pack &&
|
cat test-1-${packname_1}.pack >test-3.pack &&
|
||||||
dd if=/dev/zero of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&
|
printf "%20s" "" | dd of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&
|
||||||
if git verify-pack test-3.pack
|
if git verify-pack test-3.pack
|
||||||
then false
|
then false
|
||||||
else :;
|
else :;
|
||||||
|
@ -208,7 +208,7 @@ test_expect_success \
|
|||||||
obj=`git hash-object file_001` &&
|
obj=`git hash-object file_001` &&
|
||||||
nr=`index_obj_nr ".git/objects/pack/pack-${pack1}.idx" $obj` &&
|
nr=`index_obj_nr ".git/objects/pack/pack-${pack1}.idx" $obj` &&
|
||||||
chmod +w ".git/objects/pack/pack-${pack1}.idx" &&
|
chmod +w ".git/objects/pack/pack-${pack1}.idx" &&
|
||||||
dd if=/dev/zero of=".git/objects/pack/pack-${pack1}.idx" conv=notrunc \
|
printf xxxx | dd of=".git/objects/pack/pack-${pack1}.idx" conv=notrunc \
|
||||||
bs=1 count=4 seek=$((8 + 256 * 4 + `wc -l <obj-list` * 20 + $nr * 4)) &&
|
bs=1 count=4 seek=$((8 + 256 * 4 + `wc -l <obj-list` * 20 + $nr * 4)) &&
|
||||||
( while read obj
|
( while read obj
|
||||||
do git cat-file -p $obj >/dev/null || exit 1
|
do git cat-file -p $obj >/dev/null || exit 1
|
||||||
|
@ -55,6 +55,8 @@ do_corrupt_object() {
|
|||||||
test_must_fail git verify-pack ${pack}.pack
|
test_must_fail git verify-pack ${pack}.pack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf '\0' > zero
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'initial setup validation' \
|
'initial setup validation' \
|
||||||
'create_test_files &&
|
'create_test_files &&
|
||||||
@ -66,7 +68,7 @@ test_expect_success \
|
|||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'create corruption in header of first object' \
|
'create corruption in header of first object' \
|
||||||
'do_corrupt_object $blob_1 0 < /dev/zero &&
|
'do_corrupt_object $blob_1 0 < zero &&
|
||||||
test_must_fail git cat-file blob $blob_1 > /dev/null &&
|
test_must_fail git cat-file blob $blob_1 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_3 > /dev/null'
|
test_must_fail git cat-file blob $blob_3 > /dev/null'
|
||||||
@ -125,7 +127,7 @@ test_expect_success \
|
|||||||
'create corruption in header of first delta' \
|
'create corruption in header of first delta' \
|
||||||
'create_new_pack &&
|
'create_new_pack &&
|
||||||
git prune-packed &&
|
git prune-packed &&
|
||||||
do_corrupt_object $blob_2 0 < /dev/zero &&
|
do_corrupt_object $blob_2 0 < zero &&
|
||||||
git cat-file blob $blob_1 > /dev/null &&
|
git cat-file blob $blob_1 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_3 > /dev/null'
|
test_must_fail git cat-file blob $blob_3 > /dev/null'
|
||||||
@ -180,7 +182,7 @@ test_expect_success \
|
|||||||
'corruption in delta base reference of first delta (OBJ_REF_DELTA)' \
|
'corruption in delta base reference of first delta (OBJ_REF_DELTA)' \
|
||||||
'create_new_pack &&
|
'create_new_pack &&
|
||||||
git prune-packed &&
|
git prune-packed &&
|
||||||
do_corrupt_object $blob_2 2 < /dev/zero &&
|
do_corrupt_object $blob_2 2 < zero &&
|
||||||
git cat-file blob $blob_1 > /dev/null &&
|
git cat-file blob $blob_1 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_3 > /dev/null'
|
test_must_fail git cat-file blob $blob_3 > /dev/null'
|
||||||
@ -207,7 +209,7 @@ test_expect_success \
|
|||||||
'corruption #0 in delta base reference of first delta (OBJ_OFS_DELTA)' \
|
'corruption #0 in delta base reference of first delta (OBJ_OFS_DELTA)' \
|
||||||
'create_new_pack --delta-base-offset &&
|
'create_new_pack --delta-base-offset &&
|
||||||
git prune-packed &&
|
git prune-packed &&
|
||||||
do_corrupt_object $blob_2 2 < /dev/zero &&
|
do_corrupt_object $blob_2 2 < zero &&
|
||||||
git cat-file blob $blob_1 > /dev/null &&
|
git cat-file blob $blob_1 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_3 > /dev/null'
|
test_must_fail git cat-file blob $blob_3 > /dev/null'
|
||||||
@ -259,7 +261,7 @@ test_expect_success \
|
|||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'... and a redundant pack allows for full recovery too' \
|
'... and a redundant pack allows for full recovery too' \
|
||||||
'do_corrupt_object $blob_2 2 < /dev/zero &&
|
'do_corrupt_object $blob_2 2 < zero &&
|
||||||
git cat-file blob $blob_1 > /dev/null &&
|
git cat-file blob $blob_1 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
test_must_fail git cat-file blob $blob_2 > /dev/null &&
|
||||||
test_must_fail git cat-file blob $blob_3 > /dev/null &&
|
test_must_fail git cat-file blob $blob_3 > /dev/null &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user