summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-07-07 09:41:31 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2008-07-07 09:41:31 +0200
commit37fd063042821dc328c88e1f7366543decdcb76f (patch)
tree5f14f9144f7c4c9ad3a071535ccc8a4b48b40218 /tests
parent06001e951f5b5d0a7919c61057bc7a87b9eb8cba (diff)
downloadrsyslog-37fd063042821dc328c88e1f7366543decdcb76f.tar.gz
rsyslog-37fd063042821dc328c88e1f7366543decdcb76f.tar.xz
rsyslog-37fd063042821dc328c88e1f7366543decdcb76f.zip
added capability to create a printable string of a vmprg
This is needed so that we can create simple testbenches which will check the result of a test (a generated program) via a simple strcmp.
Diffstat (limited to 'tests')
-rw-r--r--tests/rscript-parse.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/rscript-parse.c b/tests/rscript-parse.c
index 176f3f7e..01ddb7d1 100644
--- a/tests/rscript-parse.c
+++ b/tests/rscript-parse.c
@@ -21,6 +21,7 @@
*
* A copy of the GPL can be found in the file "COPYING" in this distribution.
*/
+#include "config.h"
#include <stdio.h>
#include "rsyslog.h"
@@ -33,12 +34,14 @@ MODULE_TYPE_TESTBENCH
DEFobjCurrIf(expr)
DEFobjCurrIf(ctok)
DEFobjCurrIf(ctok_token)
+DEFobjCurrIf(vmprg)
BEGINInit
CODESTARTInit
pErrObj = "expr"; CHKiRet(objUse(expr, CORE_COMPONENT));
pErrObj = "ctok"; CHKiRet(objUse(ctok, CORE_COMPONENT));
pErrObj = "ctok_token"; CHKiRet(objUse(ctok_token, CORE_COMPONENT));
+ pErrObj = "vmprg"; CHKiRet(objUse(vmprg, CORE_COMPONENT));
ENDInit
BEGINExit
@@ -46,13 +49,15 @@ CODESTARTExit
ENDExit
BEGINTest
+ cstr_t *pstrPrg;
ctok_t *tok;
ctok_token_t *pToken;
expr_t *pExpr;
/* the string below is an expression as defined up to 3.19.x - note that the
* then and the space after it MUST be present!
*/
- uchar szExpr[] = " $msg contains 'test' then ";
+ //uchar szExpr[] = " $msg contains 'test' then ";
+ uchar szExpr[] = "'test 1' <> $var or /* some comment */($SEVERITY == -4 +5 -(3 * - 2) and $fromhost == '127.0.0.1') then ";
/*uchar szSynErr[] = "$msg == 1 and syntaxerror ";*/
CODESTARTTest
/* we first need a tokenizer... */
@@ -77,16 +82,19 @@ CODESTARTTest
* Should anyone have any insight, I'd really appreciate if you drop me
* a line.
*/
-#if 0
CHKiRet(ctok.GetToken(tok, &pToken));
if(pToken->tok != ctok_THEN) {
-//printf("invalid token, probably due to invalid alignment between runtime lib and this program\n");
ctok_token.Destruct(&pToken);
ABORT_FINALIZE(RS_RET_SYNTAX_ERROR);
}
ctok_token.Destruct(&pToken); /* no longer needed */
-#endif
+
+ CHKiRet(rsCStrConstruct(&pstrPrg));
+ CHKiRet(vmprg.Obj2Str(pExpr->pVmprg, pstrPrg));
+
+ printf("string returned: '%s'\n", rsCStrGetSzStr(pstrPrg));
+ rsCStrDestruct(&pstrPrg);
/* we are done, so we now need to restore things */
CHKiRet(ctok.Destruct(&tok));