diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/3.rstest | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 28 | ||||
-rwxr-xr-x | tests/omod-if-array.sh | 1 | ||||
-rwxr-xr-x | tests/parsertest.sh | 1 | ||||
-rw-r--r-- | tests/testsuites/1.omod-if-array | 2 | ||||
-rw-r--r-- | tests/testsuites/1.parse1 (renamed from tests/testruns/1.parse1) | 0 | ||||
-rw-r--r-- | tests/testsuites/2.parse1 | 3 | ||||
-rw-r--r-- | tests/testsuites/3.parse1 | 3 | ||||
-rw-r--r-- | tests/testsuites/date1.parse1 | 3 | ||||
-rw-r--r-- | tests/testsuites/date2.parse1 | 3 | ||||
-rw-r--r-- | tests/testsuites/date3.parse1 | 3 | ||||
-rw-r--r-- | tests/testsuites/date4.parse1 | 3 | ||||
-rw-r--r-- | tests/testsuites/date5.parse1 | 3 | ||||
-rw-r--r-- | tests/testsuites/omod-if-array.conf | 14 | ||||
-rw-r--r-- | tests/testsuites/parse1.conf (renamed from tests/testruns/parser.conf) | 0 | ||||
-rw-r--r-- | tests/testsuites/rfc3164.parse1 (renamed from tests/testruns/rfc3164.parse1) | 0 | ||||
-rw-r--r-- | tests/testsuites/rfc5424-1.parse1 (renamed from tests/testruns/rfc5424-1.parse1) | 0 | ||||
-rw-r--r-- | tests/testsuites/rfc5424-2.parse1 (renamed from tests/testruns/rfc5424-2.parse1) | 0 | ||||
-rw-r--r-- | tests/testsuites/rfc5424-3.parse1 (renamed from tests/testruns/rfc5424-3.parse1) | 0 | ||||
-rw-r--r-- | tests/testsuites/rfc5424-4.parse1 (renamed from tests/testruns/rfc5424-4.parse1) | 0 | ||||
-rw-r--r-- | tests/udptester.c (renamed from tests/parsertest.c) | 50 |
21 files changed, 94 insertions, 27 deletions
diff --git a/tests/3.rstest b/tests/3.rstest index 93cb941a..e75d9754 100644 --- a/tests/3.rstest +++ b/tests/3.rstest @@ -7,10 +7,10 @@ out: 00000000: push_msgvar msg[cstr] 00000001: push_const abc[cstr] 00000002: push_const 1[nbr] -00000003: func_call strlen[cstr] +00000003: func_call strlen 00000004: strconcat 00000005: push_const 1[nbr] -00000006: func_call strlen[cstr] +00000006: func_call strlen 00000007: push_const 20[nbr] 00000008: push_const 30[nbr] 00000009: add diff --git a/tests/Makefile.am b/tests/Makefile.am index 09d1a0b6..ab1c5a62 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ -TESTRUNS = rt_init rscript parsertest -check_PROGRAMS = $(TESTRUNS) ourtail -TESTS = $(TESTRUNS) cfg.sh +TESTRUNS = rt_init rscript +check_PROGRAMS = $(TESTRUNS) ourtail udptester +TESTS = $(TESTRUNS) cfg.sh parsertest.sh omod-if-array.sh TESTS_ENVIRONMENT = RSYSLOG_MODDIR='$(abs_top_builddir)'/runtime/.libs/ DISTCLEANFILES=rsyslog.pid test_files = testbench.h runtime-dummy.c @@ -17,19 +17,23 @@ EXTRA_DIST= 1.rstest 2.rstest 3.rstest err1.rstest \ DevNull.cfgtest \ err1.rstest \ NoExistFile.cfgtest \ - testruns/parser.conf \ - testruns/1.parse1 \ - testruns/rfc3164.parse1 \ - testruns/rfc5424-1.parse1 \ - testruns/rfc5424-2.parse1 \ - testruns/rfc5424-3.parse1 \ - testruns/rfc5424-4.parse1 \ + testsuites/parse1.conf \ + testsuites/1.parse1 \ + testsuites/rfc3164.parse1 \ + testsuites/rfc5424-1.parse1 \ + testsuites/rfc5424-2.parse1 \ + testsuites/rfc5424-3.parse1 \ + testsuites/rfc5424-4.parse1 \ + testsuites/omod-if-array.conf \ + testsuites/1.omod-if-array \ + parsertest.sh \ + omod-if-array.sh \ cfg.sh ourtail_SOURCES = ourtail.c -parsertest_SOURCES = parsertest.c getline.c -parsertest_LDADD = $(SOL_LIBS) +udptester_SOURCES = udptester.c getline.c +udptester_LDADD = $(SOL_LIBS) rt_init_SOURCES = rt-init.c $(test_files) rt_init_CPPFLAGS = -I$(top_srcdir) $(PTHREADS_CFLAGS) $(RSRT_CFLAGS) diff --git a/tests/omod-if-array.sh b/tests/omod-if-array.sh new file mode 100755 index 00000000..cac08928 --- /dev/null +++ b/tests/omod-if-array.sh @@ -0,0 +1 @@ +./udptester omod-if-array diff --git a/tests/parsertest.sh b/tests/parsertest.sh new file mode 100755 index 00000000..e7985bb0 --- /dev/null +++ b/tests/parsertest.sh @@ -0,0 +1 @@ +./udptester parse1 diff --git a/tests/testsuites/1.omod-if-array b/tests/testsuites/1.omod-if-array new file mode 100644 index 00000000..c464b19c --- /dev/null +++ b/tests/testsuites/1.omod-if-array @@ -0,0 +1,2 @@ +<167>Mar 6 16:57:54 172.20.245.8 %PIX-7-710005: UDP request discarded from SERVER1/2741 to test_app:255.255.255.255/61601 +167,Mar 6 16:57:54,172.20.245.8,%PIX-7-710005,%PIX-7-710005:, diff --git a/tests/testruns/1.parse1 b/tests/testsuites/1.parse1 index 5ae655e6..5ae655e6 100644 --- a/tests/testruns/1.parse1 +++ b/tests/testsuites/1.parse1 diff --git a/tests/testsuites/2.parse1 b/tests/testsuites/2.parse1 new file mode 100644 index 00000000..628e06df --- /dev/null +++ b/tests/testsuites/2.parse1 @@ -0,0 +1,3 @@ +<38>Mar 27 19:06:53 source_server sshd(pam_unix)[12750]: session opened for user foo by (uid=0) +38,auth,info,Mar 27 19:06:53,source_server,sshd(pam_unix),sshd(pam_unix)[12750]:, session opened for user foo by (uid=0) +# yet another real-life sample where we had some issues with diff --git a/tests/testsuites/3.parse1 b/tests/testsuites/3.parse1 new file mode 100644 index 00000000..a6b4e884 --- /dev/null +++ b/tests/testsuites/3.parse1 @@ -0,0 +1,3 @@ +<38>Apr 6 15:07:10 lxcvs07 sshd(pam_unix)[31738]: session closed for user cvsadmin +38,auth,info,Apr 6 15:07:10,lxcvs07,sshd(pam_unix),sshd(pam_unix)[31738]:, session closed for user cvsadmin +# yet another real-life sample where we had some issues with diff --git a/tests/testsuites/date1.parse1 b/tests/testsuites/date1.parse1 new file mode 100644 index 00000000..ffc7c373 --- /dev/null +++ b/tests/testsuites/date1.parse1 @@ -0,0 +1,3 @@ +<38> Mar 7 19:06:53 example tag: testmessage (only date actually tested) +38,auth,info,Mar 7 19:06:53,example,tag,tag:, testmessage (only date actually tested) +# one space in front of the date diff --git a/tests/testsuites/date2.parse1 b/tests/testsuites/date2.parse1 new file mode 100644 index 00000000..8d587d9d --- /dev/null +++ b/tests/testsuites/date2.parse1 @@ -0,0 +1,3 @@ +<38>Mar 7 19:06:53 example tag: testmessage (only date actually tested) +38,auth,info,Mar 7 19:06:53,example,tag,tag:, testmessage (only date actually tested) +# only one space between "Mar" and "7" diff --git a/tests/testsuites/date3.parse1 b/tests/testsuites/date3.parse1 new file mode 100644 index 00000000..940d261e --- /dev/null +++ b/tests/testsuites/date3.parse1 @@ -0,0 +1,3 @@ +<38>Mar 7 2008 19:06:53: example tag: testmessage (only date actually tested) +38,auth,info,Mar 7 19:06:53,example,tag,tag:, testmessage (only date actually tested) +# the year should not be there, nor the colon after the date, but we accept it... diff --git a/tests/testsuites/date4.parse1 b/tests/testsuites/date4.parse1 new file mode 100644 index 00000000..eee5fb09 --- /dev/null +++ b/tests/testsuites/date4.parse1 @@ -0,0 +1,3 @@ +<38>Mar 7 2008 19:06:53 example tag: testmessage (only date actually tested) +38,auth,info,Mar 7 19:06:53,example,tag,tag:, testmessage (only date actually tested) +# the year should not be there, but we accept it... diff --git a/tests/testsuites/date5.parse1 b/tests/testsuites/date5.parse1 new file mode 100644 index 00000000..be32e605 --- /dev/null +++ b/tests/testsuites/date5.parse1 @@ -0,0 +1,3 @@ +<38>Mar 7 19:06:53: example tag: testmessage (only date actually tested) +38,auth,info,Mar 7 19:06:53,example,tag,tag:, testmessage (only date actually tested) +# colon after timestamp is strictly not ok, but we accept it diff --git a/tests/testsuites/omod-if-array.conf b/tests/testsuites/omod-if-array.conf new file mode 100644 index 00000000..e6c05a52 --- /dev/null +++ b/tests/testsuites/omod-if-array.conf @@ -0,0 +1,14 @@ +# Test config for array-passing output module interface +# (stanard string passing is already tested via the other test inside +# the testbench, so we do not need to focus on that) +# rgerhards, 2009-04-03 +$ModLoad ../plugins/omstdout/.libs/omstdout +$ModLoad ../plugins/imudp/.libs/imudp +$UDPServerRun 12514 + +$ActionOMStdoutArrayInterface on +$ErrorMessagesToStderr off + +# do NOT remove \n, that would hang the test driver! +$template expect,"%PRI%%timestamp%%hostname%%programname%%syslogtag%\n" +*.* :omstdout:;expect diff --git a/tests/testruns/parser.conf b/tests/testsuites/parse1.conf index 0fb7d16d..0fb7d16d 100644 --- a/tests/testruns/parser.conf +++ b/tests/testsuites/parse1.conf diff --git a/tests/testruns/rfc3164.parse1 b/tests/testsuites/rfc3164.parse1 index e7a5fa18..e7a5fa18 100644 --- a/tests/testruns/rfc3164.parse1 +++ b/tests/testsuites/rfc3164.parse1 diff --git a/tests/testruns/rfc5424-1.parse1 b/tests/testsuites/rfc5424-1.parse1 index 23836c9f..23836c9f 100644 --- a/tests/testruns/rfc5424-1.parse1 +++ b/tests/testsuites/rfc5424-1.parse1 diff --git a/tests/testruns/rfc5424-2.parse1 b/tests/testsuites/rfc5424-2.parse1 index a86fbc35..a86fbc35 100644 --- a/tests/testruns/rfc5424-2.parse1 +++ b/tests/testsuites/rfc5424-2.parse1 diff --git a/tests/testruns/rfc5424-3.parse1 b/tests/testsuites/rfc5424-3.parse1 index 6ad4073d..6ad4073d 100644 --- a/tests/testruns/rfc5424-3.parse1 +++ b/tests/testsuites/rfc5424-3.parse1 diff --git a/tests/testruns/rfc5424-4.parse1 b/tests/testsuites/rfc5424-4.parse1 index ecf27e14..ecf27e14 100644 --- a/tests/testruns/rfc5424-4.parse1 +++ b/tests/testsuites/rfc5424-4.parse1 diff --git a/tests/parsertest.c b/tests/udptester.c index 6c2221e8..a3c6658d 100644 --- a/tests/parsertest.c +++ b/tests/udptester.c @@ -1,11 +1,14 @@ -/* Runs a test suite on the rsyslog parser (and later potentially +/* Runs a test suite on the rsyslog (and later potentially * other things). * - * Please note that this - * program works together with the config file AND easily extensible - * test case files (*.parse1) to run a number of checks. All test - * cases are executed, even if there is a failure early in the - * process. When finished, the numberof failed tests will be given. + * The name of the test suite must be given as argv[1]. In this config, + * rsyslogd is loaded with config ./testsuites/<name>.conf and then + * test cases ./testsuites/ *.<name> are executed on it. This test driver is + * suitable for testing cases where a message sent (via UDP) results in + * exactly one response. It can not be used in cases where no response + * is expected (that would result in a hang of the test driver). + * Note: each test suite can contain many tests, but they all need to work + * with the same rsyslog configuration. * * Part of the testbench for rsyslog. * @@ -44,6 +47,9 @@ #define EXIT_FAILURE 1 +static char *srcdir; /* global $srcdir, set so that we can run outside of "make check" */ +static char *testSuite; /* name of current test suite */ + void readLine(int fd, char *ln) { @@ -90,12 +96,13 @@ udpSend(char *buf, int lenBuf) return 0; } + /* open pipe to test candidate - so far, this is * always rsyslogd and with a fixed config. Later, we may * change this. Returns 0 if ok, something else otherwise. * rgerhards, 2009-03-31 */ -int openPipe(pid_t *pid, int *pfd) +int openPipe(char *configFile, pid_t *pid, int *pfd) { int pipefd[2]; pid_t cpid; @@ -105,7 +112,7 @@ int openPipe(pid_t *pid, int *pfd) char *newenviron[] = { NULL }; - sprintf(confFile, "-f%s/testruns/parser.conf", getenv("srcdir")); + sprintf(confFile, "-f%s/testsuites/%s.conf", srcdir, configFile); newargv[1] = confFile; if (pipe(pipefd) == -1) { @@ -243,27 +250,44 @@ doTests(int fd, char *files) } -/* */ +/* Run the test suite. This must be called with exactly one parameter, the + * name of the test suite. For details, see file header comment at the top + * of this file. + * rgerhards, 2009-04-03 + */ int main(int argc, char *argv[]) { int fd; pid_t pid; + int status; int ret = 0; char buf[4096]; char testcases[4096]; - printf("running rsyslog parser tests ($srcdir=%s)\n", getenv("srcdir")); + if(argc != 2) { + printf("Invalid call of udptester\n"); + printf("Usage: udptester testsuite-name\n"); + exit(1); + } + + testSuite = argv[1]; + + if((srcdir = getenv("srcdir")) == NULL) + srcdir = "."; + + printf("Start of udptester run ($srcdir=%s, testsuite=%s)\n", srcdir, testSuite); - openPipe(&pid, &fd); + openPipe(argv[1], &pid, &fd); readLine(fd, buf); /* generate filename */ - sprintf(testcases, "%s/testruns/*.parse1", getenv("srcdir")); + sprintf(testcases, "%s/testsuites/*.%s", srcdir, testSuite); if(doTests(fd, testcases) != 0) ret = 1; /* cleanup */ kill(pid, SIGTERM); - printf("End of parser tests.\n"); + waitpid(pid, &status, 0); /* wait until instance terminates */ + printf("End of udptester run.\n"); exit(ret); } |