31
31
#include "gsockaddr.h"
32
32
#include "timeutils/cache.h"
33
33
#include "timeutils/misc.h"
34
+ #include "scratch-buffers.h"
34
35
#include "cfg.h"
35
36
#include "plugin.h"
36
37
@@ -138,6 +139,7 @@ setup(void)
138
139
void
139
140
teardown (void )
140
141
{
142
+ scratch_buffers_explicit_gc ();
141
143
deinit_syslogformat_module ();
142
144
app_shutdown ();
143
145
}
@@ -175,7 +177,8 @@ test_log_messages_can_be_parsed(struct msgparse_params *param)
175
177
176
178
cr_assert_eq (parsed_message -> pri , param -> expected_pri , "Unexpected message priority %d != %d" ,
177
179
parsed_message -> pri , param -> expected_pri );
178
- assert_log_message_value (parsed_message , LM_V_HOST , param -> expected_host );
180
+ if (param -> expected_host )
181
+ assert_log_message_value (parsed_message , LM_V_HOST , param -> expected_host );
179
182
assert_log_message_value (parsed_message , LM_V_PROGRAM , param -> expected_program );
180
183
assert_log_message_value (parsed_message , LM_V_MESSAGE , param -> expected_msg );
181
184
if (param -> expected_pid )
@@ -241,10 +244,10 @@ Test(msgparse, test_bad_sd_data_unescaped)
241
244
{
242
245
{
243
246
"<132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [a i=\"\"ok\"] An application event log entry..." ,
244
- LP_SYSLOG_PROTOCOL , NULL ,
247
+ LP_SYSLOG_PROTOCOL | LP_PIGGYBACK_ERRORS , NULL ,
245
248
43 , // pri
246
249
0 , 0 , 0 , // timestamp (sec/usec/zone)
247
- "" , // host
250
+ NULL , // host
248
251
"syslog-ng" , //app
249
252
"Error processing log message: <132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [a i=\">@<\"ok\"] An application event log entry..." , // msg
250
253
"" , //sd_str
@@ -691,10 +694,11 @@ Test(msgparse, test_expected_sd_pairs_1)
691
694
expected_sd_pairs_test_1
692
695
},
693
696
{
694
- "<7>1 2006-10-29T01:59:59.156Z mymachine.example.com evntslog - ID47 [ exampleSDID@0 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"][examplePriority@0 class=\"high\"] \xEF\xBB\xBF" "An application event log entry..." , LP_SYSLOG_PROTOCOL , NULL ,
697
+ "<7>1 2006-10-29T01:59:59.156Z mymachine.example.com evntslog - ID47 [ exampleSDID@0 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"][examplePriority@0 class=\"high\"] \xEF\xBB\xBF" "An application event log entry..." ,
698
+ LP_PIGGYBACK_ERRORS | LP_SYSLOG_PROTOCOL , NULL ,
695
699
43 , // pri
696
700
0 , 0 , 0 , // timestamp (sec/usec/zone)
697
- "" , // host
701
+ NULL , // host
698
702
"syslog-ng" , //app
699
703
"Error processing log message: <7>1 2006-10-29T01:59:59.156Z mymachine.example.com evntslog - ID47 >@<[ exampleSDID@0 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"][examplePriority@0 class=\"high\"] \xEF\xBB\xBF" "An application event log entry..." , // msg
700
704
"" ,
@@ -879,10 +883,11 @@ Test(msgparse, test_expected_sd_pairs_long)
879
883
880
884
// parse longer than 255 sd id
881
885
{
882
- "<132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa i=\"long\"] An application event log entry..." , LP_SYSLOG_PROTOCOL , NULL ,
886
+ "<132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa i=\"long\"] An application event log entry..." ,
887
+ LP_PIGGYBACK_ERRORS | LP_SYSLOG_PROTOCOL , NULL ,
883
888
43 , // pri
884
889
0 , 0 , 0 , // timestamp (sec/usec/zone)
885
- "" , // host
890
+ NULL , // host
886
891
"syslog-ng" , //app
887
892
"Error processing log message: <132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>@<aaaaaaaa i=\"long\"] An application event log entry..." , // msg
888
893
"" , //sd_str 0,//processid
@@ -923,10 +928,11 @@ Test(msgparse, test_unescaped_too_long_message_parts)
923
928
{
924
929
// too long hostname
925
930
{
926
- "<132>1 2006-10-29T01:59:59.156+01:00 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa evntslog - - [a i=\"ok\"] An application event log entry..." , LP_SYSLOG_PROTOCOL , NULL ,
931
+ "<132>1 2006-10-29T01:59:59.156+01:00 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa evntslog - - [a i=\"ok\"] An application event log entry..." ,
932
+ LP_PIGGYBACK_ERRORS | LP_SYSLOG_PROTOCOL , NULL ,
927
933
43 , // pri
928
934
0 , 0 , 0 , // timestamp (sec/usec/zone)
929
- "" , //host
935
+ NULL , //host
930
936
"syslog-ng" , //app
931
937
"Error processing log message: <132>1 2006-10-29T01:59:59.156+01:00 >@<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa evntslog - - [a i=\"ok\"] An application event log entry..." , // msg
932
938
"" , //sd_str
@@ -979,10 +985,11 @@ Test(msgparse, test_unescaped_too_long_message_parts)
979
985
980
986
// unescaped ]
981
987
{
982
- "<132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [a i=\"]ok\"] An application event log entry..." , LP_SYSLOG_PROTOCOL , NULL ,
988
+ "<132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [a i=\"]ok\"] An application event log entry..." ,
989
+ LP_PIGGYBACK_ERRORS | LP_SYSLOG_PROTOCOL , NULL ,
983
990
43 , // pri
984
991
0 , 0 , 0 , // timestamp (sec/usec/zone)
985
- "" , // host
992
+ NULL , // host
986
993
"syslog-ng" , //app
987
994
"Error processing log message: <132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [a i=\">@<]ok\"] An application event log entry..." , // msg
988
995
"" , //sd_str
@@ -994,10 +1001,11 @@ Test(msgparse, test_unescaped_too_long_message_parts)
994
1001
995
1002
// bad sd data unescaped "
996
1003
{
997
- "<132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [a i=\"\"ok\"] An application event log entry..." , LP_SYSLOG_PROTOCOL , NULL ,
1004
+ "<132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [a i=\"\"ok\"] An application event log entry..." ,
1005
+ LP_PIGGYBACK_ERRORS | LP_SYSLOG_PROTOCOL , NULL ,
998
1006
43 , // pri
999
1007
0 , 0 , 0 , // timestamp (sec/usec/zone)
1000
- "" , // host
1008
+ NULL , // host
1001
1009
"syslog-ng" , //app
1002
1010
"Error processing log message: <132>1 2006-10-29T01:59:59.156+01:00 mymachine evntslog - - [a i=\">@<\"ok\"] An application event log entry..." , // msg
1003
1011
"" , //sd_str
@@ -1218,10 +1226,10 @@ Test(msgparse, test_no_rfc3164_fallback_flag)
1218
1226
{
1219
1227
{
1220
1228
.msg = "<189>some message" ,
1221
- .parse_flags = LP_SYSLOG_PROTOCOL | LP_NO_RFC3164_FALLBACK ,
1229
+ .parse_flags = LP_SYSLOG_PROTOCOL | LP_NO_RFC3164_FALLBACK | LP_PIGGYBACK_ERRORS ,
1222
1230
.expected_pri = 43 ,
1223
1231
.expected_program = "syslog-ng" ,
1224
- .expected_host = "" ,
1232
+ .expected_host = NULL ,
1225
1233
.expected_msg = "Error processing log message: <189>some message" ,
1226
1234
},
1227
1235
{NULL }
0 commit comments