diff options
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r-- | t/test-lib-functions.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index ca40a1289f..4f7eadb596 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -976,3 +976,17 @@ test_match_signal () { fi return 1 } + +# Read up to "$1" bytes (or to EOF) from stdin and write them to stdout. +test_copy_bytes () { + perl -e ' + my $len = $ARGV[1]; + while ($len > 0) { + my $s; + my $nread = sysread(STDIN, $s, $len); + die "cannot read: $!" unless defined($nread); + print $s; + $len -= $nread; + } + ' - "$1" +} |