~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to tests/unit/test_filters.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS), Gergely Nagy
  • Date: 2011-10-11 14:30:48 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20111011143048-r1iljux9xbvj3lwh
Tags: 3.3.1.dfsg-1
* New upstream release with important fixes from upstream git tree with
  non-free manpages removed.
* Drop syslog-ng.conf(5) (closes: #496521).
* syslog-ng(8) is generated, and does not mention -Q anymore
  (closes: #616069).
* Supports CAP_SYSLOG on recent kernels (closes: #630172).
* Does not use g_timeout_add_seconds anymore (closes: #609154).

[ Gergely Nagy <algernon@madhouse-project.org> ]
* Update debian/copyright to DEP-5 format.
* Simplified the logrotate file by merging identical entries.
* Include local configuration files from /etc/syslog-ng/conf.d/ (Closes:
  #609050).
* Update syslog-ng.conf to be fully 3.3 compliant.
* Compress both source and binaries (except the syslog-ng meta
  package) with xz, instead of gzip.
* Use dpkg triggers to restart syslog-ng when appropriate.
* Include DFSG-free manual pages for all binaries.
* Build with Hardening enabled.
* Mention syslog(3) in /etc/default/syslog-ng, instead of
  <linux/kernel.h> (Closes: #608605)
* Support 'status' in the init script.
  Patch from Peter Eisentraut <petere@debian.org> (Closes: #644458)
* Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs.
* Use [linux-any] in Build-Depends instead of hardcoded links.
  (Closes: #634715)
* Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng.
  (Closes: #589081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
    return NULL;
64
64
}
65
65
 
 
66
LogTemplate *
 
67
create_template(const gchar *template)
 
68
{
 
69
  LogTemplate *t;
 
70
 
 
71
  t = log_template_new(configuration, NULL);
 
72
  log_template_compile(t, template, NULL);
 
73
  return t;
 
74
}
 
75
 
66
76
#if ENABLE_PCRE
67
77
FilterExprNode *
68
78
create_pcre_regexp_filter(gint field, gchar* regexp, gint flags)
120
130
    }
121
131
 
122
132
  log_msg_unref(logmsg);
123
 
  filter_expr_free(f);
 
133
  filter_expr_unref(f);
124
134
}
125
135
 
126
136
void
133
143
{
134
144
  LogMessage *logmsg;
135
145
  const gchar *value_msg;
 
146
  NVTable *nv_table;
136
147
  gboolean res;
137
148
  static gint testno = 0;
138
149
  gssize length;
151
162
  /* add a non-zero terminated indirect value which contains the whole message */
152
163
  log_msg_set_value_indirect(logmsg, nonasciiz, log_msg_get_value_handle("MESSAGE2"), 0, 0, msglen);
153
164
 
154
 
 
 
165
  nv_table = nv_table_ref(logmsg->payload);
155
166
  res = filter_expr_eval(f, logmsg);
156
167
  if (res != expected_result)
157
168
    {
158
169
      fprintf(stderr, "Filter test failed; num='%d', msg='%s'\n", testno, msg);
159
170
      exit(1);
160
171
    }
161
 
 
 
172
  nv_table_unref(nv_table);
162
173
  f->comp = 1;
 
174
 
 
175
  nv_table = nv_table_ref(logmsg->payload);
163
176
  res = filter_expr_eval(f, logmsg);
164
177
  if (res != !expected_result)
165
178
    {
167
180
      exit(1);
168
181
    }
169
182
  value_msg = log_msg_get_value(logmsg, log_msg_get_value_handle(name), &length);
170
 
 
 
183
  nv_table_unref(nv_table);
171
184
  if(value == NULL || value[0] == 0)
172
185
     {
173
186
       if (value_msg != NULL && value_msg[0] != 0)
185
198
        }
186
199
    }
187
200
  log_msg_unref(logmsg);
188
 
  filter_expr_free(f);
 
201
  filter_expr_unref(f);
189
202
}
190
203
 
191
204
 
311
324
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_and_new(create_posix_regexp_match(" PAD ", 0), create_posix_regexp_match("^PTHREAD$", 0)), 0);
312
325
 
313
326
 
314
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "korte"), KW_LT), 1);
315
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "korte"), KW_LE), 1);
316
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "korte"), KW_EQ), 0);
317
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "korte"), KW_NE), 1);
318
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "korte"), KW_GE), 0);
319
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "korte"), KW_GT), 0);
320
 
 
321
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "korte"), log_template_new(configuration, NULL, "alma"), KW_LT), 0);
322
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "korte"), log_template_new(configuration, NULL, "alma"), KW_LE), 0);
323
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "korte"), log_template_new(configuration, NULL, "alma"), KW_EQ), 0);
324
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "korte"), log_template_new(configuration, NULL, "alma"), KW_NE), 1);
325
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "korte"), log_template_new(configuration, NULL, "alma"), KW_GE), 1);
326
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "korte"), log_template_new(configuration, NULL, "alma"), KW_GT), 1);
327
 
 
328
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "alma"), KW_LT), 0);
329
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "alma"), KW_LE), 1);
330
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "alma"), KW_EQ), 1);
331
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "alma"), KW_NE), 0);
332
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "alma"), KW_GE), 1);
333
 
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(log_template_new(configuration, NULL, "alma"), log_template_new(configuration, NULL, "alma"), KW_GT), 0);
 
327
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("korte"), KW_LT), 1);
 
328
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("korte"), KW_LE), 1);
 
329
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("korte"), KW_EQ), 0);
 
330
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("korte"), KW_NE), 1);
 
331
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("korte"), KW_GE), 0);
 
332
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("korte"), KW_GT), 0);
 
333
 
 
334
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("korte"), create_template("alma"), KW_LT), 0);
 
335
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("korte"), create_template("alma"), KW_LE), 0);
 
336
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("korte"), create_template("alma"), KW_EQ), 0);
 
337
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("korte"), create_template("alma"), KW_NE), 1);
 
338
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("korte"), create_template("alma"), KW_GE), 1);
 
339
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("korte"), create_template("alma"), KW_GT), 1);
 
340
 
 
341
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("alma"), KW_LT), 0);
 
342
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("alma"), KW_LE), 1);
 
343
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("alma"), KW_EQ), 1);
 
344
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("alma"), KW_NE), 0);
 
345
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("alma"), KW_GE), 1);
 
346
  testcase("<15>Oct 15 16:17:01 host openvpn[2499]: PTHREAD support initialized", fop_cmp_new(create_template("alma"), create_template("alma"), KW_GT), 0);
334
347
 
335
348
 
336
349
  testcase_with_backref_chk("<15>Oct 15 16:17:01 host openvpn[2499]: al fa", create_posix_regexp_filter(LM_V_MESSAGE, "(a)(l) (fa)", LMF_STORE_MATCHES), 1, "1","a");