summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-04-21 16:55:09 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-04-21 16:55:09 +0200
commit9e99fa5812d9653547327eafd640dc60277c89dd (patch)
treeae739ed79f1efe0d70de6a8c99515ae15b6e2960 /tests
parent88caccecf8dd8beaf46915df05241a44f7d635f6 (diff)
parentaa43d7f83125f20f8efdf4152bdd9a09e7a81495 (diff)
downloadrsyslog-9e99fa5812d9653547327eafd640dc60277c89dd.tar.gz
rsyslog-9e99fa5812d9653547327eafd640dc60277c89dd.tar.xz
rsyslog-9e99fa5812d9653547327eafd640dc60277c89dd.zip
Merge branch 'nextmaster'
Diffstat (limited to 'tests')
-rw-r--r--tests/3.rstest4
-rw-r--r--tests/Makefile.am16
-rw-r--r--tests/chkseq.c76
-rwxr-xr-xtests/diskqueue.sh31
-rw-r--r--tests/getline.c3
-rwxr-xr-xtests/manytcp.sh21
-rw-r--r--tests/nettester.c (renamed from tests/udptester.c)131
-rwxr-xr-xtests/omod-if-array.sh13
-rwxr-xr-xtests/parsertest.sh12
-rw-r--r--tests/tcpflood.c290
-rw-r--r--tests/testsuites/3.parse13
-rw-r--r--tests/testsuites/diskqueue.conf16
-rw-r--r--tests/testsuites/manytcp.conf13
-rw-r--r--tests/testsuites/omod-if-array.conf3
-rw-r--r--tests/testsuites/parse1.conf3
15 files changed, 607 insertions, 28 deletions
diff --git a/tests/3.rstest b/tests/3.rstest
index 93cb941a..e75d9754 100644
--- a/tests/3.rstest
+++ b/tests/3.rstest
@@ -7,10 +7,10 @@ out:
00000000: push_msgvar msg[cstr]
00000001: push_const abc[cstr]
00000002: push_const 1[nbr]
-00000003: func_call strlen[cstr]
+00000003: func_call strlen
00000004: strconcat
00000005: push_const 1[nbr]
-00000006: func_call strlen[cstr]
+00000006: func_call strlen
00000007: push_const 20[nbr]
00000008: push_const 30[nbr]
00000009: add
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ab1c5a62..0f4cbce1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
TESTRUNS = rt_init rscript
-check_PROGRAMS = $(TESTRUNS) ourtail udptester
-TESTS = $(TESTRUNS) cfg.sh parsertest.sh omod-if-array.sh
+check_PROGRAMS = $(TESTRUNS) ourtail nettester tcpflood chkseq
+TESTS = $(TESTRUNS) cfg.sh parsertest.sh omod-if-array.sh manytcp.sh diskqueue.sh
TESTS_ENVIRONMENT = RSYSLOG_MODDIR='$(abs_top_builddir)'/runtime/.libs/
DISTCLEANFILES=rsyslog.pid
test_files = testbench.h runtime-dummy.c
@@ -27,13 +27,21 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/omod-if-array.conf \
testsuites/1.omod-if-array \
parsertest.sh \
+ diskqueue.sh \
+ testsuites/diskqueue.conf \
+ manytcp.sh \
+ testsuites/manytcp.conf \
omod-if-array.sh \
cfg.sh
ourtail_SOURCES = ourtail.c
+chkseq_SOURCES = chkseq.c
-udptester_SOURCES = udptester.c getline.c
-udptester_LDADD = $(SOL_LIBS)
+tcpflood_SOURCES = tcpflood.c
+tcpflood_LDADD = $(SOL_LIBS)
+
+nettester_SOURCES = nettester.c getline.c
+nettester_LDADD = $(SOL_LIBS)
rt_init_SOURCES = rt-init.c $(test_files)
rt_init_CPPFLAGS = -I$(top_srcdir) $(PTHREADS_CFLAGS) $(RSRT_CFLAGS)
diff --git a/tests/chkseq.c b/tests/chkseq.c
new file mode 100644
index 00000000..3203c250
--- /dev/null
+++ b/tests/chkseq.c
@@ -0,0 +1,76 @@
+/* Checks if a file consists of line of strictly monotonically
+ * increasing numbers. An expected start and end number may
+ * be set.
+ *
+ * Params
+ * argv[1] file to check
+ * argv[2] start number
+ * argv[3] end number
+ *
+ * Part of the testbench for rsyslog.
+ *
+ * Copyright 2009 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of rsyslog.
+ *
+ * Rsyslog is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Rsyslog is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+ FILE *fp;
+ int val;
+ int i;
+ int ret = 0;
+ int start, end;
+
+ if(argc != 4) {
+ printf("Invalid call of chkseq\n");
+ printf("Usage: chkseq file start end\n");
+ exit(1);
+ }
+
+ start = atoi(argv[2]);
+ end = atoi(argv[3]);
+
+ if(start > end) {
+ printf("start must be less than or equal end!\n");
+ exit(1);
+ }
+
+ /* read file */
+ fp = fopen(argv[1], "r");
+ if(fp == NULL) {
+ perror(argv[1]);
+ exit(1);
+ }
+
+ for(i = start ; i < end ; ++i) {
+ if(fscanf(fp, "%d\n", &val) != 1) {
+ printf("scanf error in index i=%d\n", i);
+ exit(1);
+ }
+ if(val != i) {
+ printf("read value %d, but expected value %d\n", val, i);
+ exit(1);
+ }
+ }
+
+ exit(ret);
+}
diff --git a/tests/diskqueue.sh b/tests/diskqueue.sh
new file mode 100755
index 00000000..6384eb64
--- /dev/null
+++ b/tests/diskqueue.sh
@@ -0,0 +1,31 @@
+# Test for disk-only queue mode
+# This test checks if queue files can be correctly written
+# and read back, but it does not test the transition from
+# memory to disk mode for DA queues.
+# added 2009-04-17 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo testing queue disk-only mode
+rm -rf test-spool
+mkdir test-spool
+rm -f work rsyslog.out.log rsyslog.out.log.save # work files
+../tools/rsyslogd -c4 -u2 -n -irsyslog.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/diskqueue.conf &
+sleep 1
+echo "rsyslogd started with pid " `cat rsyslog.pid`
+# 20000 messages should be enough - the disk test is slow enough ;)
+./tcpflood 127.0.0.1 13514 1 20000
+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
+fi
+sleep 4 # we need this so that rsyslogd can receive all outstanding messages
+kill `cat rsyslog.pid`
+rm -f work
+sort < rsyslog.out.log > work
+./chkseq work 0 19999
+if [ "$?" -ne "0" ]; then
+ # rm -f work rsyslog.out.log
+ echo "sequence error detected"
+ exit 1
+fi
+rm -f work rsyslog.out.log
+rm -rf test-spool
diff --git a/tests/getline.c b/tests/getline.c
index 10de2ffe..617d1b0e 100644
--- a/tests/getline.c
+++ b/tests/getline.c
@@ -23,7 +23,8 @@
*/
#include "config.h"
#include <stdio.h>
-#include <malloc.h>
+#include <sys/types.h>
+#include <stdlib.h>
/* we emulate getline (the dirty way) if we do not have it
* We do not try very hard, as this is just a test driver.
diff --git a/tests/manytcp.sh b/tests/manytcp.sh
new file mode 100755
index 00000000..d9b2e9a0
--- /dev/null
+++ b/tests/manytcp.sh
@@ -0,0 +1,21 @@
+rm -f work rsyslog.out.log rsyslog.out.log.save # work files
+../tools/rsyslogd -c4 -u2 -n -irsyslog.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/manytcp.conf &
+sleep 1
+echo "rsyslogd started with pid " `cat rsyslog.pid`
+# the config file specifies exactly 1100 connections
+./tcpflood 127.0.0.1 13514 1000 40000
+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
+fi
+sleep 5 # we need this so that rsyslogd can receive all outstanding messages
+kill `cat rsyslog.pid`
+rm -f work
+sort < rsyslog.out.log > work
+./chkseq work 0 39999
+if [ "$?" -ne "0" ]; then
+ rm -f work rsyslog.out.log
+ echo "sequence error detected"
+ exit 1
+fi
+rm -f work rsyslog.out.log
diff --git a/tests/udptester.c b/tests/nettester.c
index a3c6658d..37183ac9 100644
--- a/tests/udptester.c
+++ b/tests/nettester.c
@@ -43,10 +43,16 @@
#include <unistd.h>
#include <string.h>
#include <glob.h>
+#include <signal.h>
#include <netinet/in.h>
#define EXIT_FAILURE 1
+#define INVALID_SOCKET -1
+/* 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 enum { inputUDP, inputTCP } inputMode; /* input for which tests are to be run */
+static pid_t rsyslogdPid = 0; /* pid of rsyslog instance being tested */
static char *srcdir; /* global $srcdir, set so that we can run outside of "make check" */
static char *testSuite; /* name of current test suite */
@@ -64,6 +70,59 @@ void readLine(int fd, char *ln)
}
+/* send a message via TCP
+ * We open the connection on the initial send, and never close it
+ * (let the OS do that). If a conneciton breaks, we do NOT try to
+ * recover, so all test after that one will fail (and the test
+ * driver probably hang. returns 0 if ok, something else otherwise.
+ * We use traditional framing '\n' at EOR for this tester. It may be
+ * worth considering additional framing modes.
+ * rgerhards, 2009-04-08
+ */
+int
+tcpSend(char *buf, int lenBuf)
+{
+ static int sock = INVALID_SOCKET;
+ struct sockaddr_in addr;
+
+ if(sock == INVALID_SOCKET) {
+ /* first time, need to connect to target */
+ if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
+ perror("socket()");
+ return(1);
+ }
+
+ memset((char *) &addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(13514);
+ if(inet_aton("127.0.0.1", &addr.sin_addr)==0) {
+ fprintf(stderr, "inet_aton() failed\n");
+ return(1);
+ }
+ if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) != 0) {
+ fprintf(stderr, "connect() failed\n");
+ return(1);
+ }
+ }
+
+ /* send test data */
+ if(send(sock, buf, lenBuf, 0) != lenBuf) {
+ perror("send test data");
+ fprintf(stderr, "send() failed\n");
+ return(1);
+ }
+
+ /* send record terminator */
+ if(send(sock, "\n", 1, 0) != 1) {
+ perror("send record terminator");
+ fprintf(stderr, "send() failed\n");
+ return(1);
+ }
+
+ return 0;
+}
+
+
/* send a message via UDP
* returns 0 if ok, something else otherwise.
*/
@@ -107,7 +166,7 @@ int openPipe(char *configFile, pid_t *pid, int *pfd)
int pipefd[2];
pid_t cpid;
char *newargv[] = {"../tools/rsyslogd", "dummy", "-c4", "-u2", "-n", "-irsyslog.pid",
- "-M../runtime//.libs", NULL };
+ "-M../runtime/.libs:../.libs", NULL };
char confFile[1024];
char *newenviron[] = { NULL };
@@ -173,9 +232,14 @@ processTestFile(int fd, char *pszFileName)
testdata[strlen(testdata)-1] = '\0'; /* remove \n */
- /* now we have the test data to send */
- if(udpSend(testdata, strlen(testdata)) != 0)
- return(2);
+ /* now we have the test data to send (we could use function pointers here...) */
+ if(inputMode == inputUDP) {
+ if(udpSend(testdata, strlen(testdata)) != 0)
+ return(2);
+ } else {
+ if(tcpSend(testdata, strlen(testdata)) != 0)
+ return(2);
+ }
/* next line is expected output
* we do not care about EOF here, this will lead to a failure and thus
@@ -249,6 +313,18 @@ doTests(int fd, char *files)
return(iFailed);
}
+/* cleanup */
+void doAtExit(void)
+{
+ int status;
+
+ if(rsyslogdPid != 0) {
+ kill(rsyslogdPid, SIGTERM);
+ waitpid(rsyslogdPid, &status, 0); /* wait until instance terminates */
+ }
+
+ unlink(NETTEST_INPUT_CONF_FILE);
+}
/* Run the test suite. This must be called with exactly one parameter, the
* name of the test suite. For details, see file header comment at the top
@@ -258,26 +334,54 @@ doTests(int fd, char *files)
int main(int argc, char *argv[])
{
int fd;
- pid_t pid;
- int status;
int ret = 0;
+ FILE *fp;
char buf[4096];
char testcases[4096];
- if(argc != 2) {
- printf("Invalid call of udptester\n");
- printf("Usage: udptester testsuite-name\n");
+ if(argc != 3) {
+ printf("Invalid call of nettester\n");
+ printf("Usage: nettester testsuite-name input\n");
+ printf(" input = udp|tcp\n");
exit(1);
}
+
+ atexit(doAtExit);
testSuite = argv[1];
+ if(!strcmp(argv[2], "udp"))
+ inputMode = inputUDP;
+ else if(!strcmp(argv[2], "tcp"))
+ inputMode = inputTCP;
+ else {
+ printf("error: unsupported input mode '%s'\n", argv[2]);
+ exit(1);
+ }
+
if((srcdir = getenv("srcdir")) == NULL)
srcdir = ".";
- printf("Start of udptester run ($srcdir=%s, testsuite=%s)\n", srcdir, testSuite);
+ printf("Start of nettester run ($srcdir=%s, testsuite=%s, input=%s)\n",
+ srcdir, testSuite, argv[2]);
+
+ /* create input config file */
+ if((fp = fopen(NETTEST_INPUT_CONF_FILE, "w")) == NULL) {
+ perror(NETTEST_INPUT_CONF_FILE);
+ printf("error opening input configuration file\n");
+ exit(1);
+ }
+ if(inputMode == inputUDP) {
+ fputs("$ModLoad ../plugins/imudp/.libs/imudp\n", fp);
+ fputs("$UDPServerRun 12514\n", fp);
+ } else {
+ fputs("$ModLoad ../plugins/imtcp/.libs/imtcp\n", fp);
+ fputs("$InputTCPServerRun 13514\n", fp);
+ }
+ fclose(fp);
- openPipe(argv[1], &pid, &fd);
+ /* start to be tested rsyslogd */
+ openPipe(argv[1], &rsyslogdPid, &fd);
readLine(fd, buf);
/* generate filename */
@@ -285,9 +389,6 @@ int main(int argc, char *argv[])
if(doTests(fd, testcases) != 0)
ret = 1;
- /* cleanup */
- kill(pid, SIGTERM);
- waitpid(pid, &status, 0); /* wait until instance terminates */
- printf("End of udptester run.\n");
+ printf("End of nettester run (%d).\n", ret);
exit(ret);
}
diff --git a/tests/omod-if-array.sh b/tests/omod-if-array.sh
index cac08928..fd845b4d 100755
--- a/tests/omod-if-array.sh
+++ b/tests/omod-if-array.sh
@@ -1 +1,12 @@
-./udptester omod-if-array
+echo test omod-if-array via udp
+./nettester omod-if-array udp
+if [ "$?" -ne "0" ]; then
+ exit 1
+fi
+
+echo test omod-if-array via tcp
+./nettester omod-if-array tcp
+if [ "$?" -ne "0" ]; then
+ exit 1
+fi
+
diff --git a/tests/parsertest.sh b/tests/parsertest.sh
index e7985bb0..a6b7d45c 100755
--- a/tests/parsertest.sh
+++ b/tests/parsertest.sh
@@ -1 +1,11 @@
-./udptester parse1
+echo test parsertest via udp
+./nettester parse1 udp
+if [ "$?" -ne "0" ]; then
+ exit 1
+fi
+
+echo test parsertest via tcp
+./nettester parse1 tcp
+if [ "$?" -ne "0" ]; then
+ exit 1
+fi
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
new file mode 100644
index 00000000..8dbc201b
--- /dev/null
+++ b/tests/tcpflood.c
@@ -0,0 +1,290 @@
+/* Opens a large number of tcp connections and sends
+ * 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)
+ *
+ * Part of the testbench for rsyslog.
+ *
+ * Copyright 2009 Rainer Gerhards and Adiscon GmbH.
+ *
+ * This file is part of rsyslog.
+ *
+ * Rsyslog is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Rsyslog is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Rsyslog. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this distribution.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <assert.h>
+#include <unistd.h>
+#include <string.h>
+#include <netinet/in.h>
+
+#define EXIT_FAILURE 1
+#define INVALID_SOCKET -1
+/* 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 int numMsgsToSend; /* number of messages to send */
+static int numConnections; /* number of connections to create */
+static int *sockArray; /* array of sockets to use */
+
+
+/* open a single tcp connection
+ */
+int openConn(int *fd)
+{
+ int sock;
+ struct sockaddr_in addr;
+
+ if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
+ perror("socket()");
+ return(1);
+ }
+
+ memset((char *) &addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(targetPort);
+ if(inet_aton(targetIP, &addr.sin_addr)==0) {
+ fprintf(stderr, "inet_aton() failed\n");
+ return(1);
+ }
+ if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) != 0) {
+ perror("connect()");
+ fprintf(stderr, "connect() failed\n");
+ return(1);
+ }
+
+ *fd = sock;
+ return 0;
+}
+
+
+/* open all requested tcp connections
+ * this includes allocating the connection array
+ */
+int openConnections(void)
+{
+ int i;
+ char msgBuf[128];
+ size_t lenMsg;
+
+ write(1, " open connections", sizeof(" open connections")-1);
+ sockArray = calloc(numConnections, sizeof(int));
+ for(i = 0 ; i < numConnections ; ++i) {
+ if(i % 10 == 0) {
+ printf("\r%5.5d", i);
+ //lenMsg = sprintf(msgBuf, "\r%5.5d", i);
+ //write(1, msgBuf, lenMsg);
+ }
+ if(openConn(&(sockArray[i])) != 0) {
+ printf("error in trying to open connection i=%d\n", i);
+ return 1;
+ }
+ }
+ lenMsg = sprintf(msgBuf, "\r%5.5d open connections\n", i);
+ write(1, msgBuf, lenMsg);
+
+ return 0;
+}
+
+
+/* we also close all connections because otherwise we may get very bad
+ * timing for the syslogd - it may not be able to process all incoming
+ * messages fast enough if we immediately shut down.
+ * TODO: it may be an interesting excercise to handle that situation
+ * at the syslogd level, too
+ * rgerhards, 2009-04-14
+ */
+void closeConnections(void)
+{
+ int i;
+ char msgBuf[128];
+ size_t lenMsg;
+
+ write(1, " close connections", sizeof(" close connections")-1);
+ for(i = 0 ; i < numConnections ; ++i) {
+ if(i % 10 == 0) {
+ lenMsg = sprintf(msgBuf, "\r%5.5d", i);
+ write(1, msgBuf, lenMsg);
+ }
+ close(sockArray[i]);
+ }
+ lenMsg = sprintf(msgBuf, "\r%5.5d close connections\n", i);
+ write(1, msgBuf, lenMsg);
+
+}
+
+
+/* send messages to the tcp connections we keep open. We use
+ * a very basic format that helps identify the message
+ * (via msgnum:<number>: e.g. msgnum:00000001:). This format is suitable
+ * for extracton to field-based properties.
+ * The first numConnection messages are sent sequentially, as are the
+ * last. All messages in between are sent over random connections.
+ * Note that message numbers start at 0.
+ */
+int sendMessages(void)
+{
+ int i;
+ int socknum;
+ int lenBuf;
+ int lenSend;
+ char buf[2048];
+ char msgBuf[128];
+ size_t lenMsg;
+
+ srand(time(NULL)); /* seed is good enough for our needs */
+
+ printf("Sending %d messages.\n", numMsgsToSend);
+ printf("\r%5.5d messages sent", 0);
+ for(i = 0 ; i < numMsgsToSend ; ++i) {
+ if(i < numConnections)
+ socknum = i;
+ else if(i >= numMsgsToSend - numConnections)
+ 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);
+ 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);
+ fflush(stderr);
+ return(1);
+ }
+ if(i % 100 == 0) {
+ printf("\r%5.5d", i);
+ }
+ }
+ printf("\r%5.5d messages sent\n", i);
+
+ return 0;
+}
+
+
+/* send a message via TCP
+ * We open the connection on the initial send, and never close it
+ * (let the OS do that). If a conneciton breaks, we do NOT try to
+ * recover, so all test after that one will fail (and the test
+ * driver probably hang. returns 0 if ok, something else otherwise.
+ * We use traditional framing '\n' at EOR for this tester. It may be
+ * worth considering additional framing modes.
+ * rgerhards, 2009-04-08
+ */
+int
+tcpSend(char *buf, int lenBuf)
+{
+ static int sock = INVALID_SOCKET;
+ struct sockaddr_in addr;
+
+ if(sock == INVALID_SOCKET) {
+ /* first time, need to connect to target */
+ if((sock=socket(AF_INET, SOCK_STREAM, 0))==-1) {
+ perror("socket()");
+ return(1);
+ }
+
+ memset((char *) &addr, 0, sizeof(addr));
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons(13514);
+ if(inet_aton("127.0.0.1", &addr.sin_addr)==0) {
+ fprintf(stderr, "inet_aton() failed\n");
+ return(1);
+ }
+ if(connect(sock, (struct sockaddr*)&addr, sizeof(addr)) != 0) {
+ fprintf(stderr, "connect() failed\n");
+ return(1);
+ }
+ }
+
+ /* send test data */
+ if(send(sock, buf, lenBuf, 0) != lenBuf) {
+ perror("send test data");
+ fprintf(stderr, "send() failed\n");
+ return(1);
+ }
+
+ /* send record terminator */
+ if(send(sock, "\n", 1, 0) != 1) {
+ perror("send record terminator");
+ fprintf(stderr, "send() failed\n");
+ return(1);
+ }
+
+ return 0;
+}
+
+
+/* Run the test suite. This must be called with exactly one parameter, the
+ * name of the test suite. For details, see file header comment at the top
+ * of this file.
+ * rgerhards, 2009-04-03
+ */
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+ struct sigaction sigAct;
+ static char buf[1024];
+
+ /* on Solaris, we do not HAVE MSG_NOSIGNAL, so for this reason
+ * we block SIGPIPE (not an issue for this program)
+ */
+ memset(&sigAct, 0, sizeof(sigAct));
+ sigemptyset(&sigAct.sa_mask);
+ sigAct.sa_handler = SIG_IGN;
+ sigaction(SIGPIPE, &sigAct, NULL);
+
+ setvbuf(stdout, buf, _IONBF, 48);
+
+ if(argc != 5) {
+ printf("Invalid call of tcpflood\n");
+ printf("Usage: tcpflood target-host target-port num-connections num-messages\n");
+ exit(1);
+ }
+
+ targetIP = argv[1];
+ targetPort = atoi(argv[2]);
+ numConnections = atoi(argv[3]);
+ numMsgsToSend = atoi(argv[4]);
+
+ if(openConnections() != 0) {
+ printf("error opening connections\n");
+ exit(1);
+ }
+
+ if(sendMessages() != 0) {
+ printf("error sending messages\n");
+ exit(1);
+ }
+
+ //closeConnections();
+ printf("End of tcpflood Run\n");
+
+ exit(ret);
+}
diff --git a/tests/testsuites/3.parse1 b/tests/testsuites/3.parse1
new file mode 100644
index 00000000..a6b4e884
--- /dev/null
+++ b/tests/testsuites/3.parse1
@@ -0,0 +1,3 @@
+<38>Apr 6 15:07:10 lxcvs07 sshd(pam_unix)[31738]: session closed for user cvsadmin
+38,auth,info,Apr 6 15:07:10,lxcvs07,sshd(pam_unix),sshd(pam_unix)[31738]:, session closed for user cvsadmin
+# yet another real-life sample where we had some issues with
diff --git a/tests/testsuites/diskqueue.conf b/tests/testsuites/diskqueue.conf
new file mode 100644
index 00000000..8851a459
--- /dev/null
+++ b/tests/testsuites/diskqueue.conf
@@ -0,0 +1,16 @@
+# Test for queue disk mode (see .sh file for details)
+# rgerhards, 2009-04-17
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+$InputTCPServerRun 13514
+
+$ErrorMessagesToStderr off
+
+# set spool locations and switch queue to disk-only mode
+$WorkDirectory test-spool
+$MainMsgQueueFilename mainq
+$MainMsgQueueType disk
+
+$template outfmt,"%msg:F,58:2%\n"
+$template dynfile,"rsyslog.out.log" # trick to use relative path names!
+:msg, contains, "msgnum:" ?dynfile;outfmt
diff --git a/tests/testsuites/manytcp.conf b/tests/testsuites/manytcp.conf
new file mode 100644
index 00000000..8175732e
--- /dev/null
+++ b/tests/testsuites/manytcp.conf
@@ -0,0 +1,13 @@
+# Test for tcp "flood" testing
+# rgerhards, 2009-04-08
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+$MaxOpenFiles 2000
+$InputTCPMaxSessions 1100
+$InputTCPServerRun 13514
+
+$ErrorMessagesToStderr off
+
+$template outfmt,"%msg:F,58:2%\n"
+$template dynfile,"rsyslog.out.log" # trick to use relative path names!
+:msg, contains, "msgnum:" ?dynfile;outfmt
diff --git a/tests/testsuites/omod-if-array.conf b/tests/testsuites/omod-if-array.conf
index e6c05a52..d88db166 100644
--- a/tests/testsuites/omod-if-array.conf
+++ b/tests/testsuites/omod-if-array.conf
@@ -3,8 +3,7 @@
# the testbench, so we do not need to focus on that)
# rgerhards, 2009-04-03
$ModLoad ../plugins/omstdout/.libs/omstdout
-$ModLoad ../plugins/imudp/.libs/imudp
-$UDPServerRun 12514
+$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
$ActionOMStdoutArrayInterface on
$ErrorMessagesToStderr off
diff --git a/tests/testsuites/parse1.conf b/tests/testsuites/parse1.conf
index 0fb7d16d..947a05a8 100644
--- a/tests/testsuites/parse1.conf
+++ b/tests/testsuites/parse1.conf
@@ -1,6 +1,5 @@
$ModLoad ../plugins/omstdout/.libs/omstdout
-$ModLoad ../plugins/imudp/.libs/imudp
-$UDPServerRun 12514
+$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
$ErrorMessagesToStderr off