summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-02-14 02:18:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-02-14 02:18:43 (GMT)
commitb46221ff175286a7bab404f6f170ead2f57c4a1b (patch)
tree5e4813b2edd45f1c820f8be0d7c251b1c8799a08
parentf26493b787d6cc057e9d8280d0b1d1ddfdcb9f1c (diff)
parentcc95bc20255e5782d2133f6173609efb1f9129c7 (diff)
downloadgit-b46221ff175286a7bab404f6f170ead2f57c4a1b.zip
git-b46221ff175286a7bab404f6f170ead2f57c4a1b.tar.gz
git-b46221ff175286a7bab404f6f170ead2f57c4a1b.tar.bz2
Merge branch 'rb/no-dev-zero-in-test'
* rb/no-dev-zero-in-test: t5562: replace /dev/zero with a pipe from generate_zero_bytes t5318: replace use of /dev/zero with generate_zero_bytes test-lib-functions.sh: add generate_zero_bytes function
-rwxr-xr-xt/t5318-commit-graph.sh2
-rwxr-xr-xt/t5562-http-backend-content-length.sh4
-rw-r--r--t/test-lib-functions.sh13
3 files changed, 16 insertions, 3 deletions
diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh
index 16d10eb..d4bd152 100755
--- a/t/t5318-commit-graph.sh
+++ b/t/t5318-commit-graph.sh
@@ -383,7 +383,7 @@ corrupt_graph_and_verify() {
cp $objdir/info/commit-graph commit-graph-backup &&
printf "$data" | dd of="$objdir/info/commit-graph" bs=1 seek="$pos" conv=notrunc &&
dd of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=0 &&
- dd if=/dev/zero of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" count=$(($orig_size - $zero_pos)) &&
+ generate_zero_bytes $(($orig_size - $zero_pos)) >>"$objdir/info/commit-graph" &&
test_must_fail git commit-graph verify 2>test_err &&
grep -v "^+" test_err >err &&
test_i18ngrep "$grepstr" err
diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh
index 90d890d..bbadde2 100755
--- a/t/t5562-http-backend-content-length.sh
+++ b/t/t5562-http-backend-content-length.sh
@@ -143,14 +143,14 @@ test_expect_success GZIP 'push gzipped empty' '
test_expect_success 'CONTENT_LENGTH overflow ssite_t' '
NOT_FIT_IN_SSIZE=$(ssize_b100dots) &&
- env \
+ generate_zero_bytes infinity | env \
CONTENT_TYPE=application/x-git-upload-pack-request \
QUERY_STRING=/repo.git/git-upload-pack \
PATH_TRANSLATED="$PWD"/.git/git-upload-pack \
GIT_HTTP_EXPORT_ALL=TRUE \
REQUEST_METHOD=POST \
CONTENT_LENGTH="$NOT_FIT_IN_SSIZE" \
- git http-backend </dev/zero >/dev/null 2>err &&
+ git http-backend >/dev/null 2>err &&
grep "fatal:.*CONTENT_LENGTH" err
'
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 969e2ba..094c077 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -116,6 +116,19 @@ remove_cr () {
tr '\015' Q | sed -e 's/Q$//'
}
+# Generate an output of $1 bytes of all zeroes (NULs, not ASCII zeroes).
+# If $1 is 'infinity', output forever or until the receiving pipe stops reading,
+# whichever comes first.
+generate_zero_bytes () {
+ perl -e 'if ($ARGV[0] == "infinity") {
+ while (-1) {
+ print "\0"
+ }
+ } else {
+ print "\0" x $ARGV[0]
+ }' "$@"
+}
+
# In some bourne shell implementations, the "unset" builtin returns
# nonzero status when a variable to be unset was not set in the first
# place.