From 4ee4add6a13de1e75a831323baf1ef3433720ab4 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 14 Sep 2012 07:28:31 +0200 Subject: Add test for script-based contains filter to testbench --- tests/Makefile.am | 3 +++ tests/rscript_contains.sh | 13 +++++++++++++ tests/testsuites/rscript_contains.conf | 4 ++++ 3 files changed, 20 insertions(+) create mode 100755 tests/rscript_contains.sh create mode 100644 tests/testsuites/rscript_contains.conf diff --git a/tests/Makefile.am b/tests/Makefile.am index c4560445..a9369929 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -64,6 +64,7 @@ TESTS += \ failover-no-rptd.sh \ failover-no-basic.sh \ rcvr_fail_restore.sh \ + rscript_contains.sh \ linkedlistqueue.sh if HAVE_VALGRIND @@ -264,6 +265,8 @@ 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 \ linkedlistqueue.sh \ testsuites/linkedlistqueue.conf \ da-mainmsg-q.sh \ 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/testsuites/rscript_contains.conf b/tests/testsuites/rscript_contains.conf new file mode 100644 index 00000000..434f0229 --- /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 -- cgit v1.2.3 From 0af3bd791952040f186bd92147867f2ec0a8896d Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 14 Sep 2012 07:51:05 +0200 Subject: Fix new testbench test --- tests/testsuites/rscript_contains.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testsuites/rscript_contains.conf b/tests/testsuites/rscript_contains.conf index 434f0229..8bead68a 100644 --- a/tests/testsuites/rscript_contains.conf +++ b/tests/testsuites/rscript_contains.conf @@ -1,4 +1,4 @@ $IncludeConfig diag-common.conf $template outfmt,"%msg:F,58:2%\n" -if $msg contains 'msgnum' then ./rsyslog.out.log +if $msg contains 'msgnum' then ./rsyslog.out.log;outfmt -- cgit v1.2.3 From 09438518bb483d7bd6451311e3a9bed740b40893 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 14 Sep 2012 07:51:28 +0200 Subject: Fix length calculation for script string constants This could lead to various problems, like if-filters not working. Note this is a regression from yesterdays escape fix, so there exist no released version with this problem. --- grammar/lexer.l | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grammar/lexer.l b/grammar/lexer.l index 289d54ff..6ac7fd9a 100644 --- a/grammar/lexer.l +++ b/grammar/lexer.l @@ -125,12 +125,12 @@ int fileno(FILE *stream); \'([^'\\]|\\['"\\$bntr]|\\x[0-9a-f][0-9a-f]|\\[0-7][0-7][0-7])*\' { yytext[yyleng-1] = '\0'; unescapeStr((uchar*)yytext+1, yyleng-2); - yylval.estr = es_newStrFromBuf(yytext+1, strlen(yytext)); + yylval.estr = es_newStrFromBuf(yytext+1, strlen(yytext)-1); return STRING; } \"([^"\\$]|\\["'\\$bntr]|\\x[0-9a-f][0-9a-f]|\\[0-7][0-7][0-7])*\" { yytext[yyleng-1] = '\0'; unescapeStr((uchar*)yytext+1, yyleng-2); - yylval.estr = es_newStrFromBuf(yytext+1, yyleng-2); + yylval.estr = es_newStrFromBuf(yytext+1, strlen(yytext)-1); return STRING; } [ \t\n] [a-z][a-z0-9_]* { yylval.estr = es_newStrFromCStr(yytext, yyleng); -- cgit v1.2.3 From acaf533712366c73e3b9abbd7a16b8008f894abe Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Fri, 14 Sep 2012 08:46:50 +0200 Subject: Debug logging slightly improved --- runtime/rule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/rule.c b/runtime/rule.c index fbc83873..a375b055 100644 --- a/runtime/rule.c +++ b/runtime/rule.c @@ -171,12 +171,12 @@ shouldProcessThisMessage(rule_t *pRule, msg_t *pMsg, sbool *bProcessMsg) if(pRule->f_filter_type == FILTER_PRI) { /* skip messages that are incorrect priority */ - dbgprintf("testing filter, f_pmask %d\n", pRule->f_filterData.f_pmask[pMsg->iFacility]); if ( (pRule->f_filterData.f_pmask[pMsg->iFacility] == TABLE_NOPRI) || \ ((pRule->f_filterData.f_pmask[pMsg->iFacility] & (1<iSeverity)) == 0) ) bRet = 0; else bRet = 1; + dbgprintf("testing filter, f_pmask %d, result %d\n", pRule->f_filterData.f_pmask[pMsg->iFacility], bRet); } else if(pRule->f_filter_type == FILTER_EXPR) { CHKiRet(vm.Construct(&pVM)); CHKiRet(vm.ConstructFinalize(pVM)); -- cgit v1.2.3