diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-10 11:07:26 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2010-03-10 11:07:26 +0100 |
commit | 4408d4137acfacef57bd2e088a0da83d25e34918 (patch) | |
tree | 705c34ee7b023ffb4a4795918acd2c0618f7cb29 /tests/tcpflood.c | |
parent | ee8bf6d6873b79a5b1ed5a2aae08adf0d4827ff3 (diff) | |
download | rsyslog-4408d4137acfacef57bd2e088a0da83d25e34918.tar.gz rsyslog-4408d4137acfacef57bd2e088a0da83d25e34918.tar.xz rsyslog-4408d4137acfacef57bd2e088a0da83d25e34918.zip |
testbench: new calling interface for tcpflood
this is a perquisite to support more flexible testing modes, which
could not intelligently be implemented with the old interface
Diffstat (limited to 'tests/tcpflood.c')
-rw-r--r-- | tests/tcpflood.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/tests/tcpflood.c b/tests/tcpflood.c index 0439e33e..308495a5 100644 --- a/tests/tcpflood.c +++ b/tests/tcpflood.c @@ -2,11 +2,11 @@ * messages over them. This is used for stress-testing. * * Params - * argv[1] target address - * 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) + * -t target address (default 127.0.0.1) + * -p target port (default 13514) + * -c number of connections (default 1) + * -m number of messages to send (connection is random) + * -i initial message number (optional) * * Part of the testbench for rsyslog. * @@ -47,10 +47,10 @@ /* Name of input file, must match $IncludeConfig in test suite .conf files */ #define NETTEST_INPUT_CONF_FILE "nettest.input.conf" /* name of input file, must match $IncludeConfig in .conf files */ -static char *targetIP; -static int targetPort; +static char *targetIP = "127.0.0.1"; +static int targetPort = 13514; static int numMsgsToSend; /* number of messages to send */ -static int numConnections; /* number of connections to create */ +static int numConnections = 1; /* number of connections to create */ static int *sockArray; /* array of sockets to use */ static int msgNum = 0; /* initial message number to start with */ @@ -259,6 +259,7 @@ tcpSend(char *buf, int lenBuf) int main(int argc, char *argv[]) { int ret = 0; + int opt; struct sigaction sigAct; static char buf[1024]; @@ -272,18 +273,20 @@ int main(int argc, char *argv[]) setvbuf(stdout, buf, _IONBF, 48); - if(argc != 5 && argc != 6) { - printf("Invalid call of tcpflood\n"); - printf("Usage: tcpflood target-host target-port num-connections num-messages [initial msgnum]\n"); - exit(1); + while((opt = getopt(argc, argv, "t:p:c:m:i:")) != -1) { + switch (opt) { + case 't': targetIP = optarg; + break; + case 'p': targetPort = atoi(optarg); + break; + case 'c': numConnections = atoi(optarg); + break; + case 'm': numMsgsToSend = atoi(optarg); + break; + case 'i': msgNum = atoi(optarg); + break; + } } - - targetIP = argv[1]; - 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"); |