ctdb-common: Add line based I/O
[vlendec/samba-autobuild/.git] / ctdb / tests / cunit / line_test_001.sh
1 #!/bin/sh
2
3 . "${TEST_SCRIPTS_DIR}/unit.sh"
4
5 tfile="${TEST_VAR_DIR}/line.$$"
6
7 remove_files ()
8 {
9         rm -f "$tfile"
10 }
11
12 test_cleanup remove_files
13
14 > "$tfile"
15
16 ok_null
17 unit_test line_test "$tfile"
18
19 printf "\0" > "$tfile"
20
21 required_result 1 <<EOF
22
23 EOF
24
25 unit_test line_test "$tfile"
26
27 echo -n "hello" > "$tfile"
28
29 ok_null
30 unit_test line_test "$tfile"
31
32 cat <<EOF > "$tfile"
33 hello
34 world
35 EOF
36
37 required_result 2 << EOF
38 hello
39 world
40 EOF
41 unit_test line_test "$tfile"
42
43 required_result 2 << EOF
44 hello
45 world
46 EOF
47 unit_test line_test "$tfile"
48
49 cat <<EOF > "$tfile"
50 This is a really long long line full of random words and hopefully it will be read properly by the line test program and identified as a single line
51 EOF
52
53 required_result 1 <<EOF
54 This is a really long long line full of random words and hopefully it will be read properly by the line test program and identified as a single line
55 EOF
56 unit_test line_test "$tfile"
57
58 cat <<EOF > "$tfile"
59 line number one
60 line number two
61 line number one
62 line number two
63 line number one
64 EOF
65
66 required_result 5 <<EOF
67 line number one
68 line number two
69 line number one
70 line number two
71 line number one
72 EOF
73 unit_test line_test "$tfile" 64
74
75 cat <<EOF > "$tfile"
76 this is line number one
77 this is line number two
78 this is line number three
79 this is line number four
80 this is line number five
81 EOF
82
83 required_result 5 <<EOF
84 this is line number one
85 this is line number two
86 this is line number three
87 this is line number four
88 this is line number five
89 EOF
90 unit_test line_test "$tfile" 64