1 # $NetBSD: t_sdiff.sh,v 1.1 2012/03/17 16:33:15 jruoho Exp $
4 # Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 # POSSIBILITY OF SUCH DAMAGE.
32 atf_set "descr" "Checks -l, -s and -w flags"
36 atf_check -o file:$(atf_get_srcdir)/d_flags_l.out -s eq:1 \
37 sdiff -l "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2"
39 atf_check -o file:$(atf_get_srcdir)/d_flags_s.out -s eq:1 \
40 sdiff -s "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2"
42 atf_check -o file:$(atf_get_srcdir)/d_flags_w.out -s eq:1 \
43 sdiff -w 125 "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2"
49 atf_set "descr" "Checks flags -l, -s and -w combined with -I"
53 tail1="-w 125 -I .*filename.* $(atf_get_srcdir)/d_input1 $(atf_get_srcdir)/d_input2"
54 tail2="-w 125 -I .*filename.* $(atf_get_srcdir)/d_input2 $(atf_get_srcdir)/d_input1"
56 atf_check -o file:$(atf_get_srcdir)/d_iflags_a1.out -s eq:1 sdiff ${tail1}
57 atf_check -o file:$(atf_get_srcdir)/d_iflags_a2.out -s eq:1 sdiff ${tail2}
58 atf_check -o file:$(atf_get_srcdir)/d_iflags_b1.out -s eq:1 sdiff -s ${tail1}
59 atf_check -o file:$(atf_get_srcdir)/d_iflags_b2.out -s eq:1 sdiff -s ${tail2}
60 atf_check -o file:$(atf_get_srcdir)/d_iflags_c1.out -s eq:1 sdiff -l ${tail1}
61 atf_check -o file:$(atf_get_srcdir)/d_iflags_c2.out -s eq:1 sdiff -l ${tail2}
62 atf_check -o file:$(atf_get_srcdir)/d_iflags_d1.out -s eq:1 sdiff -s ${tail1}
63 atf_check -o file:$(atf_get_srcdir)/d_iflags_d2.out -s eq:1 sdiff -s ${tail2}
69 atf_set "descr" "Checks comparing files containing tabs"
73 atf_check -o file:$(atf_get_srcdir)/d_tabs.out -s eq:1 \
74 sdiff "$(atf_get_srcdir)/d_tabs1.in" "$(atf_get_srcdir)/d_tabs2.in"
80 atf_set "descr" "Checks correct handling of lines ended with tabs"
84 atf_check -o file:$(atf_get_srcdir)/d_tabends_a.out -s eq:1 \
85 sdiff -w30 "$(atf_get_srcdir)/d_tabends.in" /dev/null
87 atf_check -o file:$(atf_get_srcdir)/d_tabends_b.out -s eq:1 \
88 sdiff -w30 /dev/null "$(atf_get_srcdir)/d_tabends.in"
90 atf_check -o file:$(atf_get_srcdir)/d_tabends_c.out -s eq:1 \
91 sdiff -w19 "$(atf_get_srcdir)/d_tabends.in" /dev/null
97 atf_set "descr" "Checks interactive merging"
101 merge_tail="-o merge.out $(atf_get_srcdir)/d_input1 \
102 $(atf_get_srcdir)/d_input2 >/dev/null ; cat merge.out"
104 cp $(atf_get_srcdir)/d_input* .
106 atf_check -o file:d_input1 -x "yes l | sdiff ${merge_tail}"
107 atf_check -o file:d_input2 -x "yes r | sdiff ${merge_tail}"
109 atf_check -o file:d_input1 -x \
110 "yes el | EDITOR=cat VISUAL=cat sdiff ${merge_tail}"
111 atf_check -o file:d_input2 -x \
112 "yes er | EDITOR=cat VISUAL=cat sdiff ${merge_tail}"
114 atf_check -o file:d_input1 -x "yes l | sdiff -s ${merge_tail}"
115 atf_check -o file:d_input2 -x "yes r | sdiff -s ${merge_tail}"
116 atf_check -o file:d_input1 -x "yes l | sdiff -l ${merge_tail}"
117 atf_check -o file:d_input2 -x "yes r | sdiff -l ${merge_tail}"
118 atf_check -o file:d_input1 -x "yes l | sdiff -ls ${merge_tail}"
119 atf_check -o file:d_input2 -x "yes r | sdiff -ls ${merge_tail}"
121 atf_check -o file:d_input1 -x "{ while :; do echo s; echo l; \
122 echo v; echo l; done; } | sdiff ${merge_tail}"
124 atf_check -o file:d_input2 -x "{ while :; do echo s; echo r; \
125 echo v; echo r; done; } | sdiff ${merge_tail}"
131 atf_set "descr" "Checks comparing file with itself"
135 atf_check -o file:$(atf_get_srcdir)/d_same.out \
136 sdiff "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input1"
139 atf_test_case oneline
142 atf_set "descr" "Checks comparing one-line files"
146 atf_check -o file:$(atf_get_srcdir)/d_oneline_a.out -s eq:1 \
147 sdiff /dev/null "$(atf_get_srcdir)/d_oneline.in"
149 atf_check -o file:$(atf_get_srcdir)/d_oneline_b.out -s eq:1 \
150 sdiff "$(atf_get_srcdir)/d_oneline.in" /dev/null
156 atf_set "descr" "Checks comparing with file containing only one character"
161 atf_check -o file:expout -s eq:1 sdiff "$(atf_get_srcdir)/d_dot.in" /dev/null
164 atf_check -o file:expout -s eq:1 sdiff /dev/null "$(atf_get_srcdir)/d_dot.in"
170 atf_set "descr" "Checks reading data from stdin"
174 echo " > stdin" > expout
175 atf_check -o file:expout -s eq:1 -x \
176 "echo stdin | sdiff /dev/null /dev/stdin"
178 echo "stdin <" > expout
179 atf_check -o file:expout -s eq:1 -x \
180 "echo stdin | sdiff /dev/stdin /dev/null"
186 atf_set "descr" "Checks premature stop of merging"
190 atf_check -o file:$(atf_get_srcdir)/d_short.out -x \
191 "printf \"r\\nl\\nr\\nl\" | sdiff -o merge.out $(atf_get_srcdir)/d_input1 \
192 $(atf_get_srcdir)/d_input2 >/dev/null ; cat merge.out"
195 atf_init_test_cases()
197 atf_add_test_case flags
198 atf_add_test_case iflags
199 atf_add_test_case tabs
200 atf_add_test_case tabends
201 atf_add_test_case merge
202 atf_add_test_case same
203 atf_add_test_case oneline
204 atf_add_test_case dot
205 atf_add_test_case stdin
206 atf_add_test_case short