|
@@ -0,0 +1,64 @@
|
|
1
|
+#include <check.h>
|
|
2
|
+#include <stdio.h>
|
|
3
|
+#include <libgen.h>
|
|
4
|
+
|
|
5
|
+#include "ttail_check.h"
|
|
6
|
+#include "ttail.h"
|
|
7
|
+#include "ttail_init.h"
|
|
8
|
+#include "ttail_search.h"
|
|
9
|
+
|
|
10
|
+START_TEST (sample0)
|
|
11
|
+{
|
|
12
|
+ int ret;
|
|
13
|
+
|
|
14
|
+ ttail->flag |= TTAIL_FLAG_DATE_MIN;
|
|
15
|
+ ttail->date_min.tm_sec = 39;
|
|
16
|
+ ttail->date_min.tm_min = 1;
|
|
17
|
+ ttail->date_min.tm_hour = 0;
|
|
18
|
+ ttail->date_min.tm_mday = 6;
|
|
19
|
+ ttail->date_min.tm_mon = 2;
|
|
20
|
+ ttail_set_fmt(ttail, "%B%n%d %H:%M:%S");
|
|
21
|
+ send_sample_stdpipe(0);
|
|
22
|
+ close_stdpipe();
|
|
23
|
+ ret = ttail_search_std_init(ttail);
|
|
24
|
+ ck_assert_int_eq(ret, 0);
|
|
25
|
+ ret = _ttail_search_closest_stdin(ttail);
|
|
26
|
+ ck_assert_int_eq(ret, 0);
|
|
27
|
+ ck_assert_str_eq(ttail_std_getline_buff(ttail),
|
|
28
|
+ "Mar 6 00:01:39 pilgrim dhclient: DHCPREQUEST on eth0 to \
|
|
29
|
+192.168.0.1 port 67\n");
|
|
30
|
+}
|
|
31
|
+END_TEST
|
|
32
|
+
|
|
33
|
+START_TEST (sample0_1)
|
|
34
|
+{
|
|
35
|
+ int ret;
|
|
36
|
+
|
|
37
|
+ send_sample_stdpipe(0);
|
|
38
|
+ close_stdpipe();
|
|
39
|
+
|
|
40
|
+ ttail->flag |= TTAIL_FLAG_DATE_MIN;
|
|
41
|
+ ttail->flag |= TTAIL_FLAG_PERMISSIVE;
|
|
42
|
+ ttail->date_min.tm_sec = 50;
|
|
43
|
+ ttail->date_min.tm_min = 1;
|
|
44
|
+ ttail->date_min.tm_hour = 0;
|
|
45
|
+ ttail->date_min.tm_mday = 6;
|
|
46
|
+ ttail->date_min.tm_mon = 2;
|
|
47
|
+ ttail_set_fmt(ttail, "%B%n%d %H:%M:%S");
|
|
48
|
+ ret = ttail_search_std_init(ttail);
|
|
49
|
+ ck_assert_int_eq(ret, 0);
|
|
50
|
+ ret = _ttail_search_closest_stdin(ttail);
|
|
51
|
+ ck_assert_int_eq(ret, 0);
|
|
52
|
+ ck_assert_str_eq(ttail_std_getline_buff(ttail),
|
|
53
|
+ "Mar 6 00:29:53 pilgrim dhclient: DHCPREQUEST on eth0 to \
|
|
54
|
+192.168.0.1 port 67\n");
|
|
55
|
+}
|
|
56
|
+END_TEST
|
|
57
|
+
|
|
58
|
+TTAIL_CHECK_START( "ttail search stdin checks",\
|
|
59
|
+ "_ttail_search_closest_stdin() checks")
|
|
60
|
+ TTAIL_SET_FIXTURE(setup_closest_stdin, teardown_closest_stdin);
|
|
61
|
+ TTAIL_ADD_TEST(sample0);
|
|
62
|
+ TTAIL_ADD_TEST(sample0_1);
|
|
63
|
+TTAIL_CHECK_END
|
|
64
|
+
|