summaryrefslogtreecommitdiffstats
path: root/tests/tcpflood.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-06-04 10:33:42 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-06-04 10:33:42 +0200
commit7dee07ea0c9dd8523fc1f3d20f07746a376b9d01 (patch)
treef4690146839ab5c2e4a8e721c725cc381ac52520 /tests/tcpflood.c
parent69eac5341d49c5c7278e6d86a77dc9d6b4a4edde (diff)
parente893a5916473c45d6b90dc2401637fe713133291 (diff)
downloadrsyslog-7dee07ea0c9dd8523fc1f3d20f07746a376b9d01.tar.gz
rsyslog-7dee07ea0c9dd8523fc1f3d20f07746a376b9d01.tar.bz2
rsyslog-7dee07ea0c9dd8523fc1f3d20f07746a376b9d01.zip
Merge branch 'master' into omfile
Diffstat (limited to 'tests/tcpflood.c')
-rw-r--r--tests/tcpflood.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index c3c9c871..2ca796ca 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -6,6 +6,7 @@
* argv[2] target port
* argv[3] number of connections
* argv[4] number of messages to send (connection is random)
+ * argv[5] initial message number (optional)
*
* Part of the testbench for rsyslog.
*
@@ -51,6 +52,7 @@ static int targetPort;
static int numMsgsToSend; /* number of messages to send */
static int numConnections; /* number of connections to create */
static int *sockArray; /* array of sockets to use */
+static int msgNum = 0; /* initial message number to start with */
/* open a single tcp connection
@@ -166,19 +168,20 @@ int sendMessages(void)
socknum = i - (numMsgsToSend - numConnections);
else
socknum = rand() % numConnections;
- lenBuf = sprintf(buf, "<167>Mar 1 01:00:00 172.20.245.8 tag msgnum:%8.8d:\n", i);
+ lenBuf = sprintf(buf, "<167>Mar 1 01:00:00 172.20.245.8 tag msgnum:%8.8d:\n", msgNum);
lenSend = send(sockArray[socknum], buf, lenBuf, 0);
if(lenSend != lenBuf) {
printf("\r%5.5d\n", i);
fflush(stdout);
perror("send test data");
- printf("send() failed at socket %d, index %d\n", socknum, i);
+ printf("send() failed at socket %d, index %d, msgNum %d\n", socknum, i, msgNum);
fflush(stderr);
return(1);
}
if(i % 100 == 0) {
printf("\r%5.5d", i);
}
+ ++msgNum;
}
printf("\r%5.5d messages sent\n", i);
@@ -260,9 +263,9 @@ int main(int argc, char *argv[])
setvbuf(stdout, buf, _IONBF, 48);
- if(argc != 5) {
+ if(argc != 5 && argc != 6) {
printf("Invalid call of tcpflood\n");
- printf("Usage: tcpflood target-host target-port num-connections num-messages\n");
+ printf("Usage: tcpflood target-host target-port num-connections num-messages [initial msgnum]\n");
exit(1);
}
@@ -270,6 +273,8 @@ int main(int argc, char *argv[])
targetPort = atoi(argv[2]);
numConnections = atoi(argv[3]);
numMsgsToSend = atoi(argv[4]);
+ if(argc == 6)
+ msgNum = atoi(argv[5]);
if(openConnections() != 0) {
printf("error opening connections\n");