⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mktests

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻
📖 第 1 页 / 共 3 页
字号:
#@(#)mktests	4.1	Ultrix	7/3/90#! /bin/csh -f## csh file to create dbx test cases## Assumes it is already in the appropriate dbx source directory.if (! -d tests) then    mkdir testsendifif (! -d tests/cc) then    mkdir tests/ccendifif (! -d tests/mod) then    mkdir tests/modendifecho tests/Makefilerm -f tests/Makefilecat > tests/Makefile <<'endcat'## Makefile for testing dbx.#TESTDBX = ../../tdbxpassed:	@chdir mod; make TESTDBX=${TESTDBX}	@chdir cc; make TESTDBX=${TESTDBX}#	@chdir pc; make TESTDBX=${TESTDBX}#	@chdir f77; make TESTDBX=${TESTDBX}	@echo ""	@echo "passed tests"'endcat'echo tests/cc/Makefilerm -f tests/cc/Makefilecat > tests/cc/Makefile <<'endcat'## Makefile for testing dbx.#.SUFFIXES:.SUFFIXES: .c .h .s .o .x .t .in .tst .outTESTDBX = ../../tdbxTESTS = \    bitfields.t enum.t struct.t user.t \    float.t reg.t own.t sleep.t nested.t \    strings.t call.t## Suffix conventions:##	.c	C source module#	.h	C definitions file#	.s	assembly code file#	.o	object file#	.x	executable file#	.t	dummy file represented last time tested#	.in	input for testing#	.tst	test output#	.out	expected output#.c.x:	cc -g $*.c -o $*.x.c.o:	cc -c -g $*.c.in.tst:	csh -f -c "${TESTDBX} $*.x < $*.in |& tail +3 > $*.tst".x.t:	@echo "    $*"	@rm -f tmp	@csh -f -c "${TESTDBX} $*.x < $*.in |& tail +3 > tmp	@check tmp $*.out	@rm -f tmp	@rm -f $*.t	@touch $*.tpassed: beforemsg ${TESTS}	@echo "passed C tests"beforemsg:	@echo ""	@echo "C tests:"strings.x: strings.c	cc -g -R strings.c -o strings.xbitfields.t: bitfields.x ${TESTDBX}enum.t: enum.x ${TESTDBX}struct.t: struct.x ${TESTDBX}user.t: user.x ${TESTDBX}float.t: float.x ${TESTDBX}reg.t: reg.x ${TESTDBX}own.t: own.x ${TESTDBX}sleep.t: sleep.x ${TESTDBX}nested.t: nested.x ${TESTDBX}call.t: call.x ${TESTDBX}strings.t: strings.x strings.core ${TESTDBX}	@echo "    $*"	@rm -f tmp	@${TESTDBX} $*.x $*.core < $*.in | tail +3 > tmp	@check -s tmp $*.out	@rm -f tmp	@rm -f $*.t	@touch $*.tstrings.core:	-csh -f -c "limit coredumpsize 6m >& /dev/null; strings.x"	mv core strings.core'endcat'echo tests/cc/checkrm -f tests/cc/checkcat > tests/cc/check <<'endcat'#! /bin/csh -f## check <test output> <expected output>## Check to see if test output matches expected output.# If not, run diff and ask if differences are "ok".  If so,# install new output as expected output.#cmp -s $1 $2if ($status != 0) then    diff $1 $2    echo -n "ok? "    if ($< != y) then	exit 1    endif    mv $1 $2endifexit 0'endcat'echo tests/cc/bitfields.crm -f tests/cc/bitfields.ccat > tests/cc/bitfields.c <<'endcat'typedef unsigned int uint;struct dot {    uint  cost		 :24;    uint  type	         : 3;    uint  dirToCenter	 : 3;    uint  pad		 : 1;    uint  pin		 : 1;    uint  traceback	 : 3;    uint  traceforward   : 3;    uint  expanded	 : 1;    uint  underDir	 : 3;    uint  underOffset	 : 4;    uint  start		 : 1;    uint  target	 : 1;    uint  owner		 : 6;    uint  segment	 : 7;    uint  intrinsicCost  : 3;};main(){    struct dot junk;    junk.owner = 63;    junk.segment = 1;    junk.intrinsicCost = 1;    printf("owner = %d, segment = %d, intrinsicCost = %d\n",	junk.owner, junk.segment, junk.intrinsicCost);    printf("done\n");    oldmain();}oldmain(){    struct {	int first;	int second;	int a : 8;	int b : 8;	int c;    } x;    x.first = 0;    x.second = 0;    x.a = 2;    x.b = 10;    x.c = 1;}'endcat'echo tests/cc/bitfields.inrm -f tests/cc/bitfields.incat > tests/cc/bitfields.in <<'endcat'whatis xwhatis x.astop at 31runprint junkprint junk.owner, junk.segment, junk.intrinsicCoststop at 50contprint xprint x.aprint x.bprint x.c'endcat'echo tests/cc/bitfields.outrm -f tests/cc/bitfields.outcat > tests/cc/bitfields.out <<'endcat'reading symbolic information ...struct {    int first;    int second;    int a : 8;    int b : 8;    int c;} x;int a : 8;[1] stop at 31[1] stopped in main at line 31   31       printf("done\n");(cost = 0, type = 0, dirToCenter = 0, pad = 0, pin = 0, traceback = 0, traceforward = 0, expanded = 0, underDir = 0, underOffset = 0, start = 0, target = 0, owner = 63, segment = 1, intrinsicCost = 1) 63 1 1 [3] stop at 50[3] stopped in oldmain at line 50   50   }(first = 0, second = 0, a = 2, b = 10, c = 1) 2 10 1 'endcat'echo tests/cc/enum.crm -f tests/cc/enum.ccat > tests/cc/enum.c <<'endcat'typedef enum { RED, GREEN, BLUE } Color;main(){    Color c;    c = BLUE;    f(RED);}f(c)Color c;{    printf("c = %d\n", c);}'endcat'echo tests/cc/enum.inrm -f tests/cc/enum.incat > tests/cc/enum.in <<'endcat'whatis Colorwhatis main.cstop in frunwhereprint cprint main.cquit'endcat'echo tests/cc/enum.outrm -f tests/cc/enum.outcat > tests/cc/enum.out <<'endcat'reading symbolic information ...typedef enum { RED, GREEN, BLUE } Color;Color c;[1] stop in f[1] stopped in f at line 13   13   {f(c = RED), line 13 in "enum.c"main(0x1, 0x7fffed78, 0x7fffed80), line 8 in "enum.c"RED BLUE 'endcat'echo tests/cc/struct.crm -f tests/cc/struct.ccat > tests/cc/struct.c <<'endcat'/* * Test for C structures. *//* * A simple nested structure. */struct simple {    int a;    char b;    double c;    struct {	int a;	char b;	double c;    } d;    int e;    char f;    double g;} simple;/* * Mutually recursive structures, using typedefs. */typedef struct first *First;typedef struct second *Second;struct second {    int b;    char c;};struct first {    int a;    Second p;};UseRecurStructs(){    struct first b, *p;    struct second list;    p = &b;    b.a = 3;    b.p = &list;    b.p->b = 4;    b.p->c = 'c';}/* * Functions returning structures. */struct simple f(x)int x;{    struct simple s;    s.a = x;    s.g = 3.14;    return s;}main(){    struct simple x;    struct simple *y;    UseRecurStructs();    x = f(3);    y = &x;}'endcat'echo tests/cc/struct.inrm -f tests/cc/struct.incat > tests/cc/struct.in <<'endcat'whatis simplewhatis $$simplewhatis Firstwhatis Secondwhatis firstwhatis secondstop in UseRecurStructsrunstepstepstepstepstepprint bprint b.pprint *(b.p)print b.p.bprint b.p.cstop in fcontwherestepstepstepstepstepstepprint yprint *y'endcat'echo tests/cc/struct.outrm -f tests/cc/struct.outcat > tests/cc/struct.out <<'endcat'reading symbolic information ...struct simple simple;struct simple {    int a;    char b;    double c;    struct {        int a;        char b;        double c;    } d;    int e;    char f;    double g;};typedef struct first *First;typedef struct second *Second;struct first {    int a;    struct second *p;};struct second {    int b;    char c;};[1] stop in UseRecurStructs[1] stopped in UseRecurStructs at line 41   41   {stopped in UseRecurStructs at line 45   45       p = &b;stopped in UseRecurStructs at line 46   46       b.a = 3;stopped in UseRecurStructs at line 47   47       b.p = &list;stopped in UseRecurStructs at line 48   48       b.p->b = 4;stopped in UseRecurStructs at line 49   49       b.p->c = 'c';(a = 3, p = 0x7fffecec) 0x7fffecec (b = 4, c = '\0') 4 '\0' [3] stop in f[3] stopped in f at line 58   58   {f(x = 3), line 58 in "struct.c"main(0x1, 0x7fffed74, 0x7fffed7c), line 72 in "struct.c"stopped in f at line 61   61       s.a = x;stopped in f at line 62   62       s.g = 3.14;stopped in f at line 63   63       return s;stopped in f at line 64   64   }stopped in main at line 73   73       y = &x;stopped in main at line 74   74   }0x7fffed1c (a = 3, b = '\0', c = 0.0, d = (a = 0, b = '\0', c = 0.0), e = 4, f = 'c', g = 3.14) 'endcat'echo tests/cc/float.crm -f tests/cc/float.ccat > tests/cc/float.c <<'endcat'/* * Test of floats and doubles. */double f(x)double x;{    return 3.14*x;}main(){    double x;    float y;    y = 3.0;    x = f(y);    return 0;}'endcat'echo tests/cc/own.crm -f tests/cc/own.ccat > tests/cc/own.c <<'endcat'/* * Test of static variables. */ static int ownx;main(){    ownx = 2;    f(3);    f(4);    return(0);}static int owny;f(x)int x;{    static int ownx;    ownx = x;}'endcat'echo tests/cc/own.inrm -f tests/cc/own.incat > tests/cc/own.in <<'endcat'whatis ownxwhereis ownystop in frunwhereprint own.ownx, ownxstepstepprint own.ownx, ownxcontstepstepwhereprint own.ownx, ownxcont'endcat'echo tests/cc/reg.crm -f tests/cc/reg.ccat > tests/cc/reg.c <<'endcat'struct blah {    int x;    int y;};main (){    register int i;    register struct blah *p;    register char *s;    struct blah b;    int j;    s = "this is a test";    s += 5;    j = 0;    p = &b;    p->x = 3;    p->y = 4;    for (i = 0; i < 2; i++) {	j = i;	put(i);    }}static put(i)register int i;{    printf("%d ", i);}'endcat'echo tests/cc/same.crm -f tests/cc/same.ccat > tests/cc/same.c <<'endcat'same (){    printf("same function and module names\n");}main (){}'endcat'echo tests/cc/user.crm -f tests/cc/user.ccat > tests/cc/user.c <<'endcat'/* * The user structure is a good test of the general symbol processing * abilities of dbx. */#include <sys/param.h>#include <sys/dir.h>#include <sys/user.h>main (){}'endcat'echo tests/cc/user.inrm -f tests/cc/user.incat > tests/cc/user.in <<'endcat''endcat'echo tests/cc/float.inrm -f tests/cc/float.incat > tests/cc/float.in <<'endcat'stop in mainrunstepstepprint yprint y + 2print 3.5*ystop in fcontwherecont'endcat'echo tests/cc/user.outrm -f tests/cc/user.outcat > tests/cc/user.out <<'endcat'reading symbolic information ...'endcat'echo tests/cc/float.outrm -f tests/cc/float.outcat > tests/cc/float.out <<'endcat'reading symbolic information ...[1] stop in main[1] stopped in main at line 12   12   {stopped in main at line 16   16       y = 3.0;stopped in main at line 17   17       x = f(y);3.0 5.0 10.5 [3] stop in f[3] stopped in f at line 7    7   {f(x = 3.0), line 7 in "float.c"main(0x1, 0x7fffed74, 0x7fffed7c), line 17 in "float.c"execution completed, exit code is 0'endcat'echo tests/cc/reg.inrm -f tests/cc/reg.incat > tests/cc/reg.in <<'endcat'stop in putrunwhereprint main.i, *(main.p), main.scontwherecont'endcat'echo tests/cc/reg.outrm -f tests/cc/reg.outcat > tests/cc/reg.out <<'endcat'reading symbolic information ...[1] stop in put0 1 [1] stopped in put at line 28   28   {put(i = 0), line 28 in "reg.c"main(0x1, 0x7fffed78, 0x7fffed80), line 22 in "reg.c"0 (x = 3, y = 4) "is a test" [1] stopped in put at line 28   28   {put(i = 1), line 28 in "reg.c"main(0x1, 0x7fffed78, 0x7fffed80), line 22 in "reg.c"execution completed, exit code is 0'endcat'echo tests/cc/own.outrm -f tests/cc/own.outcat > tests/cc/own.out <<'endcat'reading symbolic information ...static int ownx;own.owny[1] stop in f[1] stopped in f at line 19   19   {f(x = 3), line 19 in "own.c"main(0x1, 0x7fffed78, 0x7fffed80), line 10 in "own.c"2 0 stopped in f at line 22   22       ownx = x;stopped in f at line 23   23   }2 3 [1] stopped in f at line 19   19   {stopped in f at line 22   22       ownx = x;stopped in f at line 23   23   }f(x = 4), line 23 in "own.c"main(0x1, 0x7fffed78, 0x7fffed80), line 11 in "own.c"2 4 execution completed, exit code is 0'endcat'echo tests/cc/signal.crm -f tests/cc/signal.ccat > tests/cc/signal.c <<'endcat'/* * Test of tracebacks from signal handlers. */#include <stdio.h>#include <signal.h>int catch(), secondcatch();main(){    signal(SIGQUIT, catch);    kill(getpid(), SIGQUIT);    printf("back in main\n");}catch(){    printf("in catch\n");    sigsetmask(0);    signal(SIGQUIT, secondcatch);    kill(getpid(), SIGQUIT);    printf("back in catch\n");}secondcatch(){    printf("in secondcatch\n");}'endcat'echo tests/cc/sleep.crm -f tests/cc/sleep.ccat > tests/cc/sleep.c <<'endcat'#include <stdio.h>main (){    char token[80];    printf("about to sleep");    fflush(stdout);    sleep(2);    endnot();}endnot(){    printf("done\n");}'endcat'echo tests/cc/sleep.inrm -f tests/cc/sleep.incat > tests/cc/sleep.in <<'endcat'run'endcat'echo tests/cc/nested.outrm -f tests/cc/nested.outcat > tests/cc/nested.out <<'endcat'reading symbolic information ...[1] stop at 20[1] stopped in $b1 at line 20   20   	j = j + i;$b1, line 20 in "nested.c"sub, line 20 in "nested.c"main(0x1, 0x7fffed74, 0x7fffed7c), line 10 in "nested.c"1 0 [3] stop at 24[3] stopped in sub at line 24   24   	j = j + i;sub, line 24 in "nested.c"main(0x1, 0x7fffed74, 0x7fffed7c), line 10 in "nested.c"11 0 3 'endcat'echo tests/cc/call.crm -f tests/cc/call.ccat > tests/cc/call.c <<'endcat'/* * Test program for dbx call command. */int global;main (argc, argv)int argc;char *argv[];{    int main_local;    global = 2;    main_local = 19;    p1();    p2(main_local);    p3("test");}p1 (){    printf("in p1\n");    global = 4;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -