test-all-template1
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
源码类别:

通讯编程

开发平台:

Visual C++

  1. #! /bin/sh
  2. #
  3. # Copyright (c) 1995 The Regents of the University of California.
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions
  8. # are met:
  9. # 1. Redistributions of source code must retain the above copyright
  10. #    notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. #    notice, this list of conditions and the following disclaimer in the
  13. #    documentation and/or other materials provided with the distribution.
  14. # 3. All advertising materials mentioning features or use of this software
  15. #    must display the following acknowledgement:
  16. # This product includes software developed by the Network Research
  17. # Group at Lawrence Berkeley National Laboratory.
  18. # 4. Neither the name of the University nor of the Laboratory may be used
  19. #    to endorse or promote products derived from this software without
  20. #    specific prior written permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. # SUCH DAMAGE.
  33. #
  34. # @(#) $Header: /cvsroot/nsnam/ns-2/tcl/test/test-all-template1,v 1.38 2007/06/11 00:51:15 tom_henderson Exp $
  35. #
  36. # The initial version of this script was written and contributed 
  37. # by Matt Mathis (mathis@psc.edu).
  38. #
  39. file=$1; shift
  40. directory=$1; shift
  41. version=$1; shift
  42. if test "$version" = "v2"; then
  43. tests=`awk '/^Class Test//{ print substr($2,index($2, "/")+1) }' $file`
  44. else
  45. tests=`awk '/^proc test_/{ print substr($2,index($2, "_")+1) }' $file`
  46. fi
  47. quiet=false
  48. new=false
  49. alltests=true
  50. case $# in
  51. quiet|QUIET) quiet=true;;
  52. esac
  53. # echo "num=$#, args $@"
  54. while test $# -ge 1
  55. do
  56. case $1 in
  57. quiet|QUIET) quiet=true;;
  58. new|NEW) new=true;;
  59. *) alltests=false; tlist="$tlist $1";;
  60. esac
  61. shift
  62. done
  63. test="$@"
  64. datafile="temp.rands"
  65. NS=${NS:-../../ns}
  66. if $alltests
  67. then
  68. :
  69. else
  70. tests=$tlist
  71. fi
  72. if [ ! -d $directory ]; then
  73. if $new
  74. then
  75. mkdir $directory
  76. else
  77. echo "no saved test output.  do cvs update -d"
  78. echo "or re-run your test with "new" as the last argument."
  79. exit 1
  80. fi
  81. fi
  82. echo Tests: $tests
  83. success="true"
  84. number=0
  85. for t in $tests; do
  86.     # Beware that xgraph is run asynchronously, and if it
  87.     # is slow to launch, you may get an incorrect graph
  88.     sleep 1
  89.     if $quiet
  90.     then
  91. qflag="QUIET"
  92.     else
  93. qflag=""
  94.     fi
  95.     echo Running test $t:
  96.     echo $NS $file $t $qflag
  97.     case $file in
  98.     *-session.tcl | *-mixmode.tcl)
  99. $NS $file $t > temp.rands ;;
  100.     *-mpls.tcl | *-webtraf.tcl | *-message.tcl)
  101. $NS $file $t $qflag > temp.rands ;;
  102.     *)
  103. $NS $file $t $qflag ;;
  104.     esac
  105.     if test $? = 2 ; then 
  106. echo "Test not implemented"
  107. continue
  108.     fi
  109.     if [ -f $datafile ]; then
  110. if [ ! -f $directory/$t.gz ]; then
  111.     echo saving output for future validation
  112.     success="unknown"
  113.     cp $datafile $datafile.bk; gzip -f $datafile  
  114.     cp $datafile.bk $datafile
  115.     mv $datafile.gz $directory/$t.gz
  116. else
  117.             # OLD: gzip -dc $directory/$t.gz | cmp -s - $datafile
  118.             # Deleted because it is not supported in Mac OS X, for "cmp".
  119.     gzip -dc $directory/$t.gz > temp.randsgz
  120.             cmp -s temp.randsgz $datafile
  121.     if [ $? = 0 ]; then
  122. echo Test output agrees with reference output
  123.     else
  124. echo Test output differs from reference output
  125. success="false"
  126. cp $datafile $directory/$t.test
  127. gzip -dc $directory/$t.gz > $directory/$t
  128. echo "Diagnose with: diff $directory/$t.test $directory/$t"
  129. echo "Or see URL "http://www.isi.edu/nsnam/ns/ns-problems.html"."
  130.     fi
  131.  fi
  132.     else
  133. success="unknown"
  134.     fi
  135.     if $quiet
  136.     then
  137. :
  138.     else
  139.         echo 'next?'
  140.         read answer
  141.     fi
  142. done
  143. # sucess can be true, false, or unknown
  144. if test "$success" = true; then
  145. echo All test output agrees with reference output.
  146. exit 0
  147. else
  148. echo Some test failed.
  149. exit 1
  150. fi