diff --git a/Makefile.in b/Makefile.in index 5c431d9ab6..53cc372f9d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -190,6 +190,9 @@ rxgen: $(DIR_roken) config rx: config lwp rxgen rx_depinstall util rxgk_depinstall +${COMPILE_PART1} rx ${COMPILE_PART2} +rx_test: rx libafsrpc + +${COMPILE_PART1} rx/test ${COMPILE_PART2} + rxstat: rx rxstat_depinstall +${COMPILE_PART1} rxstat ${COMPILE_PART2} @@ -635,7 +638,7 @@ finale_notest: project cmd comerr afsd butc tbutc tbudb @ENABLE_KERNEL_MODULE@ \ bozo @VFSCK@ volser tvolser tsalvaged dviced dvolser libafscp \ venus venustests update xstat afsmonitor rxdebug libafsrpc rfc3961 \ hcrypto libafsauthent libadmin man-pages tools platform kopenafs \ - authtools $(DIR_roken) rxgk + authtools $(DIR_roken) rxgk rx_test +${COMPILE_PART1} finale ${COMPILE_PART2} finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit kauth \ @@ -643,7 +646,7 @@ finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit k volser tvolser tsalvaged dviced dvolser libafscp venus venustests \ update xstat afsmonitor rxdebug libafsrpc rfc3961 hcrypto \ libafsauthent libadmin man-pages tools platform kopenafs \ - authtools $(DIR_roken) rxgk + authtools $(DIR_roken) rxgk rx_test +${COMPILE_PART1} finale ${COMPILE_PART2} finale: finale_notest test_build diff --git a/src/rx/Makefile.in b/src/rx/Makefile.in index 1f56975403..77b37bda40 100644 --- a/src/rx/Makefile.in +++ b/src/rx/Makefile.in @@ -182,6 +182,7 @@ dest: librx.a # Misc. targets # clean: + cd test && $(MAKE) clean $(LT_CLEAN) $(RM) -f *.o *.a core *_component_version_number.c diff --git a/src/rx/test/.gitignore b/src/rx/test/.gitignore index f1fecd2ebe..f90255583d 100644 --- a/src/rx/test/.gitignore +++ b/src/rx/test/.gitignore @@ -2,8 +2,11 @@ # git ls-files -i --exclude-standard # to check that you haven't inadvertently ignored any tracked files. +/generator +/kctest +/kstest +/tableGen /testclient /testserver -/generator -/tableGen -/th_rxperf +/th_testclient +/th_testserver diff --git a/src/rx/test/Makefile.in b/src/rx/test/Makefile.in index d84e9690d6..84fdcc3137 100644 --- a/src/rx/test/Makefile.in +++ b/src/rx/test/Makefile.in @@ -12,7 +12,8 @@ include @TOP_OBJDIR@/src/config/Makefile.lwp LDIRS= -L.. -L${TOP_LIBDIR} LIBS= ${TOP_LIBDIR}/libcmd.a ../librx.a ${TOP_LIBDIR}/liblwp.a \ - ${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/libsys.a ${XLIBS} + ${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libopr.a \ + ${LIB_hcrypto} ${LIB_roken} ${XLIBS} MODULE_CFLAGS=-DRXDEBUG @@ -26,12 +27,14 @@ MT_LINK = $(CC) $(MT_CFLAGS) $(COMMON_CFLAGS) $(AFS_LDFLAGS) -o $@ \ $(LIB_hcrypto) $(LIB_roken) \ $(MT_LIBS) -TESTS = testclient testserver kstest kctest testqueue tableGen generator +TESTS = testclient testserver kstest kctest tableGen generator TH_TESTS = th_testserver th_testclient -all: test +all: test th_test + +install dest: test tests: ${TESTS} @@ -49,7 +52,10 @@ kstest: ../librx.a kstest.o kctest: ../librx.a kctest.o ${LINK} -rxperf: rxperf.o ../librx.a +tableGen: ../librx.a tableGen.o + ${LINK} + +generator: ../librx.a generator.o ${LINK} # th_ versions only have link lines for Solaris now. @@ -67,16 +73,6 @@ th_testserver.o: testserver.c $(MT_CC) $(COMMON_CFLAGS) $(MT_CFLAGS) -c -o th_testserver.o \ ${srcdir}/testserver.c -th_rxperf: th_rxperf.o ${TOP_LIBDIR}/libafsrpc.a ${TOP_LIBDIR}/libopr.a - $(MT_LINK) - -th_rxperf.o: rxperf.c - $(MT_CC) $(COMMON_CFLAGS) $(MT_CFLAGS) -c $(srcdir)/rxperf.c \ - -o th_rxperf.o - -testqueue: ../librx.a testqueue.o - ${LINK} - ${RXTESTOBJS}: ${BASICINCLS} ../rx.h clean: diff --git a/src/rx/test/generator.c b/src/rx/test/generator.c index d2cb3e9850..871697add4 100644 --- a/src/rx/test/generator.c +++ b/src/rx/test/generator.c @@ -262,14 +262,14 @@ WriteXG(rpcArgs * argsP, FILE * xg_h, char *serverName, int sign_no) /* declare each arg */ for (i = 0; i < argsP->argCount; i++) { - WriteXGDecl(&argsP->argDescr[i], xg_h, i, FALSE, + WriteXGDecl(&argsP->argDescr[i], xg_h, i, 0, (i == argsP->argCount - 1)); } /* Now pass the paramaters inside a structure */ fprintf(xg_h, "\nstruct %s_t {\n", name); for (i = 0; i < argsP->argCount; i++) { - WriteXGDecl(&argsP->argDescr[i], xg_h, i, TRUE, + WriteXGDecl(&argsP->argDescr[i], xg_h, i, 1, (i == argsP->argCount - 1)); } fprintf(xg_h, "} ;\n"); @@ -285,7 +285,7 @@ WriteXG(rpcArgs * argsP, FILE * xg_h, char *serverName, int sign_no) PRIVATE void GetRandStr(int strLen, char **ret, int *rP) { - int i, randI; + int i, randI = 0; char buf[5]; strcpy(*ret, "\""); @@ -537,7 +537,7 @@ WriteServC(rpcArgs * argsP, FILE * srv_h, char *serverName, int sign_no) argsP->argDescr[i].outValue[0]); } else if (strstr(typ, "String")) { fprintf(srv_h, "\n\t*a%d = (drpc_%s_t)rpc_ss_allocate(%d);", - i, typ, strlen(argsP->argDescr[i].outValue[0]) - 1); + i, typ, (int)strlen(argsP->argDescr[i].outValue[0]) - 1); fprintf(srv_h, "\n\tstrcpy((char *)*a%d, %s);", i, argsP->argDescr[i].outValue[0]); } else { @@ -609,7 +609,7 @@ WriteServC(rpcArgs * argsP, FILE * srv_h, char *serverName, int sign_no) argsP->argDescr[i].outValue[0]); } else if (strstr(typ, "String")) { fprintf(srv_h, "\n\ts->a%d = rpc_ss_allocate(%d);", i, - strlen(argsP->argDescr[i].outValue[0]) - 1); + (int)strlen(argsP->argDescr[i].outValue[0]) - 1); fprintf(srv_h, "\n\tstrcpy((char *)s->a%d, %s);", i, argsP->argDescr[i].outValue[0]); } else { @@ -1004,7 +1004,7 @@ WriteClt(rpcArgs * argsP, char *serverName, int sign_no, FILE * itl_h) /* initialize IN/INOUT args */ for (i = 0; i < argsP->argCount; i++) { - WriteCltInit(&argsP->argDescr[i], itl_h, i, FALSE); + WriteCltInit(&argsP->argDescr[i], itl_h, i, 0); } /* call the server */ @@ -1075,7 +1075,7 @@ WriteClt(rpcArgs * argsP, char *serverName, int sign_no, FILE * itl_h) /* initialize IN/INOUT args */ for (i = 0; i < argsP->argCount; i++) { - WriteCltInit(&argsP->argDescr[i], itl_h, i, TRUE); + WriteCltInit(&argsP->argDescr[i], itl_h, i, 1); } /* call the server */ @@ -1274,7 +1274,7 @@ ProcessCmdLine(int argc, char **argv, char **serverName, char **ipFileName, } -void +int main(int argc, char **argv) { FILE *table_h, *srv_h, *xg_h, *clt_h, *mak_h; @@ -1431,5 +1431,5 @@ main(int argc, char **argv) fprintf(mak_h, "\t%s %s%d.mak clean\n", platform[0], serverName, i); fclose(mak_h); - exit(0); + return 0; } diff --git a/src/rx/test/generator.h b/src/rx/test/generator.h index 637ff8ad4c..5104f6ee1e 100644 --- a/src/rx/test/generator.h +++ b/src/rx/test/generator.h @@ -14,7 +14,7 @@ #define MACRO_END } while (0) -typedef enum { FALSE, TRUE } boolean_t; +typedef int boolean_t; /* no. tests per file */ #define TESTS_PER_FILE 50 diff --git a/src/rx/test/kctest.c b/src/rx/test/kctest.c index abf98fc49d..5c7f88036f 100644 --- a/src/rx/test/kctest.c +++ b/src/rx/test/kctest.c @@ -16,13 +16,10 @@ #include #include #include -#include "xdr.h" -#include "rx.h" -#include "rx_globals.h" -#include "rx_null.h" -#if RX_VAB_EXISTS -#include "rx_vab.h" -#endif +#include "rx/xdr.h" +#include "rx/rx.h" +#include "rx/rx_globals.h" +#include "rx/rx_null.h" static long host; static short port; @@ -30,23 +27,7 @@ static short count; static short secLevel = 0; static short stats = 0; -#if RX_VAB_EXISTS -static -MakeVTest(akey, aticket, asession) - struct rxvab_EncryptionKey *akey, *asession; - struct rxvab_Ticket *aticket; -{ - aticket->ViceId = htonl(71); - memcpy(&aticket->HandShakeKey, "testkeyx", 8); - memcpy(asession, "testkeyx", 8); - bcrypt_encrypt(aticket, aticket, sizeof(struct rxvab_Ticket), akey); - return 0; -} -#else -#define MakeVTest(a,b,c) (printf ("rx_vab support removed\n"), exit (-1)) -#endif - -void +static void SigInt(int ignore) { if (rx_debugFile) { @@ -59,10 +40,8 @@ SigInt(int ignore) exit(1); } -static -ParseCmd(argc, argv) - int argc; - char **argv; +static int +ParseCmd(int argc, char **argv) { int i; struct hostent *th; @@ -100,7 +79,8 @@ ParseCmd(argc, argv) return 0; } -nowms() +static long +nowms(void) { struct timeval tv; long temp; @@ -110,9 +90,8 @@ nowms() return temp; } -main(argc, argv) - int argc; - char **argv; +int +main(int argc, char **argv) { struct rx_securityClass *so; struct rx_connection *tconn; @@ -120,10 +99,6 @@ main(argc, argv) XDR xdr; int i, startms, endms; long temp; -#if RX_VAB_EXISTS - struct rxvab_Ticket ticket; - struct rxvab_EncryptionKey session; -#endif host = htonl(0x7f000001); port = htons(10000); @@ -133,20 +108,8 @@ main(argc, argv) exit(1); } rx_Init(0); - if (secLevel == 0) + if (secLevel == 0) { so = rxnull_NewClientSecurityObject(); - else if (secLevel == 1) { - MakeVTest((struct rxvab_EncryptionKey *)"applexxx", &ticket, - &session); -#if RX_VAB_EXISTS - so = rxvab_NewClientSecurityObject(&session, &ticket, 0); -#endif - } else if (secLevel == 2) { - MakeVTest((struct rxvab_EncryptionKey *)"applexxx", &ticket, - &session); -#if RX_VAB_EXISTS - so = rxvab_NewClientSecurityObject(&session, &ticket, 1); -#endif } else { printf("bad security index\n"); exit(1); @@ -156,7 +119,7 @@ main(argc, argv) exit(1); } tconn = rx_NewConnection(host, port, 1, so, secLevel); - printf("conn is %x\n", tconn); + printf("conn is %p\n", tconn); startms = nowms(); for (i = 0; i < count; i++) { @@ -168,7 +131,7 @@ main(argc, argv) xdr.x_op = XDR_DECODE; xdr_long(&xdr, &temp); if (temp != 1989) - printf("wrong value returned (%d)\n", temp); + printf("wrong value returned (%ld)\n", temp); rx_EndCall(tcall, 0); } endms = nowms(); @@ -179,4 +142,5 @@ main(argc, argv) rx_PrintStats(stdout); #endif SigInt(0); + return 1; } diff --git a/src/rx/test/kstest.c b/src/rx/test/kstest.c index 9c68d71575..6303ed3bcd 100644 --- a/src/rx/test/kstest.c +++ b/src/rx/test/kstest.c @@ -16,10 +16,10 @@ #include #include #include -#include "xdr.h" -#include "rx.h" -#include "rx_globals.h" -#include "rx_null.h" +#include "rx/xdr.h" +#include "rx/rx.h" +#include "rx/rx_globals.h" +#include "rx/rx_null.h" static int port; static short stats = 0; @@ -37,10 +37,8 @@ SigInt(int ignore) } -static -ParseCmd(argc, argv) - int argc; - char **argv; +static int +ParseCmd(int argc, char **argv) { int i; for (i = 1; i < argc; i++) { @@ -64,9 +62,8 @@ ParseCmd(argc, argv) } /* er loop */ -static -rxk_erproc(acall) - struct rx_call *acall; +static int +rxk_erproc(struct rx_call *acall) { XDR xdr; long temp; @@ -79,11 +76,10 @@ rxk_erproc(acall) return 0; } -main(argc, argv) - int argc; - char **argv; +int +main(int argc, char **argv) { - long code; + int code; static struct rx_securityClass *sc[3]; /* so other kernel procs can reference it */ struct rx_service *tservice; @@ -103,10 +99,11 @@ main(argc, argv) sc[1] = sc[2] = 0; printf("new secobj created\n"); tservice = rx_NewService(0, 1, "test", sc, 1 /* 3 */ , rxk_erproc); - printf("service is %x\n", tservice); + printf("service is %p\n", tservice); if (!tservice) { printf("failed to create service\n"); exit(1); } rx_StartServer(1); /* donate self */ + return -1; } diff --git a/src/rx/test/tableGen.c b/src/rx/test/tableGen.c index 078de99c77..cf758e6929 100644 --- a/src/rx/test/tableGen.c +++ b/src/rx/test/tableGen.c @@ -66,20 +66,10 @@ \n"); \ MACRO_END -/* macro which sets if attributes for var/conf found */ -#define SET_ATTR_FLAGS( x ) \ - MACRO_BEGIN \ - if (!strcmp(attrib[x], "size")) SIZE = TRUE;\ - else if (!strcmp(attrib[x], "max")) MAX = TRUE; \ - else if (!strcmp(attrib[x], "length")) LENGTH = TRUE;\ - else if (!strcmp(attrib[x], "last")) LAST = TRUE;\ - MACRO_END - static char **dir; static char **typ; static int dir_size; static int typ_size; -static int attr_size; PRIVATE char *init_dir[] = { "IN", "OUT", "INOUT" }; @@ -92,25 +82,6 @@ PRIVATE char *init_typ[] = { "ar_short", "ar_int32", }; -PRIVATE char *attrib[] = { - "1 max", - "1 size", - "1 first", - "1 last", - "1 length", - "2 max first", - "2 max last", - "2 max length", - "2 size first", - "2 size last", - "2 size length", - "2 first last", - "2 first length", - "3 max first last", - "3 max first length", - "3 size first last", - "3 size first length" -}; /* * 31 bit random number generator, we don't really care how random @@ -120,7 +91,7 @@ PRIVATE char *attrib[] = { static unsigned long randVal = 0x330E16; PRIVATE double -drand32() +drand32(void) { randVal = ((randVal * 0xEECE66D) + 0xB) & 0xFFFFFFFF; return ((double)(randVal) / 4294967296.0); @@ -158,9 +129,7 @@ BunchArg(FILE * O_FP) * SingleArg -- prints signature for single argument of given type */ PRIVATE void -SingleArg(O_FP, typ_index) - FILE *O_FP; - IN int typ_index; +SingleArg(FILE *O_FP, int typ_index) { int dir_index; @@ -180,10 +149,7 @@ SingleArg(O_FP, typ_index) * DoubleArg -- prints signature for two arguments of given types */ PRIVATE void -DoubleArg(O_FP, typ_index1, typ_index2) - FILE *O_FP; - IN int typ_index1; - IN int typ_index2; +DoubleArg(FILE *O_FP, int typ_index1, int typ_index2) { int dir_index1; int dir_index2; @@ -209,11 +175,7 @@ DoubleArg(O_FP, typ_index1, typ_index2) * ProcessCmdLine -- processes the command line args */ PRIVATE void -ProcessCmdLine(argc, argv, apFileNamePP, outputFileP) - int argc; - char **argv; - char **apFileNamePP; - char **outputFileP; +ProcessCmdLine(int argc, char **argv, char **apFileNamePP, char **outputFileP) { int i, n; char **p; @@ -299,14 +261,10 @@ ProcessCmdLine(argc, argv, apFileNamePP, outputFileP) typ_size = sizeof(init_typ) / sizeof(init_typ[0]); typ = &init_typ[0]; } - - attr_size = sizeof(attrib) / sizeof(attrib[0]); } -void -main(argc, argv) - int argc; - char **argv; +int +main(int argc, char **argv) { int i, j; char *apFileName = NULL; @@ -340,5 +298,5 @@ main(argc, argv) } fclose(O_FP); - exit(0); + return 0; } diff --git a/src/rx/test/testclient.c b/src/rx/test/testclient.c index 0ed74c6253..fe4df9f9bb 100644 --- a/src/rx/test/testclient.c +++ b/src/rx/test/testclient.c @@ -82,7 +82,6 @@ main(int argc, char **argv) int logstdout = 0; struct rx_connection *conn; struct rx_call *call; - struct rx_peer *peer; int err = 0; int nCalls = 1, nBytes = 1; int bufferSize = 4000000; diff --git a/src/rx/test/testqueue.c b/src/rx/test/testqueue.c deleted file mode 100644 index b6c4669e7c..0000000000 --- a/src/rx/test/testqueue.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2000, International Business Machines Corporation and others. - * All Rights Reserved. - * - * This software has been released under the terms of the IBM Public - * License. For details, see the LICENSE file in the top-level source - * directory or online at http://www.openafs.org/dl/license10.html - */ - -#include -#include - - -#include - -struct myq { - struct rx_queue queue_header; - int value; -}; - -void -qprint(char *s, struct myq *qe) -{ - printf("%s/%x: next:%x, prev:%x, value=%d\n", s, qe, queue_Next(qe, myq), - queue_Prev(qe, myq), qe->value); -} - -void -qremove(char *s, struct myq *q) -{ - struct myq *qe, *nqe; - printf("*head* "); - qprint(s, q); - for (queue_Scan(q, qe, nqe, myq)) { - if (qe->value <= 10) - queue_Remove(qe); - else - qprint(s, qe); - } -} - -/* Separate test for the splice macros */ -struct rx_queue * -createQueue(int n) -{ - int i; - struct rx_queue *q; - struct myq *qe; - q = malloc(sizeof(struct rx_queue)); - queue_Init(q); - for (i = 0; i < 3; i++) { - qe = malloc(sizeof(struct myq)); - qe->value = n * 1000 + i; - queue_Append(q, qe); - } - return q; -} - -void -testSplice(void) -{ - struct rx_queue *q[10]; - struct myq *qe, *nqe; - int i; - for (i = 0; i < 10; i++) - q[i] = createQueue(i); - for (i = 0; i < 9; i++) { - if (i & 1) - queue_SplicePrepend(q[0], q[i + 1]); - else - queue_SpliceAppend(q[0], q[i + 1]); - } - /* Move the queue to the middle (splice non-empty onto empty) */ - queue_SpliceAppend(q[7], q[0]); - queue_SplicePrepend(q[6], q[0]); - /* Splice some empty&non-empty queues onto empty&non-empty queues */ - for (i = 0; i < 9; i++) - queue_SpliceAppend(q[i], q[i + 1]); - for (i = 0; i < 9; i++) - queue_SplicePrepend(q[i], q[i + 1]); - printf("All queues except 5 should be empty\n"); - for (i = 0; i < 10; i++) { - printf("Forwards, i=%d:", i); - for (queue_Scan(q[i], qe, nqe, myq)) - printf(" %d", qe->value); - printf("\n"); - } - for (i = 0; i < 10; i++) { - printf("Backwards, i=%d:", i); - for (queue_ScanBackwards(q[i], qe, nqe, myq)) - printf(" %d", qe->value); - printf("\n"); - } -} - -void -testAppend(void) -{ - int i; - struct myq x; - struct myq xa[20]; - struct myq y; - struct myq ya[20]; - - queue_Init(&x); - x.value = 100001; - for (i = 0; i < 20; i++) - queue_Prepend(&x, &xa[i]), xa[i].value = i + 1; - queue_Init(&y); - y.value = 100002; - for (i = 0; i < 20; i++) - queue_Append(&y, &ya[i]), ya[i].value = i + 1; - qremove("x, first pass", &x); - qremove("x, later", &x); - qremove("y, first pass", &y); - qremove("y, later", &y); -} - -int -main(int argc, char **argv) -{ - - if (argc > 1) { - testSplice(); - } else { - testAppend(); - } - exit(0); -} diff --git a/src/rx/test/testserver.c b/src/rx/test/testserver.c index deead44641..189c1f01b6 100644 --- a/src/rx/test/testserver.c +++ b/src/rx/test/testserver.c @@ -55,9 +55,7 @@ quitSignal(int ignore) #if !defined(AFS_NT40_ENV) && !defined(AFS_LINUX_ENV) int -test_syscall(a3, a4, a5) - afs_uint32 a3, a4; - void *a5; +test_syscall(afs_uint32 a3, afs_uint32 a4, void *a5) { afs_uint32 rcode; void (*old) (int); @@ -71,8 +69,8 @@ test_syscall(a3, a4, a5) } #endif -main(argc, argv) - char **argv; +int +main(int argc, char **argv) { struct rx_service *service; struct rx_securityClass *(secobjs[1]); @@ -94,8 +92,10 @@ main(argc, argv) else if (strcmp(*argv, "-rxlog") == 0) rxlog = 1; #if defined(RXDEBUG) && !defined(AFS_NT40_ENV) - else if (strcmp(*argv, "-trace") == 0) + else if (strcmp(*argv, "-trace") == 0) { + extern char rxi_tracename[80]; strcpy(rxi_tracename, *(++argv)), argc--; + } #endif else if (strcmp(*argv, "-logstdout") == 0) logstdout = 1; @@ -193,6 +193,7 @@ main(argc, argv) printf("Using %d packet buffers\n", rx_nPackets); rx_StartServer(1); + return -1; } static char buf[2000000]; @@ -278,7 +279,7 @@ FileRequest(struct rx_call *call) rx_SetLocalStatus(call, 79); /* Emulation of file server's old "RCallBackReceivedStore" */ - while (nbytes = rx_Read(call, buffer, blockSize)) { + while ((nbytes = rx_Read(call, buffer, blockSize)) != 0) { if (write(fd, buffer, nbytes) != nbytes) { perror("writev"); Abort("Write Failed.\n");