summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-07-28 13:18:00 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-07-28 13:18:00 -0700
commit5bae9272220ce25d170e35c3cb84bcc110685363 (patch)
tree1b3b5b8f41e70f7927fe51369b899aefad9f9bda /t/test-lib-functions.sh
parentMerge branch 'jk/t0000-subtests-fix' (diff)
parenttest-lib-functions: use test-tool for [de]packetize() (diff)
downloadtgif-5bae9272220ce25d170e35c3cb84bcc110685363.tar.xz
Merge branch 'ab/pkt-line-tests'
Tests that cover protocol bits have been updated and helpers used there have been consolidated. * ab/pkt-line-tests: test-lib-functions: use test-tool for [de]packetize()
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh38
1 files changed, 8 insertions, 30 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index ce41596514..e28411bb75 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1479,46 +1479,24 @@ nongit () {
)
} 7>&2 2>&4
-# convert function arguments or stdin (if not arguments given) to pktline
-# representation. If multiple arguments are given, they are separated by
-# whitespace and put in a single packet. Note that data containing NULs must be
-# given on stdin, and that empty input becomes an empty packet, not a flush
-# packet (for that you can just print 0000 yourself).
+# These functions are historical wrappers around "test-tool pkt-line"
+# for older tests. Use "test-tool pkt-line" itself in new tests.
packetize () {
if test $# -gt 0
then
packet="$*"
printf '%04x%s' "$((4 + ${#packet}))" "$packet"
else
- perl -e '
- my $packet = do { local $/; <STDIN> };
- printf "%04x%s", 4 + length($packet), $packet;
- '
+ test-tool pkt-line pack
fi
}
-# Parse the input as a series of pktlines, writing the result to stdout.
-# Sideband markers are removed automatically, and the output is routed to
-# stderr if appropriate.
-#
-# NUL bytes are converted to "\\0" for ease of parsing with text tools.
+packetize_raw () {
+ test-tool pkt-line pack-raw-stdin
+}
+
depacketize () {
- perl -e '
- while (read(STDIN, $len, 4) == 4) {
- if ($len eq "0000") {
- print "FLUSH\n";
- } else {
- read(STDIN, $buf, hex($len) - 4);
- $buf =~ s/\0/\\0/g;
- if ($buf =~ s/^[\x2\x3]//) {
- print STDERR $buf;
- } else {
- $buf =~ s/^\x1//;
- print $buf;
- }
- }
- }
- '
+ test-tool pkt-line unpack
}
# Converts base-16 data into base-8. The output is given as a sequence of