Deleted Added
full compact
multi_test.sh (167549) multi_test.sh (167552)
1#!/bin/sh -
2#
3# Copyright (c) 1992 Diomidis Spinellis.
4# Copyright (c) 1992, 1993
5# The Regents of the University of California. All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29# SUCH DAMAGE.
30#
31# @(#)sed.test 8.1 (Berkeley) 6/6/93
32#
1#!/bin/sh -
2#
3# Copyright (c) 1992 Diomidis Spinellis.
4# Copyright (c) 1992, 1993
5# The Regents of the University of California. All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29# SUCH DAMAGE.
30#
31# @(#)sed.test 8.1 (Berkeley) 6/6/93
32#
33# $FreeBSD: head/tools/regression/usr.bin/sed/multitest.t 167549 2007-03-14 11:03:00Z dds $
33# $FreeBSD: head/tools/regression/usr.bin/sed/multitest.t 167552 2007-03-14 13:05:45Z dds $
34#
35
36# sed Regression Tests
37#
34#
35
36# sed Regression Tests
37#
38# The following files are created:
39# lines[1-4], script1, script2
40# Two directories *.out contain the test results
38# The directory regress.test.out contains the expected test results
39#
40# These are the regression tests created during the development of the
41# BSD sed. The reference file naming scheme used in this script can't
42# handle gracefully the insertion of new tests between existing ones.
43# Therefore, either use the new m4-based regress.t framework, or add
44# tests after the last existing test.
41
42main()
43{
45
46main()
47{
44 #BASE=/usr/bin/sed
45 BASE=/usr/ports/textproc/gsed/work/sed-4.1.5/sed/sed
46 BASELOG=sed.out
47 #TEST=`cd ..; make whereobj`/sed
48 TEST=/home/dds/src/fbsd-head/sed/sed
49 TESTLOG=nsed.out
48 REGRESS=regress.multitest.out
50 DICT=/usr/share/dict/words
51
52 #test_error | more
53
54 awk 'END { for (i = 1; i < 15; i++) print "l1_" i}' </dev/null >lines1
55 awk 'END { for (i = 1; i < 10; i++) print "l2_" i}' </dev/null >lines2
56
49 DICT=/usr/share/dict/words
50
51 #test_error | more
52
53 awk 'END { for (i = 1; i < 15; i++) print "l1_" i}' </dev/null >lines1
54 awk 'END { for (i = 1; i < 10; i++) print "l2_" i}' </dev/null >lines2
55
57 exec 4>&1 5>&2
56 echo "1..90"
58
57
59 # Set these flags to get messages about known problems
60 BSD=0
61 GNU=1
62 SUN=0
63 tests $BASE $BASELOG
64
65 BSD=1
66 GNU=0
67 SUN=0
68 tests $TEST $TESTLOG
58 exec 4>&1 5>&2
59 tests
69 exec 1>&4 2>&5
60 exec 1>&4 2>&5
70 diff -c $BASELOG $TESTLOG | more
61
62 # Remove temporary files
63 rm -f current.out lines[1-4] script[1-2]
71}
72
73tests()
74{
64}
65
66tests()
67{
75 SED=$1
76 DIR=$2
77 rm -rf $DIR
78 mkdir $DIR
79 MARK=100
68 SED=sed
69 MARK=0
80
81 test_args
82 test_addr
70
71 test_args
72 test_addr
83 echo Testing commands
84 test_group
85 test_acid
86 test_branch
87 test_pattern
88 test_print
89 test_subst
73 test_group
74 test_acid
75 test_branch
76 test_pattern
77 test_print
78 test_subst
79 # Handle the result of the last test
80 result
90}
91
81}
82
83# Display a test's result
84result()
85{
86 if [ "$TODO" = '1' ] ; then
87 TODO='TODO '
88 else
89 TODO=''
90 fi
91 if diff -c $REGRESS/${MARK}_${TESTNAME} current.out ; then
92 echo "ok $MARK $TESTNAME # $TODO$COMMENT"
93 else
94 echo "not ok $MARK $TESTNAME # $TODO$COMMENT"
95 fi 1>&4 2>&5
96}
97
98# Mark the beginning of each test
92mark()
93{
99mark()
100{
101 [ $MARK -gt 0 ] && result
94 MARK=`expr $MARK + 1`
102 MARK=`expr $MARK + 1`
103 TESTNAME=$1
95 exec 1>&4 2>&5
104 exec 1>&4 2>&5
96 exec >"$DIR/${MARK}_$1"
97 echo "Test $1:$MARK"
98 # Uncomment this line to match tests with sed error messages
99 echo "Test $1:$MARK" >&5
105 exec >"current.out"
100}
101
102test_args()
103{
106}
107
108test_args()
109{
110 COMMENT='Argument parsing - first type'
104 mark '1.1'
111 mark '1.1'
105 echo Testing argument parsing
106 echo First type
107 $SED 's/^/e1_/p' lines1
108 mark '1.2' ; $SED -n 's/^/e1_/p' lines1
109 mark '1.3'
110 $SED 's/^/e1_/p' <lines1
111 mark '1.4' ; $SED -n 's/^/e1_/p' <lines1
112 $SED 's/^/e1_/p' lines1
113 mark '1.2' ; $SED -n 's/^/e1_/p' lines1
114 mark '1.3'
115 $SED 's/^/e1_/p' <lines1
116 mark '1.4' ; $SED -n 's/^/e1_/p' <lines1
112 echo Second type
117 COMMENT='Argument parsing - second type'
113 mark '1.4.1'
114 $SED -e '' <lines1
115 echo 's/^/s1_/p' >script1
116 echo 's/^/s2_/p' >script2
117 mark '1.5'
118 $SED -f script1 lines1
119 mark '1.6'
120 $SED -f script1 <lines1

--- 6 unchanged lines hidden (view full) ---

127 mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1
128 mark '1.12'
129 $SED -n -e 's/^/e1_/p' <lines1
130 mark '1.13'
131 $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1
132 mark '1.14'
133 $SED -f script1 -f script2 lines1
134 mark '1.15'
118 mark '1.4.1'
119 $SED -e '' <lines1
120 echo 's/^/s1_/p' >script1
121 echo 's/^/s2_/p' >script2
122 mark '1.5'
123 $SED -f script1 lines1
124 mark '1.6'
125 $SED -f script1 <lines1

--- 6 unchanged lines hidden (view full) ---

132 mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1
133 mark '1.12'
134 $SED -n -e 's/^/e1_/p' <lines1
135 mark '1.13'
136 $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1
137 mark '1.14'
138 $SED -f script1 -f script2 lines1
139 mark '1.15'
135 if [ $SUN -eq 1 ] ; then
136 echo SunOS sed fails this following older POSIX draft
137 else
138 $SED -e 's/^/e1_/p' -f script1 lines1
139 fi
140 $SED -e 's/^/e1_/p' -f script1 lines1
140 mark '1.16'
141 $SED -e 's/^/e1_/p' lines1 lines1
142 # POSIX D11.2:11251
143 mark '1.17' ; $SED p <lines1 lines1
144cat >script1 <<EOF
145#n
146# A comment
147
148p
149EOF
150 mark '1.18' ; $SED -f script1 <lines1 lines1
151}
152
153test_addr()
154{
141 mark '1.16'
142 $SED -e 's/^/e1_/p' lines1 lines1
143 # POSIX D11.2:11251
144 mark '1.17' ; $SED p <lines1 lines1
145cat >script1 <<EOF
146#n
147# A comment
148
149p
150EOF
151 mark '1.18' ; $SED -f script1 <lines1 lines1
152}
153
154test_addr()
155{
155 echo Testing address ranges
156 COMMENT='Address ranges'
156 mark '2.1' ; $SED -n -e '4p' lines1
157 mark '2.2' ; $SED -n -e '20p' lines1 lines2
158 mark '2.3' ; $SED -n -e '$p' lines1
159 mark '2.4' ; $SED -n -e '$p' lines1 lines2
160 mark '2.5' ; $SED -n -e '$a\
161hello' /dev/null
162 mark '2.6' ; $SED -n -e '$p' lines1 /dev/null lines2
163 # Should not print anything

--- 10 unchanged lines hidden (view full) ---

174 mark '2.17' ; $SED -n '/4/,/10/p' lines1 lines2
175 mark '2.18' ; $SED -n '/l2_3/,/l1_8/p' lines1 lines2
176 mark '2.19' ; $SED -n '12,3p' lines1 lines2
177 mark '2.20' ; $SED -n '/l1_7/,3p' lines1 lines2
178}
179
180test_group()
181{
157 mark '2.1' ; $SED -n -e '4p' lines1
158 mark '2.2' ; $SED -n -e '20p' lines1 lines2
159 mark '2.3' ; $SED -n -e '$p' lines1
160 mark '2.4' ; $SED -n -e '$p' lines1 lines2
161 mark '2.5' ; $SED -n -e '$a\
162hello' /dev/null
163 mark '2.6' ; $SED -n -e '$p' lines1 /dev/null lines2
164 # Should not print anything

--- 10 unchanged lines hidden (view full) ---

175 mark '2.17' ; $SED -n '/4/,/10/p' lines1 lines2
176 mark '2.18' ; $SED -n '/l2_3/,/l1_8/p' lines1 lines2
177 mark '2.19' ; $SED -n '12,3p' lines1 lines2
178 mark '2.20' ; $SED -n '/l1_7/,3p' lines1 lines2
179}
180
181test_group()
182{
182 echo Brace and other grouping
183 COMMENT='Brace and other grouping'
183 mark '3.1' ; $SED -e '
1844,12 {
185 s/^/^/
186 s/$/$/
187 s/_/T/
188}' lines1
189 mark '3.2' ; $SED -e '
1904,12 {

--- 11 unchanged lines hidden (view full) ---

202 /8/ !s/_/T/
203 }
204}' lines1
205 mark '3.4' ; $SED -e '4,12!s/^/^/' lines1
206}
207
208test_acid()
209{
184 mark '3.1' ; $SED -e '
1854,12 {
186 s/^/^/
187 s/$/$/
188 s/_/T/
189}' lines1
190 mark '3.2' ; $SED -e '
1914,12 {

--- 11 unchanged lines hidden (view full) ---

203 /8/ !s/_/T/
204 }
205}' lines1
206 mark '3.4' ; $SED -e '4,12!s/^/^/' lines1
207}
208
209test_acid()
210{
210 echo Testing a c d and i commands
211 COMMENT='Commands a c d and i'
211 mark '4.1' ; $SED -n -e '
212s/^/before_i/p
21320i\
214inserted
215s/^/after_i/p
216' lines1 lines2
217 mark '4.2' ; $SED -n -e '
2185,12s/^/5-12/

--- 27 unchanged lines hidden (view full) ---

2468,3c\
247hello
248' lines1
249 mark '4.8' ; $SED d <lines1
250}
251
252test_branch()
253{
212 mark '4.1' ; $SED -n -e '
213s/^/before_i/p
21420i\
215inserted
216s/^/after_i/p
217' lines1 lines2
218 mark '4.2' ; $SED -n -e '
2195,12s/^/5-12/

--- 27 unchanged lines hidden (view full) ---

2478,3c\
248hello
249' lines1
250 mark '4.8' ; $SED d <lines1
251}
252
253test_branch()
254{
254 echo Testing labels and branching
255 COMMENT='Labels and branching'
255 mark '5.1' ; $SED -n -e '
256b label4
257:label3
258s/^/label3_/p
259b end
260:label4
2612,12b label1
262b label2

--- 54 unchanged lines hidden (view full) ---

317:b
318}
319s/l/m/
320tb' lines1
321}
322
323test_pattern()
324{
256 mark '5.1' ; $SED -n -e '
257b label4
258:label3
259s/^/label3_/p
260b end
261:label4
2622,12b label1
263b label2

--- 54 unchanged lines hidden (view full) ---

318:b
319}
320s/l/m/
321tb' lines1
322}
323
324test_pattern()
325{
325echo Pattern space commands
326COMMENT='Pattern space commands'
326# Check that the pattern space is deleted
327 mark '6.1' ; $SED -n -e '
328c\
329changed
330p
331' lines1
332 mark '6.2' ; $SED -n -e '
3334d
334p
335' lines1
336 mark '6.3'
327# Check that the pattern space is deleted
328 mark '6.1' ; $SED -n -e '
329c\
330changed
331p
332' lines1
333 mark '6.2' ; $SED -n -e '
3344d
335p
336' lines1
337 mark '6.3'
337 if [ $GNU -eq 1 ] ; then
338 echo GNU sed cannot pass 6.3
339 else
340 $SED -e 'N;N;N;D' lines1
341 fi
338 $SED -e 'N;N;N;D' lines1
342 mark '6.4' ; $SED -e '
3432h
3443H
3454g
3465G
3476x
3486p
3496x
3506p
351' lines1
352 mark '6.5' ; $SED -e '4n' lines1
353 mark '6.6' ; $SED -n -e '4n' lines1
354}
355
356test_print()
357{
339 mark '6.4' ; $SED -e '
3402h
3413H
3424g
3435G
3446x
3456p
3466x
3476p
348' lines1
349 mark '6.5' ; $SED -e '4n' lines1
350 mark '6.6' ; $SED -n -e '4n' lines1
351}
352
353test_print()
354{
358 echo Testing print and file routines
355 COMMENT='Print and file routines'
359 awk 'END {for (i = 1; i < 256; i++) printf("%c", i);print "\n"}' \
360 </dev/null >lines3
361 # GNU and SunOS sed behave differently here
362 mark '7.1'
363 $SED -n l lines3
364 mark '7.2' ; $SED -e '/l2_/=' lines1 lines2
365 rm -f lines4
366 mark '7.3' ; $SED -e '3,12w lines4' lines1
356 awk 'END {for (i = 1; i < 256; i++) printf("%c", i);print "\n"}' \
357 </dev/null >lines3
358 # GNU and SunOS sed behave differently here
359 mark '7.1'
360 $SED -n l lines3
361 mark '7.2' ; $SED -e '/l2_/=' lines1 lines2
362 rm -f lines4
363 mark '7.3' ; $SED -e '3,12w lines4' lines1
367 echo w results
364 COMMENT='w results'
368 cat lines4
369 mark '7.4' ; $SED -e '4r lines2' lines1
370 mark '7.5' ; $SED -e '5r /dev/dds' lines1
371 mark '7.6' ; $SED -e '6r /dev/null' lines1
372 mark '7.7'
373 sed '200q' $DICT | sed 's$.*$s/^/&/w tmpdir/&$' >script1
374 rm -rf tmpdir
375 mkdir tmpdir
376 $SED -f script1 lines1
377 cat tmpdir/*
378 rm -rf tmpdir
379 mark '7.8'
365 cat lines4
366 mark '7.4' ; $SED -e '4r lines2' lines1
367 mark '7.5' ; $SED -e '5r /dev/dds' lines1
368 mark '7.6' ; $SED -e '6r /dev/null' lines1
369 mark '7.7'
370 sed '200q' $DICT | sed 's$.*$s/^/&/w tmpdir/&$' >script1
371 rm -rf tmpdir
372 mkdir tmpdir
373 $SED -f script1 lines1
374 cat tmpdir/*
375 rm -rf tmpdir
376 mark '7.8'
380 if [ $BSD -eq 1 ] ; then
381 echo BSD sed cannot pass 7.8
382 else
383 echo line1 > lines3
384 echo "" >> lines3
385 $SED -n -e '$p' lines3 /dev/null
386 fi
377 echo line1 > lines3
378 echo "" >> lines3
379 TODO=1
380 $SED -n -e '$p' lines3 /dev/null
387
388}
389
390test_subst()
391{
381
382}
383
384test_subst()
385{
392 echo Testing substitution commands
386 COMMENT='Substitution commands'
393 mark '8.1' ; $SED -e 's/./X/g' lines1
394 mark '8.2' ; $SED -e 's,.,X,g' lines1
395# SunOS sed thinks we are escaping . as wildcard, not as separator
396 mark '8.3'
387 mark '8.1' ; $SED -e 's/./X/g' lines1
388 mark '8.2' ; $SED -e 's,.,X,g' lines1
389# SunOS sed thinks we are escaping . as wildcard, not as separator
390 mark '8.3'
397 if [ $SUN -eq 1 ] ; then
398 echo SUN sed fails test 8.3
399 else
400 $SED -e 's.\..X.g' lines1
401 fi
391 $SED -e 's.\..X.g' lines1
402 mark '8.4' ; $SED -e 's/[\/]/Q/' lines1
403 mark '8.5' ; $SED -e 's_\__X_' lines1
404 mark '8.6' ; $SED -e 's/./(&)/g' lines1
405 mark '8.7' ; $SED -e 's/./(\&)/g' lines1
406 mark '8.8' ; $SED -e 's/\(.\)\(.\)\(.\)/x\3x\2x\1/g' lines1
407 mark '8.9' ; $SED -e 's/_/u0\
408u1\
409u2/g' lines1
410 mark '8.10'
411 $SED -e 's/./X/4' lines1
412 rm -f lines4
413 mark '8.11' ; $SED -e 's/1/X/w lines4' lines1
392 mark '8.4' ; $SED -e 's/[\/]/Q/' lines1
393 mark '8.5' ; $SED -e 's_\__X_' lines1
394 mark '8.6' ; $SED -e 's/./(&)/g' lines1
395 mark '8.7' ; $SED -e 's/./(\&)/g' lines1
396 mark '8.8' ; $SED -e 's/\(.\)\(.\)\(.\)/x\3x\2x\1/g' lines1
397 mark '8.9' ; $SED -e 's/_/u0\
398u1\
399u2/g' lines1
400 mark '8.10'
401 $SED -e 's/./X/4' lines1
402 rm -f lines4
403 mark '8.11' ; $SED -e 's/1/X/w lines4' lines1
414 echo s wfile results
404 COMMENT='s wfile results'
415 cat lines4
416 mark '8.12' ; $SED -e 's/[123]/X/g' lines1
417 mark '8.13' ; $SED -e 'y/0123456789/9876543210/' lines1
418 mark '8.14' ;
419 $SED -e 'y10\123456789198765432\101' lines1
420 mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1
421 mark '8.16'
422 echo 'eeefff' | $SED -e '

--- 61 unchanged lines hidden ---
405 cat lines4
406 mark '8.12' ; $SED -e 's/[123]/X/g' lines1
407 mark '8.13' ; $SED -e 'y/0123456789/9876543210/' lines1
408 mark '8.14' ;
409 $SED -e 'y10\123456789198765432\101' lines1
410 mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1
411 mark '8.16'
412 echo 'eeefff' | $SED -e '

--- 61 unchanged lines hidden ---