summaryrefslogtreecommitdiff
path: root/pattest.c
diff options
context:
space:
mode:
authorfile <file@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-01-17 19:47:21 +0000
committerfile <file@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-01-17 19:47:21 +0000
commit09b4857c756ec320188f099d51697a708245e311 (patch)
tree7d7bf8fb69bd8a303dd3da548e0277edcf464f8f /pattest.c
parent7374f6f92ba1a61cd24e6b7f926a4d69c7c008da (diff)
Add timeout capability similar to patlooptest to pattest. (issue #8837 reported by opticron)
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1838 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'pattest.c')
-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;
+ }
}
}