|
@@ -8,9 +8,9 @@
|
8
|
8
|
|
9
|
9
|
ttail_t *ttail;
|
10
|
10
|
|
11
|
|
-char *samples[5] = { "./samples/1.log", "./samples/2.log", "./samples/3.log",\
|
12
|
|
- "./samples/4.log", "./samples/5.log"};
|
13
|
|
-off_t samples_sz[5] = { 442, 0, 893, 2587, 2310 };
|
|
11
|
+char *samples[6] = { "./samples/1.log", "./samples/2.log", "./samples/3.log",\
|
|
12
|
+ "./samples/4.log", "./samples/5.log", "./samples/1.1.log"};
|
|
13
|
+off_t samples_sz[6] = { 442, 0, 893, 2587, 2310, 220 };
|
14
|
14
|
FILE *fpl;
|
15
|
15
|
|
16
|
16
|
void setup_file_line(void)
|
|
@@ -43,7 +43,7 @@ void setup_closest_fileinit(void)
|
43
|
43
|
{
|
44
|
44
|
size_t i;
|
45
|
45
|
setup_closest();
|
46
|
|
- for(i=0; i<5; i++)
|
|
46
|
+ for(i=0; i<6; i++)
|
47
|
47
|
{
|
48
|
48
|
ttail_add_logfile(ttail, samples[i]);
|
49
|
49
|
}
|
|
@@ -72,7 +72,7 @@ START_TEST (test_search_closest_init_filesz)
|
72
|
72
|
{
|
73
|
73
|
size_t i;
|
74
|
74
|
_ttail_search_closest_files_init(ttail);
|
75
|
|
- for(i=0;i<5;i++)
|
|
75
|
+ for(i=0;i<6;i++)
|
76
|
76
|
{
|
77
|
77
|
ck_assert(samples_sz[i] == ttail->session->file.file_sz[i]);
|
78
|
78
|
}
|
|
@@ -88,7 +88,7 @@ START_TEST (test_search_closest_init_vfile)
|
88
|
88
|
_ttail_search_closest_files_init(ttail);
|
89
|
89
|
|
90
|
90
|
full_sz = 0;
|
91
|
|
- for(i=0;i<5;i++)
|
|
91
|
+ for(i=0;i<6;i++)
|
92
|
92
|
{
|
93
|
93
|
ck_assert(full_sz == ttail->session->file.vfile[i]);
|
94
|
94
|
full_sz += samples_sz[i];
|
|
@@ -356,6 +356,35 @@ START_TEST (test_search_files2)
|
356
|
356
|
}
|
357
|
357
|
END_TEST
|
358
|
358
|
|
|
359
|
+START_TEST (test_search_files3)
|
|
360
|
+{
|
|
361
|
+ int ret;
|
|
362
|
+ size_t i;
|
|
363
|
+ struct tm tm;
|
|
364
|
+ memset(&tm, 0, sizeof(tm));
|
|
365
|
+ for(i=1;i<ttail->logfile_sz-1;i++)
|
|
366
|
+ {
|
|
367
|
+ fclose(ttail->logfile[i]);
|
|
368
|
+ ttail->logfile[i] = NULL;
|
|
369
|
+ }
|
|
370
|
+ ttail->flag |= TTAIL_FLAG_PREFIX;
|
|
371
|
+ ttail->prefix_sz = 0;
|
|
372
|
+ ttail_set_fmt(ttail, "%B%n%d %H:%M");
|
|
373
|
+
|
|
374
|
+ tm.tm_year = -1;
|
|
375
|
+ tm.tm_mon = 2;
|
|
376
|
+ tm.tm_mday = 6;
|
|
377
|
+ tm.tm_hour = 1;
|
|
378
|
+ tm.tm_min = 0;
|
|
379
|
+ tm.tm_sec = -1;
|
|
380
|
+
|
|
381
|
+ ret = _ttail_search_closest_files(ttail, &tm);
|
|
382
|
+ ck_assert_int_eq(ret, 0);
|
|
383
|
+ ck_assert_int_eq(ttail->session->file.id, 5);
|
|
384
|
+ ck_assert_int_eq(ttail->session->file.off, 0);
|
|
385
|
+}
|
|
386
|
+END_TEST
|
|
387
|
+
|
359
|
388
|
Suite * ttail_search_files_suite(void)
|
360
|
389
|
{
|
361
|
390
|
Suite *s;
|
|
@@ -407,6 +436,7 @@ ttail_logline_closest_files_init() checks");
|
407
|
436
|
setup_closest_fileinit, teardown_closest_fileinit);
|
408
|
437
|
tcase_add_test(tc_search_files, test_search_files1);
|
409
|
438
|
tcase_add_test(tc_search_files, test_search_files2);
|
|
439
|
+ tcase_add_test(tc_search_files, test_search_files3);
|
410
|
440
|
|
411
|
441
|
|
412
|
442
|
suite_add_tcase(s, tc_search_closest_fileinit);
|