Browse Source

Updated tests

Yann Weber 7 years ago
parent
commit
0080357465
6 changed files with 121 additions and 12 deletions
  1. 8
    0
      tests/samples/1.log
  2. 0
    0
      tests/samples/2.log
  3. 11
    0
      tests/samples/3.log
  4. 15
    0
      tests/samples/4.log
  5. 29
    0
      tests/samples/5.log
  6. 58
    12
      tests/ttail_search_check.c

+ 8
- 0
tests/samples/1.log View File

@@ -0,0 +1,8 @@
1
+Mar  6 00:01:39 pilgrim dhclient: DHCPREQUEST on eth0 to 192.168.0.1 port 67
2
+Mar  6 00:01:40 pilgrim dhclient: DHCPACK from 192.168.0.1
3
+Mar  6 00:01:40 pilgrim dhclient: bound to 192.168.0.42 -- renewal in 1693 seconds.
4
+
5
+Mar  6 00:29:53 pilgrim dhclient: DHCPREQUEST on eth0 to 192.168.0.1 port 67
6
+Mar  6 00:29:54 pilgrim dhclient: DHCPACK from 192.168.0.1
7
+Mar  6 00:29:54 pilgrim dhclient: bound to 192.168.0.42 -- renewal in 1505 seconds.
8
+

+ 0
- 0
tests/samples/2.log View File


+ 11
- 0
tests/samples/3.log View File

@@ -0,0 +1,11 @@
1
+2017-03-01 20:01:53,926 fail2ban.server [1266]: INFO    Stopping all jails
2
+2017-03-01 20:01:54,082 fail2ban.jail   [1266]: INFO    Jail 'ssh' stopped
3
+2017-03-01 20:01:54,087 fail2ban.server [1266]: INFO    Exiting Fail2ban
4
+2017-03-01 20:02:55,937 fail2ban.server [1431]: INFO    Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.13
5
+2017-03-01 20:02:55,938 fail2ban.jail   [1431]: INFO    Creating new jail 'ssh'
6
+2017-03-01 20:02:55,997 fail2ban.jail   [1431]: INFO    Jail 'ssh' uses pyinotify
7
+2017-03-01 20:02:56,032 fail2ban.jail   [1431]: INFO    Initiated 'pyinotify' backend
8
+2017-03-01 20:02:56,036 fail2ban.filter [1431]: INFO    Set maxRetry = 6
9
+2017-03-01 20:02:56,038 fail2ban.filter [1431]: INFO    Set findtime = 600
10
+2017-03-01 20:02:56,039 fail2ban.actions[1431]: INFO    Set banTime = 600
11
+2017-03-01 20:02:56,089 fail2ban.jail   [1431]: INFO    Jail 'ssh' started

+ 15
- 0
tests/samples/4.log View File

