+ char *host = 0;
+ int port = 0;
+ int c;
+ int i;
+ int ok;
+ int nok = 0;
+ char *arg;
+
+ while ((c = options("c:s:p:fbd:rv:", argv, argc, &arg)) != -2) {
+ switch (c) {
+ case 0:
+ if (!host)
+ host = arg;
+ else if (!port)
+ port = atoi(arg);
+ else
+ usage(*argv);
+ break;
+ case 'c': boptions.nconnect = atoi(arg); break;
+ case 's': boptions.nsearch = atoi(arg); break;
+ case 'p': boptions.npresent = atoi(arg); break;
+ case 'f': boptions.full = 1; break;
+ case 'b': boptions.full = 0; break;
+ case 'd': boptions.delay = atoi(arg); break;
+ case 'r': boptions.random = 1; break;
+ case 'v': boptions.verbosity = atoi(arg); break;
+ default: usage(*argv);
+ }
+ }
+
+ if (!host || !port)
+ usage(*argv);
+
+ for (i = 0; i < boptions.nconnect; i++) {
+ db_printf(2, "iteration %d of %d", i+1, boptions.nconnect);
+ ok = test(host, port);
+ if (ok) nok++;
+ }
+
+ db_printf(1, "passed %d of %d tests", nok, boptions.nconnect);
+ if (nok < boptions.nconnect)
+ printf("Failed %d of %d tests\n",
+ boptions.nconnect-nok, boptions.nconnect);
+
+ return 0;
+}
+
+static void usage(const char *prog)
+{
+ fprintf(stderr, "Usage: %s [options] <host> <port>\n"
+" -c <n> Make <n> connection to the server [default: 3]\n"
+" -s <n> Perform <n> searches on each connection [3]\n"
+" -p <n> Make <n> present requests after each search [3]\n"
+" -f Fetch full records [default: brief]\n"
+" -b Fetch brief records\n"
+" -d <n> Delay <n> ms after each operation\n"
+" -r Delays are random between 0 and the specified number of ms\n"
+" -v <n> Set verbosity level to <n> [0, silent on success]\n"
+ , prog);
+ exit(1);