summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pattest.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/pattest.c b/pattest.c
index d7b6fca..1923614 100644
--- a/pattest.c
+++ b/pattest.c
@@ -8,6 +8,7 @@
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
+#include <time.h>
#include "bittest.h"
#ifdef STANDALONE_ZAPATA
@@ -38,8 +39,10 @@ int main(int argc, char *argv[])
int setup=0;
int errors=0;
int bytes=0;
+ time_t start_time = 0;
+ int timeout = 0;
if (argc < 2) {
- fprintf(stderr, "Usage: markhdlctest <tor device>\n");
+ fprintf(stderr, "Usage: %s <zap device> [optional timeout]\n",argv[0]);
exit(1);
}
fd = open(argv[1], O_RDWR, 0600);
@@ -56,6 +59,11 @@ int main(int argc, char *argv[])
exit(1);
}
ioctl(fd, ZT_GETEVENT);
+ if (argc == 3) {
+ timeout = atoi(argv[2]);
+ start_time = time(NULL);
+ printf("Using Timeout of %d Seconds\n",timeout);
+ }
for(;;) {
res = bs;
res = read(fd, outbuf, res);
@@ -99,6 +107,10 @@ int main(int argc, char *argv[])
#if 0
printf("(%d) Wrote %d bytes\n", packets++, res);
#endif
+ if (timeout && (time(NULL) - start_time) > timeout) {
+ printf("Timeout achieved Ending Program\n");
+ return errors;
+ }
}
}