summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-16 14:23:13 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-16 14:23:13 +0100
commit4cb3e80152ed4674ed370915f7c02889b5bfb6f3 (patch)
treefd2be5fd90f164dffd293bcbf0fd8d897792418b
parent46861a84f835a9579fa97b757be361d78b3d1c64 (diff)
downloadrsyslog-4cb3e80152ed4674ed370915f7c02889b5bfb6f3.tar.gz
rsyslog-4cb3e80152ed4674ed370915f7c02889b5bfb6f3.tar.xz
rsyslog-4cb3e80152ed4674ed370915f7c02889b5bfb6f3.zip
added new, complex testcase to testbench
this is an excerpt from some of the more intensen manual tests I am doing, stripped down to be useful inside the testbench.
-rw-r--r--tests/Makefile.am3
-rwxr-xr-xtests/diag.sh2
-rw-r--r--tests/tcpflood.c27
3 files changed, 24 insertions, 8 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 91152679..bc7902b1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -16,6 +16,7 @@ TESTS = $(TESTRUNS) cfg.sh \
asynwr_large.sh \
gzipwr_large.sh \
gzipwr_large_dynfile.sh \
+ complex1.sh \
queue-persist.sh \
pipeaction.sh
execonlyonce.sh \
@@ -157,6 +158,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/gzipwr_large.conf \
gzipwr_large_dynfile.sh \
testsuites/gzipwr_large_dynfile.conf \
+ complex1.sh \
+ testsuites/complex1.conf \
proprepltest.sh \
testsuites/rfctag.conf \
testsuites/master.rfctag \
diff --git a/tests/diag.sh b/tests/diag.sh
index b3154c44..a4f13afd 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -66,7 +66,7 @@ case $1 in
# note: we do not wait for the actual termination!
;;
'tcpflood') # do a tcpflood run and check if it worked params are passed to tcpflood
- ./tcpflood $2 $3 $4 $5 $6 $7 $8
+ ./tcpflood $2 $3 $4 $5 $6 $7 $8 $9
if [ "$?" -ne "0" ]; then
echo "error during tcpflood! see rsyslog.out.log.save for what was written"
cp rsyslog.out.log rsyslog.out.log.save
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index 0f9f21f2..0d819d1d 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -4,6 +4,7 @@
* Params
* -t target address (default 127.0.0.1)
* -p target port (default 13514)
+ * -n number of target ports (targets are in range -p..(-p+-n-1)
* -c number of connections (default 1)
* -m number of messages to send (connection is random)
* -i initial message number (optional)
@@ -62,6 +63,7 @@
static char *targetIP = "127.0.0.1";
static char *msgPRI = "167";
static int targetPort = 13514;
+static int numTargetPorts = 1;
static int dynFileIDs = 0;
static int extraDataLen = 0; /* amount of extra data to add to message */
static int bRandomizeExtraData = 0; /* randomize amount of extra data added */
@@ -77,16 +79,25 @@ int openConn(int *fd)
{
int sock;
struct sockaddr_in addr;
+ int port;
int retries = 0;
+ int rnd;
if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
perror("socket()");
return(1);
}
+ /* randomize port if required */
+ if(numTargetPorts > 1) {
+ rnd = rand(); /* easier if we need value for debug messages ;) */
+ port = targetPort + (rnd % numTargetPorts);
+ } else {
+ port = targetPort;
+ }
memset((char *) &addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
- addr.sin_port = htons(targetPort);
+ addr.sin_port = htons(port);
if(inet_aton(targetIP, &addr.sin_addr)==0) {
fprintf(stderr, "inet_aton() failed\n");
return(1);
@@ -185,10 +196,8 @@ int sendMessages(void)
char buf[MAX_EXTRADATA_LEN + 1024];
char extraData[MAX_EXTRADATA_LEN + 1];
- srand(time(NULL)); /* seed is good enough for our needs */
-
printf("Sending %d messages.\n", numMsgsToSend);
- printf("\r%5.5d messages sent", 0);
+ printf("\r%8.8d messages sent", 0);
for(i = 0 ; i < numMsgsToSend ; ++i) {
if(i < numConnections)
socknum = i;
@@ -222,11 +231,11 @@ int sendMessages(void)
return(1);
}
if(i % 100 == 0) {
- printf("\r%5.5d", i);
+ printf("\r%8.8d", i);
}
++msgNum;
}
- printf("\r%5.5d messages sent\n", i);
+ printf("\r%8.8d messages sent\n", i);
return 0;
}
@@ -295,6 +304,8 @@ int main(int argc, char *argv[])
struct sigaction sigAct;
static char buf[1024];
+ srand(time(NULL)); /* seed is good enough for our needs */
+
/* on Solaris, we do not HAVE MSG_NOSIGNAL, so for this reason
* we block SIGPIPE (not an issue for this program)
*/
@@ -305,12 +316,14 @@ int main(int argc, char *argv[])
setvbuf(stdout, buf, _IONBF, 48);
- while((opt = getopt(argc, argv, "f:t:p:c:m:i:P:d:r")) != -1) {
+ while((opt = getopt(argc, argv, "f:t:p:c:m:i:P:d:n:r")) != -1) {
switch (opt) {
case 't': targetIP = optarg;
break;
case 'p': targetPort = atoi(optarg);
break;
+ case 'n': numTargetPorts = atoi(optarg);
+ break;
case 'c': numConnections = atoi(optarg);
break;
case 'm': numMsgsToSend = atoi(optarg);