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_init_re_prefix.c 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <check.h>
  2. #include <errno.h>
  3. #include <stdio.h>
  4. #include <unistd.h>
  5. #include "ttail_check.h"
  6. #include "ttail.h"
  7. #include "ttail_init.h"
  8. /*
  9. * ttail_set_prefix() tests
  10. */
  11. START_TEST (test_init_prefix)
  12. {
  13. int ret;
  14. ret = ttail_set_prefix(ttail, "^[^ ]+ ");
  15. ck_assert_int_eq(ret, 0);
  16. ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
  17. }
  18. END_TEST
  19. START_TEST (test_init_bad_prefix)
  20. {
  21. int ret;
  22. ret = ttail_set_prefix(ttail, "^[^ + ");
  23. ck_assert_int_eq(ret, -1);
  24. ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == 0);
  25. }
  26. END_TEST
  27. START_TEST (test_init_again_prefix)
  28. {
  29. int ret;
  30. ret = ttail_set_prefix(ttail, "^[^ ]+ ");
  31. ck_assert_int_eq(ret, 0);
  32. ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
  33. ret = ttail_set_prefix(ttail, "^[^ + ");
  34. ck_assert_int_eq(ret, 1);
  35. ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
  36. }
  37. END_TEST
  38. START_TEST (test_init_againbad_prefix)
  39. {
  40. int ret;
  41. ret = ttail_set_prefix(ttail, "^[^ + ");
  42. ck_assert_int_eq(ret, -1);
  43. ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == 0);
  44. ret = ttail_set_prefix(ttail, "^[^ ]+ ");
  45. ck_assert_int_eq(ret, 0);
  46. ck_assert((ttail->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
  47. }
  48. END_TEST
  49. TTAIL_CHECK_START("ttail init checks", "date prefix regex init checks")
  50. TTAIL_SET_FIXTURE(setup_ttail_empty, teardown_ttail);
  51. TTAIL_ADD_TEST(test_init_prefix);
  52. TTAIL_ADD_TEST(test_init_bad_prefix);
  53. TTAIL_ADD_TEST(test_init_again_prefix);
  54. TTAIL_ADD_TEST(test_init_againbad_prefix);
  55. TTAIL_CHECK_END