No empty .Rs/.Re
[netbsd-mini2440.git] / tests / util / sdiff / t_sdiff.sh
blob84f029f2ac69914559982af2a8809ae8e147ebaf
1 # $NetBSD$
3 # Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 atf_test_case flags
29 flags_head()
31 atf_set "descr" "Checks -l, -s and -w flags"
33 flags_body()
35 atf_check -o file:$(atf_get_srcdir)/d_flags_l.out -s eq:1 \
36 sdiff -l "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2"
38 atf_check -o file:$(atf_get_srcdir)/d_flags_s.out -s eq:1 \
39 sdiff -s "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2"
41 atf_check -o file:$(atf_get_srcdir)/d_flags_w.out -s eq:1 \
42 sdiff -w 125 "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2"
45 atf_test_case iflags
46 iflags_head()
48 atf_set "descr" "Checks flags -l, -s and -w combined with -I"
50 iflags_body()
52 tail1="-w 125 -I .*filename.* $(atf_get_srcdir)/d_input1 $(atf_get_srcdir)/d_input2"
53 tail2="-w 125 -I .*filename.* $(atf_get_srcdir)/d_input2 $(atf_get_srcdir)/d_input1"
55 atf_check -o file:$(atf_get_srcdir)/d_iflags_a1.out -s eq:1 sdiff ${tail1}
56 atf_check -o file:$(atf_get_srcdir)/d_iflags_a2.out -s eq:1 sdiff ${tail2}
57 atf_check -o file:$(atf_get_srcdir)/d_iflags_b1.out -s eq:1 sdiff -s ${tail1}
58 atf_check -o file:$(atf_get_srcdir)/d_iflags_b2.out -s eq:1 sdiff -s ${tail2}
59 atf_check -o file:$(atf_get_srcdir)/d_iflags_c1.out -s eq:1 sdiff -l ${tail1}
60 atf_check -o file:$(atf_get_srcdir)/d_iflags_c2.out -s eq:1 sdiff -l ${tail2}
61 atf_check -o file:$(atf_get_srcdir)/d_iflags_d1.out -s eq:1 sdiff -s ${tail1}
62 atf_check -o file:$(atf_get_srcdir)/d_iflags_d2.out -s eq:1 sdiff -s ${tail2}
65 atf_test_case tabs
66 tabs_head()
68 atf_set "descr" "Checks comparing files containing tabs"
70 tabs_body()
72 atf_check -o file:$(atf_get_srcdir)/d_tabs.out -s eq:1 \
73 sdiff "$(atf_get_srcdir)/d_tabs1.in" "$(atf_get_srcdir)/d_tabs2.in"
76 atf_test_case tabends
77 tabends_head()
79 atf_set "descr" "Checks correct handling of lines ended with tabs"
81 tabends_body()
83 atf_check -o file:$(atf_get_srcdir)/d_tabends_a.out -s eq:1 \
84 sdiff -w30 "$(atf_get_srcdir)/d_tabends.in" /dev/null
86 atf_check -o file:$(atf_get_srcdir)/d_tabends_b.out -s eq:1 \
87 sdiff -w30 /dev/null "$(atf_get_srcdir)/d_tabends.in"
89 atf_check -o file:$(atf_get_srcdir)/d_tabends_c.out -s eq:1 \
90 sdiff -w19 "$(atf_get_srcdir)/d_tabends.in" /dev/null
93 atf_test_case merge
94 merge_head()
96 atf_set "descr" "Checks interactive merging"
98 merge_body()
100 merge_tail="-o merge.out $(atf_get_srcdir)/d_input1 \
101 $(atf_get_srcdir)/d_input2 >/dev/null ; cat merge.out"
103 cp $(atf_get_srcdir)/d_input* .
105 atf_check -o file:d_input1 -x "yes l | sdiff ${merge_tail}"
106 atf_check -o file:d_input2 -x "yes r | sdiff ${merge_tail}"
108 atf_check -o file:d_input1 -x \
109 "yes el | EDITOR=cat VISUAL=cat sdiff ${merge_tail}"
110 atf_check -o file:d_input2 -x \
111 "yes er | EDITOR=cat VISUAL=cat sdiff ${merge_tail}"
113 atf_check -o file:d_input1 -x "yes l | sdiff -s ${merge_tail}"
114 atf_check -o file:d_input2 -x "yes r | sdiff -s ${merge_tail}"
115 atf_check -o file:d_input1 -x "yes l | sdiff -l ${merge_tail}"
116 atf_check -o file:d_input2 -x "yes r | sdiff -l ${merge_tail}"
117 atf_check -o file:d_input1 -x "yes l | sdiff -ls ${merge_tail}"
118 atf_check -o file:d_input2 -x "yes r | sdiff -ls ${merge_tail}"
120 atf_check -o file:d_input1 -x "{ while :; do echo s; echo l; \
121 echo v; echo l; done; } | sdiff ${merge_tail}"
123 atf_check -o file:d_input2 -x "{ while :; do echo s; echo r; \
124 echo v; echo r; done; } | sdiff ${merge_tail}"
127 atf_test_case same
128 same_head()
130 atf_set "descr" "Checks comparing file with itself"
132 same_body()
134 atf_check -o file:$(atf_get_srcdir)/d_same.out \
135 sdiff "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input1"
138 atf_test_case oneline
139 oneline_head()
141 atf_set "descr" "Checks comparing one-line files"
143 oneline_body()
145 atf_check -o file:$(atf_get_srcdir)/d_oneline_a.out -s eq:1 \
146 sdiff /dev/null "$(atf_get_srcdir)/d_oneline.in"
148 atf_check -o file:$(atf_get_srcdir)/d_oneline_b.out -s eq:1 \
149 sdiff "$(atf_get_srcdir)/d_oneline.in" /dev/null
152 atf_test_case dot
153 dot_head()
155 atf_set "descr" "Checks comparing with file containing only one character"
157 dot_body()
159 echo ". <" > expout
160 atf_check -o file:expout -s eq:1 sdiff "$(atf_get_srcdir)/d_dot.in" /dev/null
162 echo " > ." > expout
163 atf_check -o file:expout -s eq:1 sdiff /dev/null "$(atf_get_srcdir)/d_dot.in"
166 atf_test_case stdin
167 stdin_head()
169 atf_set "descr" "Checks reading data from stdin"
171 stdin_body()
173 echo " > stdin" > expout
174 atf_check -o file:expout -s eq:1 -x \
175 "echo stdin | sdiff /dev/null /dev/stdin"
177 echo "stdin <" > expout
178 atf_check -o file:expout -s eq:1 -x \
179 "echo stdin | sdiff /dev/stdin /dev/null"
182 atf_test_case short
183 short_head()
185 atf_set "descr" "Checks premature stop of merging"
187 short_body()
189 atf_check -o file:$(atf_get_srcdir)/d_short.out -x \
190 "printf \"r\\nl\\nr\\nl\" | sdiff -o merge.out $(atf_get_srcdir)/d_input1 \
191 $(atf_get_srcdir)/d_input2 >/dev/null ; cat merge.out"
194 atf_init_test_cases()
196 atf_add_test_case flags
197 atf_add_test_case iflags
198 atf_add_test_case tabs
199 atf_add_test_case tabends
200 atf_add_test_case merge
201 atf_add_test_case same
202 atf_add_test_case oneline
203 atf_add_test_case dot
204 atf_add_test_case stdin
205 atf_add_test_case short