diff options
-rw-r--r-- | tests/test.tcl | 41 | ||||
-rw-r--r-- | tests/testruns/parser.conf | 10 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/test.tcl b/tests/test.tcl new file mode 100644 index 00000000..7f1b7a6b --- /dev/null +++ b/tests/test.tcl @@ -0,0 +1,41 @@ +# rsyslog parser tests +package require Expect +package require udp 1.0 + +set rsyslogdPID [spawn "../tools/rsyslogd" "-c4" "-ftestruns/parser.conf" "-u2" "-n" "-iwork/rsyslog.pid" "-M../runtime/.libs"]; +#interact; +#puts "pid: $rsyslogdPID"; +#sleep 1; +#expect "\n"; +expect "}}"; # eat startup message +set udpSock [udp_open]; +udp_conf $udpSock 127.0.0.1 514 +set files [glob *.parse1] +puts "done init\n"; + + +foreach testcase $files { + puts "File $testcase"; + set fp [open "$testcase" r]; + fconfigure $fp -buffering line + #set data [read $fp]; + #set data [split $data "\n"]; + gets $fp input + puts "Line 1: $input\n"; + + puts $udpSock $input; + flush $udpSock; + + + set i 1 + expect -re "{{.*}}"; + set result $expect_out(buffer); + + #puts "MSG $i: '$expect_out(buffer)'"; + puts "MSG $i: '$result'\n"; + set i [expr {$i + 1}]; + +} + +exec kill $rsyslogdPID; +close $udpSock; diff --git a/tests/testruns/parser.conf b/tests/testruns/parser.conf new file mode 100644 index 00000000..a515ff6c --- /dev/null +++ b/tests/testruns/parser.conf @@ -0,0 +1,10 @@ +$ModLoad ../plugins/omstdout/.libs/omstdout +$ModLoad ../plugins/imuxsock/.libs/imuxsock +$ModLoad ../plugins/imudp/.libs/imudp +$UDPServerRun 514 + +$ErrorMessagesToStderr off + +# use a special format that we can easily parse in expect +$template expect,"{{%PRI%,%syslogtag%,%hostname%}}" +*.* :omstdout:;expect |