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 167544 2007-03-14 09:05:41Z 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 42main() 43{ |
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 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 57 exec 4>&1 5>&2 58 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 69 exec 1>&4 2>&5 70 diff -c $BASELOG $TESTLOG | more 71} 72 73tests() --- 92 unchanged lines hidden (view full) --- 166 fi 167 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 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' 180 if [ $SUN -eq 1 ] ; then 181 echo SunOS sed prints only with -n 182 else 183 $SED -e 's/^/e1_/p' lines1 lines1 --- 19 unchanged lines hidden (view full) --- 203 mark '2.5' ; $SED -n -e '$a\ 204hello' /dev/null 205 mark '2.6' ; $SED -n -e '$p' lines1 /dev/null lines2 206 # Should not print anything 207 mark '2.7' ; $SED -n -e '20p' lines1 208 mark '2.8' ; $SED -n -e '0p' lines1 209 mark '2.9' ; $SED -n '/l1_7/p' lines1 210 mark '2.10' ; $SED -n ' /l1_7/ p' lines1 |
211 mark '2.11' ; $SED -n '\_l1\_7_p' lines1 |
212 mark '2.12' ; $SED -n '1,4p' lines1 213 mark '2.13' ; $SED -n '1,$p' lines1 lines2 214 mark '2.14' ; $SED -n '1,/l2_9/p' lines1 lines2 215 mark '2.15' ; $SED -n '/4/,$p' lines1 lines2 216 mark '2.16' ; $SED -n '/4/,20p' lines1 lines2 217 mark '2.17' ; $SED -n '/4/,/10/p' lines1 lines2 218 mark '2.18' ; $SED -n '/l2_3/,/l1_8/p' lines1 lines2 |
219 mark '2.19' ; $SED -n '12,3p' lines1 lines2 220 mark '2.20' ; $SED -n '/l1_7/,3p' lines1 lines2 |
221} 222 223test_group() 224{ 225 echo Brace and other grouping 226 mark '3.1' ; $SED -e ' 2274,12 { 228 s/^/^/ --- 31 unchanged lines hidden (view full) --- 260 mark '4.2' ; $SED -n -e ' 2615,12s/^/5-12/ 262s/^/before_a/p 263/5-12/a\ 264appended 265s/^/after_a/p 266' lines1 lines2 267 mark '4.3' |
268 $SED -n -e ' 269s/^/^/p 270/l1_/a\ 271appended 2728,10N 273s/$/$/p 274' lines1 lines2 275 mark '4.4' ; $SED -n -e ' --- 31 unchanged lines hidden (view full) --- 307s/^/label1_/p 308b 309:label2 310s/^/label2_/p 311b label3 312:end 313' lines1 314 mark '5.2' |
315 $SED -n -e ' 316s/l1_/l2_/ 317t ok 318b 319:ok 320s/^/tested /p 321' lines1 lines2 322# SunOS sed behaves differently here. Clarification needed. --- 13 unchanged lines hidden (view full) --- 336t l2 337s/$/$/p 338b 339:l2 340s/^/ERROR/ 341' lines1 342# Check that reading a line clears the substitution done flag 343 mark '5.5' |
344 $SED -n -e ' 345t l2 3461,8s/^/^/p 3472,7N 348b 349:l2 350s/^/ERROR/p 351' lines1 --- 59 unchanged lines hidden (view full) --- 411 rm -f lines4 412 mark '7.3' ; $SED -e '3,12w lines4' lines1 413 echo w results 414 cat lines4 415 mark '7.4' ; $SED -e '4r lines2' lines1 416 mark '7.5' ; $SED -e '5r /dev/dds' lines1 417 mark '7.6' ; $SED -e '6r /dev/null' lines1 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' 426 if [ $BSD -eq 1 ] ; then |
427 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 --- 95 unchanged lines hidden --- |