3 test_description
="Test the svn importer's input handling routines.
5 These tests exercise the line_buffer library, but their real purpose
6 is to check the assumptions that library makes of the platform's input
7 routines. Processes engaged in bi-directional communication would
8 hang if fread or fgets is too greedy.
10 While at it, check that input of newlines and null bytes are handled
15 test -n "$GIT_REMOTE_SVN_TEST_BIG_FILES" && test_set_prereq EXPENSIVE
17 generate_tens_of_lines
() {
22 while test $i -lt "$tens"
24 for j
in a b c d e f g h i j
34 : each line is
10 bytes
, including newline
&&
36 echo "$line" >expect
&&
38 if ! test_declared_prereq PIPE
40 echo >&4 "long_read_test: need to declare PIPE prerequisite"
43 tens_of_lines
=$
(($1 / 100 + 1)) &&
44 lines
=$
(($tens_of_lines * 10)) &&
45 readsize
=$
((($lines - 1) * 10 + 3)) &&
51 generate_tens_of_lines
$tens_of_lines "$line" &&
55 test-line-buffer input
<<-EOF >output &&
60 test_line_count
= $lines output
&&
61 tail -n 1 <output
>actual
&&
62 test_cmp expect actual
65 test_expect_success
'setup: have pipes?' '
73 test_expect_success
'hello world' '
75 test-line-buffer <<-\EOF >actual &&
79 test_cmp expect actual
82 test_expect_success PIPE
'0-length read, no input available' '
89 test-line-buffer input <<-\EOF >actual &&
94 test_cmp expect actual
97 test_expect_success
'0-length read, send along greeting' '
99 test-line-buffer <<-\EOF >actual &&
104 test_cmp expect actual
107 test_expect_success PIPE
'1-byte read, no input available' '
108 printf "%s" ab >expect &&
118 test-line-buffer input <<-\EOF >actual &&
123 test_cmp expect actual
126 test_expect_success PIPE
'long read (around 8192 bytes)' '
130 test_expect_success PIPE
,EXPENSIVE
'longer read (around 65536 bytes)' '
134 test_expect_success
'read from file descriptor' '
136 echo hello >expect &&
139 test-line-buffer "&4" 4<input >actual &&
140 test_cmp expect actual
143 test_expect_success
'buffer_read_string copes with null byte' '
145 q_to_nul <<-\EOF | test-line-buffer >actual &&
149 test_cmp expect actual
152 test_expect_success
'skip, copy null byte' '
153 echo Q | q_to_nul >expect &&
154 q_to_nul <<-\EOF | test-line-buffer >actual &&
160 test_cmp expect actual
163 test_expect_success
'read null byte' '
164 echo ">QhelloQ" | q_to_nul >expect &&
165 q_to_nul <<-\EOF | test-line-buffer >actual &&
169 test_cmp expect actual
172 test_expect_success
'long reads are truncated' '
174 test-line-buffer <<-\EOF >actual &&
178 test_cmp expect actual
181 test_expect_success
'long copies are truncated' '
182 printf "%s\n" "" foo >expect &&
183 test-line-buffer <<-\EOF >actual &&
189 test_cmp expect actual
192 test_expect_success
'long binary reads are truncated' '
193 echo ">foo" >expect &&
194 test-line-buffer <<-\EOF >actual &&
198 test_cmp expect actual