summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/zttest.88
-rw-r--r--zttest.c43
2 files changed, 49 insertions, 2 deletions
diff --git a/doc/zttest.8 b/doc/zttest.8
index 79b1772..7b9970f 100644
--- a/doc/zttest.8
+++ b/doc/zttest.8
@@ -25,6 +25,14 @@ Values of 99.98% and 99.97% are probably OK as well.
Be more verbose: print one line per test.
.RE
+.B -c
+.I count
+.RS
+Run for
+.I count
+times instead of running forever.
+.RE
+
.SH FILES
.B /dev/zap/pseudo
.RS
diff --git a/zttest.c b/zttest.c
index 350d7ee..1ee1a2c 100644
--- a/zttest.c
+++ b/zttest.c
@@ -7,6 +7,7 @@
#include <sys/time.h>
#include <sys/signal.h>
#include <math.h>
+#include <getopt.h>
#define SIZE 8000
@@ -24,12 +25,30 @@ void hup_handler(int sig)
exit(0);
}
+static void usage(char *argv0)
+{
+ char *c;
+ c = strrchr(argv0, '/');
+ if (!c)
+ c = argv0;
+ else
+ c++;
+ fprintf(stderr,
+ "Usage: %s [-c COUNT] [-v]\n"
+ " Valid options are:\n"
+ " -c COUNT Run just COUNT cycles (otherwise: forever).\n"
+ " -v More verbose output.\n"
+ " -h This help text.\n"
+ ,c);
+}
+
int main(int argc, char *argv[])
{
int fd;
int res;
+ int c;
int count=0;
- int seconds;
+ int seconds = 0;
int curarg = 1;
int verbose=0;
char buf[8192];
@@ -41,6 +60,25 @@ int main(int argc, char *argv[])
fprintf(stderr, "Unable to open zap interface: %s\n", strerror(errno));
exit(1);
}
+
+ while((c = getopt(argc, argv, "c:hv")) != -1) {
+ switch(c) {
+ case 'c':
+ seconds = atoi(optarg);
+ break;
+ case 'h':
+ usage(argv[0]);
+ exit(0);
+ break;
+ case '?':
+ usage(argv[0]);
+ exit(1);
+ break;
+ case 'v':
+ verbose++;
+ break;
+ }
+ }
while(curarg < argc) {
if (!strcasecmp(argv[curarg], "-v"))
verbose++;
@@ -56,8 +94,9 @@ int main(int argc, char *argv[])
for (count = 0;count < 4; count++)
res = read(fd, buf, sizeof(buf));
count = 0;
+ ms = 0; /* Makes the compiler happy */
if (seconds > 0)
- alarm(seconds + 1);
+ alarm(seconds + 1); /* This will give 'seconds' cycles */
for(;;) {
if (count == 0)
ms = 0;