Debian Codegraph @

bin/ktest-all

raw symbols SCIP
1 #! /bin/sh
2 # script to run all tests in test-suite.tcl
3 #
4 # Copyright (c) 1995 The Regents of the University of California.
5 # 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
9 # are met:
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
15 # 3. All advertising materials mentioning features or use of this software
16 # must display the following acknowledgement:
17 # This product includes software developed by the Network Research
18 # Group at Lawrence Berkeley National Laboratory.
19 # 4. Neither the name of the University nor of the Laboratory may be used
20 # to endorse or promote products derived from this software without
21 # specific prior written permission.
22 #
23 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 # SUCH DAMAGE.
34 #
35 # @(#) $Header: /cvsroot/nsnam/ns-2/bin/ktest-all,v 1.6 1997/09/11 00:50:51 heideman Exp $
36 #
37 # This script was written and contributed by Matt Mathis ([email protected])
38 # This script was later hacked extensively by Kannan to build the rtglib
39 # test suites. The script has been renamed to reflet this extensive hacking.
40 # -- Kannan ([email protected]) Mon Apr 28 10:44:11 PDT 1997
41 #
42 PROG=`basename $0`
43
44 # Compress raw trace files for storage.
45 COMPRESSP=:
46
47 if [ $# -ge 1 ] ; then
48 TESTSUITE=tcl/test/test-suite-$1
49 shift
50 else
51 TESTSUITE=tcl/test/test-suite-routed
52 fi
53
54 old_tests=`perl -ane 'm.^proc test_. &&
55 print substr($F[1], index($F[1], "_")+1), " "' $TESTSUITE.tcl`
56 new_tests=`perl -ane 'm.^Class Test/. &&
57 print substr($F[1], index($F[1], "/")+1), " "' $TESTSUITE.tcl`
58 top=`perl -ane 'm.^Class Topology/. &&
59 print substr($F[1], index($F[1], "/")+1), " "' tcl/test/topologies.tcl`
60
61 if [ -n "$old_tests" -a -n "$new_tests" ] ; then
62 echo "$PROG: warning $TESTSUITE.tcl mixes old and new test suites" 2>&1
63 echo "$PROG: ignore old tests" 2>&1
64 old_tests=
65 fi
66
67 if [ $# -ge 1 ] ; then
68 tests="$@"
69 else
70 tests="$old_tests $new_tests"
71 fi
72 topologies=${top:-X}
73
74 # Note that the telnet test includes random source behavior - its output
75 # is not currently repeatable from run to run
76
77 if [ ! -d test-output-raw ]; then
78 mkdir test-output-raw
79 fi
80
81 compare() {
82 if [ -f all.tr ]
83 then
84 file=`perl -ane '$F[2] =~ s/test_// ; $F[2] =~ s/_/-/g; print $F[2]; exit' out.tr`
85 # if echo $file | grep : >/dev/null ; then
86 # file=`echo $file | sed 's/^[a-zA-Z0-9_]*:\(.*\)/'$1':\1/'`
87 # fi
88 if [ -f test-output-raw/$file.gz ]
89 then
90 gunzip test-output-raw/$file.gz
91 fi
92 COMPRESS=$COMPRESSP
93 if [ ! -f test-output-raw/$file ]
94 then
95 echo saving output to $file for future validation
96 cp all.tr test-output-raw/$file
97 else
98 cmp -s all.tr test-output-raw/$file
99 if [ $? = 0 ]
100 then
101 echo Test output agrees with reference output "($file)"
102 else
103 echo Test output differs from reference output "($file)"
104 DIFFCMD="diff test-output-raw/$file.test test-output-raw/$file"
105 if [ `diff test-output-raw/$file all.tr | wc -l` -le 10 ]
106 then
107 echo "output of $DIFFCMD"
108 diff -c all.tr test-output-raw/$file
109 fi
110 cp all.tr test-output-raw/$file.test
111 echo "Diagnose with: $DIFFCMD"
112 COMPRESS=false
113 fi
114 fi
115 if [ -n "$DISPLAY" ] ; then
116 raw2xg -s 0.01 -m 90 out.tr | xgraph &
117 sleep 5
118 else
119 if [ ! -d ps-files ] ; then
120 mkdir ps-files
121 fi
122 if raw2gp -g -a -s 0.01 -m 90 out.tr | gnuplot ; then
123 egrep BoundingBox $file.ps > ps-files/$file.bb
124 gzip $file.ps
125 mv $file.ps.gz ps-files
126 rm -f packets drops link-fails link-recovery
127 fi
128 fi
129 if ${COMPRESS} ; then
130 gzip test-output-raw/$file
131 fi
132 else
133 echo "Test $1 did not run over topology $2. Continuing..."
134 fi
135 }
136
137 #
138
139 echo $tests
140 for t in $tests; do
141 for p in $topologies; do
142 echo
143 echo -n Running test: ./ns $TESTSUITE.tcl $t
144 case $p in
145 X) p=""; echo "" ;;
146 *) echo " $p" ;;
147 esac
148
149 # Beware that xgraph is run on temp.rands asynchronously, if it
150 # is slow to launch, you may get an incorrect graph
151 rm -f all.tr out.tr core
152 ./ns $TESTSUITE.tcl $t $p && compare $t $p
153 if [ -f core ] ; then
154 if [ ! -d crash ] ; then
155 mkdir crash
156 fi
157 mv core crash/$t:$p.core
158 echo Core dump moved to crash/$t:$p.core
159 fi
160 done
161 if [ -n "$DISPLAY" ] ; then
162 echo 'next?'
163 read answer
164 fi
165 done