summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am27
-rw-r--r--tests/cfg4.testin52
-rwxr-xr-xtests/imuxsock_ccmiddle_root.sh18
-rwxr-xr-xtests/imuxsock_logger_root.sh18
-rwxr-xr-xtests/imuxsock_traillf_root.sh18
-rw-r--r--tests/resultdata/imuxsock_ccmiddle.log1
-rw-r--r--tests/resultdata/imuxsock_logger.log1
-rw-r--r--tests/resultdata/imuxsock_traillf.log1
-rw-r--r--tests/syslog_caller.c75
-rw-r--r--tests/syslog_inject.c28
-rw-r--r--tests/tcpflood.c4
-rw-r--r--tests/testconfgen.c72
-rw-r--r--tests/testsuites/imuxsock_ccmiddle_root.conf7
-rw-r--r--tests/testsuites/imuxsock_logger_root.conf7
-rw-r--r--tests/testsuites/imuxsock_traillf_root.conf7
-rw-r--r--tests/testsuites/parse1.conf1
16 files changed, 288 insertions, 49 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3c00c24a..694b28ab 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
if ENABLE_TESTBENCH
TESTRUNS = rt_init rscript
-check_PROGRAMS = $(TESTRUNS) ourtail nettester tcpflood chkseq msleep randomgen diagtalker uxsockrcvr
+check_PROGRAMS = $(TESTRUNS) ourtail nettester tcpflood chkseq msleep randomgen diagtalker uxsockrcvr syslog_caller syslog_inject
TESTS = $(TESTRUNS) cfg.sh \
arrayqueue.sh \
linkedlistqueue.sh \
@@ -13,7 +13,6 @@ TESTS = $(TESTRUNS) cfg.sh \
rulesetmultiqueue.sh \
manytcp.sh \
rsf_getenv.sh \
- manyptcp.sh \
imtcp_conndrop.sh \
imtcp_addtlframedelim.sh \
sndrcv.sh \
@@ -37,7 +36,6 @@ TESTS = $(TESTRUNS) cfg.sh \
complex1.sh \
queue-persist.sh \
pipeaction.sh \
- uxsock_simple.sh \
execonlyonce.sh \
execonlywhenprevsuspended.sh \
execonlywhenprevsuspended2.sh \
@@ -46,15 +44,23 @@ TESTS = $(TESTRUNS) cfg.sh \
pipe_noreader.sh \
dircreate_dflt.sh \
dircreate_off.sh \
+ imuxsock_logger_root.sh \
+ imuxsock_traillf_root.sh \
+ imuxsock_ccmiddle_root.sh \
queue-persist.sh
if ENABLE_IMPTCP
TESTS += \
+ manyptcp.sh \
imptcp_large.sh \
imptcp_addtlframedelim.sh \
imptcp_conndrop.sh
endif
+if ENABLE_OMUXSOCK
+TESTS += uxsock_simple.sh
+endif
+
if ENABLE_OMUDPSPOOF
TESTS += sndrcv_omudpspoof.sh \
sndrcv_omudpspoof_nonstdpt.sh
@@ -316,6 +322,15 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/dircreate_dflt.conf \
dircreate_off.sh \
testsuites/dircreate_off.conf \
+ imuxsock_logger_root.sh \
+ testsuites/imuxsock_logger_root.conf \
+ resultdata/imuxsock_logger.log \
+ imuxsock_traillf_root.sh \
+ testsuites/imuxsock_traillf_root.conf \
+ resultdata/imuxsock_traillf.log \
+ imuxsock_ccmiddle_root.sh \
+ testsuites/imuxsock_ccmiddle_root.conf \
+ resultdata/imuxsock_ccmiddle.log \
cfg.sh
ourtail_SOURCES = ourtail.c
@@ -328,6 +343,12 @@ uxsockrcvr_LDADD = $(SOL_LIBS)
tcpflood_SOURCES = tcpflood.c
tcpflood_LDADD = $(SOL_LIBS)
+syslog_caller_SOURCES = syslog_caller.c
+syslog_caller_LDADD = $(SOL_LIBS)
+
+syslog_inject_SOURCES = syslog_inject.c
+syslog_inject_LDADD = $(SOL_LIBS)
+
diagtalker_SOURCES = diagtalker.c
diagtalker_LDADD = $(SOL_LIBS)
diff --git a/tests/cfg4.testin b/tests/cfg4.testin
index a49c0fb6..2dc0e830 100644
--- a/tests/cfg4.testin
+++ b/tests/cfg4.testin
@@ -12,48 +12,6 @@
# If you do not load inputs, nothing happens!
# You may need to set the module load path if modules are not found.
-#$ModLoad immark # provides --MARK-- message capability
-#$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
-#$ModLoad imklog # kernel logging (formerly provided by rklogd)
-
-# Log all kernel messages to the console.
-# Logging much else clutters up the screen.
-#kern.* /dev/console
-
-# Log anything (except mail) of level info or higher.
-# Don't log private authentication messages!
-*.info;mail.none;authpriv.none;cron.none -/var/log/messages
-
-# The authpriv file has restricted access.
-authpriv.* /var/log/secure
-
-# Log all the mail messages in one place.
-mail.* -/var/log/maillog
-
-
-# Log cron stuff
-cron.* -/var/log/cron
-
-# Everybody gets emergency messages
-*.emerg *
-
-# Save news errors of level crit and higher in a special file.
-uucp,news.crit -/var/log/spooler
-
-# Save boot messages also to boot.log
-local7.* /var/log/boot.log
-
-# Remote Logging (we use TCP for reliable delivery)
-# An on-disk queue is created for this action. If the remote host is
-# down, messages are spooled to disk and sent when it is up again.
-#$WorkDirectory /rsyslog/spool # where to place spool files
-#$ActionQueueFileName uniqName # unique name prefix for spool files
-#$ActionQueueMaxDiskSpace 1g # 1gb space limit (use as much as possible)
-#$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
-#$ActionQueueType LinkedList # run asynchronously
-#$ActionResumeRetryCount -1 # infinite retries if host is down
-# remote host is: name/ip:port, e.g. 192.168.0.1:514, port optional
-#*.* @@remote-host:514
# ######### Receiving Messages from Remote Hosts ##########
@@ -63,5 +21,11 @@ local7.* /var/log/boot.log
#$InputTCPServerRun 514 # start up TCP listener at port 514
# UDP Syslog Server:
-#$ModLoad imudp.so # provides UDP syslog reception
-#$UDPServerRun 514 # start a UDP syslog server at standard port 514
+$ModLoad imudp.so # provides UDP syslog reception
+$ModLoad omoracle.so
+$UDPServerRun 514 # start a UDP syslog server at standard port 514
+
+$IncludeConfig /home/munoz/logging/rsyslog/20*conf
+$IncludeConfig /home/munoz/logging/rsyslog/30*conf
+
+#*.* ~
diff --git a/tests/imuxsock_ccmiddle_root.sh b/tests/imuxsock_ccmiddle_root.sh
new file mode 100755
index 00000000..b487611a
--- /dev/null
+++ b/tests/imuxsock_ccmiddle_root.sh
@@ -0,0 +1,18 @@
+# note: we must be root and no other syslogd running in order to
+# carry out this test
+echo \[imuxsock_ccmiddle_root.sh\]: test trailing LF handling in imuxsock
+echo This test must be run as root with no other active syslogd
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup imuxsock_ccmiddle_root.conf
+# send a message with trailing LF
+./syslog_inject -c
+# the sleep below is needed to prevent too-early termination of rsyslogd
+./msleep 100
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown # we need to wait until rsyslogd is finished!
+cmp rsyslog.out.log $srcdir/resultdata/imuxsock_ccmiddle.log
+if [ ! $? -eq 0 ]; then
+echo "imuxsock_ccmiddle_root.sh failed"
+exit 1
+fi;
+source $srcdir/diag.sh exit
diff --git a/tests/imuxsock_logger_root.sh b/tests/imuxsock_logger_root.sh
new file mode 100755
index 00000000..377999f7
--- /dev/null
+++ b/tests/imuxsock_logger_root.sh
@@ -0,0 +1,18 @@
+# note: we must be root and no other syslogd running in order to
+# carry out this test.
+echo \[imuxsock_logger_root.sh\]: test trailing LF handling in imuxsock
+echo This test must be run as root with no other active syslogd
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup imuxsock_logger_root.conf
+# send a message with trailing LF
+logger test
+# the sleep below is needed to prevent too-early termination of rsyslogd
+./msleep 100
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown # we need to wait until rsyslogd is finished!
+cmp rsyslog.out.log $srcdir/resultdata/imuxsock_logger.log
+if [ ! $? -eq 0 ]; then
+echo "imuxsock_logger.sh failed"
+exit 1
+fi;
+source $srcdir/diag.sh exit
diff --git a/tests/imuxsock_traillf_root.sh b/tests/imuxsock_traillf_root.sh
new file mode 100755
index 00000000..1b821ee7
--- /dev/null
+++ b/tests/imuxsock_traillf_root.sh
@@ -0,0 +1,18 @@
+# note: we must be root and no other syslogd running in order to
+# carry out this test
+echo \[imuxsock_traillf_root.sh\]: test trailing LF handling in imuxsock
+echo This test must be run as root with no other active syslogd
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup imuxsock_traillf_root.conf
+# send a message with trailing LF
+./syslog_inject -l
+# the sleep below is needed to prevent too-early termination of rsyslogd
+./msleep 100
+source $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
+source $srcdir/diag.sh wait-shutdown # we need to wait until rsyslogd is finished!
+cmp rsyslog.out.log $srcdir/resultdata/imuxsock_traillf.log
+if [ ! $? -eq 0 ]; then
+echo "imuxsock_traillf_root.sh failed"
+exit 1
+fi;
+source $srcdir/diag.sh exit
diff --git a/tests/resultdata/imuxsock_ccmiddle.log b/tests/resultdata/imuxsock_ccmiddle.log
new file mode 100644
index 00000000..d2531f9d
--- /dev/null
+++ b/tests/resultdata/imuxsock_ccmiddle.log
@@ -0,0 +1 @@
+ test 1#0112
diff --git a/tests/resultdata/imuxsock_logger.log b/tests/resultdata/imuxsock_logger.log
new file mode 100644
index 00000000..883dabdf
--- /dev/null
+++ b/tests/resultdata/imuxsock_logger.log
@@ -0,0 +1 @@
+ test
diff --git a/tests/resultdata/imuxsock_traillf.log b/tests/resultdata/imuxsock_traillf.log
new file mode 100644
index 00000000..883dabdf
--- /dev/null
+++ b/tests/resultdata/imuxsock_traillf.log
@@ -0,0 +1 @@
+ test
diff --git a/tests/syslog_caller.c b/tests/syslog_caller.c
new file mode 100644
index 00000000..3f2702a6
--- /dev/null
+++ b/tests/syslog_caller.c
@@ -0,0 +1,75 @@
+/* A very primitive testing tool that just emits a number of
+ * messages to the system log socket. Currently sufficient, but
+ * obviously room for improvement.
+ *
+ * It is highly suggested NOT to "base" any derivative work
+ * on this tool ;)
+ *
+ * Options
+ *
+ * -s severity (0..7 accoding to syslog spec, r "rolling", default 6)
+ * -m number of messages to generate (default 500)
+ *
+ * Part of the testbench for rsyslog.
+ *
+ * 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 <getopt.h>
+#include <syslog.h>
+
+static void usage(void)
+{
+ fprintf(stderr, "usage: syslog_caller num-messages\n");
+ exit(1);
+}
+
+
+int main(int argc, char *argv[])
+{
+ int i;
+ int opt;
+ int bRollingSev = 0;
+ int sev = 6;
+ int msgs = 500;
+
+ while((opt = getopt(argc, argv, "m:s:")) != -1) {
+ switch (opt) {
+ case 's': if(*optarg == 'r') {
+ bRollingSev = 1;
+ sev = 0;
+ } else
+ sev = atoi(optarg);
+ break;
+ case 'm': msgs = atoi(optarg);
+ break;
+ default: usage();
+ break;
+ }
+ }
+
+ for(i = 0 ; i < msgs ; ++i) {
+ syslog(sev % 8, "test message nbr %d, severity=%d", i, sev % 8);
+ if(bRollingSev)
+ sev++;
+ }
+ return(0);
+}
diff --git a/tests/syslog_inject.c b/tests/syslog_inject.c
new file mode 100644
index 00000000..a5d77b1a
--- /dev/null
+++ b/tests/syslog_inject.c
@@ -0,0 +1,28 @@
+/* This tool deliberately logs a message with the a trailing LF */
+/* Options:
+ * -l: inject linefeed at end of message
+ * -c: inject control character in middle of message
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <syslog.h>
+#include <string.h>
+
+static inline void usage(void) {
+ fprintf(stderr, "Usage: syslog_inject [-l] [-c]\n");
+ exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2)
+ usage();
+ if(!strcmp(argv[1], "-l"))
+ syslog(LOG_NOTICE, "test\n");
+ else if(!strcmp(argv[1], "-c"))
+ syslog(LOG_NOTICE, "test 1\t2");
+ else
+ usage();
+
+ return 0;
+}
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index 0efbef4e..a37845a3 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -452,12 +452,12 @@ int main(int argc, char *argv[])
exit(1);
}
- closeConnections();
+ closeConnections(); /* this is important so that we do not finish too early! */
if(nConnDrops > 0)
printf("-D option initiated %ld connection closures\n", nConnDrops);
+
printf("End of tcpflood Run\n");
- closeConnections(); /* this is important so that we do not finish too early! */
exit(ret);
}
diff --git a/tests/testconfgen.c b/tests/testconfgen.c
new file mode 100644
index 00000000..9f191cc7
--- /dev/null
+++ b/tests/testconfgen.c
@@ -0,0 +1,72 @@
+/* a testcase generator
+ * THis program reads stdin, which must consist of (name,stmt) tupels
+ * where name is a part of the config name (small!) and stmt is an actual
+ * config statement. These tupels must be encoded as
+ * name<SP>stmt<LF>
+ * on stdin. After all tupels are read, the power set of all possible
+ * configurations is generated.
+ * Copyright (C) 2011 by Rainer Gerhards and Adiscon GmbH
+ * Released under the GPLv3 as part of the rsyslog project.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static int arr[128];
+static char *name[128];
+static char *stmt[128];
+
+void output(int n)
+{
+ int i;
+
+ printf("name:");
+ for(i = 0 ; i < n ; ++i) {
+ if(arr[i]) {
+ printf("-%s", name[i]);
+ }
+ }
+ printf("\n");
+}
+
+void pows(int n, int i)
+{
+ if(i == 0) {
+ output(n);
+ } else {
+ --i;
+ arr[i] = 0;
+ pows(n, i);
+ arr[i] = 1;
+ pows(n, i);
+ }
+}
+
+
+int main(int argc, char *argv[])
+{
+ int n;
+ char iname[512];
+ char istmt[2048];
+ int nscanned;
+
+ n = 0;
+ while(!feof(stdin)) {
+ nscanned = scanf("%s %[^\n]s\n", iname, istmt);
+ if(nscanned == EOF)
+ break;
+ else if(nscanned != 2) {
+ fprintf(stderr, "problem scanning entry %d, scanned %d\n",
+ n, nscanned);
+ exit(1);
+ }
+ name[n] = strdup(iname);
+ stmt[n] = strdup(istmt);
+ n++;
+ printf("name: %s, stmt: %s\n", iname, istmt);
+ }
+ /* n is on to high for an index, but just right as the actual number! */
+
+ printf("read %d entries\n", n);
+ pows(n, n);
+}
diff --git a/tests/testsuites/imuxsock_ccmiddle_root.conf b/tests/testsuites/imuxsock_ccmiddle_root.conf
new file mode 100644
index 00000000..8336ecfa
--- /dev/null
+++ b/tests/testsuites/imuxsock_ccmiddle_root.conf
@@ -0,0 +1,7 @@
+# rgerhards, 2011-02-21
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imuxsock/.libs/imuxsock
+
+$template outfmt,"%msg:%\n"
+*.notice ./rsyslog.out.log;outfmt
diff --git a/tests/testsuites/imuxsock_logger_root.conf b/tests/testsuites/imuxsock_logger_root.conf
new file mode 100644
index 00000000..8336ecfa
--- /dev/null
+++ b/tests/testsuites/imuxsock_logger_root.conf
@@ -0,0 +1,7 @@
+# rgerhards, 2011-02-21
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imuxsock/.libs/imuxsock
+
+$template outfmt,"%msg:%\n"
+*.notice ./rsyslog.out.log;outfmt
diff --git a/tests/testsuites/imuxsock_traillf_root.conf b/tests/testsuites/imuxsock_traillf_root.conf
new file mode 100644
index 00000000..8336ecfa
--- /dev/null
+++ b/tests/testsuites/imuxsock_traillf_root.conf
@@ -0,0 +1,7 @@
+# rgerhards, 2011-02-21
+$IncludeConfig diag-common.conf
+
+$ModLoad ../plugins/imuxsock/.libs/imuxsock
+
+$template outfmt,"%msg:%\n"
+*.notice ./rsyslog.out.log;outfmt
diff --git a/tests/testsuites/parse1.conf b/tests/testsuites/parse1.conf
index 947a05a8..094cd762 100644
--- a/tests/testsuites/parse1.conf
+++ b/tests/testsuites/parse1.conf
@@ -2,6 +2,7 @@ $ModLoad ../plugins/omstdout/.libs/omstdout
$IncludeConfig nettest.input.conf # This picks the to be tested input from the test driver!
$ErrorMessagesToStderr off
+$LocalHostName localhost
# use a special format that we can easily parse in expect
$template expect,"%PRI%,%syslogfacility-text%,%syslogseverity-text%,%timestamp%,%hostname%,%programname%,%syslogtag%,%msg%\n"