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