From 0be199af6cc2cd9a9acb96e97e1cd061affaa6d9 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 26 Mar 2009 17:48:59 +0100 Subject: initial parser testing suite added integrated tcl test script into autotools make check, created a few test cases based a real-world sample and samples from RFC3164 and 5424. --- ChangeLog | 2 ++ tests/Makefile.am | 10 +++++----- tests/parser.tcl | 3 ++- tests/parsertest | 2 ++ tests/testruns/1.parse1 | 3 +++ tests/testruns/rfc3164.parse1 | 4 ++++ tests/testruns/rfc5424-1.parse1 | 4 ++++ tests/testruns/rfc5424-2.parse1 | 4 ++++ tests/testruns/rfc5424-3.parse1 | 4 ++++ tests/testruns/rfc5424-4.parse1 | 4 ++++ 10 files changed, 34 insertions(+), 6 deletions(-) create mode 100755 tests/parsertest create mode 100644 tests/testruns/1.parse1 create mode 100644 tests/testruns/rfc3164.parse1 create mode 100644 tests/testruns/rfc5424-1.parse1 create mode 100644 tests/testruns/rfc5424-2.parse1 create mode 100644 tests/testruns/rfc5424-3.parse1 create mode 100644 tests/testruns/rfc5424-4.parse1 diff --git a/ChangeLog b/ChangeLog index 1cfb3c3a..e74c7209 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,8 @@ Version 4.1.6 [DEVEL] (rgerhards), 2009-03-?? is used in a secure way. (may be removed later) - added omstdout module for testing purposes. Spits out all messages to stdout - no config option, no other features +- added a parser testing suite (still needs to be extended, but a good + start) - modified $ModLoad statement so that for modules whom's name starts with a dot, no path is prepended (this enables relative-pathes and should not break any valid current config) diff --git a/tests/Makefile.am b/tests/Makefile.am index 384afd4e..225f087f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,8 +1,5 @@ -#AUTOMAKE_OPTIONS=dejagnu -#DEJATOOL=Rainer - check_PROGRAMS = rt_init rscript -TESTS = $(check_PROGRAMS) cfg.sh +TESTS = $(check_PROGRAMS) cfg.sh parsertest TESTS_ENVIRONMENT = RSYSLOG_MODDIR='$(abs_top_builddir)'/runtime/.libs/ #TESTS = $(check_PROGRAMS) @@ -19,7 +16,10 @@ EXTRA_DIST=1.rstest 2.rstest 3.rstest err1.rstest \ cfg4.testin \ DevNull.cfgtest \ err1.rstest \ - NoExistFile.cfgtest + NoExistFile.cfgtest \ + parsertest + parser.tcl + testruns/*.parser1 rt_init_SOURCES = rt-init.c $(test_files) rt_init_CPPFLAGS = -I$(top_srcdir) $(PTHREADS_CFLAGS) $(RSRT_CFLAGS) diff --git a/tests/parser.tcl b/tests/parser.tcl index 274c08a3..6b08717b 100644 --- a/tests/parser.tcl +++ b/tests/parser.tcl @@ -73,4 +73,5 @@ foreach testcase $files { exec kill $rsyslogdPID; close $udpSock; -puts "Number of failed test: $failed.\n"; +puts "Number of failed tests: $failed.\n"; +if { $failed != 0 } { exit 1 }; diff --git a/tests/parsertest b/tests/parsertest new file mode 100755 index 00000000..78c42c07 --- /dev/null +++ b/tests/parsertest @@ -0,0 +1,2 @@ +# run parser test suite +tclsh parser.tcl diff --git a/tests/testruns/1.parse1 b/tests/testruns/1.parse1 new file mode 100644 index 00000000..5ae655e6 --- /dev/null +++ b/tests/testruns/1.parse1 @@ -0,0 +1,3 @@ +<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,local4,debug,Mar 6 16:57:54,172.20.245.8,%PIX-7-710005,%PIX-7-710005:, UDP request discarded from SERVER1/2741 to test_app:255.255.255.255/61601 +#Only the first two lines are important, you may place anything behind them! diff --git a/tests/testruns/rfc3164.parse1 b/tests/testruns/rfc3164.parse1 new file mode 100644 index 00000000..e7a5fa18 --- /dev/null +++ b/tests/testruns/rfc3164.parse1 @@ -0,0 +1,4 @@ +<34>Oct 11 22:14:15 mymachine su: 'su root' failed for lonvick on /dev/pts/8 +34,auth,crit,Oct 11 22:14:15,mymachine,su,su:, 'su root' failed for lonvick on /dev/pts/8 +#Example from RFC3164, section 5.4 +#Only the first two lines are important, you may place anything behind them! diff --git a/tests/testruns/rfc5424-1.parse1 b/tests/testruns/rfc5424-1.parse1 new file mode 100644 index 00000000..90236c7f --- /dev/null +++ b/tests/testruns/rfc5424-1.parse1 @@ -0,0 +1,4 @@ +<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - BOM'su root' failed for lonvick on /dev/pts/8 +34,auth,crit,Oct 11 22:14:15,mymachine.example.com,,su,- BOM'su root' failed for lonvick on /dev/pts/8 +#Example from RFC5424, section 6.5 / sample 1 +#Only the first two lines are important, you may place anything behind them! diff --git a/tests/testruns/rfc5424-2.parse1 b/tests/testruns/rfc5424-2.parse1 new file mode 100644 index 00000000..a86fbc35 --- /dev/null +++ b/tests/testruns/rfc5424-2.parse1 @@ -0,0 +1,4 @@ +<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - %% It's time to make the do-nuts. +165,local4,notice,Aug 24 05:14:15,192.0.2.1,,myproc[8710],- %% It's time to make the do-nuts. +#Example from RFC5424, section 6.5 / sample 2 +#Only the first two lines are important, you may place anything behind them! diff --git a/tests/testruns/rfc5424-3.parse1 b/tests/testruns/rfc5424-3.parse1 new file mode 100644 index 00000000..6ad4073d --- /dev/null +++ b/tests/testruns/rfc5424-3.parse1 @@ -0,0 +1,4 @@ +<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource= "Application" eventID="1011"][examplePriority@32473 class="high"] +165,local4,notice,Oct 11 22:14:15,mymachine.example.com,,evntslog, +#Example from RFC5424, section 6.5 / sample 4 +#Only the first two lines are important, you may place anything behind them! diff --git a/tests/testruns/rfc5424-4.parse1 b/tests/testruns/rfc5424-4.parse1 new file mode 100644 index 00000000..ecf27e14 --- /dev/null +++ b/tests/testruns/rfc5424-4.parse1 @@ -0,0 +1,4 @@ +<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource= "Application" eventID="1011"] BOMAn application event log entry... +165,local4,notice,Oct 11 22:14:15,mymachine.example.com,,evntslog,BOMAn application event log entry... +#Example from RFC5424, section 6.5 / sample 3 +#Only the first two lines are important, you may place anything behind them! -- cgit