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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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(fpl);
  15. ck_assert(res == 77);
  16. res = _ttail_file_next_line(fpl);
  17. ck_assert(res == 136);
  18. res = _ttail_file_next_line(fpl);
  19. ck_assert(res == 221);
  20. res = _ttail_file_next_line(fpl);
  21. ck_assert(res == 298);
  22. res = _ttail_file_next_line(fpl);
  23. ck_assert(res == 357);
  24. res = _ttail_file_next_line(fpl);
  25. ck_assert(res == 0);
  26. res = _ttail_file_next_line(fpl);
  27. ck_assert(res == -1);
  28. }
  29. END_TEST
  30. START_TEST (test_file_line_start)
  31. {
  32. long res;
  33. fseek(fpl, -1, SEEK_END);
  34. res = _ttail_file_start_line(fpl);
  35. ck_assert(res == 357);
  36. res = _ttail_file_start_line(fpl);
  37. ck_assert(res == 357);
  38. fseek(fpl, -1, SEEK_CUR);
  39. res = _ttail_file_start_line(fpl);
  40. ck_assert(res == 298);
  41. fseek(fpl, -1, SEEK_CUR);
  42. res = _ttail_file_start_line(fpl);
  43. ck_assert(res == 221);
  44. fseek(fpl, -1, SEEK_CUR);
  45. res = _ttail_file_start_line(fpl);
  46. ck_assert(res == 136);
  47. fseek(fpl, -1, SEEK_CUR);
  48. res = _ttail_file_start_line(fpl);
  49. ck_assert(res == 77);
  50. fseek(fpl, -1, SEEK_CUR);
  51. res = _ttail_file_start_line(fpl);
  52. ck_assert(res == 0);
  53. }
  54. END_TEST
  55. Suite * ttail_search_files_suite(void)
  56. {
  57. Suite *s;
  58. TCase *tc_file_line;
  59. s = suite_create("ttail search_files checks");
  60. tc_file_line = tcase_create("ttail_file_*line*() checks");
  61. tcase_add_checked_fixture(tc_file_line,
  62. setup_file_line, teardown_file_line);
  63. tcase_add_test(tc_file_line, test_file_line_next);
  64. tcase_add_test(tc_file_line, test_file_line_start);
  65. suite_add_tcase(s, tc_file_line);
  66. return s;
  67. }
  68. TTAIL_CHECK_MAIN(ttail_search_files_suite)