summaryrefslogtreecommitdiffstats
path: root/tests/chkseq.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-10 12:19:51 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-10 12:19:51 +0100
commit5106cbe466781e824846742a036d36ba5f884ad6 (patch)
treec1a3e42dee13ae59daaafcbd415a4973e36d386b /tests/chkseq.c
parent4408d4137acfacef57bd2e088a0da83d25e34918 (diff)
downloadrsyslog-5106cbe466781e824846742a036d36ba5f884ad6.tar.gz
rsyslog-5106cbe466781e824846742a036d36ba5f884ad6.tar.xz
rsyslog-5106cbe466781e824846742a036d36ba5f884ad6.zip
added ability to work with larger message sizes to testbench tools
Diffstat (limited to 'tests/chkseq.c')
-rw-r--r--tests/chkseq.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/chkseq.c b/tests/chkseq.c
index 6334d787..b8088cd5 100644
--- a/tests/chkseq.c
+++ b/tests/chkseq.c
@@ -32,6 +32,7 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <getopt.h>
int main(int argc, char *argv[])
@@ -40,14 +41,18 @@ int main(int argc, char *argv[])
int val;
int i;
int ret = 0;
+ int scanfOK;
int verbose = 0;
+ int bHaveExtraData = 0;
int dupsPermitted = 0;
int start = 0, end = 0;
int opt;
int nDups = 0;
+ int edLen; /* length of extra data */
+ static char edBuf[500*1024]; /* buffer for extra data (pretty large to be on the save side...) */
char *file = NULL;
- while((opt = getopt(argc, argv, "e:f:ds:v")) != EOF) {
+ while((opt = getopt(argc, argv, "e:f:ds:vE")) != EOF) {
switch((char)opt) {
case 'f':
file = optarg;
@@ -64,8 +69,11 @@ int main(int argc, char *argv[])
case 'v':
++verbose;
break;
- default:printf("Invalid call of chkseq\n");
- printf("Usage: chkseq file -sstart -eend -d\n");
+ case 'E':
+ bHaveExtraData = 1;
+ break;
+ default:printf("Invalid call of chkseq, optchar='%c'\n", opt);
+ printf("Usage: chkseq file -sstart -eend -d -E\n");
exit(1);
}
}
@@ -93,7 +101,17 @@ int main(int argc, char *argv[])
}
for(i = start ; i < end+1 ; ++i) {
- if(fscanf(fp, "%d\n", &val) != 1) {
+ if(bHaveExtraData) {
+ scanfOK = fscanf(fp, "%d,%d,%s\n", &val, &edLen, edBuf) == 3 ? 1 : 0;
+ if(edLen != (int) strlen(edBuf)) {
+ printf("extra data length specified %d, but actually is %ld in record %d\n",
+ edLen, (long) strlen(edBuf), i);
+ exit(1);
+ }
+ } else {
+ scanfOK = fscanf(fp, "%d\n", &val) == 1 ? 1 : 0;
+ }
+ if(!scanfOK) {
printf("scanf error in index i=%d\n", i);
exit(1);
}