diff options
Diffstat (limited to 't')
-rw-r--r-- | t/helper/test-genzeros.c | 21 | ||||
-rw-r--r-- | t/helper/test-tool.c | 1 | ||||
-rw-r--r-- | t/helper/test-tool.h | 1 | ||||
-rwxr-xr-x | t/t1300-config.sh | 1 | ||||
-rwxr-xr-x | t/t5318-commit-graph.sh | 2 | ||||
-rwxr-xr-x | t/t5562-http-backend-content-length.sh | 12 | ||||
-rwxr-xr-x | t/t6120-describe.sh | 8 | ||||
-rw-r--r-- | t/test-lib-functions.sh | 8 |
8 files changed, 36 insertions, 18 deletions
diff --git a/t/helper/test-genzeros.c b/t/helper/test-genzeros.c new file mode 100644 index 0000000000..9532f5bac9 --- /dev/null +++ b/t/helper/test-genzeros.c @@ -0,0 +1,21 @@ +#include "test-tool.h" +#include "git-compat-util.h" + +int cmd__genzeros(int argc, const char **argv) +{ + long count; + + if (argc > 2) { + fprintf(stderr, "usage: %s [<count>]\n", argv[0]); + return 1; + } + + count = argc > 1 ? strtol(argv[1], NULL, 0) : -1L; + + while (count < 0 || count--) { + if (putchar(0) == EOF) + return -1; + } + + return 0; +} diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 50c55f8b1a..99db7409b8 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -19,6 +19,7 @@ static struct test_cmd cmds[] = { { "dump-untracked-cache", cmd__dump_untracked_cache }, { "example-decorate", cmd__example_decorate }, { "genrandom", cmd__genrandom }, + { "genzeros", cmd__genzeros }, { "hashmap", cmd__hashmap }, { "hash-speed", cmd__hash_speed }, { "index-version", cmd__index_version }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index a563df49bf..25abed1cf2 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -16,6 +16,7 @@ int cmd__dump_split_index(int argc, const char **argv); int cmd__dump_untracked_cache(int argc, const char **argv); int cmd__example_decorate(int argc, const char **argv); int cmd__genrandom(int argc, const char **argv); +int cmd__genzeros(int argc, const char **argv); int cmd__hashmap(int argc, const char **argv); int cmd__hash_speed(int argc, const char **argv); int cmd__index_version(int argc, const char **argv); diff --git a/t/t1300-config.sh b/t/t1300-config.sh index 9652b241c7..428177c390 100755 --- a/t/t1300-config.sh +++ b/t/t1300-config.sh @@ -892,6 +892,7 @@ test_expect_success 'get --expiry-date' ' 1510348087 0 EOF + : "work around heredoc parsing bug fixed in dash 0.5.7 (in ec2c84d)" && { echo "$rel_out $(git config --expiry-date date.valid1)" git config --expiry-date date.valid2 && diff --git a/t/t5318-commit-graph.sh b/t/t5318-commit-graph.sh index d4bd1522fe..561796f280 100755 --- a/t/t5318-commit-graph.sh +++ b/t/t5318-commit-graph.sh @@ -382,7 +382,7 @@ corrupt_graph_and_verify() { test_when_finished mv commit-graph-backup $objdir/info/commit-graph && 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 of="$objdir/info/commit-graph" bs=1 seek="$zero_pos" if=/dev/null && 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 && diff --git a/t/t5562-http-backend-content-length.sh b/t/t5562-http-backend-content-length.sh index bbadde2c6e..f0f425b2cf 100755 --- a/t/t5562-http-backend-content-length.sh +++ b/t/t5562-http-backend-content-length.sh @@ -8,12 +8,12 @@ test_lazy_prereq GZIP 'gzip --version' verify_http_result() { # some fatal errors still produce status 200 # so check if there is the error message - if grep 'fatal:' act.err + if grep 'fatal:' act.err.$test_count then return 1 fi - if ! grep "Status" act.out >act + if ! grep "Status" act.out.$test_count >act then printf "Status: 200 OK\r\n" >act fi @@ -33,7 +33,7 @@ test_http_env() { REQUEST_METHOD=POST \ "$PERL_PATH" \ "$TEST_DIRECTORY"/t5562/invoke-with-content-length.pl \ - "$request_body" git http-backend >act.out 2>act.err + "$request_body" git http-backend >act.out.$test_count 2>act.err.$test_count } ssize_b100dots() { @@ -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) && - generate_zero_bytes infinity | env \ + 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/null 2>err && + git http-backend </dev/null >/dev/null 2>err && grep "fatal:.*CONTENT_LENGTH" err ' @@ -161,7 +161,7 @@ test_expect_success 'empty CONTENT_LENGTH' ' GIT_HTTP_EXPORT_ALL=TRUE \ REQUEST_METHOD=GET \ CONTENT_LENGTH="" \ - git http-backend <empty_body >act.out 2>act.err && + git http-backend <empty_body >act.out.$test_count 2>act.err.$test_count && verify_http_result "200 OK" ' diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index ee5b03ee18..2b883d8174 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -146,7 +146,7 @@ check_describe A-* HEAD test_expect_success 'describe works from outside repo using --git-dir' ' git clone --bare "$TRASH_DIRECTORY" "$TRASH_DIRECTORY/bare" && git --git-dir "$TRASH_DIRECTORY/bare" describe >out && - grep "^A-[1-9][0-9]\?-g[0-9a-f]\+$" out + grep -E "^A-[1-9][0-9]?-g[0-9a-f]+$" out ' check_describe "A-*[0-9a-f]" --dirty @@ -156,7 +156,7 @@ test_expect_success 'describe --dirty with --work-tree' ' cd "$TEST_DIRECTORY" && git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty >"$TRASH_DIRECTORY/out" ) && - grep "^A-[1-9][0-9]\?-g[0-9a-f]\+$" out + grep -E "^A-[1-9][0-9]?-g[0-9a-f]+$" out ' test_expect_success 'set-up dirty work tree' ' @@ -170,7 +170,7 @@ test_expect_success 'describe --dirty with --work-tree (dirty)' ' cd "$TEST_DIRECTORY" && git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty >"$TRASH_DIRECTORY/out" ) && - grep "^A-[1-9][0-9]\?-g[0-9a-f]\+-dirty$" out + grep -E "^A-[1-9][0-9]?-g[0-9a-f]+-dirty$" out ' check_describe "A-*[0-9a-f].mod" --dirty=.mod @@ -180,7 +180,7 @@ test_expect_success 'describe --dirty=.mod with --work-tree (dirty)' ' cd "$TEST_DIRECTORY" && git --git-dir "$TRASH_DIRECTORY/.git" --work-tree "$TRASH_DIRECTORY" describe --dirty=.mod >"$TRASH_DIRECTORY/out" ) && - grep "^A-[1-9][0-9]\?-g[0-9a-f]\+.mod$" out + grep -E "^A-[1-9][0-9]?-g[0-9a-f]+.mod$" out ' test_expect_success 'describe --dirty HEAD' ' diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 094c07748a..80402a428f 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -120,13 +120,7 @@ remove_cr () { # 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] - }' "$@" + test-tool genzeros "$@" } # In some bourne shell implementations, the "unset" builtin returns |