1
0
mirror of https://github.com/git/git synced 2024-06-30 22:54:27 +00:00
git/t/t5704-protocol-violations.sh
Junio C Hamano 6789275d37 tests: teach callers of test_i18ngrep to use test_grep
They are equivalents and the former still exists, so as long as the
only change this commit makes are to rewrite test_i18ngrep to
test_grep, there won't be any new bug, even if there still are
callers of test_i18ngrep remaining in the tree, or when merged to
other topics that add new uses of test_i18ngrep.

This patch was produced more or less with

    git grep -l -e 'test_i18ngrep ' 't/t[0-9][0-9][0-9][0-9]-*.sh' |
    xargs perl -p -i -e 's/test_i18ngrep /test_grep /'

and a good way to sanity check the result yourself is to run the
above in a checkout of c4603c1c (test framework: further deprecate
test_i18ngrep, 2023-10-31) and compare the resulting working tree
contents with the result of applying this patch to the same commit.
You'll see that test_i18ngrep in a few t/lib-*.sh files corrected,
in addition to the manual reproduction.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-11-02 17:13:44 +09:00

53 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
test_description='Test responses to violations of the network protocol. In most
of these cases it will generally be acceptable for one side to break off
communications if the other side says something unexpected. We are mostly
making sure that we do not segfault or otherwise behave badly.'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'extra delim packet in v2 ls-refs args' '
{
packetize command=ls-refs &&
packetize "object-format=$(test_oid algo)" &&
printf 0001 &&
# protocol expects 0000 flush here
printf 0001
} >input &&
test_must_fail env GIT_PROTOCOL=version=2 \
git upload-pack . <input 2>err &&
test_grep "expected flush after ls-refs arguments" err
'
test_expect_success 'extra delim packet in v2 fetch args' '
{
packetize command=fetch &&
packetize "object-format=$(test_oid algo)" &&
printf 0001 &&
# protocol expects 0000 flush here
printf 0001
} >input &&
test_must_fail env GIT_PROTOCOL=version=2 \
git upload-pack . <input 2>err &&
test_grep "expected flush after fetch arguments" err
'
test_expect_success 'bogus symref in v0 capabilities' '
test_commit foo &&
oid=$(git rev-parse HEAD) &&
dst=refs/heads/foo &&
{
printf "%s HEAD\0symref object-format=%s symref=HEAD:%s\n" \
"$oid" "$GIT_DEFAULT_HASH" "$dst" |
test-tool pkt-line pack-raw-stdin &&
printf "0000"
} >input &&
git ls-remote --symref --upload-pack="cat input; read junk;:" . >actual &&
printf "ref: %s\tHEAD\n%s\tHEAD\n" "$dst" "$oid" >expect &&
test_cmp expect actual
'
test_done