summaryrefslogtreecommitdiffstats
path: root/tests/test.tcl
blob: 7f1b7a6b60b3c63416df96cef7e96c939505cc4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;