timed tail for logfiles. Display loglines given a minimum date and/or a maximum date.
c
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ttail_search_file_line.c 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include <check.h>
  2. #include <stdio.h>
  3. #include <libgen.h>
  4. #include "ttail_check.h"
  5. #include "ttail.h"
  6. #include "ttail_init.h"
  7. #include "ttail_search.h"
  8. /*
  9. * _ttail_file_next_line() & _ttail_file_line_start() tests
  10. */
  11. START_TEST (test_file_line_next)
  12. {
  13. long res;
  14. res = _ttail_file_next_line(ttail, 0);
  15. ck_assert(res == 77);
  16. res = _ttail_file_next_line(ttail, 0);
  17. ck_assert(res == 136);
  18. res = _ttail_file_next_line(ttail, 0);
  19. ck_assert(res == 221);
  20. res = _ttail_file_next_line(ttail, 0);
  21. ck_assert(res == 298);
  22. res = _ttail_file_next_line(ttail, 0);
  23. ck_assert(res == 357);
  24. res = _ttail_file_next_line(ttail, 0);
  25. ck_assert(res == 0);
  26. res = _ttail_file_next_line(ttail, 0);
  27. ck_assert(res == -1);
  28. }
  29. END_TEST
  30. START_TEST (test_file_line_start)
  31. {
  32. long res;
  33. fseek(ttail->logfile[0], -1, SEEK_END);
  34. res = _ttail_file_start_line(ttail, 0);
  35. ck_assert(res == 357);
  36. res = _ttail_file_start_line(ttail, 0);
  37. ck_assert(res == 357);
  38. fseek(ttail->logfile[0], -1, SEEK_CUR);
  39. res = _ttail_file_start_line(ttail, 0);
  40. ck_assert(res == 298);
  41. fseek(ttail->logfile[0], -1, SEEK_CUR);
  42. res = _ttail_file_start_line(ttail, 0);
  43. ck_assert(res == 221);
  44. fseek(ttail->logfile[0], -1, SEEK_CUR);
  45. res = _ttail_file_start_line(ttail, 0);
  46. ck_assert(res == 136);
  47. fseek(ttail->logfile[0], -1, SEEK_CUR);
  48. res = _ttail_file_start_line(ttail, 0);
  49. ck_assert(res == 77);
  50. fseek(ttail->logfile[0], -1, SEEK_CUR);
  51. res = _ttail_file_start_line(ttail, 0);
  52. ck_assert(res == 0);
  53. }
  54. END_TEST
  55. TTAIL_CHECK_START("ttail search_files checks", "ttail_file_*line*() checks")
  56. TTAIL_SET_FIXTURE(setup_file_line, teardown_ttail);
  57. TTAIL_ADD_TEST(test_file_line_next);
  58. TTAIL_ADD_TEST(test_file_line_start);
  59. TTAIL_CHECK_END