multi_test.sh (167547) | multi_test.sh (167549) |
---|---|
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 167547 2007-03-14 10:10:10Z dds $ | 33# $FreeBSD: head/tools/regression/usr.bin/sed/multitest.t 167549 2007-03-14 11:03:00Z dds $ |
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 41 --- 57 unchanged lines hidden (view full) --- 99 echo "Test $1:$MARK" >&5 100} 101 102test_args() 103{ 104 mark '1.1' 105 echo Testing argument parsing 106 echo First type | 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 41 --- 57 unchanged lines hidden (view full) --- 99 echo "Test $1:$MARK" >&5 100} 101 102test_args() 103{ 104 mark '1.1' 105 echo Testing argument parsing 106 echo First type |
107 if [ $SUN -eq 1 ] ; then 108 echo SunOS sed prints only with -n 109 else 110 $SED 's/^/e1_/p' lines1 111 fi | 107 $SED 's/^/e1_/p' lines1 |
112 mark '1.2' ; $SED -n 's/^/e1_/p' lines1 113 mark '1.3' | 108 mark '1.2' ; $SED -n 's/^/e1_/p' lines1 109 mark '1.3' |
114 if [ $SUN -eq 1 ] ; then 115 echo SunOS sed prints only with -n 116 else 117 $SED 's/^/e1_/p' <lines1 118 fi | 110 $SED 's/^/e1_/p' <lines1 |
119 mark '1.4' ; $SED -n 's/^/e1_/p' <lines1 120 echo Second type 121 mark '1.4.1' | 111 mark '1.4' ; $SED -n 's/^/e1_/p' <lines1 112 echo Second type 113 mark '1.4.1' |
122 if [ $SUN -eq 1 ] ; then 123 echo SunOS sed fails this 124 fi | |
125 $SED -e '' <lines1 126 echo 's/^/s1_/p' >script1 127 echo 's/^/s2_/p' >script2 128 mark '1.5' | 114 $SED -e '' <lines1 115 echo 's/^/s1_/p' >script1 116 echo 's/^/s2_/p' >script2 117 mark '1.5' |
129 if [ $SUN -eq 1 ] ; then 130 echo SunOS sed prints only with -n 131 else 132 $SED -f script1 lines1 133 fi | 118 $SED -f script1 lines1 |
134 mark '1.6' | 119 mark '1.6' |
135 if [ $SUN -eq 1 ] ; then 136 echo SunOS sed prints only with -n 137 else 138 $SED -f script1 <lines1 139 fi | 120 $SED -f script1 <lines1 |
140 mark '1.7' | 121 mark '1.7' |
141 if [ $SUN -eq 1 ] ; then 142 echo SunOS sed prints only with -n 143 else 144 $SED -e 's/^/e1_/p' lines1 145 fi | 122 $SED -e 's/^/e1_/p' lines1 |
146 mark '1.8' | 123 mark '1.8' |
147 if [ $SUN -eq 1 ] ; then 148 echo SunOS sed prints only with -n 149 else 150 $SED -e 's/^/e1_/p' <lines1 151 fi | 124 $SED -e 's/^/e1_/p' <lines1 |
152 mark '1.9' ; $SED -n -f script1 lines1 153 mark '1.10' ; $SED -n -f script1 <lines1 154 mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1 155 mark '1.12' | 125 mark '1.9' ; $SED -n -f script1 lines1 126 mark '1.10' ; $SED -n -f script1 <lines1 127 mark '1.11' ; $SED -n -e 's/^/e1_/p' lines1 128 mark '1.12' |
156 if [ $SUN -eq 1 ] ; then 157 echo SunOS sed prints only with -n 158 else 159 $SED -n -e 's/^/e1_/p' <lines1 160 fi | 129 $SED -n -e 's/^/e1_/p' <lines1 |
161 mark '1.13' | 130 mark '1.13' |
162 if [ $SUN -eq 1 ] ; then 163 echo SunOS sed prints only with -n 164 else 165 $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1 166 fi | 131 $SED -e 's/^/e1_/p' -e 's/^/e2_/p' lines1 |
167 mark '1.14' | 132 mark '1.14' |
168 if [ $SUN -eq 1 ] ; then 169 echo SunOS sed prints only with -n 170 else 171 $SED -f script1 -f script2 lines1 172 fi | 133 $SED -f script1 -f script2 lines1 |
173 mark '1.15' 174 if [ $SUN -eq 1 ] ; then 175 echo SunOS sed fails this following older POSIX draft 176 else 177 $SED -e 's/^/e1_/p' -f script1 lines1 178 fi 179 mark '1.16' | 134 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 mark '1.16' |
180 if [ $SUN -eq 1 ] ; then 181 echo SunOS sed prints only with -n 182 else 183 $SED -e 's/^/e1_/p' lines1 lines1 184 fi | 141 $SED -e 's/^/e1_/p' lines1 lines1 |
185 # POSIX D11.2:11251 186 mark '1.17' ; $SED p <lines1 lines1 187cat >script1 <<EOF 188#n 189# A comment 190 191p 192EOF --- 87 unchanged lines hidden (view full) --- 2808c\ 281hello 282' lines1 283 mark '4.6' ; $SED -n -e ' 2843,14c\ 285hello 286' lines1 287# SunOS and GNU sed behave differently. We follow POSIX | 142 # POSIX D11.2:11251 143 mark '1.17' ; $SED p <lines1 lines1 144cat >script1 <<EOF 145#n 146# A comment 147 148p 149EOF --- 87 unchanged lines hidden (view full) --- 2378c\ 238hello 239' lines1 240 mark '4.6' ; $SED -n -e ' 2413,14c\ 242hello 243' lines1 244# SunOS and GNU sed behave differently. We follow POSIX |
288# mark '4.7' ; $SED -n -e ' 289#8,3c\ 290#hello 291#' lines1 | 245 mark '4.7' ; $SED -n -e ' 2468,3c\ 247hello 248' lines1 |
292 mark '4.8' ; $SED d <lines1 293} 294 295test_branch() 296{ 297 echo Testing labels and branching 298 mark '5.1' ; $SED -n -e ' 299b label4 --- 14 unchanged lines hidden (view full) --- 314 mark '5.2' 315 $SED -n -e ' 316s/l1_/l2_/ 317t ok 318b 319:ok 320s/^/tested /p 321' lines1 lines2 | 249 mark '4.8' ; $SED d <lines1 250} 251 252test_branch() 253{ 254 echo Testing labels and branching 255 mark '5.1' ; $SED -n -e ' 256b label4 --- 14 unchanged lines hidden (view full) --- 271 mark '5.2' 272 $SED -n -e ' 273s/l1_/l2_/ 274t ok 275b 276:ok 277s/^/tested /p 278' lines1 lines2 |
322# SunOS sed behaves differently here. Clarification needed. 323# mark '5.3' ; $SED -n -e ' 324#5,8b inside 325#1,5 { 326# s/^/^/p 327# :inside 328# s/$/$/p 329#} 330#' lines1 | 279# SunOS and GNU sed behave differently here. Clarification needed. 280 mark '5.3' ; $SED -n -e ' 2815,8b inside 2821,5 { 283 s/^/^/p 284 :inside 285 s/$/$/p 286} 287' lines1 |
331# Check that t clears the substitution done flag 332 mark '5.4' ; $SED -n -e ' 3331,8s/^/^/ 334t l1 335:l1 336t l2 337s/$/$/p 338b --- 32 unchanged lines hidden (view full) --- 371c\ 372changed 373p 374' lines1 375 mark '6.2' ; $SED -n -e ' 3764d 377p 378' lines1 | 288# Check that t clears the substitution done flag 289 mark '5.4' ; $SED -n -e ' 2901,8s/^/^/ 291t l1 292:l1 293t l2 294s/$/$/p 295b --- 32 unchanged lines hidden (view full) --- 328c\ 329changed 330p 331' lines1 332 mark '6.2' ; $SED -n -e ' 3334d 334p 335' lines1 |
379# SunOS sed refused to print here 380# mark '6.3' ; $SED -e ' 381#N 382#N 383#N 384#D 385#P 386#4p 387#' lines1 | 336 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 |
388 mark '6.4' ; $SED -e ' 3892h 3903H 3914g 3925G 3936x 3946p 3956x --- 22 unchanged lines hidden (view full) --- 418 mark '7.7' 419 sed '200q' $DICT | sed 's$.*$s/^/&/w tmpdir/&$' >script1 420 rm -rf tmpdir 421 mkdir tmpdir 422 $SED -f script1 lines1 423 cat tmpdir/* 424 rm -rf tmpdir 425 mark '7.8' | 342 mark '6.4' ; $SED -e ' 3432h 3443H 3454g 3465G 3476x 3486p 3496x --- 22 unchanged lines hidden (view full) --- 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' |
426 if [ $GNU -eq 1 ] ; then 427 echo GNU sed cannot pass 7.8 | 380 if [ $BSD -eq 1 ] ; then 381 echo BSD sed cannot pass 7.8 |
428 else 429 echo line1 > lines3 430 echo "" >> lines3 431 $SED -n -e '$p' lines3 /dev/null 432 fi 433 434} 435 436test_subst() 437{ 438 echo Testing substitution commands 439 mark '8.1' ; $SED -e 's/./X/g' lines1 440 mark '8.2' ; $SED -e 's,.,X,g' lines1 | 382 else 383 echo line1 > lines3 384 echo "" >> lines3 385 $SED -n -e '$p' lines3 /dev/null 386 fi 387 388} 389 390test_subst() 391{ 392 echo Testing substitution commands 393 mark '8.1' ; $SED -e 's/./X/g' lines1 394 mark '8.2' ; $SED -e 's,.,X,g' lines1 |
441# GNU and SunOS sed thinks we are escaping . as wildcard, not as separator 442# mark '8.3' ; $SED -e 's.\..X.g' lines1 443# POSIX does not say that this should work 444# mark '8.4' ; $SED -e 's/[/]/Q/' lines1 | 395# SunOS sed thinks we are escaping . as wildcard, not as separator 396 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 |
445 mark '8.4' ; $SED -e 's/[\/]/Q/' lines1 446 mark '8.5' ; $SED -e 's_\__X_' lines1 447 mark '8.6' ; $SED -e 's/./(&)/g' lines1 448 mark '8.7' ; $SED -e 's/./(\&)/g' lines1 449 mark '8.8' ; $SED -e 's/\(.\)\(.\)\(.\)/x\3x\2x\1/g' lines1 450 mark '8.9' ; $SED -e 's/_/u0\ 451u1\ 452u2/g' lines1 453 mark '8.10' 454 $SED -e 's/./X/4' lines1 455 rm -f lines4 456 mark '8.11' ; $SED -e 's/1/X/w lines4' lines1 457 echo s wfile results 458 cat lines4 459 mark '8.12' ; $SED -e 's/[123]/X/g' lines1 460 mark '8.13' ; $SED -e 'y/0123456789/9876543210/' lines1 461 mark '8.14' ; | 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 414 echo 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' ; |
462 if [ $SUN -eq 1 ] ; then 463 echo SUN sed fails this test 464 else 465 $SED -e 'y10\123456789198765432\101' lines1 466 fi | 419 $SED -e 'y10\123456789198765432\101' lines1 |
467 mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1 468 mark '8.16' 469 echo 'eeefff' | $SED -e ' 470 p 471 s/e/X/p 472 :x 473 s//Y/p 474 # Establish limit counter in the hold space 475 # GNU sed version 3.02 enters into an infinite loop here 476 x 477 /.\{10\}/ { 478 s/.*/ERROR/ 479 b 480 } 481 s/.*/&./ 482 x 483 /f/bx 484 ' | 420 mark '8.15' ; $SED -e '1N;2y/\n/X/' lines1 421 mark '8.16' 422 echo 'eeefff' | $SED -e ' 423 p 424 s/e/X/p 425 :x 426 s//Y/p 427 # Establish limit counter in the hold space 428 # GNU sed version 3.02 enters into an infinite loop here 429 x 430 /.\{10\}/ { 431 s/.*/ERROR/ 432 b 433 } 434 s/.*/&./ 435 x 436 /f/bx 437 ' |
438 # POSIX does not say that this should work, 439 # but it does for GNU, BSD, and SunOS 440 mark '8.17' ; $SED -e 's/[/]/Q/' lines1 |
|
485} 486 487test_error() 488{ 489 exec 0>&3 4>&1 5>&2 490 exec 0</dev/null 491 exec 2>&1 492 set -x --- 35 unchanged lines hidden --- | 441} 442 443test_error() 444{ 445 exec 0>&3 4>&1 5>&2 446 exec 0</dev/null 447 exec 2>&1 448 set -x --- 35 unchanged lines hidden --- |