|
@@ -238,12 +238,72 @@ START_TEST (test_search_subst_re_nomatch)
|
238
|
238
|
}
|
239
|
239
|
END_TEST
|
240
|
240
|
|
|
241
|
+/*
|
|
242
|
+ * ttail_logline2date() checks
|
|
243
|
+ */
|
|
244
|
+START_TEST (test_search_log2date1)
|
|
245
|
+{
|
|
246
|
+ char re[] = "^[0-9]+ ";
|
|
247
|
+ char fmt[] = "%Y-%m-%d:%H:%M";
|
|
248
|
+ struct tm tm;
|
|
249
|
+ int ret;
|
|
250
|
+ ttail_set_flag_re_ex(ttail);
|
|
251
|
+ ttail_set_prefix(ttail, re);
|
|
252
|
+ ttail_set_fmt(ttail, fmt);
|
|
253
|
+ ret = ttail_logline2date(ttail, "1337 1988-10-22:22:10 foobar", &tm);
|
|
254
|
+ ck_assert_int_eq(ret, 0);
|
|
255
|
+ ck_assert_int_eq(tm.tm_year, 88);
|
|
256
|
+ ck_assert_int_eq(tm.tm_mon, 9);
|
|
257
|
+ ck_assert_int_eq(tm.tm_mday, 22);
|
|
258
|
+ ck_assert_int_eq(tm.tm_hour, 22);
|
|
259
|
+ ck_assert_int_eq(tm.tm_min, 10);
|
|
260
|
+}
|
|
261
|
+END_TEST
|
|
262
|
+
|
|
263
|
+START_TEST (test_search_log2date_failpref)
|
|
264
|
+{
|
|
265
|
+ char re[] = "^[0-9]+aa ";
|
|
266
|
+ char fmt[] = "%Y-%m-%d:%H:%M";
|
|
267
|
+ struct tm tm;
|
|
268
|
+ int ret;
|
|
269
|
+ ttail_set_flag_re_ex(ttail);
|
|
270
|
+ ttail_set_prefix(ttail, re);
|
|
271
|
+ ttail_set_fmt(ttail, fmt);
|
|
272
|
+ ret = ttail_logline2date(ttail, "1337 1988-10-22:22:10 foobar", &tm);
|
|
273
|
+ ck_assert_int_eq(ret, 1);
|
|
274
|
+ ck_assert_int_eq(tm.tm_year, 0);
|
|
275
|
+ ck_assert_int_eq(tm.tm_mon, 0);
|
|
276
|
+ ck_assert_int_eq(tm.tm_mday, 0);
|
|
277
|
+ ck_assert_int_eq(tm.tm_hour, 0);
|
|
278
|
+ ck_assert_int_eq(tm.tm_min, 0);
|
|
279
|
+}
|
|
280
|
+END_TEST
|
|
281
|
+
|
|
282
|
+START_TEST (test_search_log2date_faildate)
|
|
283
|
+{
|
|
284
|
+ char re[] = "^[0-9]+ ";
|
|
285
|
+ char fmt[] = "%y-%m-%d:%H:%M";
|
|
286
|
+ struct tm tm;
|
|
287
|
+ int ret;
|
|
288
|
+ ttail_set_flag_re_ex(ttail);
|
|
289
|
+ ttail_set_prefix(ttail, re);
|
|
290
|
+ ttail_set_fmt(ttail, fmt);
|
|
291
|
+ ret = ttail_logline2date(ttail, "1337 1988-10-22:22:10 foobar", &tm);
|
|
292
|
+ ck_assert_int_eq(ret, 2);
|
|
293
|
+ ck_assert_int_eq(tm.tm_year, 0);
|
|
294
|
+ ck_assert_int_eq(tm.tm_mon, 0);
|
|
295
|
+ ck_assert_int_eq(tm.tm_mday, 0);
|
|
296
|
+ ck_assert_int_eq(tm.tm_hour, 0);
|
|
297
|
+ ck_assert_int_eq(tm.tm_min, 0);
|
|
298
|
+}
|
|
299
|
+END_TEST
|
|
300
|
+
|
241
|
301
|
Suite * ttail_search_files_suite(void)
|
242
|
302
|
{
|
243
|
303
|
Suite *s;
|
244
|
|
- TCase *tc_search_subst;
|
245
|
304
|
TCase *tc_search_closest_fileinit, *tc_file_line,
|
246
|
305
|
*tc_file_minmax;
|
|
306
|
+ TCase *tc_search_subst, *tc_search_logline2date;
|
247
|
307
|
|
248
|
308
|
s = suite_create("ttail search_files checks");
|
249
|
309
|
tc_search_closest_fileinit = tcase_create("\
|
|
@@ -276,10 +336,18 @@ ttail_logline_closest_files_init() checks");
|
276
|
336
|
tcase_add_test(tc_search_subst, test_search_subst_re2);
|
277
|
337
|
tcase_add_test(tc_search_subst, test_search_subst_re_nomatch);
|
278
|
338
|
|
279
|
|
- suite_add_tcase(s, tc_search_subst);
|
|
339
|
+ tc_search_logline2date = tcase_create("ttail_logline2date() checks");
|
|
340
|
+ tcase_add_checked_fixture(tc_search_logline2date,
|
|
341
|
+ setup_closest_fileinit, teardown_closest_fileinit);
|
|
342
|
+ tcase_add_test(tc_search_subst, test_search_log2date1);
|
|
343
|
+ tcase_add_test(tc_search_subst, test_search_log2date_failpref);
|
|
344
|
+ tcase_add_test(tc_search_subst, test_search_log2date_faildate);
|
|
345
|
+
|
280
|
346
|
suite_add_tcase(s, tc_search_closest_fileinit);
|
281
|
347
|
suite_add_tcase(s, tc_file_line);
|
282
|
348
|
suite_add_tcase(s, tc_file_minmax);
|
|
349
|
+ suite_add_tcase(s, tc_search_subst);
|
|
350
|
+ suite_add_tcase(s, tc_search_logline2date);
|
283
|
351
|
return s;
|
284
|
352
|
}
|
285
|
353
|
|