home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / extensions / test / InsPEX / inspex.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1991-07-08  |  28.5 KB  |  1,184 lines

  1. #!/bin/sh 
  2. # $XConsortium: inspex.sh,v 5.6 91/07/08 18:12:04 hersh Exp $
  3. ###################################################################
  4. # Copyright (c) 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
  5. #                         All Rights Reserved
  6. # Permission to use, copy, modify, and distribute this software and its 
  7. # documentation for any purpose and without fee is hereby granted, 
  8. # provided that the above copyright notice appear in all copies and that
  9. # both that copyright notice and this permission notice appear in 
  10. # supporting documentation, and that the names of Sun Microsystems,
  11. # the X Consortium, and MIT not be used in advertising or publicity 
  12. # pertaining to distribution of the software without specific, written 
  13. # prior permission.  
  14. # SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
  15. # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
  16. # SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
  17. # DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  18. # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  19. # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  20. # SOFTWARE.
  21. #
  22. ##################################################################
  23.  
  24.  
  25.  
  26.  
  27. #============================================================
  28. # inspex.sh - execution script for InsPEX, the PEX test suite
  29. #============================================================
  30.  
  31. # Options:
  32. # -display <display-name> makes the test run on the named display's server.
  33. # -a <test-area-names>    The user may specify one or more specific test areas;
  34. #            all subsequent arguments up to the next option flag
  35. #            or the end of the line are taken to be test areas.
  36. # -t <individ-tests>    Only runs specified tests - all following arguments
  37. #            up to the next option flag are taken to be test
  38. #            script names (with or without .c or .pi extension),
  39. #            complete pathnames of tests, or of the form
  40. #            areaname/testname.
  41. # -keep            Keep executables for C-based tests after execution,
  42. #            rather than removing them.  If executables are
  43. #            very large, this option may eat up a lot of disk
  44. #            space, but may be desireable for debugging.
  45. # -clean        Before beginning test execution, empty out
  46. #            the bin, lib, and tmp directories under
  47. #            $INSPEXDEST in order to get a clean run.
  48. #            This option is recommended if testing a new
  49. #            version of the PEX library.
  50. # -clean_all        This does all of the above, plus deletes
  51. #            everything under $INSPEXDEST/include, where
  52. #            pdt.h and wdt.h live.  This should only be
  53. #            used if the user has not customized these files
  54. #            under $INSPEXDEST to suit particular phigs
  55. #            and workstation capabilities.
  56. # -server_side, -client_side  These options will force server-side or
  57. #            client-side structure storage, respectively,
  58. #            in most tests.    The same result can be obtained by 
  59. #            using the environment variables described below
  60. #            (though these switches override the variables).
  61.  
  62.  
  63. # Required Environment Variables:
  64. #
  65. # INSPEXHOME - Path to the InsPEX test suite's directory, where inspex.sh
  66. #    and the associated subdirectories are.
  67. # INSPEXDEST - Destination directory for test suite output.  Compilations,
  68. #    new images, and log files are placed under this directory by
  69. #    the test suite.  
  70. # These are in addition to the other variables required for execution
  71. # of a PEX or X program, such as PEXAPIDIR and DISPLAY.  Also 
  72. # note: the suite requires that the X utility xdpyinfo is in the path
  73. # (this is used strictly to diagnose the health of the server).
  74.  
  75. # Optional Environment Variables:
  76. #
  77. # INSPEXLOG - full pathname of log file, default "$INSPEXDEST/ilog.<date>"
  78. # INSPEXIMAGEREF - master reference directory, default INSPEXHOME/refimages
  79. # PEXLIBDIR, PEXINCDIR - directories containing the PEX includes and libs. 
  80. #    These default to "../../lib/PEX" and "../../lib/PEX/include"
  81. #    respectively (absolute paths are derived from these relative ones).
  82. # XLIBDIR, XINCDIR - the directory containing the X library
  83. #    libX11.a, and the directory containing the include
  84. #    directory "X11".
  85. # SERVER_RESTART_CMD - if the server dies during test execution,
  86. #    and this variable is set, the script will attempt to use
  87. #    the command to restart the server before continuing.
  88. #    The command should exit after starting the server, since
  89. #    the test script does not run it in the background.
  90. #    Example: 
  91. #        csh% setenv SERVER_RESTART_CMD "mystartpex.csh; sleep 15"
  92. # I_CFLAGS, I_LDFLAGS - these variables can be set to any required
  93. #    additional compiler flags, for the compile & link phases
  94. #    respectively; they will be used in the compilation of the
  95. #    interpreter and C-based tests.  If there are multiple
  96. #    words in these variables, they should be enclosed in both
  97. #    single and double quotes so that the grouping isn't lost
  98. #    when these are passed to make.
  99. #    Example: csh% setenv I_LDFLAGS "'-Bstatic -f68881'"
  100. #
  101. # Optional environment variables used by many test programs
  102. # (described more fully in the documentation):
  103. #
  104. # MAXFAIL - number of failures a test will accept before aborting
  105. # VERBOSITY - Can be set to 0, 1, 2, or 3; specifies various
  106. #    levels of tracing and diagnostic output.  The user guide
  107. #    details the different values; The default (0) and 1 are
  108. #    useful
  109. # PAUSE - if set, rendering tests will pause after drawing and
  110. #     wait for a carriage return.  Not recommended if running 
  111. #    tests through this script, but useful when running
  112. #    a test program by itself.
  113. # SHOWPIX - if set, some automatic rendering tests will show which pixels
  114. #     are being sampled.
  115. # MACROPATH - interpreter scripts search this path for macros files.
  116. #    default is .:$INSPEXHOME/testcases/shared, causing it to check
  117. #    the current directory and then the directory containing
  118. #    shared macro files.  You shouldn't need to set this unless
  119. #    you want to substitute different macro definitions.
  120. # I_CLIENT_SIDE - if set, will direct most tests to 
  121. #    call popen_pex() with appropriate arguments to specify
  122. #    client-side structure storage, rather than popen_phigs(),
  123. #    which would give the default behavior, server-side storage.
  124. # I_NO_MONITOR - although single-process execution (without phigsmon) is
  125. #    not yet implemented, I_NO_MONITOR will cause most
  126. #    tests to call popen_pex() with the flags set to
  127. #    force this behavior, in a manner similar to I_CLIENT_SIDE.
  128.  
  129.  
  130.  
  131.  
  132. #################################################
  133. #        Test Area Functions        #    
  134. #################################################
  135.  
  136. #set -x
  137. #set -v
  138.  
  139. i_statectl()
  140. {
  141.     cd $INSPEXHOME/testcases/statectl
  142.     list="systemst.pi wsst[12].pi structst.pi archivest.pi"
  143.     for t in $list
  144.     do
  145.         i_exec $t
  146.     done
  147. }
  148.  
  149. i_utils()
  150. {
  151.     cd $INSPEXHOME/testcases/utils
  152.     list="translate.pi scale.pi rotate.pi compmtx.pi buildtran.pi \
  153.         comptran.pi tranpt.pi evalori.pi evalmap.pi"
  154.     for t in $list
  155.     do
  156.         i_exec $t
  157.     done
  158. }
  159.  
  160. i_filter()
  161. {
  162.     cd $INSPEXHOME/testcases/filter
  163.     list="highl.pi invis.pi pick.pi"
  164.     for t in $list
  165.     do
  166.         i_exec $t
  167.     done
  168. }
  169.  
  170. i_archive()
  171. {
  172.     cd $INSPEXHOME/testcases/archive
  173.     list="confres.pi archive.pi archstr.pi archnet.pi archall.pi \
  174.         retrieve.pi retrstr.pi retrnet.pi retrall.pi deletear.pi \
  175.         delstrar.pi delnetar.pi delallar.pi specar[1-4].pi \
  176.         inqcfnet.pi inqallcf.pi retrances.pi retrdesc.pi"
  177.     for t in $list
  178.     do
  179.         i_exec $t
  180.     done
  181. }
  182.  
  183. i_face()
  184. {
  185.     cd $INSPEXHOME/testcases/face
  186.     list="cull1.pi cull2.pi"
  187.     for t in $list
  188.     do
  189.         i_exec $t
  190.     done
  191. }
  192.  
  193. i_dcue()
  194. {
  195.     cd $INSPEXHOME/testcases/dcue
  196.     list="dcue1.pi dcue2.pi"
  197.     for t in $list
  198.     do
  199.         i_exec $t
  200.     done
  201. }
  202.  
  203. i_nurbs()
  204. {
  205.     cd $INSPEXHOME/testcases/nurbs
  206.     list="nurbsc[1-3].pi nurbss[1-6].pi"
  207.     for t in $list
  208.     do
  209.         i_exec $t
  210.     done
  211. }
  212.  
  213. i_triquad()
  214. {
  215.     cd $INSPEXHOME/testcases/triquad
  216.     list="ts[1-6].pi qm[1-4].pi faswd[1-4].pi sofas[1-4].pi"
  217.     for t in $list
  218.     do
  219.         i_exec $t
  220.     done
  221. }
  222.  
  223. i_light()
  224. {
  225.     cd $INSPEXHOME/testcases/light
  226.     list="light[1-5].pi" 
  227.     for t in $list
  228.     do
  229.         i_exec $t
  230.     done
  231. }
  232.  
  233. i_iss()
  234. {
  235.     cd $INSPEXHOME/testcases/iss
  236.     list="iss[1-6].pi"
  237.     for t in $list
  238.     do
  239.         i_exec $t
  240.     done
  241. }
  242.  
  243. i_search()
  244. {
  245.     cd $INSPEXHOME/testcases/search
  246.  
  247.      list="elemsrch[1-4].pi" 
  248.     for t in $list
  249.     do
  250.         i_exec $t 
  251.     done
  252. }
  253.  
  254. i_rep()
  255. {
  256.     cd $INSPEXHOME/testcases/rep
  257.  
  258.     list="edgerep.pi linerep.pi markerrep.pi colrep.pi textrep.pi \
  259.         viewrep.pi patrep.pi interrep.pi dcuerep.pi lightrep.pi" 
  260.     for t in $list
  261.     do
  262.         i_exec $t 
  263.     done
  264. }
  265.  
  266.  
  267. i_pdtwdt()
  268. {
  269.     cd $INSPEXHOME/testcases/pdtwdt
  270.  
  271.     i_comp_and_run pdt 
  272.  
  273.     list="wdt1 wdt2 wdt3 wdt4 wdt5 wdt6"
  274.     for t in $list
  275.     do
  276.         i_comp_and_run $t "CPPFLAGS=-DPHIGS_WS_TYPE_X_TOOL"
  277.     done
  278. }
  279.  
  280.  
  281. i_xform()
  282. {
  283.     cd $INSPEXHOME/testcases/xform
  284.  
  285.      list="wsxf[1-5].pi viewxf[1-5].pi modelxf[1-9].pi primxf[123].pi" 
  286.     for t in $list
  287.     do
  288.         i_exec $t 
  289.     done
  290. }
  291.  
  292. i_dispctl()
  293. {
  294.     cd $INSPEXHOME/testcases/dispctl
  295.  
  296.      list="redrawstr.pi updatews.pi dispupst[1-3].pi dccolrep.pi \
  297.           dcdelstr.pi dclinerep.pi dcrefmod.pi \
  298.           dcviewrep.pi"
  299.     for t in $list
  300.     do
  301.         i_exec $t 
  302.     done
  303. }
  304.  
  305. i_fillarea()
  306.     cd $INSPEXHOME/testcases/fillarea
  307.  
  308.      list="fa[1-4].pi fas[1-8].pi"
  309.     for t in $list
  310.     do
  311.         i_exec $t 
  312.     done
  313. }
  314.  
  315. i_text()
  316. {
  317.     cd $INSPEXHOME/testcases/text
  318.  
  319.      list="tx[1-9].pi tx1[01].pi atx[1-9].pi atx1[01].pi"
  320.     for t in $list
  321.     do
  322.         i_exec $t 
  323.     done
  324. }
  325.  
  326. i_input()
  327. {
  328.     cd $INSPEXHOME/testcases/input
  329.  
  330.      list="loc[1-5].pi event[1-6].pi viewpri[12].pi val[12].pi stroke[12].pi\
  331.         pick[1-9].pi pick10.pi string[12].pi choice[12].pi"
  332.     for t in $list
  333.     do
  334.         i_exec $t 
  335.     done
  336. }
  337.  
  338. i_error()
  339. {
  340.     cd $INSPEXHOME/testcases/error
  341.  
  342.     list="errhandle1 errhandle2"
  343.     for t in $list
  344.     do
  345.         i_comp_and_run $t 
  346.     done
  347. }
  348.  
  349. i_strcon()
  350. {
  351.     cd $INSPEXHOME/testcases/strcon
  352.     list="*[1-9].pi"
  353.     for t in $list
  354.     do
  355.         i_exec $t
  356.     done
  357.  
  358.     list="copyall2"
  359.     for t in $list
  360.     do
  361.         i_comp_and_run $t
  362.     done
  363.  
  364.     # elemcon9 is compiled once and executed multiple times,
  365.     # so that a core dump in one primitive doesn't kill
  366.     # the whole set of tests.  These can be broken up differently
  367.     # if core dumps do occur, so that all structure elements get
  368.     # tested.
  369.  
  370.     # exit function if compile fails
  371.     i_compile elemcon9  ||  return
  372.  
  373.     # Save value of I_KEEP_EXEC, set it to 1 so that
  374.     # the executable is not deleted in between each run.
  375.     OLD_KEEP_EXEC=$I_KEEP_EXEC
  376.     I_KEEP_EXEC=1
  377.  
  378.     # test inquiry of element content for each structure element.
  379.     i_run_executable elemcon9 1 2 3 4 5 6 
  380.     i_run_executable elemcon9 7 8
  381.     i_run_executable elemcon9 9 
  382.     i_run_executable elemcon9 10 11
  383.     i_run_executable elemcon9 12 13 14 15 16 17 18 19 20 
  384.     i_run_executable elemcon9 21
  385.     i_run_executable elemcon9 22 23 24 25 26 27 28 29 30 
  386.     i_run_executable elemcon9 31 32 33 34 35 36 37 38 39 40
  387.     i_run_executable elemcon9 41 42 
  388.     i_run_executable elemcon9 43 44 
  389.     i_run_executable elemcon9 45 46 47 48 49 50 
  390.     i_run_executable elemcon9 51 52 53 54 55 56 57 59 60 
  391.     i_run_executable elemcon9 58
  392.     i_run_executable elemcon9 61 62 63 64 65 66 67 68
  393.     i_run_executable elemcon9 69 70 71 72 73 74 75 76 77 78 79 80
  394.     i_run_executable elemcon9 81
  395.     i_run_executable elemcon9 82 83 84
  396.     i_run_executable elemcon9 85 86
  397.     i_run_executable elemcon9 87
  398.     i_run_executable elemcon9 88
  399.     i_run_executable elemcon9 89 90 91 92
  400.     
  401.     # restore old value before last testcase is run
  402.     I_KEEP_EXEC=$OLD_KEEP_EXEC
  403.  
  404.     i_run_executable elemcon9 93
  405. }
  406.  
  407. i_strman()
  408. {
  409.     cd $INSPEXHOME/testcases/strman
  410.     list="delallst[12].pi delstnet[12].pi delstr[1-5].pi poststr[123].pi"
  411.     for t in $list
  412.     do
  413.         i_exec $t
  414.     done
  415. }
  416.  
  417. i_poly()
  418. {
  419.     cd $INSPEXHOME/testcases/poly
  420.     list="polyline[1234].pi pl_inher.pi \
  421.           polymark[1234].pi pm_inher.pi"
  422.     for t in $list
  423.     do
  424.         i_exec $t
  425.     done
  426. }
  427.  
  428.  
  429. i_plinedata()
  430. {
  431.     cd $INSPEXHOME/testcases/plinedata
  432.     list="pldata1.pi pldata2.pi pldata3.pi pldata4.pi pld_inher.pi"
  433.     for t in $list
  434.     do
  435.         i_exec $t
  436.     done
  437. }
  438.  
  439. #################################################
  440. #              Utility Functions        #    
  441. #################################################
  442.  
  443.  
  444. #
  445. # i_server_check() - check that the server is still alive.
  446. # Takes a single argument: name of the last test executed.
  447. # if server doesn't respond and SERVER_RESTART_CMD is
  448. # defined, attempt to use it to restart the server.  If it
  449. # isn't defined, just abort.
  450. # Return exit status 1 if server is restarted
  451. #
  452. i_server_check()
  453. {
  454.     if xdpyinfo >/dev/null
  455.     then
  456.         echo server still alive >/dev/null
  457.     else
  458.         echolog ERROR: server $DISPLAY not responding after test $*
  459.         # if a method for restarting the server is defined, use it.
  460.         if [ "$SERVER_RESTART_CMD" ]
  461.         then
  462.         echolog attempting restart of server with command: $SERVER_RESTART_CMD
  463.         echo $SERVER_RESTART_CMD | sh -s
  464.         if xdpyinfo >/dev/null
  465.         then
  466.             echolog server successfully restarted after $1 
  467.             return 1
  468.         else
  469.             echolog ERROR: Attempt to restart server after $1 failed - aborting at `date`
  470.             exit
  471.         fi
  472.         else
  473.         echolog Aborting test suite at `date`
  474.         exit
  475.         fi
  476.             
  477.     fi
  478.  
  479. }
  480.  
  481.  
  482. #
  483. # i_exec() -  execute an interpreted test.
  484. # Takes one argument, the name of a test script.
  485. # (including extension)
  486. i_exec()
  487. {
  488.     # remove any pre-existing core file
  489.     rm -f core
  490.  
  491.     # test for existence of file
  492.     if [ ! -f $1 ]
  493.     then
  494.         echolog ERROR: could not find script !$
  495.         return 1
  496.     fi
  497.  
  498.     # Execute the interpreter on the supplied script
  499.     #echo "$INSPEXDEST/bin/pexint $1 2>&1 | tee -a $INSPEXLOG"
  500.     $INSPEXDEST/bin/pexint $1 2>&1 | tee -a $INSPEXLOG
  501.  
  502.     # test for existence of core file
  503.     if [ -f core ]
  504.     then
  505.         echolog $1 FAILED: core dumped
  506.     fi
  507.  
  508.     # test that server is still alive
  509.     i_server_check $1
  510. }
  511.  
  512. #
  513. # i_comp_and_run() --  compile and execute a C-based test
  514. # The first argument is the name of a C-based test
  515. # (with or without .c extension).  Any additional arguments
  516. # are passed along as additional "make" arguments.
  517. #
  518. i_comp_and_run()
  519. {
  520.     test_basename=`basename $1 .c`
  521.     if i_compile $* 
  522.     then
  523.         i_run_executable $test_basename
  524.     fi
  525.  
  526. }
  527.  
  528. # i_compile() - compile a C-based test.  A single argument
  529. # is required, the name of the test (with or without .c extension).
  530. # Any additional arguments are passed on as args to make.
  531. # Note that it cleans up after itself, even removing the .c file.
  532. i_compile()
  533. {
  534.     test_basename=`basename $1 .c`
  535.     if [ ! -f $INSPEXDEST/tmp/${test_basename}.c ]
  536.     then
  537.         case $1 in
  538.         *.c)
  539.         cp $1 $INSPEXDEST/tmp
  540.         ;;
  541.        *)
  542.             cp $1.c $INSPEXDEST/tmp
  543.         ;;
  544.         esac
  545.     fi
  546.     startdir=`pwd`
  547.     cd  $INSPEXDEST/tmp
  548.     if [ ! -f Makefile ] 
  549.     then
  550.         cp $INSPEXHOME/testcases/shared/Makefile .
  551.     fi
  552.     shift   # so that any remaining args (make flags) are $*
  553.  
  554.     # don't crowd the log file with successful make commands
  555.     pwd
  556.     make_cmd="make $CDEBUGFLAGS $test_basename $* PEXINCDIR=$PEXINCDIR PEXLIBDIR=$PEXLIBDIR XINCDIR=$XINCDIR XLIBDIR=$XLIBDIR I_CFLAGS=$I_CFLAGS I_LDFLAGS=$I_LDFLAGS "
  557.     echo "cd $INSPEXDEST/tmp ; $make_cmd"
  558.     if sh -c "$make_cmd" > make.out 2>&1
  559.     then
  560.         #rm -f make.out ${test_basename}.o ${test_basename}.c
  561.         cd $startdir
  562.     else
  563.         echolog "Make of $test_basename FAILED, with output:"
  564.         cat make.out | tee -a $INSPEXLOG
  565.         #rm -f $test_basename.o $test_basename.c $test_basename
  566.         cd $startdir
  567.         return 1
  568.     fi
  569. }
  570.  
  571. # i_run_executable() - run an already-compiled executable,
  572. # check whether it dumped core or killed the server.
  573. # First argument should be the program; any others
  574. # are passed on as arguments.
  575. i_run_executable()
  576. {
  577.     startdir=`pwd`
  578.  
  579.     # execute the command
  580.     cd $INSPEXDEST/tmp
  581.     $* 2>&1 | tee -a $INSPEXLOG
  582.  
  583.     # remove the .o and .c file, and the executable if required
  584.     # rm -f $1.o $1.c 
  585.     #if [ $I_KEEP_EXEC = 0 ]
  586.     #then
  587.     #    rm -f $1
  588.     #fi
  589.  
  590.     # test for existence of core file
  591.     if [ -f core ]
  592.     then
  593.         echolog $* "FAILED: core dumped (removing)"
  594.         rm core
  595.     fi
  596.  
  597.     # test that server is still alive
  598.     i_server_check $1
  599.  
  600.     cd $startdir
  601.  
  602. }
  603.  
  604. # i_testfind() - used in i_individual_test() below.  Given
  605. # a wild-carded path, i_testfind will determine whether it expanded
  606. # to more than one path (ambiguous test name), or failed to expand
  607. # (meaning test not found using wildcarded path).
  608. i_testfind()
  609. {
  610.     if [ $# = 1 ]
  611.     then
  612.         if [ -f $1 ]
  613.         then    # a single file was found
  614.             return 0
  615.         else    # wildcard did not expand to real filename
  616.             return 1
  617.         fi
  618.     else   # wildcard expanded to more than one
  619.         echolog ERROR: ambiguous test name could be any of: $*
  620.         return 2
  621.     fi
  622. }
  623.  
  624. # i_individual_test() - run an individual test script or program.
  625. # Single argument is the test name, with our without extension,
  626. # and may be either an absolute path, testname alone, or of the form
  627. # areadir/testname, where areadir is the name of a test area.
  628. i_individual_test()
  629. {
  630.     indtest=$1
  631.  
  632.     case $indtest in
  633.     */*.pi)  
  634.         # interpreter script with specified path
  635.         if [ -f $indtest ]
  636.         then 
  637.         i_exec $indtest   # path was complete
  638.         elif [ -f $INSPEXHOME/testcases/$indtest ]
  639.         then
  640.         i_exec $INSPEXHOME/testcases/$indtest  # was areaname/testname
  641.         else
  642.         echolog ERROR: could not find test $indtest - skipping
  643.         fi
  644.         ;;
  645.     *.pi)    
  646.         # script with no path: find it here or in testcases dir
  647.         if [ -f $indtest]
  648.         then
  649.            i_exec $indtest  # was in current directory
  650.         elif i_testfind $INSPEXHOME/testcases/*/$indtest
  651.         then
  652.         i_exec $INSPEXHOME/testcases/*/$indtest
  653.         else
  654.            echolog ERROR: could not find test $indtest - skipping
  655.         fi
  656.         ;;
  657.     */*.c)
  658.         # C test with specified path
  659.         if [ -f $indtest ]
  660.         then   # path was complete
  661.         i_comp_and_run $indtest   "CPPFLAGS=-DPHIGS_WS_TYPE_X_TOOL"
  662.         elif [ -f $INSPEXHOME/testcases/$indtest ]
  663.         then   # was in form areaname/testname
  664.         i_comp_and_run $INSPEXHOME/testcases/$indtest "CPPFLAGS=-DPHIGS_WS_TYPE_X_TOOL"
  665.         else
  666.         echolog ERROR: could not find test $indtest - skipping
  667.         fi
  668.         ;;
  669.     *.c)
  670.         # C prog with no path: find it here or in testcases dir
  671.         if [ -f $indtest ]
  672.         then   # was in current directory
  673.            i_comp_and_run $indtest  "CPPFLAGS=-DPHIGS_WS_TYPE_X_TOOL"
  674.         elif i_testfind $INSPEXHOME/testcases/*/$indtest
  675.         then   # was in a testcase directory
  676.         i_comp_and_run $INSPEXHOME/testcases/*/$indtest "CPPFLAGS=-DPHIGS_WS_TYPE_X_TOOL"
  677.         else
  678.         echolog ERROR: could not find test $indtest - skipping
  679.         fi       
  680.         ;;
  681.     *)  
  682.         # test of unknown filetype - we will look for scripts
  683.         # first, since auto translation can leave .c's around
  684.         # with same name.
  685.         if [ -f ${indtest}.pi ]
  686.         then   # script in current dir or with full path
  687.         i_exec ${indtest}.pi
  688.         elif [ -f ${indtest}.c ]
  689.         then   # C prog in current dir or with full path
  690.         i_exec ${indtest}.c
  691.         elif [ -f $INSPEXHOME/testcases/${indtest}.pi ]
  692.         then   # script in areaname/testcase form
  693.         i_exec $INSPEXHOME/testcases/${indtest}.pi
  694.         elif [ -f $INSPEXHOME/testcases/${indtest}.c ]
  695.         then   # C program in areaname/testcase form
  696.         i_comp_and_run $INSPEXHOME/testcases/${indtest}.c "CPPFLAGS=-DPHIGS_WS_TYPE_X_TOOL"
  697.         elif i_testfind $INSPEXHOME/testcases/*/${indtest}.pi
  698.         then   # script in testcase dir
  699.         i_exec $INSPEXHOME/testcases/*/${indtest}.pi
  700.         elif [ $? = 2 ]
  701.         then   # more than one script matches
  702.         echolog ERROR: skipping ambiguous test $indtest
  703.         elif i_testfind $INSPEXHOME/testcases/*/${indtest}.c 
  704.         then   # C program in testcase dir
  705.         i_comp_and_run $INSPEXHOME/testcases/*/${indtest}.c "CPPFLAGS=-DPHIGS_WS_TYPE_X_TOOL"
  706.         elif [ $? = 2 ]
  707.         then
  708.         echolog ERROR: skipping ambiguous test $indtest
  709.         else
  710.         echolog ERROR: could not find test $indtest - skipping
  711.         fi
  712.         ;;
  713.     esac
  714. }
  715.  
  716. #outputs month and day
  717. smalldate()
  718. {
  719.     echo `date +%m\.%d\.%H""%M`
  720. }
  721.  
  722. #prints message on terminal and in log
  723. echolog()
  724. {
  725.     echo "$*" | tee -a $INSPEXLOG
  726. }
  727.  
  728. #################################################
  729. #              Main Procedure            #    
  730. #################################################
  731. # main() 
  732.  
  733. INSPEXVERSION="5.2" ; export INSPEXVERSION
  734. umask 0
  735. RM=/bin/rm ; export RM
  736.  
  737. #
  738. # Test for required environment variables
  739. #
  740. if [ ! "$INSPEXDEST" ] ; then
  741.     echo Must define environment variable INSPEXDEST
  742.     exit 1
  743. elif [ ! "$INSPEXHOME" ] ; then
  744.     echo Must define environment variable INSPEXHOME
  745.     exit 1
  746. fi
  747.  
  748. if [ ! "$INSPEXIMAGEREF" ] ; then
  749.     INSPEXIMAGEREF=$INSPEXHOME/refimages ; export INSPEXIMAGEREF
  750. fi
  751.  
  752.  
  753.  
  754. #
  755. # initialize flags
  756. #
  757. DEBUG_OPT= ; export DEBUG_OPT
  758. I_KEEP_EXEC=0; export I_KEEP_EXEC
  759. unset ADDING_AREAS
  760. unset ADDING_TESTS
  761.  
  762. #
  763. # process cmd line args
  764. #
  765. while [ "$*" ]
  766. do
  767.     case $1 in
  768.     -display)
  769.         shift
  770.         DISPLAY=$1; export DISPLAY
  771.     unset ADDING_TESTS ; unset ADDING_AREAS
  772.         shift
  773.     ;;
  774.     -a)
  775.     # subsequent non-flag arguments will be added to AREALIST
  776.     unset ADDING_TESTS
  777.     ADDING_AREAS=1
  778.         shift
  779.     ;;
  780.     -t)
  781.     # subsequent non-flag arguments will be added to TESTLIST
  782.     unset ADDING_AREAS
  783.     ADDING_TESTS=1
  784.         shift
  785.     ;;
  786.     -clean)
  787.     # dirs bin, lib, & tmp will be cleaned out under INSPEXDEST
  788.     I_CLEAN=1; export I_CLEAN
  789.     unset ADDING_TESTS ; unset ADDING_AREAS
  790.     shift
  791.     ;;
  792.     -clean_all)
  793.     # above, plus include dir under INSPEXDEST will be cleaned out.
  794.     I_CLEAN_ALL=1; export I_CLEAN_ALL
  795.     unset ADDING_TESTS ; unset ADDING_AREAS
  796.     shift
  797.     ;;
  798.     -keep)
  799.     # C-based test executables will be kept
  800.     I_KEEP_EXEC=1; export I_KEEP_EXEC
  801.     unset ADDING_TESTS ; unset ADDING_AREAS
  802.     shift
  803.     ;;
  804.     -server_side)
  805.     unset I_CLIENT_SIDE
  806.     unset ADDING_TESTS ; unset ADDING_AREAS
  807.     shift
  808.     ;;
  809.     -client_side)
  810.     I_CLIENT_SIDE=1; export I_CLIENT_SIDE
  811.     unset ADDING_TESTS ; unset ADDING_AREAS
  812.     shift
  813.     ;;
  814.     -*)
  815.     echo ERROR -- unknown flag, $1
  816.     exit 1
  817.     ;;
  818.     *)
  819.     if [ $ADDING_AREAS ] ; then
  820.         # add this argument to test area list
  821.         AREALIST="$AREALIST $1"; export AREALIST
  822.     elif [ $ADDING_TESTS ] ; then
  823.         # add this argument to test list
  824.         TESTLIST="$TESTLIST $1"; export TESTLIST
  825.     else
  826.         echo ERROR -- unknown argument, $1
  827.         exit 1
  828.     fi
  829.     shift
  830.     ;;
  831.     esac;
  832. done
  833.  
  834. DATE=`date`
  835. export DATE
  836.  
  837. # Set a macropath if none defined; interpreter will use
  838. # this path to search for macro files loaded with "source" command.
  839. if [ ! "$MACROPATH" ]
  840. then
  841.     MACROPATH=.:$INSPEXHOME/testcases/shared ; export MACROPATH
  842. fi
  843.  
  844. # create name for log file if not set; if the file already
  845. # exists, name it to <name>.old
  846. if [ ! "$INSPEXLOG" ]
  847. then
  848.     INSPEXLOG=$INSPEXDEST/ilog`smalldate` 
  849. fi
  850. export INSPEXLOG
  851.  
  852. if [ -f $INSPEXLOG ]
  853. then
  854.     mv $INSPEXLOG $INSPEXLOG.old
  855. fi
  856.  
  857.  
  858. echolog "The InsPEX Test Suite $INSPEXVERSION" 
  859. echolog "Run started on "`date`
  860. echolog  Running on client machine `hostname`
  861. if [ "$DISPLAY" ]
  862. then
  863.     echolog Using display $DISPLAY
  864. else
  865.     echolog Using default display, unix:0 
  866.     DISPLAY=unix:0 ; export DISPLAY
  867. fi
  868. echolog Test results going into log file $INSPEXLOG
  869.  
  870.  
  871. # The X utility xdpyinfo is used to test for existence of server.
  872. # To see whether the command itself was actually found, we
  873. # check whether the output file was ever created.  This
  874. # requires deleting any pre-existing copy.
  875. rm -f $INSPEXDEST/display_info
  876. if [ -f $INSPEXDEST/display_info ] 
  877. then
  878.     echolog ERROR - could not delete file $INSPEXDEST/display_info
  879.     echolog please delete it and restart suite
  880.     exit 1
  881. fi
  882.  
  883. if xdpyinfo -display $DISPLAY > $INSPEXDEST/display_info
  884. then
  885.     echolog server is responding - xdpyinfo output in display_info
  886. else
  887.     if [ -f $INSPEXDEST/display_info ] 
  888.     then
  889.         # the program ran but failed
  890.         echolog ERROR - server $DISPLAY not responding: aborting
  891.         exit 1
  892.     else
  893.         # xdpyinfo didn't generate any output so didn't run
  894.         echolog ERROR - could not execute required X utility xdpyinfo
  895.         exit 1
  896.     fi
  897. fi
  898.  
  899. # record presence of I_CLIENT_SIDE in log
  900. if [ -n "$I_CLIENT_SIDE" ]
  901. then
  902.     echolog I_CLIENT_SIDE is set - client side storage will be used
  903. else
  904.     echolog I_CLIENT_SIDE is not set - server side storage will be used
  905. fi
  906.  
  907. # create directories in $INSPEXDEST if they don't exist
  908. dirlist="bin lib tmp include currimages localrefimages"
  909. for d in $dirlist
  910. do
  911.     if [ ! -d $INSPEXDEST/$d ]
  912.     then
  913.         mkdir $INSPEXDEST/$d
  914.     fi
  915. done
  916.  
  917. # clean out directories if requested
  918. if [ -n "$I_CLEAN_ALL" -o -n "$I_CLEAN" ]
  919. then
  920.     echolog emptying dirs bin, lib, tmp under INSPEXDEST
  921.     rm -f $INSPEXDEST/bin/*
  922.     rm -f $INSPEXDEST/lib/*
  923.     rm -f $INSPEXDEST/tmp/*
  924.     if [ -n "$I_CLEAN_ALL" ]
  925.     then
  926.         echolog emptying directory include under INSPEXDEST
  927.         rm -f $INSPEXDEST/include/*
  928.     fi
  929. fi
  930.  
  931. # copy pdt.h and wdt.h into $INSPEXEST/include if they
  932. # aren't already there
  933. for incfile in pdt.h wdt.h
  934. do
  935.     if [ ! -f $INSPEXDEST/include/$incfile ]
  936.     then    
  937.         cp $INSPEXHOME/include/$incfile $INSPEXDEST/include
  938.     fi
  939. done
  940.  
  941. #
  942. # Set or confirm required directory variables
  943. #
  944. if [ ! "$PEXINCDIR" ]
  945. then
  946.     default=../../../X11
  947.     if [ -d $default ]
  948.     then
  949.         if [ -d $default/phigs ]
  950.         then
  951.             # it's good - get an absolute path
  952.             PEXINCDIR=`cd $default; pwd`; export PEXINCDIR
  953.         else
  954.             echolog ERROR - no directory phigs found under default PEXINCDIR $default - must be set manually
  955.             exit 1
  956.         fi
  957.     else 
  958.          echolog ERROR - default PEXINCDIR not found - must be set manually
  959.          exit 1
  960.     fi
  961. else              # make sure phigs directory exists
  962.     if [ ! -d $PEXINCDIR/phigs ]
  963.     then
  964.         echolog ERROR - value for PEXINCDIR incorrect - no directory phigs found under $PEXINCDIR
  965.         exit 1
  966.     fi
  967. fi
  968.  
  969. if [ ! "$PEXLIBDIR" ]
  970. then
  971.     default=../../lib/PEX
  972.     if [ -d $default ]
  973.     then
  974.         # get an absolute path
  975.         PEXLIBDIR=`cd $default; pwd`; export PEXLIBDIR
  976.     else 
  977.          echolog ERROR - default PEXLIBDIR $default not found - must be set manually
  978.          exit 1
  979.     fi
  980. else  # make sure directory exists
  981.     if [ ! -d $PEXLIBDIR ]
  982.     then
  983.         echolog ERROR - value for PEXLIBDIR incorrect - $PEXLIBDIR not found
  984.         exit 1
  985.     fi
  986. fi
  987.  
  988. # X directories default to the PEX ones...
  989. if [ ! "$XINCDIR" ]
  990. then
  991.     default=$PEXINCDIR
  992.     if [ -d $default ]
  993.     then
  994.         if [ -d $default ]
  995.         then
  996.             # it's good -get an absolute path
  997.             XINCDIR=`cd $default; pwd`; export XINCDIR
  998.         else
  999.             echolog ERROR - no directory X11 found under default XINCDIR $default - must be set manually
  1000.             exit 1
  1001.         fi
  1002.     else 
  1003.          echolog ERROR - default XINCDIR not found - must be set manually
  1004.          exit 1
  1005.     fi
  1006. else              # make sure X11 directory exists
  1007.     if [ ! -d $XINCDIR ]
  1008.     then
  1009.         echolog ERROR - value for XINCDIR incorrect - no directory X11 found under $XINCDIR
  1010.         exit 1
  1011.     fi
  1012. fi
  1013.  
  1014. if [ ! "$XLIBDIR" ]
  1015. then
  1016.     default=$PEXLIBDIR
  1017.     if [ -d $default ]
  1018.     then
  1019.         # get an absolute path
  1020.         XLIBDIR=`cd $default; pwd`; export XLIBDIR
  1021.     else 
  1022.          echolog ERROR - default XLIBDIR $default not found - must be set manually
  1023.          exit 1
  1024.     fi
  1025. else  # make sure directory exists
  1026.     if [ ! -d $XLIBDIR ]
  1027.     then
  1028.         echolog ERROR - value for XLIBDIR incorrect - directory $XLIBDIR not found
  1029.         exit 1
  1030.     fi
  1031. fi
  1032.  
  1033. echolog "PEX include directory:       " $PEXINCDIR
  1034. echolog "PEX lib directory:           " $PEXLIBDIR
  1035. echolog "X include directory:         " $XINCDIR
  1036. echolog "X lib directory:             " $XLIBDIR
  1037. echolog "InsPEX home directory:       " $INSPEXHOME
  1038. echolog "InsPEX destination directory:" $INSPEXDEST
  1039. echolog "Image reference directory:   " $INSPEXIMAGEREF
  1040.  
  1041. # User may use these to add to compiler flags if desired.
  1042. if [ -n "$I_CFLAGS" ]
  1043. then
  1044.     echolog User-supplied CFLAGS: $I_CFLAGS
  1045. else
  1046.     I_CFLAGS= ; export I_CFLAGS
  1047. fi
  1048. if [ -n "$I_LDFLAGS" ]
  1049. then
  1050.     echolog User-supplied LDFLAGS: $I_LDFLAGS
  1051. else
  1052.     I_LDFLAGS= ; export I_LDFLAGS
  1053. fi
  1054.  
  1055. cd $INSPEXHOME/tools/pexint
  1056. # the CPPFLAGS=-DNEWT is required when compiling interpreter!
  1057. MAKE_CMD="make CPPFLAGS='-DNEWT' PEXINCDIR=$PEXINCDIR PEXLIBDIR=$PEXLIBDIR XINCDIR=$XINCDIR XLIBDIR=$XLIBDIR I_CFLAGS=$I_CFLAGS I_LDFLAGS=$I_LDFLAGS pexint"
  1058. echolog $MAKE_CMD 
  1059. # We would pipe the make output into "tee", but it masks the return status.
  1060. if sh -c "$MAKE_CMD" > $INSPEXDEST/bin/make.out  2>&1
  1061. then
  1062.     echo removing log of make >/dev/null
  1063.     #rm $INSPEXDEST/bin/make.out
  1064. else
  1065.     echolog ERROR: make of pexint failed, with output:
  1066.     cat $INSPEXDEST/bin/make.out | tee -a $INSPEXLOG
  1067.     echolog ABORTING -- could not make interpreter 
  1068.     exit 1
  1069. fi
  1070.  
  1071.  
  1072. cd $INSPEXDEST
  1073. rm -f core
  1074.  
  1075. if [ "$TESTLIST" ]
  1076. then
  1077.     echolog -------------- Running Individual Tests --------------
  1078.     echolog "test list: $TESTLIST" 
  1079.     for indtest in $TESTLIST
  1080.     do
  1081.     i_individual_test $indtest
  1082.     done
  1083. fi
  1084.  
  1085. if [ -n "$AREALIST" -o -z "$TESTLIST" ] 
  1086. then
  1087.     # some or all test areas are to be executed
  1088.     if [ "$AREALIST" ]
  1089.     then
  1090.     echolog Test will include test areas:  $AREALIST 
  1091.     else
  1092.     AREALIST="statectl utils rep xform dispctl fillarea search \
  1093.                  text strcon strman poly plinedata archive face dcue \
  1094.          nurbs triquad light iss error pdtwdt filter input";\
  1095.          export AREALIST
  1096.     fi
  1097.  
  1098.     for a in $AREALIST
  1099.     do
  1100.         echolog "-------- Starting test area $a --------" 
  1101.         case $a in
  1102.         search)
  1103.         i_search
  1104.         ;;
  1105.         statectl)
  1106.         i_statectl
  1107.         ;;
  1108.     utils)
  1109.         i_utils
  1110.         ;;
  1111.     filter)
  1112.         i_filter
  1113.         ;;
  1114.     xform)
  1115.         i_xform
  1116.         ;;
  1117.     archive)
  1118.         i_archive
  1119.         ;;
  1120.     face)
  1121.         i_face
  1122.         ;;
  1123.     dcue)
  1124.         i_dcue
  1125.         ;;
  1126.     nurbs)
  1127.         i_nurbs
  1128.         ;;
  1129.     triquad)
  1130.         i_triquad
  1131.         ;;
  1132.     light)
  1133.         i_light
  1134.         ;;
  1135.     iss)
  1136.         i_iss
  1137.         ;;
  1138.     pdtwdt)
  1139.         i_pdtwdt
  1140.         ;;
  1141.     rep)
  1142.         i_rep
  1143.         ;;
  1144.     dispctl)
  1145.         i_dispctl
  1146.         ;;
  1147.     fillarea)
  1148.         i_fillarea
  1149.         ;;
  1150.     text)
  1151.         i_text
  1152.         ;;
  1153.     input)
  1154.         i_input
  1155.         ;;
  1156.     error)
  1157.         i_error
  1158.         ;;
  1159.     strcon)
  1160.         i_strcon
  1161.         ;;
  1162.     strman)
  1163.         i_strman
  1164.         ;;
  1165.     poly)
  1166.         i_poly
  1167.         ;;
  1168.     plinedata)
  1169.         i_plinedata
  1170.         ;;
  1171.          *)
  1172.             echo "Unknown test area: $a"
  1173.             exit 1;
  1174.         ;;
  1175.         esac
  1176.     done        
  1177. fi
  1178.  
  1179. echolog "InsPEX run completed on " `date`  
  1180.