2011-01-03 00:51:07 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description="Test the svn importer's input handling routines.
|
2011-01-03 01:07:16 +00:00
|
|
|
|
2011-03-30 08:11:41 +00:00
|
|
|
These tests provide some simple checks that the line_buffer API
|
|
|
|
behaves as advertised.
|
2011-01-03 01:07:16 +00:00
|
|
|
|
|
|
|
While at it, check that input of newlines and null bytes are handled
|
|
|
|
correctly.
|
2011-01-03 00:51:07 +00:00
|
|
|
"
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2011-01-03 01:07:16 +00:00
|
|
|
test_expect_success 'hello world' '
|
2011-03-25 04:09:19 +00:00
|
|
|
echo ">HELLO" >expect &&
|
2011-01-03 00:51:07 +00:00
|
|
|
test-line-buffer <<-\EOF >actual &&
|
2011-03-25 04:09:19 +00:00
|
|
|
binary 6
|
2011-01-03 00:51:07 +00:00
|
|
|
HELLO
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '0-length read, send along greeting' '
|
2011-03-25 04:09:19 +00:00
|
|
|
echo ">HELLO" >expect &&
|
2011-01-03 00:51:07 +00:00
|
|
|
test-line-buffer <<-\EOF >actual &&
|
2011-03-25 04:09:19 +00:00
|
|
|
binary 0
|
2011-01-03 00:52:28 +00:00
|
|
|
copy 6
|
2011-01-03 00:51:07 +00:00
|
|
|
HELLO
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 03:09:38 +00:00
|
|
|
test_expect_success 'read from file descriptor' '
|
|
|
|
rm -f input &&
|
|
|
|
echo hello >expect &&
|
|
|
|
echo hello >input &&
|
|
|
|
echo copy 6 |
|
|
|
|
test-line-buffer "&4" 4<input >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
2011-01-03 01:07:16 +00:00
|
|
|
|
2011-01-03 00:52:28 +00:00
|
|
|
test_expect_success 'skip, copy null byte' '
|
|
|
|
echo Q | q_to_nul >expect &&
|
2011-01-03 00:51:07 +00:00
|
|
|
q_to_nul <<-\EOF | test-line-buffer >actual &&
|
2011-01-03 00:52:28 +00:00
|
|
|
skip 2
|
|
|
|
Q
|
|
|
|
copy 2
|
2011-01-03 00:51:07 +00:00
|
|
|
Q
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 03:05:46 +00:00
|
|
|
test_expect_success 'read null byte' '
|
|
|
|
echo ">QhelloQ" | q_to_nul >expect &&
|
|
|
|
q_to_nul <<-\EOF | test-line-buffer >actual &&
|
|
|
|
binary 8
|
|
|
|
QhelloQ
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 00:51:07 +00:00
|
|
|
test_expect_success 'long reads are truncated' '
|
2011-03-25 04:09:19 +00:00
|
|
|
echo ">foo" >expect &&
|
2011-01-03 00:51:07 +00:00
|
|
|
test-line-buffer <<-\EOF >actual &&
|
2011-03-25 04:09:19 +00:00
|
|
|
binary 5
|
2011-01-03 00:51:07 +00:00
|
|
|
foo
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'long copies are truncated' '
|
2011-03-25 04:09:19 +00:00
|
|
|
printf "%s\n" ">" foo >expect &&
|
2011-01-03 00:51:07 +00:00
|
|
|
test-line-buffer <<-\EOF >actual &&
|
2011-03-25 04:09:19 +00:00
|
|
|
binary 1
|
2011-01-03 00:51:07 +00:00
|
|
|
|
|
|
|
copy 5
|
|
|
|
foo
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 03:05:46 +00:00
|
|
|
test_expect_success 'long binary reads are truncated' '
|
|
|
|
echo ">foo" >expect &&
|
|
|
|
test-line-buffer <<-\EOF >actual &&
|
|
|
|
binary 5
|
|
|
|
foo
|
|
|
|
EOF
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2011-01-03 00:51:07 +00:00
|
|
|
test_done
|