Annotation of 43BSD/contrib/spms/src/bin/ptest/ptest.sh, revision 1.1.1.1

1.1       root        1: #! /bin/csh -f
                      2: #
                      3: # $Header$
                      4: #
                      5: # ptest - test a project module
                      6: #
                      7: # Author: Peter J. Nicklin
                      8: #
                      9: set template = t.Makefile
                     10: 
                     11: top:
                     12: 
                     13: if ($#argv > 0) then
                     14:        switch ($argv[1])
                     15:                case -d:
                     16:                        set debug
                     17:                        shift
                     18:                        breaksw
                     19:                case -F*:
                     20:                        if ($argv[1] != -F) then
                     21:                                set argv[1] = `echo $argv[1] | sed -e s/-F//`
                     22:                        else if ($#argv < 2) then
                     23:                                set error
                     24:                                breaksw
                     25:                        else
                     26:                                shift
                     27:                        endif
                     28:                        set template = $argv[1]
                     29:                        shift
                     30:                        breaksw
                     31:                case -P*:
                     32:                        if ($argv[1] != -P) then
                     33:                                set argv[1] = `echo $argv[1] | sed -e s/-P//`
                     34:                        else if ($#argv < 2) then
                     35:                                set error
                     36:                                breaksw
                     37:                        else
                     38:                                shift
                     39:                        endif
                     40:                        pushd . >& /dev/null
                     41:                        eval `chproject -f $argv[1]`
                     42:                        if ($status != 0) exit(1)
                     43:                        popd >& /dev/null
                     44:                        shift
                     45:                        breaksw
                     46:                case -*:
                     47:                        echo "ptest: bad option $argv[1]"
                     48:                        set error
                     49:                        shift
                     50:                        breaksw
                     51:                default:
                     52:                        goto next
                     53:                        breaksw
                     54:                endsw
                     55:                goto top
                     56: endif
                     57: 
                     58: next:
                     59: 
                     60: if ($?error) then
                     61:        echo "ptest: usage: ptest [-d] [-F template] [-P projectname] [module ...]"
                     62:        exit(1)
                     63: endif
                     64: 
                     65: if (!($?PROJECT)) then
                     66:        echo "ptest: no project environment"
                     67:        exit(1)
                     68: endif
                     69: 
                     70: # does the test case directory exist?
                     71: if (!(-e $PROJECT/test)) then
                     72:        echo "ptest: $PROJECT/test: No such file or directory"
                     73:        exit(1)
                     74: endif
                     75: 
                     76: # test all modules
                     77: if ($#argv < 1) then
                     78:        pushd $PROJECT/test >& /dev/null
                     79:        foreach test (`ls`)
                     80:                if ($test =~ *.a) set argv = ($argv $test:r)
                     81:        end
                     82:        if ($#argv < 1) then
                     83:                echo "ptest: no test cases available"
                     84:                exit(1)
                     85:        endif
                     86:        popd >& /dev/null
                     87: endif
                     88: 
                     89: # remove compilable test programs
                     90: foreach file (`ls`)
                     91:        switch ($file)
                     92:                case T*.sh:
                     93:                        breaksw
                     94:                case T*.*:
                     95:                        rm -f $file
                     96:                        breaksw
                     97:        endsw
                     98: end
                     99: 
                    100: foreach test ($argv[*])
                    101:        # extract test files from archive
                    102:        if (!(-e $PROJECT/test/$test.a)) then
                    103:                echo "ptest: test case $test not found"
                    104:                continue
                    105:        endif
                    106:        echo -n "$test:q: extracting archive ... "
                    107:        ar xo $PROJECT/test/$test.a
                    108: 
                    109:        # Compile test program
                    110:        unset userscript
                    111:        foreach program (T*.*)
                    112:                switch ($program)
                    113:                        case T*.sh:
                    114:                                set userscript
                    115:                                breaksw
                    116:                        default:
                    117:                                echo -n "compiling test ... "
                    118:                                mkmf -cd -fT_makefile -F$template PROGRAM=T$test
                    119:                                make -f T_makefile -s >& E$test
                    120:                                if ($status != 0) goto badtest
                    121:                                breaksw
                    122:                endsw
                    123:        end
                    124: 
                    125:        # Run test
                    126:        echo -n "executing test ... "
                    127:        if ($?userscript) then
                    128:                # User supplied test script
                    129:                T$test.sh >>& E$test
                    130:                if ($status != 0) goto badtest
                    131:        else if (-e I$test) then
                    132:                # Default test script with input
                    133:                T$test < I$test |& diff - O$test >>& E$test
                    134:                if ($status != 0) goto badtest
                    135:        else
                    136:                # Default test script without input
                    137:                T$test |& diff - O$test >>& E$test
                    138:                if ($status != 0) goto badtest
                    139:        endif
                    140: 
                    141:        if (!($?debug)) rm -f E$test T$test* I$test O$test T_makefile
                    142:        echo done
                    143:        continue
                    144: 
                    145: badtest:
                    146:        if (!($?debug)) rm -f T$test* I$test O$test T_makefile
                    147:        echo failed
                    148:        set error
                    149: end
                    150: 
                    151: if ($?error) exit(1)
                    152: exit(0)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.