|
|
1.1 ! root 1: /* @(#)test3.c 1.4 90/01/03 NFS Rev 2 Testsuite ! 2: * 1.5 Lachman ONC Test Suite source ! 3: * ! 4: * Test lookup up and down across mount points ! 5: * ! 6: * Uses the following important system calls against the server: ! 7: * ! 8: * chdir() ! 9: * getwd() ! 10: * stat() ! 11: */ ! 12: ! 13: #include <sys/param.h> ! 14: #ifdef SVR3 ! 15: #include <sys/types.h> ! 16: #include <sys/fs/nfs/time.h> ! 17: #else ! 18: #include <sys/vfs.h> ! 19: #include <sys/time.h> ! 20: #endif ! 21: #include <sys/stat.h> ! 22: #include <sys/errno.h> ! 23: #include <stdio.h> ! 24: #include "tests.h" ! 25: ! 26: int Tflag = 0; /* print timing */ ! 27: int Hflag = 0; /* print help message */ ! 28: int Fflag = 0; /* test function only; set count to 1, negate -t */ ! 29: int Nflag = 0; /* Suppress directory operations */ ! 30: ! 31: usage() ! 32: { ! 33: fprintf(stdout, "usage: %s [-htfn] [count]\n", Myname); ! 34: fprintf(stdout, " Flags: h Help - print this usage info\n"); ! 35: fprintf(stdout, " t Print execution time statistics\n"); ! 36: fprintf(stdout, " f Test function only (negate -t)\n"); ! 37: fprintf(stdout, " n Suppress test directory create operations\n"); ! 38: } ! 39: ! 40: main(argc, argv) ! 41: int argc; ! 42: char *argv[]; ! 43: { ! 44: int count = 250; /* times to do test */ ! 45: int ct; ! 46: struct timeval time; ! 47: struct stat statb; ! 48: char *opts; ! 49: char path[MAXPATHLEN]; ! 50: ! 51: umask(0); ! 52: setbuf(stdout, NULL); ! 53: Myname = *argv++; ! 54: argc--; ! 55: while (argc && **argv == '-') { ! 56: for (opts = &argv[0][1]; *opts; opts++) { ! 57: switch (*opts) { ! 58: case 'h': /* help */ ! 59: usage(); ! 60: exit(1); ! 61: ! 62: case 't': /* time */ ! 63: Tflag++; ! 64: break; ! 65: ! 66: case 'f': /* funtionality */ ! 67: Fflag++; ! 68: break; ! 69: ! 70: case 'n': /* No Test Directory create */ ! 71: Nflag++; ! 72: break; ! 73: ! 74: default: ! 75: error("unknown option '%c'", *opts); ! 76: usage(); ! 77: exit(1); ! 78: } ! 79: } ! 80: argc--; ! 81: argv++; ! 82: } ! 83: ! 84: if (argc) { ! 85: count = getparm(*argv, 1, "count"); ! 86: argv++; ! 87: argc--; ! 88: } ! 89: if (argc) { ! 90: usage(); ! 91: exit(1); ! 92: } ! 93: ! 94: if (Fflag) { ! 95: Tflag = 0; ! 96: count = 1; ! 97: } ! 98: ! 99: fprintf(stdout, "%s: lookups across mount point\n", Myname); ! 100: ! 101: if (!Nflag) ! 102: testdir(NULL); ! 103: else ! 104: mtestdir(NULL); ! 105: ! 106: if (Tflag) { ! 107: starttime(); ! 108: } ! 109: ! 110: for (ct = 0; ct < count; ct++) { ! 111: #ifdef SVR3 ! 112: if (getcwd(path, sizeof(path)) == NULL) { ! 113: fprintf(stderr, "%s: getcwd failed\n", Myname); ! 114: exit(1); ! 115: } ! 116: #else ! 117: if (getwd(path) == NULL) { ! 118: fprintf(stderr, "%s: getwd failed\n", Myname); ! 119: exit(1); ! 120: } ! 121: #endif ! 122: if (stat(path, &statb) < 0) { ! 123: error("can't stat %s after getwd", path); ! 124: exit(1); ! 125: } ! 126: } ! 127: ! 128: if (Tflag) { ! 129: endtime(&time); ! 130: } ! 131: fprintf(stdout, "\t%d getwd and stat calls", count * 2); ! 132: if (Tflag) { ! 133: fprintf(stdout, " in %d.%-2d seconds", ! 134: time.tv_sec, time.tv_usec / 10000); ! 135: } ! 136: fprintf(stdout, "\n"); ! 137: complete(); ! 138: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.