summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am36
-rwxr-xr-xtests/diag.sh4
-rw-r--r--tests/filewriter.c158
-rwxr-xr-xtests/imtcp-tls-basic.sh14
-rwxr-xr-xtests/sndrcv_drvr.sh1
-rwxr-xr-xtests/sndrcv_tls_anon_rebind.sh5
-rw-r--r--tests/testsuites/imtcp-tls-basic.conf21
-rw-r--r--tests/testsuites/sndrcv_tls_anon_rebind_rcvr.conf22
-rw-r--r--tests/testsuites/sndrcv_tls_anon_rebind_sender.conf20
-rw-r--r--tests/testsuites/udp-msgreduc-orgmsg-vg.conf11
-rw-r--r--tests/testsuites/udp-msgreduc-vg.conf11
-rwxr-xr-xtests/udp-msgreduc-orgmsg-vg.sh18
-rwxr-xr-xtests/udp-msgreduc-vg.sh18
13 files changed, 334 insertions, 5 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 77381d2f..3f6110db 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -50,6 +50,9 @@ TESTS += \
imuxsock_logger_root.sh \
imuxsock_traillf_root.sh \
imuxsock_ccmiddle_root.sh \
+ udp-msgreduc-vg.sh \
+ udp-msgreduc-orgmsg-vg.sh \
+ queue-persist.sh
discard-rptdmsg.sh \
discard-allmark.sh \
discard.sh \
@@ -100,6 +103,10 @@ TESTS += \
endif
if ENABLE_GNUTLS
+TESTS += \
+ sndrcv_tls_anon.sh \
+ sndrcv_tls_anon_rebind.sh \
+ imtcp-tls-basic.sh
if HAVE_VALGRIND
# This test does not work on v5 as we keep DH params
#TESTS += manytcp-too-few-tls.sh
@@ -155,6 +162,12 @@ test_files = testbench.h runtime-dummy.c
EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
validation-run.sh \
+ testsuites/x.509/ca.pem \
+ testsuites/x.509/ca-key.pem \
+ testsuites/x.509/client-cert.pem \
+ testsuites/x.509/client-key.pem \
+ testsuites/x.509/machine-cert.pem \
+ testsuites/x.509/machine-key.pem \
testsuites/invalid.conf \
testsuites/valid.conf \
cfg.sh \
@@ -251,8 +264,18 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/da-mainmsg-q.conf \
diskqueue-fsync.sh \
testsuites/diskqueue-fsync.conf \
+ imtcp-tls-basic.sh \
+ testsuites/imtcp-tls-basic.conf \
+ tls-certs/ca-key.pem \
+ tls-certs/ca.pem \
+ tls-certs/cert.pem \
+ tls-certs/key.pem \
imtcp-multiport.sh \
testsuites/imtcp-multiport.conf \
+ udp-msgreduc-orgmsg-vg.sh \
+ testsuites/udp-msgreduc-orgmsg-vg.conf \
+ udp-msgreduc-vg.sh \
+ testsuites/udp-msgreduc-vg.conf \
manytcp.sh \
testsuites/manytcp.conf \
manyptcp.sh \
@@ -337,6 +360,12 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
sndrcv_gzip.sh \
testsuites/sndrcv_gzip_sender.conf \
testsuites/sndrcv_gzip_rcvr.conf \
+ sndrcv_tls_anon_rebind.sh \
+ testsuites/sndrcv_tls_anon_rebind_sender.conf \
+ testsuites/sndrcv_tls_anon_rebind_rcvr.conf \
+ sndrcv_tls_anon.sh \
+ testsuites/sndrcv_tls_anon_sender.conf \
+ testsuites/sndrcv_tls_anon_rcvr.conf \
pipeaction.sh \
testsuites/pipeaction.conf \
pipe_noreader.sh \
@@ -444,8 +473,11 @@ uxsockrcvr_SOURCES = uxsockrcvr.c
uxsockrcvr_LDADD = $(SOL_LIBS)
tcpflood_SOURCES = tcpflood.c
-tcpflood_CPPFLAGS = $(PTHREADS_CFLAGS)
-tcpflood_LDADD = $(SOL_LIBS) $(PTHREADS_LIBS)
+tcpflood_CPPFLAGS = $(PTHREADS_CFLAGS) $(GNUTLS_CFLAGS)
+tcpflood_LDADD = $(SOL_LIBS) $(PTHREADS_LIBS) $(GNUTLS_LIBS)
+if ENABLE_GNUTLS
+tcpflood_LDADD += -lgcrypt
+endif
syslog_caller_SOURCES = syslog_caller.c
syslog_caller_LDADD = $(SOL_LIBS)
diff --git a/tests/diag.sh b/tests/diag.sh
index 3e0263c1..9fd878a4 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -31,7 +31,7 @@ case $1 in
rm -f work rsyslog.out.log rsyslog2.out.log rsyslog.out.log.save # common work files
rm -rf test-spool test-logdir stat-file1
rm -f rsyslog.out.*.log rsyslog.random.data work-presort rsyslog.pipe
- rm -f rsyslog.input stat-file1 #rsyslog.empty
+ rm -f rsyslog.input rsyslog.conf.tlscert stat-file1 rsyslog.empty
echo -------------------------------------------------------------------------------
;;
'startup') # start rsyslogd with default params. $2 is the config file name to use
@@ -41,7 +41,7 @@ case $1 in
;;
'startup-vg') # start rsyslogd with default params under valgrind control. $2 is the config file name to use
# returns only after successful startup, $3 is the instance (blank or 2!)
- valgrind --error-exitcode=10 --malloc-fill=ff --free-fill=fe --leak-check=full ../tools/rsyslogd -c6 -u2 -n -irsyslog$3.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 &
+ valgrind --log-fd=1 --error-exitcode=10 --malloc-fill=ff --free-fill=fe --leak-check=full ../tools/rsyslogd -c6 -u2 -n -irsyslog$3.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 &
$srcdir/diag.sh wait-startup $3
;;
'wait-startup') # wait for rsyslogd startup ($2 is the instance)
diff --git a/tests/filewriter.c b/tests/filewriter.c
new file mode 100644
index 00000000..07991b1d
--- /dev/null
+++ b/tests/filewriter.c
@@ -0,0 +1,158 @@
+/* This program expands the input file several times. This
+ * is done in order to obtain large (and maybe huge) files for
+ * testing. Note that the input file is stored in memory. It's
+ * last line must properly be terminated.
+ * Max input line size is 10K.
+ *
+ * command line options:
+ * -i file to be used for input (else stdin)
+ * -o file to be used for output (else stdout)
+ * -c number of times the file is to be copied
+ * -n add line numbers (default: off)
+ * -w wait nbr of microsecs between batches
+ * -W number of file lines to generate in a batch
+ * This is useful only if -w is specified as well,
+ * default is 1000.
+ *
+ * Copyright 2010 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <getopt.h>
+
+/* input file is stored in a single-linked list */
+struct line {
+ struct line *next;
+ char *ln;
+} *root, *tail;
+
+static FILE *fpIn;
+static FILE *fpOut;
+static long long nCopies = 1;
+static int linenbrs = 0;
+static int waitusecs = 0;
+static int batchsize = 1000;
+
+
+/* read the input file and create in-memory representation
+ */
+static inline void
+readFile()
+{
+ char *r;
+ char lnBuf[10240];
+ struct line *node;
+
+ root = tail = NULL;
+ r = fgets(lnBuf, sizeof(lnBuf), fpIn);
+ while(r != NULL) {
+ node = malloc(sizeof(struct line));
+ if(node == NULL) {
+ perror("malloc node");
+ exit(1);
+ }
+ node->next = NULL;
+ node->ln = strdup(lnBuf);
+ if(node->ln == NULL) {
+ perror("malloc node");
+ exit(1);
+ }
+ if(tail == NULL) {
+ tail = root = node;
+ } else {
+ tail->next = node;
+ tail = node;
+ }
+ r = fgets(lnBuf, sizeof(lnBuf), fpIn);
+ }
+ if(!feof(fpIn)) {
+ perror("fgets");
+ fprintf(stderr, "end of read loop, but not end of file!");
+ exit(1);
+ }
+}
+
+
+static void
+genCopies()
+{
+ long long i;
+ long long unsigned lnnbr;
+ struct line *node;
+
+ lnnbr = 1;
+ for(i = 0 ; i < nCopies ; ++i) {
+ if(i % 10000 == 0)
+ fprintf(stderr, "copyrun %d\n", i);
+ if(waitusecs && (i % batchsize == 0)) {
+ usleep(waitusecs);
+ }
+ for(node = root ; node != NULL ; node = node->next) {
+ if(linenbrs)
+ fprintf(fpOut, "%12.12llu:%s", lnnbr, node->ln);
+ else
+ fprintf(fpOut, "%s", node->ln);
+ ++lnnbr;
+ }
+ }
+}
+
+void main(int argc, char *argv[])
+{
+ int opt;
+ fpIn = stdin;
+ fpOut = stdout;
+
+ while((opt = getopt(argc, argv, "i:o:c:nw:W:")) != -1) {
+ switch (opt) {
+ case 'i': /* input file */
+ if((fpIn = fopen(optarg, "r")) == NULL) {
+ perror(optarg);
+ exit(1);
+ }
+ break;
+ case 'o': /* output file */
+ if((fpOut = fopen(optarg, "w")) == NULL) {
+ perror(optarg);
+ exit(1);
+ }
+ break;
+ case 'c':
+ nCopies = atoll(optarg);
+ break;
+ case 'n':
+ linenbrs = 1;
+ break;
+ case 'w':
+ waitusecs = atoi(optarg);
+ break;
+ case 'W':
+ batchsize = atoi(optarg);
+ break;
+ default: printf("invalid option '%c' or value missing - terminating...\n", opt);
+ exit (1);
+ break;
+ }
+ }
+
+ readFile();
+ genCopies();
+}
diff --git a/tests/imtcp-tls-basic.sh b/tests/imtcp-tls-basic.sh
new file mode 100755
index 00000000..bfe24880
--- /dev/null
+++ b/tests/imtcp-tls-basic.sh
@@ -0,0 +1,14 @@
+# added 2011-02-28 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
+echo \[imtcp-tls-basic.sh\]: testing imtcp in TLS mode - basic test
+source $srcdir/diag.sh init
+echo \$DefaultNetstreamDriverCAFile $srcdir/tls-certs/ca.pem >rsyslog.conf.tlscert
+echo \$DefaultNetstreamDriverCertFile $srcdir/tls-certs/cert.pem >>rsyslog.conf.tlscert
+echo \$DefaultNetstreamDriverKeyFile $srcdir/tls-certs/key.pem >>rsyslog.conf.tlscert
+source $srcdir/diag.sh startup imtcp-tls-basic.conf
+source $srcdir/diag.sh tcpflood -p13514 -m50000 -Ttls -Z$srcdir/tls-certs/cert.pem -z$srcdir/tls-certs/key.pem
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 49999
+source $srcdir/diag.sh exit
diff --git a/tests/sndrcv_drvr.sh b/tests/sndrcv_drvr.sh
index f9092647..1f3b9113 100755
--- a/tests/sndrcv_drvr.sh
+++ b/tests/sndrcv_drvr.sh
@@ -1,2 +1 @@
source $srcdir/sndrcv_drvr_noexit.sh $1 $2
-source $srcdir/diag.sh exit
diff --git a/tests/sndrcv_tls_anon_rebind.sh b/tests/sndrcv_tls_anon_rebind.sh
new file mode 100755
index 00000000..55b96d04
--- /dev/null
+++ b/tests/sndrcv_tls_anon_rebind.sh
@@ -0,0 +1,5 @@
+# rgerhards, 2011-04-04
+# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
+echo \[sndrcv_tls_anon_rebind.sh\]: testing sending and receiving via TLS with anon auth and rebind
+source $srcdir/sndrcv_drvr.sh sndrcv_tls_anon_rebind 25000
diff --git a/tests/testsuites/imtcp-tls-basic.conf b/tests/testsuites/imtcp-tls-basic.conf
new file mode 100644
index 00000000..a94a00ef
--- /dev/null
+++ b/tests/testsuites/imtcp-tls-basic.conf
@@ -0,0 +1,21 @@
+# Test for queue disk mode (see .sh file for details)
+# rgerhards, 2009-05-22
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$MainMsgQueueTimeoutShutdown 10000
+
+$DefaultNetstreamDriver gtls
+
+# certificate files - just CA for a client
+$IncludeConfig rsyslog.conf.tlscert
+$InputTCPServerStreamDriverMode 1
+$InputTCPServerStreamDriverAuthMode anon
+$InputTCPServerRun 13514
+
+$template outfmt,"%msg:F,58:2%\n"
+$OMFileFlushOnTXEnd off
+$OMFileFlushInterval 2
+$OMFileAsyncWriting on
+$OMFileIOBufferSize 16k
+:msg, contains, "msgnum:" ./rsyslog.out.log;outfmt
diff --git a/tests/testsuites/sndrcv_tls_anon_rebind_rcvr.conf b/tests/testsuites/sndrcv_tls_anon_rebind_rcvr.conf
new file mode 100644
index 00000000..01143b22
--- /dev/null
+++ b/tests/testsuites/sndrcv_tls_anon_rebind_rcvr.conf
@@ -0,0 +1,22 @@
+# see equally-named shell file for details
+# this is the config fil for the TLS server
+# rgerhards, 2009-11-11
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imtcp/.libs/imtcp
+
+# certificates
+$DefaultNetstreamDriverCAFile testsuites/x.509/ca.pem
+$DefaultNetstreamDriverCertFile testsuites/x.509/client-cert.pem
+$DefaultNetstreamDriverKeyFile testsuites/x.509/client-key.pem
+
+$DefaultNetstreamDriver gtls # use gtls netstream driver
+
+# then SENDER sends to this port (not tcpflood!)
+$InputTCPServerStreamDriverMode 1
+$InputTCPServerStreamDriverAuthMode anon
+$InputTCPServerRun 13515
+
+$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/sndrcv_tls_anon_rebind_sender.conf b/tests/testsuites/sndrcv_tls_anon_rebind_sender.conf
new file mode 100644
index 00000000..47633349
--- /dev/null
+++ b/tests/testsuites/sndrcv_tls_anon_rebind_sender.conf
@@ -0,0 +1,20 @@
+# see tcpsndrcv.sh for details
+# this is the TLS client
+# rgerhards, 2009-11-11
+$IncludeConfig diag-common2.conf
+
+# certificates
+$DefaultNetstreamDriverCAFile testsuites/x.509/ca.pem
+$DefaultNetstreamDriverCertFile testsuites/x.509/client-cert.pem
+$DefaultNetstreamDriverKeyFile testsuites/x.509/client-key.pem
+
+# Note: no TLS for the listener, this is for tcpflood!
+$ModLoad ../plugins/imtcp/.libs/imtcp
+$InputTCPServerRun 13514
+
+# set up the action
+$DefaultNetstreamDriver gtls # use gtls netstream driver
+$ActionSendStreamDriverMode 1 # require TLS for the connection
+$ActionSendStreamDriverAuthMode anon
+$ActionSendTCPRebindInterval 50
+*.* @@127.0.0.1:13515
diff --git a/tests/testsuites/udp-msgreduc-orgmsg-vg.conf b/tests/testsuites/udp-msgreduc-orgmsg-vg.conf
new file mode 100644
index 00000000..5e80e49b
--- /dev/null
+++ b/tests/testsuites/udp-msgreduc-orgmsg-vg.conf
@@ -0,0 +1,11 @@
+# Test for queue disk mode (see .sh file for details)
+# rgerhards, 2009-05-22
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imudp/.libs/imudp
+$UDPServerRun 13514
+$RepeatedMsgReduction on
+$RepeatedMsgContainsOriginalMsg on
+
+$template outfmt,"%msg:F,58:2%\n"
+*.* ./rsyslog.out.log;outfmt
diff --git a/tests/testsuites/udp-msgreduc-vg.conf b/tests/testsuites/udp-msgreduc-vg.conf
new file mode 100644
index 00000000..150bef2e
--- /dev/null
+++ b/tests/testsuites/udp-msgreduc-vg.conf
@@ -0,0 +1,11 @@
+# Test for queue disk mode (see .sh file for details)
+# rgerhards, 2009-05-22
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imudp/.libs/imudp
+$UDPServerRun 13514
+$RepeatedMsgReduction on
+
+$template outfmt,"%msg:F,58:2%\n"
+*.* ./rsyslog.out.log;outfmt
+#:msg, contains, "msgnum:" ./rsyslog.out.log;outfmt
diff --git a/tests/udp-msgreduc-orgmsg-vg.sh b/tests/udp-msgreduc-orgmsg-vg.sh
new file mode 100755
index 00000000..1594c89a
--- /dev/null
+++ b/tests/udp-msgreduc-orgmsg-vg.sh
@@ -0,0 +1,18 @@
+# check if valgrind violations occur. Correct output is not checked.
+# added 2011-03-01 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
+echo \[udp-msgreduc-orgmsg-vg.sh\]: testing msg reduction via udp, with org message
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup-vg udp-msgreduc-orgmsg-vg.conf
+source $srcdir/diag.sh wait-startup
+./tcpflood -t 127.0.0.1 -m 4 -r -Tudp -M "<133>2011-03-01T11:22:12Z host tag msgh ..."
+./tcpflood -t 127.0.0.1 -m 1 -r -Tudp -M "<133>2011-03-01T11:22:12Z host tag msgh ...x"
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown-vg
+if [ "$RSYSLOGD_EXIT" -eq "10" ]
+then
+ echo "udp-msgreduc-orgmsg-vg.sh FAILED"
+ exit 1
+fi
+source $srcdir/diag.sh exit
diff --git a/tests/udp-msgreduc-vg.sh b/tests/udp-msgreduc-vg.sh
new file mode 100755
index 00000000..e19ffd86
--- /dev/null
+++ b/tests/udp-msgreduc-vg.sh
@@ -0,0 +1,18 @@
+# check if valgrind violations occur. Correct output is not checked.
+# added 2011-03-01 by Rgerhards
+# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
+echo \[udp-msgreduc-vg.sh\]: testing imtcp multiple listeners
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup-vg udp-msgreduc-vg.conf
+source $srcdir/diag.sh wait-startup
+./tcpflood -t 127.0.0.1 -m 4 -r -Tudp -M "<133>2011-03-01T11:22:12Z host tag msgh ..."
+./tcpflood -t 127.0.0.1 -m 1 -r -Tudp -M "<133>2011-03-01T11:22:12Z host tag msgh ...x"
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown-vg
+if [ "$RSYSLOGD_EXIT" -eq "10" ]
+then
+ echo "udp-msgreduc-vg.sh FAILED"
+ exit 1
+fi
+source $srcdir/diag.sh exit