home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dbmalloc.zip / Runtests < prev    next >
Text File  |  1993-01-04  |  4KB  |  156 lines

  1. #!/bin/sh
  2. #
  3. #
  4. # (c) Copyright 1990, 1991, 1992 Conor P. Cahill (cpcahil@virtech.vti.com)
  5. #
  6. # This software may be distributed freely as long as the following conditions
  7. # are met:
  8. #         * the distribution, or any derivative thereof, may not be
  9. #          included as part of a commercial product
  10. #        * full source code is provided including this copyright
  11. #        * there is no charge for the software itself (there may be
  12. #          a minimal charge for the copying or distribution effort)
  13. #        * this copyright notice is not modified or removed from any
  14. #          source file
  15. #
  16. # $Id: Runtests,v 1.13 1992/08/22 16:27:13 cpcahil Exp $
  17. #
  18. # This shell attempts to run all of the tests distributed with the
  19. # malloc library and detmine if they pass.
  20. #
  21. # The following tests are processed
  22. #
  23. #    testmem        - test str* and mem* functions
  24. #    teststack    - test stack mechanism
  25. #    testmalloc    - test malloc routines
  26. #    testerr        - test error conditions
  27. #
  28.  
  29. #
  30. # before we run any tests, lets make sure we have the programs that
  31. # we intend to test
  32. #
  33.  
  34. if [ ! -r testmem -o ! -r teststack -o ! -r testmalloc -o ! -r testerr ]; then
  35.  
  36.     echo "All of the test programs are not available.  Pleas run"
  37.     echo "make tests before you run this shell"
  38.     exit 1
  39.  
  40. fi
  41.  
  42. #
  43. # these tests have to run with the default malloc environment variables,
  44. # so make sure they are not overridden (otherwise the validation of the
  45. # results may be incorrect)
  46. #
  47. MALLOC_CKCHAIN=0
  48. MALLOC_DETAIL=0
  49. MALLOC_WARN=0
  50. MALLOC_FATAL=1
  51. MALLOC_CKDATA=1
  52. MALLOC_LOWFRAG=0
  53. MALLOC_REUSE=1
  54. MALLOC_ERRFILE="-"
  55. MALLOC_FILLAREA=3
  56. MALLOC_SHOW_LINKS=0
  57.  
  58. export MALLOC_CKCHAIN MALLOC_DETAIL MALLOC_WARN MALLOC_FATAL MALLOC_CKDATA
  59. export MALLOC_LOWFRAG MALLOC_REUSE MALLOC_ERRFILE MALLOC_FILLAREA
  60. export MALLOC_SHOW_LINKS
  61.  
  62.  
  63.  
  64. OUT=Runtests.out
  65. TMPOUT=/tmp/err.$$
  66. TMPFILE=/tmp/ttt.$$
  67. failed=0
  68.  
  69. rm -f $OUT
  70. cat <<endcat > $OUT
  71.  
  72. This file contains the outputs from the tests run by the Runtests script.
  73. For more info on a particular test, check the README file
  74.  
  75. endcat
  76.  
  77. #
  78. # run testmem and verify that it had no output and returned a zero exit code
  79. #
  80. echo "************ Running testmem test..." >> $OUT
  81.  
  82. rm -f ${TMPOUT}
  83. ./testmem > ${TMPOUT} 2>&1
  84. if [ $? != 0 -o -s ${TMPOUT} ]; then
  85.     echo "FAILED testmem test"
  86.     echo "FAILED testmem test" >> $OUT
  87.     failed=`expr $failed + 1`
  88. fi
  89.  
  90. cat ${TMPOUT} >> $OUT
  91.  
  92. #
  93. # run stack tests and verify the output is correct
  94. #
  95. echo "************ Running stack test" >> $OUT
  96. ./teststack > ${TMPOUT} 2>&1
  97. result=$?
  98. lines=`grep "\->" ${TMPOUT} | wc -l | sed -e "s/ //g"`
  99. if [ $result != 0 -o "x$lines" != "x53" ]; then
  100.     echo "FAILED teststack test"
  101.     echo "FAILED teststack test" >> $OUT
  102.     failed=`expr $failed + 1`
  103. fi
  104.  
  105. cat ${TMPOUT} >> $OUT
  106.  
  107. #
  108. # run the malloc tests.  Note that we only run 5,000 iterations of the test and
  109. # a real test should be well over 1,000,000 tests.  However, since I don't want
  110. # the user thinking the system has locked up, I will just run the short test
  111. # here.  (this can be overridden by passing an arugment to Runtests (any
  112. # arugment will do))
  113. #
  114. echo "************ Running malloc test" >> $OUT
  115. ./testmalloc 5000 > ${TMPOUT} 2>&1
  116. result=$?
  117. line="`grep 'Did 5000 iterations' ${TMPOUT}`"
  118. line2="`grep Warning ${TMPOUT}`"
  119. if [ $result != 0 -o -z "$line" -o ! -z "$line2" ]; then
  120.     echo "FAILED malloc test"
  121.     echo "FAILED malloc test" >> $OUT
  122.     failed=`expr $failed + 1`
  123. fi
  124.  
  125. cat ${TMPOUT} >> $OUT
  126.  
  127. #
  128. # run the malloc error test.  Note that this test *should* abort therefore we
  129. # have to run it in a sub-shell in order to ensure that the user doesn't see
  130. # an error message
  131. #
  132. echo "************ Running error test" >> $OUT
  133. sh -c "./testerr" > ${TMPOUT} 2>&1 
  134. sed -e "111,\$ d" -e "/ was /d" < ${TMPOUT} > ${TMPFILE}
  135. cmp ${TMPFILE} testerr.base
  136. if [ $? != 0 ]; then
  137.     echo "FAILED error test"
  138.     echo "FAILED error test" >> $OUT
  139.     failed=`expr $failed + 1`
  140. fi
  141.  
  142. cat ${TMPOUT} >> $OUT
  143.  
  144. rm -f ${TMPOUT} ${TMPFILE}
  145.  
  146. if [ $failed = 0 ]; then
  147.  
  148.     echo "All tests seem to have passed.  Review $OUT to make sure"
  149.  
  150. fi
  151.  
  152. rm -f core a.out
  153.  
  154. exit $failed
  155.  
  156.