diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-03-01 16:00:22 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-03-01 16:00:22 +0100 |
commit | c130eb20215d5f4ed4fc23c4bf0223b77176617b (patch) | |
tree | cf00632ac5c70f2e4aa70be76938127e4fa5d054 | |
parent | 74a71e798efd58e20cc150b04de2613bf518eed4 (diff) | |
download | rsyslog-c130eb20215d5f4ed4fc23c4bf0223b77176617b.tar.gz rsyslog-c130eb20215d5f4ed4fc23c4bf0223b77176617b.tar.bz2 rsyslog-c130eb20215d5f4ed4fc23c4bf0223b77176617b.zip |
improved testbench
- added valgrind-based test (the first one ever ;))
- fixed memory leak in imdiag (guess how this was detected...)
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | plugins/imdiag/imdiag.c | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rwxr-xr-x | tests/diag.sh | 19 | ||||
-rw-r--r-- | tests/testsuites/udp-msgreduc-vg.conf | 11 | ||||
-rwxr-xr-x | tests/udp-msgreduc-vg.sh | 18 |
6 files changed, 55 insertions, 1 deletions
@@ -1,5 +1,6 @@ --------------------------------------------------------------------------- Version 6.1.5 [DEVEL] (rgerhards), 2011-02-?? +- improved testbench - bugfix: fixed a memory leak and potential abort condition this could happen if multiple rulesets were used and some output batches contained messages belonging to more than one ruleset. diff --git a/plugins/imdiag/imdiag.c b/plugins/imdiag/imdiag.c index f96bf754..36fe7e50 100644 --- a/plugins/imdiag/imdiag.c +++ b/plugins/imdiag/imdiag.c @@ -291,6 +291,7 @@ OnMsgReceived(tcps_sess_t *pSess, uchar *pRcv, int iLenMsg) { int iMsgQueueSize; uchar *pszMsg; + uchar *pToFree = NULL; uchar cmdBuf[1024]; DEFiRet; @@ -302,6 +303,7 @@ OnMsgReceived(tcps_sess_t *pSess, uchar *pRcv, int iLenMsg) * before proceeding. */ CHKmalloc(pszMsg = MALLOC(sizeof(uchar) * (iLenMsg + 1))); + pToFree = pszMsg; memcpy(pszMsg, pRcv, iLenMsg); pszMsg[iLenMsg] = '\0'; @@ -321,6 +323,8 @@ OnMsgReceived(tcps_sess_t *pSess, uchar *pRcv, int iLenMsg) } finalize_it: + if(pToFree != NULL) + free(pToFree); RETiRet; } diff --git a/tests/Makefile.am b/tests/Makefile.am index 261a56c1..a040a9d9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -47,6 +47,7 @@ TESTS = $(TESTRUNS) cfg.sh \ imuxsock_logger_root.sh \ imuxsock_traillf_root.sh \ imuxsock_ccmiddle_root.sh \ + udp-msgreduc-vg.sh \ queue-persist.sh if ENABLE_IMPTCP @@ -196,6 +197,8 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ testsuites/diskqueue-fsync.conf \ imtcp-multiport.sh \ testsuites/imtcp-multiport.conf \ + udp-msgreduc-vg.sh \ + testsuites/udp-msgreduc-vg.conf \ manytcp.sh \ testsuites/manytcp.conf \ manyptcp.sh \ diff --git a/tests/diag.sh b/tests/diag.sh index 2f307750..64b507e6 100755 --- a/tests/diag.sh +++ b/tests/diag.sh @@ -34,7 +34,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 -c4 -u2 -n -irsyslog$3.pid -M../runtime/.libs:../.libs -f$srcdir/testsuites/$2 & + $valgrind ../tools/rsyslogd -c6 -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 --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) @@ -58,6 +63,18 @@ case $1 in exit 1 fi ;; + 'wait-shutdown-vg') # actually, we wait for rsyslog.pid to be deleted. $2 is the + # instance + wait `cat rsyslog.pid` + export RSYSLOGD_EXIT=$? + echo rsyslogd run exited with $RSYSLOGD_EXIT + if [ -e core.* ] + then + echo "ABORT! core file exists, starting interactive shell" + bash + exit 1 + fi + ;; 'wait-queueempty') # wait for main message queue to be empty. $2 is the instance. if [ "$2" == "2" ] then 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-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 |