Ver código fonte

Bugfixes in logfile minmax + tests update

Yann Weber 7 anos atrás
pai
commit
876cc00dec
3 arquivos alterados com 15 adições e 10 exclusões
  1. 0
    1
      src/ttail_search.c
  2. 3
    3
      src/ttail_search_files.c
  3. 12
    6
      tests/ttail_search_check.c

+ 0
- 1
src/ttail_search.c Ver arquivo

37
 	{
37
 	{
38
 		return 1;
38
 		return 1;
39
 	}
39
 	}
40
-	fprintf(stderr, "FORMAT : %s\n", ttail->fmt);
41
 	ret = strptime(subst, ttail->fmt, tm);
40
 	ret = strptime(subst, ttail->fmt, tm);
42
 	return ret?0:1;
41
 	return ret?0:1;
43
 }
42
 }

+ 3
- 3
src/ttail_search_files.c Ver arquivo

136
 	{
136
 	{
137
 		return 1;
137
 		return 1;
138
 	}
138
 	}
139
-	if(!fseek(fp, 0, SEEK_SET))
139
+	if(fseek(fp, 0, SEEK_SET) < 0)
140
 	{
140
 	{
141
 		perror("Unable to manipulate fp");
141
 		perror("Unable to manipulate fp");
142
 		return -1;
142
 		return -1;
152
 			break;
152
 			break;
153
 		}
153
 		}
154
 	}
154
 	}
155
-	if(!fseek(fp, -1, SEEK_END))
155
+	if(fseek(fp, -1, SEEK_END) < 0)
156
 	{
156
 	{
157
 		perror("Unable to manipulate fp");
157
 		perror("Unable to manipulate fp");
158
 		return -1;
158
 		return -1;
175
 		{
175
 		{
176
 			return 1;
176
 			return 1;
177
 		}
177
 		}
178
-		if(!fseek(fp, cur-1, SEEK_SET))
178
+		if(fseek(fp, cur-1, SEEK_SET) < 0)
179
 		{
179
 		{
180
 			perror("Unable to manipulate fp");
180
 			perror("Unable to manipulate fp");
181
 			return -1;
181
 			return -1;

+ 12
- 6
tests/ttail_search_check.c Ver arquivo

152
 START_TEST (test_file_minmax1)
152
 START_TEST (test_file_minmax1)
153
 {
153
 {
154
 	int r;
154
 	int r;
155
-	/*
156
 	struct tm tm[2];
155
 	struct tm tm[2];
157
-	*/
158
 	printf("%ld\n", ttail->logfile_sz);
156
 	printf("%ld\n", ttail->logfile_sz);
159
-	ttail->flag |= TTAIL_FLAG_FORMAT;
160
-	ttail_set_fmt(ttail, "%B%n%d %H:%M");
157
+	ttail->flag |= TTAIL_FLAG_PREFIX;
158
+	ttail->prefix_sz = 0;
159
+	ttail_set_fmt(ttail, "%b%n%d %H:%M");
161
 	r = _ttail_search_closest_files_init(ttail);
160
 	r = _ttail_search_closest_files_init(ttail);
162
 	ck_assert_int_eq(r, 0);
161
 	ck_assert_int_eq(r, 0);
163
-	/*
164
 	r = _ttail_file_minmax(ttail, 0, tm);
162
 	r = _ttail_file_minmax(ttail, 0, tm);
165
-	*/
163
+	ck_assert_int_eq(r, 0);
164
+	ck_assert_int_eq(tm[0].tm_mon, 2);
165
+	ck_assert_int_eq(tm[0].tm_mday, 6);
166
+	ck_assert_int_eq(tm[0].tm_hour, 0);
167
+	ck_assert_int_eq(tm[0].tm_min, 1);
168
+	ck_assert_int_eq(tm[1].tm_mon, 2);
169
+	ck_assert_int_eq(tm[1].tm_mday, 6);
170
+	ck_assert_int_eq(tm[1].tm_hour, 0);
171
+	ck_assert_int_eq(tm[1].tm_min, 29);
166
 }
172
 }
167
 END_TEST
173
 END_TEST
168
 
174
 

Carregando…
Cancelar
Salvar