@@ -0,0 +1,15 @@
1
+Mar  5 19:24:12 foobar kernel: [343648.872840] ttail_init_chec[16192]: segfault at 0 ip 00007fa0d8869c3a sp 00007ffed359ca08 error 4 in libc-2.19.so[7fa0d87e8000+1a1000]
2
+Mar  5 20:29:09 foobar kernel: [347550.597495] ttail_init_chec[7461]: segfault at ffffffffffffff90 ip 00007f84401186de sp 00007ffc9d722f68 error 7 in libc-2.19.so[7f8440097000+1a1000]
3
+Mar  5 20:29:24 foobar kernel: [347565.053550] ttail_init_chec[8046]: segfault at ffffffffffffff90 ip 00007fe9112b46de sp 00007ffea3fedeb8 error 7 in libc-2.19.so[7fe911233000+1a1000]
4
+Mar  5 20:29:35 foobar kernel: [347576.031156] ttail_init_chec[8533]: segfault at ffffffffffffff90 ip 00007f545b5296de sp 00007ffeaa280ae8 error 7 in libc-2.19.so[7f545b4a8000+1a1000]
5
+Mar  5 20:29:46 foobar kernel: [347587.318358] ttail_init_chec[9013]: segfault at ffffffffffffff90 ip 00007f8fb4fcf6de sp 00007ffec5e78888 error 7 in libc-2.19.so[7f8fb4f4e000+1a1000]
6
+Mar  5 20:44:50 foobar kernel: [348492.502146] ttail_argparse_[3582]: segfault at 0 ip 00000000004019cd sp 00007fff7bc8dfb0 error 4 in ttail_argparse_check[400000+b000]
7
+Mar  5 20:44:50 foobar kernel: [348492.503071] ttail_argparse_[3583]: segfault at 8 ip 0000000000401a28 sp 00007fff7bc8dfb0 error 4 in ttail_argparse_check[400000+b000]
8
+Mar  5 20:44:50 foobar kernel: [348492.503778] ttail_argparse_[3584]: segfault at 10 ip 0000000000401a84 sp 00007fff7bc8dfb0 error 4 in ttail_argparse_check[400000+b000]
9
+Mar  5 20:44:50 foobar kernel: [348492.504501] ttail_argparse_[3585]: segfault at d4 ip 0000000000401ae0 sp 00007fff7bc8dfb0 error 4 in ttail_argparse_check[400000+b000]
10
+Mar  5 20:44:50 foobar kernel: [348492.505228] ttail_argparse_[3586]: segfault at 58 ip 0000000000401b3d sp 00007fff7bc8dfb0 error 4 in ttail_argparse_check[400000+b000]
11
+Mar  5 20:44:50 foobar kernel: [348492.506038] ttail_argparse_[3587]: segfault at d0 ip 0000000000401b99 sp 00007fff7bc8dfb0 error 4 in ttail_argparse_check[400000+b000]
12
+Mar  5 20:44:50 foobar kernel: [348492.531953] ttail_init_chec[3610]: segfault at 0 ip 00000000004019cd sp 00007ffd1a215bf0 error 4 in ttail_init_check[400000+e000]
13
+Mar  5 20:44:50 foobar kernel: [348492.532638] ttail_init_chec[3611]: segfault at 10 ip 0000000000405511 sp 00007ffd1a215b80 error 4 in ttail_init_check[400000+e000]
14
+Mar  5 20:44:50 foobar kernel: [348492.533500] ttail_init_chec[3612]: segfault at 10 ip 0000000000405511 sp 00007ffd1a215b70 error 4 in ttail_init_check[400000+e000]
15
+Mar  5 20:44:50 foobar kernel: [348492.534337] ttail_init_chec[3613]: segfault at 10 ip 0000000000405511 sp 00007ffd1a215b50 error 4 in ttail_init_check[400000+e000]

+ 29
- 0
tests/samples/5.log View File

@@ -0,0 +1,29 @@
1
+[30167] 06 Nov 01:59:24.520 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
2
+[30167] 06 Nov 01:59:24.520 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
3
+[30167] 06 Nov 01:59:24.520 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
4
+                _._                                                  
5
+           _.-``__ ''-._                                             
6
+      _.-``    `.  `_.  ''-._           Redis 2.8.17 (00000000/0) 64 bit
7
+  .-`` .-```.  ```\/    _.,_ ''-._                                   
8
+ (    '      ,       .-`  | `,    )     Running in stand alone mode
9
+ |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
10
+ |    `-._   `._    /     _.-'    |     PID: 30167
11
+  `-._    `-._  `-./  _.-'    _.-'                                   
12
+ |`-._`-._    `-.__.-'    _.-'_.-'|                                  
13
+ |    `-._`-._        _.-'_.-'    |           http://redis.io        
14
+  `-._    `-._`-.__.-'_.-'    _.-'                                   
15
+ |`-._`-._    `-.__.-'    _.-'_.-'|                                  
16
+ |    `-._`-._        _.-'_.-'    |                                  
17
+  `-._    `-._`-.__.-'_.-'    _.-'                                   
18
+      `-._    `-.__.-'    _.-'                                       
19
+          `-._        _.-'                                           
20
+              `-.__.-'                                               
21
+
22
+[30167] 06 Nov 01:59:24.520 # Server started, Redis version 2.8.17
23
+[30167] 06 Nov 01:59:24.520 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
24
+[30167] 06 Nov 01:59:24.520 * The server is now ready to accept connections on port 6379
25
+[30167] 06 Nov 02:01:32.522 # User requested shutdown...
26
+[30167] 06 Nov 02:01:32.522 * Saving the final RDB snapshot before exiting.
27
+[30167] 06 Nov 02:01:32.528 * DB saved on disk
28
+[30167] 06 Nov 02:01:32.528 * Removing the pid file.
29
+[30167] 06 Nov 02:01:32.528 # Redis is now ready to exit, bye bye...

+ 58
- 12
tests/ttail_search_check.c View File

@@ -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
 

Loading…
Cancel
Save