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

« back to all changes in this revision

Viewing changes to modules/dbparser/tests/test_patterndb.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:
29
29
} while (0);
30
30
 
31
31
#define MYHOST "MYHOST"
 
32
#define MYPID "999"
32
33
 
33
34
PatternDB *patterndb;
34
35
gchar *filename;
99
100
    <value name='n11-1'>v11-1</value>\
100
101
    <value name='n11-2'>v11-2</value>\
101
102
    <value name='vvv'>${HOST}</value>\
 
103
    <value name='context-id'>${CONTEXT_ID}</value>\
102
104
   </values>\
103
105
   <actions>\
104
106
     <action rate='1/60' condition='\"${n11-1}\" == \"v11-1\"' trigger='match'>\
105
107
       <message>\
106
108
         <value name='MESSAGE'>rule11 matched</value>\
 
109
         <value name='context-id'>${CONTEXT_ID}</value>\
107
110
         <tags>\
108
111
           <tag>tag11-3</tag>\
109
112
         </tags>\
112
115
     <action rate='1/60' condition='\"${n11-1}\" == \"v11-1\"' trigger='timeout'>\
113
116
       <message>\
114
117
         <value name='MESSAGE'>rule11 timed out</value>\
 
118
         <value name='context-id'>${CONTEXT_ID}</value>\
115
119
         <tags>\
116
120
           <tag>tag11-4</tag>\
117
121
         </tags>\
148
152
  log_msg_set_value(msg, LM_V_MESSAGE, pattern, strlen(pattern));
149
153
  log_msg_set_value(msg, LM_V_PROGRAM, "prog1", 5);
150
154
  log_msg_set_value(msg, LM_V_HOST, MYHOST, strlen(MYHOST));
 
155
  log_msg_set_value(msg, LM_V_PID, MYPID, strlen(MYPID));
151
156
 
152
157
  result = pattern_db_process(patterndb, msg);
153
158
  val = log_msg_get_value(msg, log_msg_get_value_handle(name), &len);
169
174
 
170
175
  log_msg_set_value(msg, LM_V_MESSAGE, pattern, strlen(pattern));
171
176
  log_msg_set_value(msg, LM_V_PROGRAM, "prog2", 5);
 
177
  log_msg_set_value(msg, LM_V_HOST, MYHOST, strlen(MYHOST));
 
178
  log_msg_set_value(msg, LM_V_PID, MYPID, strlen(MYPID));
172
179
 
173
180
  result = pattern_db_process(patterndb, msg);
174
181
  found = log_msg_is_tag_by_name(msg, tag);
190
197
 
191
198
  log_msg_set_value(msg, LM_V_MESSAGE, pattern, strlen(pattern));
192
199
  log_msg_set_value(msg, LM_V_PROGRAM, "prog2", 5);
193
 
  msg->timestamps[LM_TS_STAMP].time.tv_sec = msg->timestamps[LM_TS_RECVD].time.tv_sec;
 
200
  log_msg_set_value(msg, LM_V_HOST, MYHOST, strlen(MYHOST));
 
201
  log_msg_set_value(msg, LM_V_PID, MYPID, strlen(MYPID));
 
202
  msg->timestamps[LM_TS_STAMP].tv_sec = msg->timestamps[LM_TS_RECVD].tv_sec;
194
203
 
195
204
  result = pattern_db_process(patterndb, msg);
196
205
  if (timeout)
222
231
 
223
232
  log_msg_set_value(msg, LM_V_MESSAGE, pattern, strlen(pattern));
224
233
  log_msg_set_value(msg, LM_V_PROGRAM, "prog2", 5);
225
 
  msg->timestamps[LM_TS_STAMP].time.tv_sec = msg->timestamps[LM_TS_RECVD].time.tv_sec;
 
234
  log_msg_set_value(msg, LM_V_HOST, MYHOST, strlen(MYHOST));
 
235
  log_msg_set_value(msg, LM_V_PID, MYPID, strlen(MYPID));
 
236
  msg->timestamps[LM_TS_STAMP].tv_sec = msg->timestamps[LM_TS_RECVD].tv_sec;
226
237
 
227
238
  result = pattern_db_process(patterndb, msg);
228
239
  if (timeout)
271
282
  test_rule_value("pattern11", ".classifier.class", "system");
272
283
  test_rule_value("pattern11", "n11-2", "v11-2");
273
284
  test_rule_value("pattern11", "n11-3", NULL);
 
285
  test_rule_value("pattern11", "context-id", "999");
274
286
  test_rule_value("pattern11a", "n11-1", "v11-1");
275
287
  test_rule_value("pattern11a", "n11-2", "v11-2");
276
288
  test_rule_value("pattern11a", "n11-3", NULL);
284
296
  test_rule_value("pattern11", "vvv", MYHOST);
285
297
 
286
298
  test_rule_action_message_value("pattern11", 0, 1, "MESSAGE", "rule11 matched");
 
299
  test_rule_action_message_value("pattern11", 0, 1, "context-id", "999");
287
300
  test_rule_action_message_tag("pattern11", 0, 1, "tag11-3", TRUE);
288
301
  test_rule_action_message_tag("pattern11", 0, 1, "tag11-4", FALSE);
289
302
 
290
303
  test_rule_action_message_value("pattern11", 60, 2, "MESSAGE", "rule11 timed out");
 
304
  test_rule_action_message_value("pattern11", 60, 2, "context-id", "999");
291
305
  test_rule_action_message_tag("pattern11", 60, 2, "tag11-3", FALSE);
292
306
  test_rule_action_message_tag("pattern11", 60, 2, "tag11-4", TRUE);
293
307
 
322
336
  if (!tzinfo)
323
337
    tzinfo = time_zone_info_new(NULL);
324
338
  if (!templ)
325
 
    templ = log_template_new(configuration, "dummy", "$TEST");
 
339
    {
 
340
      templ = log_template_new(configuration, "dummy");
 
341
      log_template_compile(templ, "$TEST", NULL);
 
342
    }
326
343
 
327
344
  log_msg_set_value(msg, LM_V_HOST, MYHOST, strlen(MYHOST));
328
345
  log_msg_set_value(msg, LM_V_PROGRAM, "test", strlen(MYHOST));
330
347
 
331
348
  result = pattern_db_process(patterndb, msg);
332
349
 
333
 
  log_template_format(templ, msg, NULL, LTZ_LOCAL, 0, res);
 
350
  log_template_format(templ, msg, NULL, LTZ_LOCAL, 0, NULL, res);
334
351
 
335
352
  if (strcmp(res->str, pattern) == 0)
336
353
    {