Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/regress/usr.bin/sort use shell functions instead of dynamica...



details:   https://anonhg.NetBSD.org/src/rev/5c3a617fb310
branches:  trunk
changeset: 502108:5c3a617fb310
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Jan 11 22:10:27 2001 +0000

description:
use shell functions instead of dynamically created external scripts
warn when test is skipped due to missing feature

diffstat:

 regress/usr.bin/sort/stests |  100 ++++++++++++++++++++++++++++---------------
 1 files changed, 64 insertions(+), 36 deletions(-)

diffs (177 lines):

diff -r 4a5e02dfce9e -r 5c3a617fb310 regress/usr.bin/sort/stests
--- a/regress/usr.bin/sort/stests       Thu Jan 11 22:07:53 2001 +0000
+++ b/regress/usr.bin/sort/stests       Thu Jan 11 22:10:27 2001 +0000
@@ -1,5 +1,6 @@
+#! /bin/sh
 #      @(#)stests      8.1 (Berkeley) 6/6/93
-#      $NetBSD: stests,v 1.2 2000/11/06 14:42:40 jdolecek Exp $
+#      $NetBSD: stests,v 1.3 2001/01/11 22:10:27 jdolecek Exp $
 
 # This code is derived from software contributed to Berkeley by
 # Peter McIlroy.
@@ -37,27 +38,50 @@
 # errors.  Set switches accordingly.
 
 echo obsolescent and nonstandard features recognized, if any:
-if sort +0 </dev/null 2>/dev/null; then o=
-                               echo '  +1 -2'; fi
-if sort /dev/null -o xx 2>/dev/null; then o=
-                               echo '  displaced -o'; fi
-if sort -g </dev/null 2>/dev/null; then g=
-                               echo '  -g g-format numbers'; fi
-if sort -M </dev/null 2>/dev/null; then M=
-                               echo '  -M months'; fi
-if sort -s </dev/null 2>/dev/null; then s=
-                               echo '  -s stable'; fi
-if sort -y10000 </dev/null 2>/dev/null; then y=-y10000
-                               echo '  -y space'; fi
+if sort +0 </dev/null 2>/dev/null; then
+       o=
+       echo '  +1 -2'
+else
+       o="not_tested +POS/-POS"
+fi
+if sort /dev/null -o xx 2>/dev/null; then
+       o=
+       echo '  displaced -o';
+else
+       o="not_tested displaced_-o"
+fi
+if sort -g </dev/null 2>/dev/null; then
+       g=
+       echo '  -g g-format numbers';
+else
+       g="not_tested -g"
+fi
+if sort -M </dev/null 2>/dev/null; then
+       M=
+       echo '  -M months';
+else
+       M="not_tested -M"
+fi
+if sort -s </dev/null 2>/dev/null; then
+       s=
+       echo '  -s stable';
+else
+       s="not_tested -s"
+fi
+if sort -y10000 </dev/null 2>/dev/null; then
+       y=-y10000
+       echo '  -y space';
+fi
 if sort -z10000 </dev/null 2>/dev/null; then
-                               echo '  -z size (not exercised)'; fi
+       echo '  -z size (not exercised)';
+fi
 if sort -T. </dev/null 2>/dev/null; then
-                               echo '  -T tempdir (not exercised)'; fi
+       echo '  -T tempdir (not exercised)';
+fi
 
+TEST=          # major sequence number of test
 
-export TEST    # major sequence number of test
-
-trap "rm -f in in1 out xx -k xsort linecount fields; exit" 0 1 2 13 15
+trap "rm -f in in1 out xx -k fields; exit" 0 1 2 13 15
 
 # xsort testno options
 # Sort file "in" with specified options.
@@ -68,35 +92,37 @@
 #      order of lines within a file.
 #      System V sum is suitable; sum -5 is the v10 equivalent.
 
-PATH=.:$PATH
-export PATH
-cat <<'!' >xsort; chmod +x xsort
-
-       X=$1; shift
+xsort () {
+       X="$1"
+       shift
 
        if sort "$@" in >xx  &&  sort -c "$@" xx 
        then 
                if test -f out
                then
-                       cmp xx out >/dev/null && exit 0
+                       cmp xx out >/dev/null && return 0
                        echo $TEST$X comparison failed
                else
-                       test "`cksum -o2 <in`" = "`cksum -o2 <xx`" && exit 0
+                       test "`cksum -o2 <in`" = "`cksum -o2 <xx`" && return 0
                        echo $TEST$X checksum failed
                fi
        else
-               echo $TEST$X failed
+               echo "$TEST$X failed"
        fi
-       exit 1
-!
+       return 1
+}
 
 # linecount testno file count
 # declares the given "testno" to be in error if number of
 # lines in "file" differs from "count"
+linecount() {
+       awk 'END{ if(NR!='$3') print "'$TEST$1' failed" }' $2
+}
 
-cat <<'!' >linecount; chmod +x linecount
-awk 'END{ if(NR!='$3') print "'$TEST$1' failed" }' $2
-!
+# print info about skipped test
+not_tested() {
+       echo "$TEST$X skipped - flag '$1' not present"
+}
 
 rm -f out
 
@@ -459,7 +485,7 @@
        run(013, 0377); }
 !
 cc xx.c
-a.out >in
+./a.out >in
 cat <<! >xx.c
 run(i,j){ for( ; i<=j; i++) printf("%.3o %c\n",i,i); }
 main(){ run(0, 011);
@@ -468,7 +494,9 @@
        run(' ', 0176); }
 !
 cc xx.c
-a.out >out
+./a.out >out
+cp in in.roo
+cp out out.roo
 
 xsort A -i -k 2
 
@@ -487,7 +515,7 @@
        run('a', 'z'); }
 !
 cc xx.c
-a.out >out
+./a.out >out
 
 xsort B -d -k 2
 
@@ -502,7 +530,7 @@
        run('z'+1, 0377); }
 !
 cc xx.c
-a.out >out
+./a.out >out
 rm xx.c
 
 xsort C -f -k 2
@@ -534,7 +562,7 @@
 main() { printf("%cb\n%ca\n",0,0); }
 !
 cc xx.c
-a.out >in
+./a.out >in
 sort in >xx
 cmp in xx >/dev/null && echo ${TEST}A failed
 test "`wc -c <in`" = "`wc -c <xx`" || echo ${TEST}B failed



Home | Main Index | Thread Index | Old Index