summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am28
-rwxr-xr-xtests/cee_diskqueue.sh14
-rwxr-xr-xtests/cee_simple.sh13
-rwxr-xr-xtests/diag.sh4
-rwxr-xr-xtests/rscript_contains.sh13
-rwxr-xr-xtests/rscript_field.sh13
-rwxr-xr-xtests/rscript_optimizer1.sh13
-rwxr-xr-xtests/rscript_prifilt.sh13
-rwxr-xr-xtests/rscript_stop.sh13
-rwxr-xr-xtests/rscript_stop2.sh13
-rwxr-xr-xtests/sndrcv_omudpspoof.sh4
-rwxr-xr-xtests/sndrcv_omudpspoof_nonstdpt.sh4
-rw-r--r--tests/tcpflood.c2
-rw-r--r--tests/testsuites/cee_diskqueue.conf9
-rw-r--r--tests/testsuites/cee_simple.conf6
-rw-r--r--tests/testsuites/rscript_contains.conf4
-rw-r--r--tests/testsuites/rscript_field.conf11
-rw-r--r--tests/testsuites/rscript_optimizer1.conf12
-rw-r--r--tests/testsuites/rscript_prifilt.conf10
-rw-r--r--tests/testsuites/rscript_stop.conf13
-rw-r--r--tests/testsuites/rscript_stop2.conf18
21 files changed, 226 insertions, 4 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index aff44eef..715c024d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -64,6 +64,14 @@ TESTS += \
failover-no-rptd.sh \
failover-no-basic.sh \
rcvr_fail_restore.sh \
+ rscript_contains.sh \
+ rscript_field.sh \
+ rscript_stop.sh \
+ rscript_stop2.sh \
+ rscript_prifilt.sh \
+ rscript_optimizer1.sh \
+ cee_simple.sh \
+ cee_diskqueue.sh \
linkedlistqueue.sh
if HAVE_VALGRIND
@@ -148,7 +156,9 @@ endif
endif
if ENABLE_EXTENDED_TESTS
-TESTS += random.sh
+# random.sh is temporarily disabled as it needs some work
+# to rsyslog core to complete in reasonable time
+#TESTS += random.sh
endif
if ENABLE_IMFILE
@@ -262,6 +272,22 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \
testsuites/diskqueue.conf \
arrayqueue.sh \
testsuites/arrayqueue.conf \
+ rscript_contains.sh \
+ testsuites/rscript_contains.conf \
+ rscript_field.sh \
+ testsuites/rscript_field.conf \
+ rscript_stop.sh \
+ testsuites/rscript_stop.conf \
+ rscript_stop2.sh \
+ testsuites/rscript_stop2.conf \
+ rscript_prifilt.sh \
+ testsuites/rscript_prifilt.conf \
+ rscript_optimizer1.sh \
+ testsuites/rscript_optimizer1.conf \
+ cee_simple.sh \
+ testsuites/cee_simple.conf \
+ cee_diskqueue.sh \
+ testsuites/cee_diskqueue.conf \
linkedlistqueue.sh \
testsuites/linkedlistqueue.conf \
da-mainmsg-q.sh \
diff --git a/tests/cee_diskqueue.sh b/tests/cee_diskqueue.sh
new file mode 100755
index 00000000..4e19855b
--- /dev/null
+++ b/tests/cee_diskqueue.sh
@@ -0,0 +1,14 @@
+# check if CEE properties are properly saved & restored to/from disk queue
+# added 2012-09-19 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[cee_diskqueue.sh\]: CEE and diskqueue test
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup cee_diskqueue.conf
+source $srcdir/diag.sh injectmsg 0 5000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/cee_simple.sh b/tests/cee_simple.sh
new file mode 100755
index 00000000..32f56393
--- /dev/null
+++ b/tests/cee_simple.sh
@@ -0,0 +1,13 @@
+# added 2012-09-19 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[cee_simple.sh\]: basic CEE property test
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup cee_simple.conf
+source $srcdir/diag.sh injectmsg 0 5000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/diag.sh b/tests/diag.sh
index b278d2c5..bd38b29d 100755
--- a/tests/diag.sh
+++ b/tests/diag.sh
@@ -36,12 +36,12 @@ case $1 in
;;
'startup') # start rsyslogd with default params. $2 is the config file name to use
# returns only after successful startup, $3 is the instance (blank or 2!)
- $valgrind ../tools/rsyslogd -c6 -u2 -n -irsyslog$3.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 &
+ $valgrind ../tools/rsyslogd -u2 -n -irsyslog$3.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 &
$srcdir/diag.sh wait-startup $3
;;
'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 --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 &
+ valgrind --log-fd=1 --error-exitcode=10 --malloc-fill=ff --free-fill=fe --leak-check=full ../tools/rsyslogd -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/rscript_contains.sh b/tests/rscript_contains.sh
new file mode 100755
index 00000000..fd5c3354
--- /dev/null
+++ b/tests/rscript_contains.sh
@@ -0,0 +1,13 @@
+# added 2012-09-14 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[rscript_contains.sh\]: test for contains script-filter
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rscript_contains.conf
+source $srcdir/diag.sh injectmsg 0 5000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/rscript_field.sh b/tests/rscript_field.sh
new file mode 100755
index 00000000..e989e666
--- /dev/null
+++ b/tests/rscript_field.sh
@@ -0,0 +1,13 @@
+# added 2012-09-20 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[rscript_field.sh\]: testing rainerscript field\(\) function
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rscript_field.conf
+source $srcdir/diag.sh injectmsg 0 5000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/rscript_optimizer1.sh b/tests/rscript_optimizer1.sh
new file mode 100755
index 00000000..1d2dcf87
--- /dev/null
+++ b/tests/rscript_optimizer1.sh
@@ -0,0 +1,13 @@
+# added 2012-09-20 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[rscript_optimizer1.sh\]: testing rainerscript optimizer
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rscript_optimizer1.conf
+source $srcdir/diag.sh injectmsg 0 5000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/rscript_prifilt.sh b/tests/rscript_prifilt.sh
new file mode 100755
index 00000000..815492ab
--- /dev/null
+++ b/tests/rscript_prifilt.sh
@@ -0,0 +1,13 @@
+# added 2012-09-20 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[rscript_prifilt.sh\]: testing rainerscript prifield\(\) function
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rscript_prifilt.conf
+source $srcdir/diag.sh injectmsg 0 5000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/rscript_stop.sh b/tests/rscript_stop.sh
new file mode 100755
index 00000000..e532a522
--- /dev/null
+++ b/tests/rscript_stop.sh
@@ -0,0 +1,13 @@
+# added 2012-09-20 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[rscript_stop.sh\]: testing rainerscript STOP statement
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rscript_stop.conf
+source $srcdir/diag.sh injectmsg 0 8000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/rscript_stop2.sh b/tests/rscript_stop2.sh
new file mode 100755
index 00000000..eae36cce
--- /dev/null
+++ b/tests/rscript_stop2.sh
@@ -0,0 +1,13 @@
+# added 2012-09-20 by rgerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+echo ===============================================================================
+echo \[rscript_stop2.sh\]: testing rainerscript STOP statement, alternate method
+source $srcdir/diag.sh init
+source $srcdir/diag.sh startup rscript_stop2.conf
+source $srcdir/diag.sh injectmsg 0 8000
+echo doing shutdown
+source $srcdir/diag.sh shutdown-when-empty
+echo wait on shutdown
+source $srcdir/diag.sh wait-shutdown
+source $srcdir/diag.sh seq-check 0 4999
+source $srcdir/diag.sh exit
diff --git a/tests/sndrcv_omudpspoof.sh b/tests/sndrcv_omudpspoof.sh
index bb804d93..cb1c2497 100755
--- a/tests/sndrcv_omudpspoof.sh
+++ b/tests/sndrcv_omudpspoof.sh
@@ -7,4 +7,8 @@
# This file is part of the rsyslog project, released under GPLv3
echo ===============================================================================
echo \[sndrcv_omudpspoof.sh\]: testing sending and receiving via omudp
+echo This test must be run as root [raw socket access required]
+if [ "$EUID" -ne 0 ]; then
+ exit 77 # Not root, skip this test
+fi
source $srcdir/sndrcv_drvr.sh sndrcv_omudpspoof 50
diff --git a/tests/sndrcv_omudpspoof_nonstdpt.sh b/tests/sndrcv_omudpspoof_nonstdpt.sh
index 6aeb1a5f..ddd3eb7e 100755
--- a/tests/sndrcv_omudpspoof_nonstdpt.sh
+++ b/tests/sndrcv_omudpspoof_nonstdpt.sh
@@ -7,4 +7,8 @@
# This file is part of the rsyslog project, released under GPLv3
echo ===============================================================================
echo \[sndrcv_omudpspoof_nonstdpt.sh\]: testing sending and receiving via omudp
+echo This test must be run as root [raw socket access required]
+if [ "$EUID" -ne 0 ]; then
+ exit 77 # Not root, skip this test
+fi
source $srcdir/sndrcv_drvr.sh sndrcv_omudpspoof_nonstdpt 50
diff --git a/tests/tcpflood.c b/tests/tcpflood.c
index f3a89c77..8fd347f1 100644
--- a/tests/tcpflood.c
+++ b/tests/tcpflood.c
@@ -360,7 +360,7 @@ genMsg(char *buf, size_t maxBuf, int *pLenBuf, struct instdata *inst)
} while(!done); /* Attention: do..while()! */
} else if(MsgToSend == NULL) {
if(dynFileIDs > 0) {
- snprintf(dynFileIDBuf, maxBuf, "%d:", rand() % dynFileIDs);
+ snprintf(dynFileIDBuf, sizeof(dynFileIDBuf), "%d:", rand() % dynFileIDs);
}
if(extraDataLen == 0) {
*pLenBuf = snprintf(buf, maxBuf, "<%s>Mar 1 01:00:00 172.20.245.8 tag msgnum:%s%8.8d:%c",
diff --git a/tests/testsuites/cee_diskqueue.conf b/tests/testsuites/cee_diskqueue.conf
new file mode 100644
index 00000000..a9b98e80
--- /dev/null
+++ b/tests/testsuites/cee_diskqueue.conf
@@ -0,0 +1,9 @@
+$IncludeConfig diag-common.conf
+
+global(workDirectory="/tmp")
+template(name="outfmt" type="string" string="%$!usr!msg:F,58:2%\n")
+
+set $!usr!msg = $msg;
+if $msg contains 'msgnum' then
+ action(type="omfile" file="./rsyslog.out.log" template="outfmt"
+ queue.type="disk" queue.filename="rsyslog-act1")
diff --git a/tests/testsuites/cee_simple.conf b/tests/testsuites/cee_simple.conf
new file mode 100644
index 00000000..1bcf83c1
--- /dev/null
+++ b/tests/testsuites/cee_simple.conf
@@ -0,0 +1,6 @@
+$IncludeConfig diag-common.conf
+
+template(name="outfmt" type="string" string="%$!usr!msg:F,58:2%\n")
+set $!usr!msg = $msg;
+if $msg contains 'msgnum' then
+ action(type="omfile" file="./rsyslog.out.log" template="outfmt")
diff --git a/tests/testsuites/rscript_contains.conf b/tests/testsuites/rscript_contains.conf
new file mode 100644
index 00000000..8bead68a
--- /dev/null
+++ b/tests/testsuites/rscript_contains.conf
@@ -0,0 +1,4 @@
+$IncludeConfig diag-common.conf
+
+$template outfmt,"%msg:F,58:2%\n"
+if $msg contains 'msgnum' then ./rsyslog.out.log;outfmt
diff --git a/tests/testsuites/rscript_field.conf b/tests/testsuites/rscript_field.conf
new file mode 100644
index 00000000..d7eb9066
--- /dev/null
+++ b/tests/testsuites/rscript_field.conf
@@ -0,0 +1,11 @@
+$IncludeConfig diag-common.conf
+
+template(name="outfmt" type="list") {
+ property(name="$!usr!msgnum")
+ constant(value="\n")
+}
+
+if $msg contains 'msgnum' then {
+ set $!usr!msgnum = field($msg, 58, 2);
+ action(type="omfile" file="./rsyslog.out.log" template="outfmt")
+}
diff --git a/tests/testsuites/rscript_optimizer1.conf b/tests/testsuites/rscript_optimizer1.conf
new file mode 100644
index 00000000..7720af7a
--- /dev/null
+++ b/tests/testsuites/rscript_optimizer1.conf
@@ -0,0 +1,12 @@
+$IncludeConfig diag-common.conf
+
+template(name="outfmt" type="list") {
+ property(name="msg" field.delimiter="58" field.number="2")
+ constant(value="\n")
+}
+
+/* tcpflood uses local4.=debug */
+if prifilt("syslog.*") then
+ stop # it actually doesn't matter what we do here
+else
+ action(type="omfile" file="./rsyslog.out.log" template="outfmt")
diff --git a/tests/testsuites/rscript_prifilt.conf b/tests/testsuites/rscript_prifilt.conf
new file mode 100644
index 00000000..8cb13a0f
--- /dev/null
+++ b/tests/testsuites/rscript_prifilt.conf
@@ -0,0 +1,10 @@
+$IncludeConfig diag-common.conf
+
+template(name="outfmt" type="list") {
+ property(name="msg" field.delimiter="58" field.number="2")
+ constant(value="\n")
+}
+
+/* tcpflood uses local4.=debug, we use a bit more generic filter */
+if prifilt("local4.*") then
+ action(type="omfile" file="./rsyslog.out.log" template="outfmt")
diff --git a/tests/testsuites/rscript_stop.conf b/tests/testsuites/rscript_stop.conf
new file mode 100644
index 00000000..ab9569e5
--- /dev/null
+++ b/tests/testsuites/rscript_stop.conf
@@ -0,0 +1,13 @@
+$IncludeConfig diag-common.conf
+
+template(name="outfmt" type="list") {
+ property(name="$!usr!msgnum")
+ constant(value="\n")
+}
+
+if $msg contains 'msgnum' then {
+ set $!usr!msgnum = field($msg, 58, 2);
+ if cnum($!usr!msgnum) >= 5000 then
+ stop
+ action(type="omfile" file="./rsyslog.out.log" template="outfmt")
+}
diff --git a/tests/testsuites/rscript_stop2.conf b/tests/testsuites/rscript_stop2.conf
new file mode 100644
index 00000000..9ac9143e
--- /dev/null
+++ b/tests/testsuites/rscript_stop2.conf
@@ -0,0 +1,18 @@
+$IncludeConfig diag-common.conf
+
+template(name="outfmt" type="list") {
+ property(name="$!usr!msgnum")
+ constant(value="\n")
+}
+
+if not ($msg contains 'msgnum') then
+ stop
+
+set $!usr!msgnum = field($msg, 58, 2);
+if cnum($!usr!msgnum) >= 5000 then
+ stop
+/* We could use yet another method, but we like to have the action statement
+ * without a filter in rsyslog.conf top level hierarchy - so this test, as
+ * a side-effect, also tests this ability.
+ */
+action(type="omfile" file="./rsyslog.out.log" template="outfmt")