|
@@ -2,43 +2,89 @@
|
2
|
2
|
#include <libgen.h>
|
3
|
3
|
|
4
|
4
|
#include "ttail.h"
|
|
5
|
+#include "ttail_init.h"
|
5
|
6
|
#include "ttail_search.h"
|
6
|
7
|
|
7
|
8
|
ttail_t *ttail;
|
8
|
9
|
|
9
|
10
|
char *samples[5] = { "./samples/1.log", "./samples/2.log", "./samples/3.log",\
|
10
|
11
|
"./samples/4.log", "./samples/5.log"};
|
11
|
|
-off_t samples_sz[5] = { 442, 141, 893, 2587, 2310 };
|
|
12
|
+off_t samples_sz[5] = { 442, 0, 893, 2587, 2310 };
|
12
|
13
|
|
|
14
|
+void teardown_closest(void)
|
|
15
|
+{
|
|
16
|
+
|
|
17
|
+ ttail_free(ttail);
|
|
18
|
+}
|
13
|
19
|
|
14
|
|
-void setup_closest(void)
|
|
20
|
+void setup_closest_fileinit(void)
|
15
|
21
|
{
|
|
22
|
+ ttail = ttail_init(1, (char**)&"foo");
|
|
23
|
+ size_t i;
|
|
24
|
+ for(i=0; i<5; i++)
|
|
25
|
+ {
|
|
26
|
+ ttail_add_logfile(ttail, samples[i]);
|
|
27
|
+ }
|
|
28
|
+}
|
16
|
29
|
|
|
30
|
+START_TEST (test_search_closest_init)
|
|
31
|
+{
|
|
32
|
+ int ret;
|
|
33
|
+
|
|
34
|
+ ret = ttail_search_closest(ttail);
|
|
35
|
+ ck_assert_int_eq(ret,0);
|
|
36
|
+ #ifdef HUGEFILE
|
|
37
|
+ ck_assert_int_eq(ttail->session->file.sz_div,0);
|
|
38
|
+ #endif
|
17
|
39
|
}
|
|
40
|
+END_TEST
|
18
|
41
|
|
19
|
|
-void teardown_closest(void)
|
|
42
|
+START_TEST (test_search_closest_init_filesz)
|
20
|
43
|
{
|
|
44
|
+ size_t i;
|
|
45
|
+ ttail_search_closest(ttail);
|
|
46
|
+ for(i=0;i<5;i++)
|
|
47
|
+ {
|
|
48
|
+ ck_assert(samples_sz[i] == ttail->session->file.file_sz[i]);
|
|
49
|
+ }
|
21
|
50
|
|
22
|
51
|
}
|
|
52
|
+END_TEST
|
23
|
53
|
|
24
|
|
-START_TEST (test_search_closest)
|
|
54
|
+START_TEST (test_search_closest_init_vfile)
|
25
|
55
|
{
|
26
|
|
- ttail_logline_subst(ttail, "Hello world !");
|
|
56
|
+ size_t i;
|
|
57
|
+ off_t full_sz;
|
|
58
|
+
|
|
59
|
+ ttail_search_closest(ttail);
|
|
60
|
+
|
|
61
|
+ full_sz = 0;
|
|
62
|
+ for(i=0;i<5;i++)
|
|
63
|
+ {
|
|
64
|
+ ck_assert(full_sz == ttail->session->file.vfile[i]);
|
|
65
|
+ full_sz += samples_sz[i];
|
|
66
|
+ }
|
|
67
|
+ ck_assert(full_sz == ttail->session->file.vsz);
|
27
|
68
|
}
|
28
|
69
|
END_TEST
|
29
|
70
|
|
30
|
71
|
Suite * ttail_search_suite(void)
|
31
|
72
|
{
|
32
|
73
|
Suite *s;
|
33
|
|
- TCase *tc_search_closest;
|
|
74
|
+ TCase *tc_search_closest_fileinit;
|
34
|
75
|
|
35
|
76
|
s = suite_create("ttail search checks");
|
36
|
|
- tc_search_closest = tcase_create("ttail_logline_closest checks");
|
37
|
|
- tcase_add_checked_fixture(tc_search_closest,
|
38
|
|
- setup_closest, teardown_closest);
|
39
|
|
- tcase_add_test(tc_search_closest, test_search_closest);
|
40
|
|
-
|
41
|
|
- suite_add_tcase(s, tc_search_closest);
|
|
77
|
+ tc_search_closest_fileinit = tcase_create("\
|
|
78
|
+ttail_logline_closest_files_init() checks");
|
|
79
|
+ tcase_add_checked_fixture(tc_search_closest_fileinit,
|
|
80
|
+ setup_closest_fileinit, teardown_closest);
|
|
81
|
+ tcase_add_test(tc_search_closest_fileinit, test_search_closest_init);
|
|
82
|
+ tcase_add_test(tc_search_closest_fileinit,
|
|
83
|
+ test_search_closest_init_filesz);
|
|
84
|
+ tcase_add_test(tc_search_closest_fileinit,
|
|
85
|
+ test_search_closest_init_vfile);
|
|
86
|
+
|
|
87
|
+ suite_add_tcase(s, tc_search_closest_fileinit);
|
42
|
88
|
return s;
|
43
|
89
|
}
|
44
|
90
|
|