132
248
testcase("<7> openvpn[2499]: PTHREAD support initialized", 0, filter_level_new(level_bits("debug")), 1);
135
testcase("<15> openvpn[2499]: PTHREAD support initialized", 0, filter_prog_new("^openvpn$"), 1);
136
testcase("<15> openvpn[2499]: PTHREAD support initialized", 0, filter_prog_new("^open$"), 0);
137
fprintf(stderr, "One \"invalid regular expression\" message is to be expected\n");
138
TEST_ASSERT(filter_prog_new("((") == NULL);
140
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_host_new("^host$"), 1);
141
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_host_new("^hos$"), 0);
142
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_host_new("pthread"), 0);
143
fprintf(stderr, "One \"invalid regular expressions\" message is to be expected\n");
144
TEST_ASSERT(filter_host_new("((") == NULL);
146
fprintf(stderr, "One \"invalid regular expressions\" message is to be expected\n");
147
TEST_ASSERT(filter_host_new("(?iana") == NULL);
149
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_match_new(" PTHREAD "), 1);
150
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_match_new("^PTHREAD$"), 0);
151
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_match_new("(?i)pthread"), 1);
152
fprintf(stderr, "One \"invalid regular expression\" message is to be expected\n");
153
TEST_ASSERT(filter_match_new("((") == NULL);
251
testcase("<15> openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_PROGRAM, "^openvpn$", 0), 1);
252
testcase("<15> openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_PROGRAM, "^open$", 0), 0);
253
fprintf(stderr, "One \"invalid regular expression\" message is to be expected\n");
254
TEST_ASSERT(create_posix_regexp_filter(LM_F_PROGRAM, "((", 0) == NULL);
256
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_HOST, "^host$", 0), 1);
257
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_HOST, "^hos$", 0), 0);
258
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_HOST, "pthread", 0), 0);
259
fprintf(stderr, "One \"invalid regular expressions\" message is to be expected\n");
260
TEST_ASSERT(create_posix_regexp_filter(LM_F_HOST, "((", 0) == NULL);
263
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_MESSAGE, "^PTHREAD ", 0), 1);
264
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_MESSAGE, "PTHREAD s", 0), 1);
265
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_MESSAGE, "^PTHREAD$", 0), 0);
266
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_filter(LM_F_MESSAGE, "(?i)pthread", 0), 1);
269
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_match(" PTHREAD ", 0), 1);
270
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_match("^openvpn\\[2499\\]: PTHREAD", 0), 1);
271
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_match("^PTHREAD$", 0), 0);
272
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_match("(?i)pthread", 0), 1);
273
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_posix_regexp_match("pthread", LMF_ICASE), 1);
276
fprintf(stderr, "One \"invalid regular expression\" message is to be expected\n");
277
TEST_ASSERT(create_posix_regexp_match("((", 0) == NULL);
280
sender_saddr = g_sockaddr_inet_new("10.10.0.1", 5000);
155
281
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_netmask_new("10.10.0.0/16"), 1);
156
282
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_netmask_new("10.10.0.0/24"), 1);
157
283
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_netmask_new("10.10.10.0/24"), 0);
158
284
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_netmask_new("0.0.10.10/24"), 0);
160
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(filter_match_new(" PTHREAD "), filter_match_new("PTHREAD")), 1);
161
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(filter_match_new(" PTHREAD "), filter_match_new("^PTHREAD$")), 1);
162
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(filter_match_new("^PTHREAD$"), filter_match_new(" PTHREAD ")), 1);
163
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(filter_match_new(" PAD "), filter_match_new("^PTHREAD$")), 0);
165
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(filter_match_new(" PTHREAD "), filter_match_new("PTHREAD")), 1);
166
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(filter_match_new(" PTHREAD "), filter_match_new("^PTHREAD$")), 0);
167
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(filter_match_new("^PTHREAD$"), filter_match_new(" PTHREAD ")), 0);
168
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(filter_match_new(" PAD "), filter_match_new("^PTHREAD$")), 0);
285
g_sockaddr_unref(sender_saddr);
287
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_netmask_new("127.0.0.1/32"), 1);
288
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, filter_netmask_new("127.0.0.2/32"), 0);
290
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(create_posix_regexp_match(" PTHREAD ", 0), create_posix_regexp_match("PTHREAD", 0)), 1);
291
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(create_posix_regexp_match(" PTHREAD ", 0), create_posix_regexp_match("^PTHREAD$", 0)), 1);
292
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(create_posix_regexp_match("^PTHREAD$", 0), create_posix_regexp_match(" PTHREAD ", 0)), 1);
293
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(create_posix_regexp_match(" PAD ", 0), create_posix_regexp_match("^PTHREAD$", 0)), 0);
295
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(create_posix_regexp_match(" PTHREAD ", 0), create_posix_regexp_match("PTHREAD", 0)), 1);
296
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(create_posix_regexp_match(" PTHREAD ", 0), create_posix_regexp_match("^PTHREAD$", 0)), 0);
297
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(create_posix_regexp_match("^PTHREAD$", 0), create_posix_regexp_match(" PTHREAD ", 0)), 0);
298
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(create_posix_regexp_match(" PAD ", 0), create_posix_regexp_match("^PTHREAD$", 0)), 0);
302
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: al fa", 0, create_posix_regexp_filter(LM_F_MESSAGE, "(a)(l) (fa)", LMF_STORE_MATCHES), 1, "1","a");
304
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: al fa", 0, create_posix_regexp_filter(LM_F_MESSAGE, "(a)(l) (fa)", LMF_STORE_MATCHES), 1, "0","al fa");
306
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: al fa", 0, create_posix_regexp_filter(LM_F_MESSAGE, "(a)(l) (fa)", LMF_STORE_MATCHES), 1, "232", NULL);
310
testcase("<15> openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_PROGRAM, "^openvpn$", 0), 1);
311
testcase("<15> openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_PROGRAM, "^open$", 0), 0);
312
fprintf(stderr, "One \"invalid regular expression\" message is to be expected\n");
313
TEST_ASSERT(create_pcre_regexp_filter(LM_F_PROGRAM, "((", 0) == NULL);
315
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_HOST, "^host$", 0), 1);
316
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_HOST, "^hos$", 0), 0);
317
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_HOST, "pthread", 0), 0);
318
fprintf(stderr, "One \"invalid regular expressions\" message is to be expected\n");
319
TEST_ASSERT(create_pcre_regexp_filter(LM_F_HOST, "((", 0) == NULL);
321
fprintf(stderr, "One \"invalid regular expressions\" message is to be expected\n");
322
TEST_ASSERT(create_posix_regexp_filter(LM_F_HOST, "(?iana", 0) == NULL);
324
fprintf(stderr, "One \"invalid regular expressions\" message is to be expected\n");
325
TEST_ASSERT(create_pcre_regexp_filter(LM_F_HOST, "(?iana", 0) == NULL);
327
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "^PTHREAD ", 0), 1);
328
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "PTHREAD s", 0), 1);
329
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "^PTHREAD$", 0), 0);
330
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "(?i)pthread", 0), 1);
332
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(create_pcre_regexp_match(" PTHREAD ", 0), create_posix_regexp_match("PTHREAD", 0)), 1);
333
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(create_pcre_regexp_match(" PTHREAD ", 0), create_posix_regexp_match("^PTHREAD$", 0)), 0);
334
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(create_pcre_regexp_match("^PTHREAD$", 0), create_posix_regexp_match(" PTHREAD ", 0)), 0);
335
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_and_new(create_pcre_regexp_match(" PAD ", 0), create_posix_regexp_match("^PTHREAD$", 0)), 0);
337
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(create_pcre_regexp_match(" PTHREAD ", 0), create_pcre_regexp_match("PTHREAD", 0)), 1);
338
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(create_pcre_regexp_match(" PTHREAD ", 0), create_pcre_regexp_match("^PTHREAD$", 0)), 1);
339
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(create_pcre_regexp_match("^PTHREAD$", 0), create_pcre_regexp_match(" PTHREAD ", 0)), 1);
340
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, fop_or_new(create_pcre_regexp_match(" PAD ", 0), create_pcre_regexp_match("^PTHREAD$", 0)), 0);
342
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_match(" PTHREAD ", 0), 1);
343
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_match("^openvpn\\[2499\\]: PTHREAD", 0), 1);
344
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_match("^PTHREAD$", 0), 0);
345
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_match("(?i)pthread", 0), 1);
346
testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", 0, create_pcre_regexp_match("pthread", LMF_ICASE), 1);
348
fprintf(stderr, "One \"invalid regular expression\" message is to be expected\n");
349
TEST_ASSERT(create_pcre_regexp_match("((", 0) == NULL);
351
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: alma fa", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "(?P<a>a)(?P<l>l)(?P<MM>m)(?P<aa>a) (?P<fa>fa)", LMF_STORE_MATCHES), 1, "MM","m");
352
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: alma fa", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "(?P<a>a)(?P<l>l)(?P<MM>m)(?P<aa>a) (?P<fa>fa)", LMF_STORE_MATCHES), 1, "aaaa", NULL);
353
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: alma fa", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "(?P<a>a)(?P<l>l)(?P<MM>m)(?P<aa>a) (?P<fa_name>fa)", LMF_STORE_MATCHES), 1, "fa_name","fa");
355
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: al fa", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "(a)(l) (fa)", LMF_STORE_MATCHES), 1, "2","l");
356
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: al fa", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "(a)(l) (fa)", LMF_STORE_MATCHES), 1, "0","al fa");
357
testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: al fa", 0, create_pcre_regexp_filter(LM_F_MESSAGE, "(a)(l) (fa)", LMF_STORE_MATCHES), 1, "233",NULL);