1*11be35a1SLionel Sambuc# $NetBSD: t_sdiff.sh,v 1.1 2012/03/17 16:33:15 jruoho Exp $ 2*11be35a1SLionel Sambuc# 3*11be35a1SLionel Sambuc# Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. 4*11be35a1SLionel Sambuc# All rights reserved. 5*11be35a1SLionel Sambuc# 6*11be35a1SLionel Sambuc# Redistribution and use in source and binary forms, with or without 7*11be35a1SLionel Sambuc# modification, are permitted provided that the following conditions 8*11be35a1SLionel Sambuc# are met: 9*11be35a1SLionel Sambuc# 1. Redistributions of source code must retain the above copyright 10*11be35a1SLionel Sambuc# notice, this list of conditions and the following disclaimer. 11*11be35a1SLionel Sambuc# 2. Redistributions in binary form must reproduce the above copyright 12*11be35a1SLionel Sambuc# notice, this list of conditions and the following disclaimer in the 13*11be35a1SLionel Sambuc# documentation and/or other materials provided with the distribution. 14*11be35a1SLionel Sambuc# 15*11be35a1SLionel Sambuc# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16*11be35a1SLionel Sambuc# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17*11be35a1SLionel Sambuc# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18*11be35a1SLionel Sambuc# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19*11be35a1SLionel Sambuc# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20*11be35a1SLionel Sambuc# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21*11be35a1SLionel Sambuc# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22*11be35a1SLionel Sambuc# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23*11be35a1SLionel Sambuc# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24*11be35a1SLionel Sambuc# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25*11be35a1SLionel Sambuc# POSSIBILITY OF SUCH DAMAGE. 26*11be35a1SLionel Sambuc# 27*11be35a1SLionel Sambuc 28*11be35a1SLionel Sambucatf_test_case flags 29*11be35a1SLionel Sambucflags_head() 30*11be35a1SLionel Sambuc{ 31*11be35a1SLionel Sambuc atf_set "descr" "Checks -l, -s and -w flags" 32*11be35a1SLionel Sambuc} 33*11be35a1SLionel Sambucflags_body() 34*11be35a1SLionel Sambuc{ 35*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_flags_l.out -s eq:1 \ 36*11be35a1SLionel Sambuc sdiff -l "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2" 37*11be35a1SLionel Sambuc 38*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_flags_s.out -s eq:1 \ 39*11be35a1SLionel Sambuc sdiff -s "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2" 40*11be35a1SLionel Sambuc 41*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_flags_w.out -s eq:1 \ 42*11be35a1SLionel Sambuc sdiff -w 125 "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input2" 43*11be35a1SLionel Sambuc} 44*11be35a1SLionel Sambuc 45*11be35a1SLionel Sambucatf_test_case iflags 46*11be35a1SLionel Sambuciflags_head() 47*11be35a1SLionel Sambuc{ 48*11be35a1SLionel Sambuc atf_set "descr" "Checks flags -l, -s and -w combined with -I" 49*11be35a1SLionel Sambuc} 50*11be35a1SLionel Sambuciflags_body() 51*11be35a1SLionel Sambuc{ 52*11be35a1SLionel Sambuc tail1="-w 125 -I .*filename.* $(atf_get_srcdir)/d_input1 $(atf_get_srcdir)/d_input2" 53*11be35a1SLionel Sambuc tail2="-w 125 -I .*filename.* $(atf_get_srcdir)/d_input2 $(atf_get_srcdir)/d_input1" 54*11be35a1SLionel Sambuc 55*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_iflags_a1.out -s eq:1 sdiff ${tail1} 56*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_iflags_a2.out -s eq:1 sdiff ${tail2} 57*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_iflags_b1.out -s eq:1 sdiff -s ${tail1} 58*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_iflags_b2.out -s eq:1 sdiff -s ${tail2} 59*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_iflags_c1.out -s eq:1 sdiff -l ${tail1} 60*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_iflags_c2.out -s eq:1 sdiff -l ${tail2} 61*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_iflags_d1.out -s eq:1 sdiff -s ${tail1} 62*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_iflags_d2.out -s eq:1 sdiff -s ${tail2} 63*11be35a1SLionel Sambuc} 64*11be35a1SLionel Sambuc 65*11be35a1SLionel Sambucatf_test_case tabs 66*11be35a1SLionel Sambuctabs_head() 67*11be35a1SLionel Sambuc{ 68*11be35a1SLionel Sambuc atf_set "descr" "Checks comparing files containing tabs" 69*11be35a1SLionel Sambuc} 70*11be35a1SLionel Sambuctabs_body() 71*11be35a1SLionel Sambuc{ 72*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_tabs.out -s eq:1 \ 73*11be35a1SLionel Sambuc sdiff "$(atf_get_srcdir)/d_tabs1.in" "$(atf_get_srcdir)/d_tabs2.in" 74*11be35a1SLionel Sambuc} 75*11be35a1SLionel Sambuc 76*11be35a1SLionel Sambucatf_test_case tabends 77*11be35a1SLionel Sambuctabends_head() 78*11be35a1SLionel Sambuc{ 79*11be35a1SLionel Sambuc atf_set "descr" "Checks correct handling of lines ended with tabs" 80*11be35a1SLionel Sambuc} 81*11be35a1SLionel Sambuctabends_body() 82*11be35a1SLionel Sambuc{ 83*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_tabends_a.out -s eq:1 \ 84*11be35a1SLionel Sambuc sdiff -w30 "$(atf_get_srcdir)/d_tabends.in" /dev/null 85*11be35a1SLionel Sambuc 86*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_tabends_b.out -s eq:1 \ 87*11be35a1SLionel Sambuc sdiff -w30 /dev/null "$(atf_get_srcdir)/d_tabends.in" 88*11be35a1SLionel Sambuc 89*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_tabends_c.out -s eq:1 \ 90*11be35a1SLionel Sambuc sdiff -w19 "$(atf_get_srcdir)/d_tabends.in" /dev/null 91*11be35a1SLionel Sambuc} 92*11be35a1SLionel Sambuc 93*11be35a1SLionel Sambucatf_test_case merge 94*11be35a1SLionel Sambucmerge_head() 95*11be35a1SLionel Sambuc{ 96*11be35a1SLionel Sambuc atf_set "descr" "Checks interactive merging" 97*11be35a1SLionel Sambuc} 98*11be35a1SLionel Sambucmerge_body() 99*11be35a1SLionel Sambuc{ 100*11be35a1SLionel Sambuc merge_tail="-o merge.out $(atf_get_srcdir)/d_input1 \ 101*11be35a1SLionel Sambuc$(atf_get_srcdir)/d_input2 >/dev/null ; cat merge.out" 102*11be35a1SLionel Sambuc 103*11be35a1SLionel Sambuc cp $(atf_get_srcdir)/d_input* . 104*11be35a1SLionel Sambuc 105*11be35a1SLionel Sambuc atf_check -o file:d_input1 -x "yes l | sdiff ${merge_tail}" 106*11be35a1SLionel Sambuc atf_check -o file:d_input2 -x "yes r | sdiff ${merge_tail}" 107*11be35a1SLionel Sambuc 108*11be35a1SLionel Sambuc atf_check -o file:d_input1 -x \ 109*11be35a1SLionel Sambuc "yes el | EDITOR=cat VISUAL=cat sdiff ${merge_tail}" 110*11be35a1SLionel Sambuc atf_check -o file:d_input2 -x \ 111*11be35a1SLionel Sambuc "yes er | EDITOR=cat VISUAL=cat sdiff ${merge_tail}" 112*11be35a1SLionel Sambuc 113*11be35a1SLionel Sambuc atf_check -o file:d_input1 -x "yes l | sdiff -s ${merge_tail}" 114*11be35a1SLionel Sambuc atf_check -o file:d_input2 -x "yes r | sdiff -s ${merge_tail}" 115*11be35a1SLionel Sambuc atf_check -o file:d_input1 -x "yes l | sdiff -l ${merge_tail}" 116*11be35a1SLionel Sambuc atf_check -o file:d_input2 -x "yes r | sdiff -l ${merge_tail}" 117*11be35a1SLionel Sambuc atf_check -o file:d_input1 -x "yes l | sdiff -ls ${merge_tail}" 118*11be35a1SLionel Sambuc atf_check -o file:d_input2 -x "yes r | sdiff -ls ${merge_tail}" 119*11be35a1SLionel Sambuc 120*11be35a1SLionel Sambuc atf_check -o file:d_input1 -x "{ while :; do echo s; echo l; \ 121*11be35a1SLionel Sambucecho v; echo l; done; } | sdiff ${merge_tail}" 122*11be35a1SLionel Sambuc 123*11be35a1SLionel Sambuc atf_check -o file:d_input2 -x "{ while :; do echo s; echo r; \ 124*11be35a1SLionel Sambucecho v; echo r; done; } | sdiff ${merge_tail}" 125*11be35a1SLionel Sambuc} 126*11be35a1SLionel Sambuc 127*11be35a1SLionel Sambucatf_test_case same 128*11be35a1SLionel Sambucsame_head() 129*11be35a1SLionel Sambuc{ 130*11be35a1SLionel Sambuc atf_set "descr" "Checks comparing file with itself" 131*11be35a1SLionel Sambuc} 132*11be35a1SLionel Sambucsame_body() 133*11be35a1SLionel Sambuc{ 134*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_same.out \ 135*11be35a1SLionel Sambuc sdiff "$(atf_get_srcdir)/d_input1" "$(atf_get_srcdir)/d_input1" 136*11be35a1SLionel Sambuc} 137*11be35a1SLionel Sambuc 138*11be35a1SLionel Sambucatf_test_case oneline 139*11be35a1SLionel Sambuconeline_head() 140*11be35a1SLionel Sambuc{ 141*11be35a1SLionel Sambuc atf_set "descr" "Checks comparing one-line files" 142*11be35a1SLionel Sambuc} 143*11be35a1SLionel Sambuconeline_body() 144*11be35a1SLionel Sambuc{ 145*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_oneline_a.out -s eq:1 \ 146*11be35a1SLionel Sambuc sdiff /dev/null "$(atf_get_srcdir)/d_oneline.in" 147*11be35a1SLionel Sambuc 148*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_oneline_b.out -s eq:1 \ 149*11be35a1SLionel Sambuc sdiff "$(atf_get_srcdir)/d_oneline.in" /dev/null 150*11be35a1SLionel Sambuc} 151*11be35a1SLionel Sambuc 152*11be35a1SLionel Sambucatf_test_case dot 153*11be35a1SLionel Sambucdot_head() 154*11be35a1SLionel Sambuc{ 155*11be35a1SLionel Sambuc atf_set "descr" "Checks comparing with file containing only one character" 156*11be35a1SLionel Sambuc} 157*11be35a1SLionel Sambucdot_body() 158*11be35a1SLionel Sambuc{ 159*11be35a1SLionel Sambuc echo ". <" > expout 160*11be35a1SLionel Sambuc atf_check -o file:expout -s eq:1 sdiff "$(atf_get_srcdir)/d_dot.in" /dev/null 161*11be35a1SLionel Sambuc 162*11be35a1SLionel Sambuc echo " > ." > expout 163*11be35a1SLionel Sambuc atf_check -o file:expout -s eq:1 sdiff /dev/null "$(atf_get_srcdir)/d_dot.in" 164*11be35a1SLionel Sambuc} 165*11be35a1SLionel Sambuc 166*11be35a1SLionel Sambucatf_test_case stdin 167*11be35a1SLionel Sambucstdin_head() 168*11be35a1SLionel Sambuc{ 169*11be35a1SLionel Sambuc atf_set "descr" "Checks reading data from stdin" 170*11be35a1SLionel Sambuc} 171*11be35a1SLionel Sambucstdin_body() 172*11be35a1SLionel Sambuc{ 173*11be35a1SLionel Sambuc echo " > stdin" > expout 174*11be35a1SLionel Sambuc atf_check -o file:expout -s eq:1 -x \ 175*11be35a1SLionel Sambuc "echo stdin | sdiff /dev/null /dev/stdin" 176*11be35a1SLionel Sambuc 177*11be35a1SLionel Sambuc echo "stdin <" > expout 178*11be35a1SLionel Sambuc atf_check -o file:expout -s eq:1 -x \ 179*11be35a1SLionel Sambuc "echo stdin | sdiff /dev/stdin /dev/null" 180*11be35a1SLionel Sambuc} 181*11be35a1SLionel Sambuc 182*11be35a1SLionel Sambucatf_test_case short 183*11be35a1SLionel Sambucshort_head() 184*11be35a1SLionel Sambuc{ 185*11be35a1SLionel Sambuc atf_set "descr" "Checks premature stop of merging" 186*11be35a1SLionel Sambuc} 187*11be35a1SLionel Sambucshort_body() 188*11be35a1SLionel Sambuc{ 189*11be35a1SLionel Sambuc atf_check -o file:$(atf_get_srcdir)/d_short.out -x \ 190*11be35a1SLionel Sambuc "printf \"r\\nl\\nr\\nl\" | sdiff -o merge.out $(atf_get_srcdir)/d_input1 \ 191*11be35a1SLionel Sambuc$(atf_get_srcdir)/d_input2 >/dev/null ; cat merge.out" 192*11be35a1SLionel Sambuc} 193*11be35a1SLionel Sambuc 194*11be35a1SLionel Sambucatf_init_test_cases() 195*11be35a1SLionel Sambuc{ 196*11be35a1SLionel Sambuc atf_add_test_case flags 197*11be35a1SLionel Sambuc atf_add_test_case iflags 198*11be35a1SLionel Sambuc atf_add_test_case tabs 199*11be35a1SLionel Sambuc atf_add_test_case tabends 200*11be35a1SLionel Sambuc atf_add_test_case merge 201*11be35a1SLionel Sambuc atf_add_test_case same 202*11be35a1SLionel Sambuc atf_add_test_case oneline 203*11be35a1SLionel Sambuc atf_add_test_case dot 204*11be35a1SLionel Sambuc atf_add_test_case stdin 205*11be35a1SLionel Sambuc atf_add_test_case short 206*11be35a1SLionel Sambuc} 207