Browse Source

+ fix tests

master
Alex 'AdUser' Z 9 years ago
parent
commit
3f98572b03
  1. 34
      t/t_logfile.c

34
t/t_logfile.c

@ -4,5 +4,39 @@
#include "../src/logfile.h" #include "../src/logfile.h"
int main() { int main() {
f2b_logfile_t file;
char filename[] = "/tmp/f2b-test.XXXXXX";
int fd = 0;
FILE *wfd = NULL;
char buf[2048];
assert((fd = mkstemp(filename)) > 0);
assert((wfd = fdopen(fd, "a")) != NULL);
assert(fputs("test1\n", wfd) > 0);
assert(fflush(wfd) == 0);
assert(f2b_logfile_open(&file, filename) == true);
assert(f2b_logfile_getline(&file, buf, sizeof(buf)) == false);
assert(fputs("test2\n", wfd) > 0);
assert(fflush(wfd) == 0);
assert(f2b_logfile_getline(&file, buf, sizeof(buf)) == true);
assert(strncmp(buf, "test2\n", sizeof(buf)) == 0);
assert(f2b_logfile_getline(&file, buf, sizeof(buf)) == false);
fclose(wfd);
close(fd);
unlink(filename);
assert((wfd = fopen(filename, "a")) != 0);
assert(f2b_logfile_rotated(&file) == true);
f2b_logfile_close(&file);
fclose(wfd);
unlink(filename);
exit(0); exit(0);
} }

Loading…
Cancel
Save