summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/omstdout/omstdout.c2
-rw-r--r--tests/Makefile.am28
-rwxr-xr-xtests/omod-if-array.sh1
-rwxr-xr-xtests/parsertest.sh1
-rw-r--r--tests/testsuites/1.omod-if-array2
-rw-r--r--tests/testsuites/1.parse1 (renamed from tests/testruns/1.parse1)0
-rw-r--r--tests/testsuites/omod-if-array.conf14
-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)48
14 files changed, 71 insertions, 25 deletions
diff --git a/plugins/omstdout/omstdout.c b/plugins/omstdout/omstdout.c
index e491005c..7c63b5c4 100644
--- a/plugins/omstdout/omstdout.c
+++ b/plugins/omstdout/omstdout.c
@@ -107,6 +107,8 @@ CODESTARTdoAction
iParam = 0;
iBuf = 0;
while(szParams[iParam] != NULL) {
+ if(iParam > 0)
+ szBuf[iBuf++] = ','; /* all but first need a delimiter */
iParamVal = 0;
while(szParams[iParam][iParamVal] != '\0' && iBuf < sizeof(szBuf)) {
szBuf[iBuf++] = szParams[iParam][iParamVal++];
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/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..ea642db6 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,7 +250,11 @@ 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;
@@ -252,18 +263,29 @@ int main(int argc, char *argv[])
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");
+ printf("End of udptester run.\n");
exit(ret);
}