Bugfixes in logfile minmax + tests update
This commit is contained in:
parent
e2d2d7f0db
commit
876cc00dec
3 changed files with 15 additions and 10 deletions
|
|
@ -37,7 +37,6 @@ int ttail_logline2date(ttail_t* ttail, const char* logline, struct tm* tm)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "FORMAT : %s\n", ttail->fmt);
|
|
||||||
ret = strptime(subst, ttail->fmt, tm);
|
ret = strptime(subst, ttail->fmt, tm);
|
||||||
return ret?0:1;
|
return ret?0:1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ int _ttail_file_minmax(ttail_t* t, size_t id, struct tm tm[2])
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!fseek(fp, 0, SEEK_SET))
|
if(fseek(fp, 0, SEEK_SET) < 0)
|
||||||
{
|
{
|
||||||
perror("Unable to manipulate fp");
|
perror("Unable to manipulate fp");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -152,7 +152,7 @@ int _ttail_file_minmax(ttail_t* t, size_t id, struct tm tm[2])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!fseek(fp, -1, SEEK_END))
|
if(fseek(fp, -1, SEEK_END) < 0)
|
||||||
{
|
{
|
||||||
perror("Unable to manipulate fp");
|
perror("Unable to manipulate fp");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -175,7 +175,7 @@ int _ttail_file_minmax(ttail_t* t, size_t id, struct tm tm[2])
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!fseek(fp, cur-1, SEEK_SET))
|
if(fseek(fp, cur-1, SEEK_SET) < 0)
|
||||||
{
|
{
|
||||||
perror("Unable to manipulate fp");
|
perror("Unable to manipulate fp");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -152,17 +152,23 @@ END_TEST
|
||||||
START_TEST (test_file_minmax1)
|
START_TEST (test_file_minmax1)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
/*
|
|
||||||
struct tm tm[2];
|
struct tm tm[2];
|
||||||
*/
|
|
||||||
printf("%ld\n", ttail->logfile_sz);
|
printf("%ld\n", ttail->logfile_sz);
|
||||||
ttail->flag |= TTAIL_FLAG_FORMAT;
|
ttail->flag |= TTAIL_FLAG_PREFIX;
|
||||||
ttail_set_fmt(ttail, "%B%n%d %H:%M");
|
ttail->prefix_sz = 0;
|
||||||
|
ttail_set_fmt(ttail, "%b%n%d %H:%M");
|
||||||
r = _ttail_search_closest_files_init(ttail);
|
r = _ttail_search_closest_files_init(ttail);
|
||||||
ck_assert_int_eq(r, 0);
|
ck_assert_int_eq(r, 0);
|
||||||
/*
|
|
||||||
r = _ttail_file_minmax(ttail, 0, tm);
|
r = _ttail_file_minmax(ttail, 0, tm);
|
||||||
*/
|
ck_assert_int_eq(r, 0);
|
||||||
|
ck_assert_int_eq(tm[0].tm_mon, 2);
|
||||||
|
ck_assert_int_eq(tm[0].tm_mday, 6);
|
||||||
|
ck_assert_int_eq(tm[0].tm_hour, 0);
|
||||||
|
ck_assert_int_eq(tm[0].tm_min, 1);
|
||||||
|
ck_assert_int_eq(tm[1].tm_mon, 2);
|
||||||
|
ck_assert_int_eq(tm[1].tm_mday, 6);
|
||||||
|
ck_assert_int_eq(tm[1].tm_hour, 0);
|
||||||
|
ck_assert_int_eq(tm[1].tm_min, 29);
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue