timed tail for logfiles. Display loglines given a minimum date and/or a maximum date.
c
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ttail_argparse_re_prefix.c 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. START_TEST (test_argparse_reprefix_short)
  9. {
  10. ttail_t *t;
  11. char *args[] = {"foo", "-r", "^[^ ]+ "};
  12. t = ttail_init(3, args);
  13. ck_assert(t != NULL);
  14. ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
  15. }
  16. END_TEST
  17. START_TEST (test_argparse_reprefix_long)
  18. {
  19. ttail_t *t;
  20. char *args[] = {"foo", "--re-prefix", "^[^ ]+ "};
  21. t = ttail_init(3, args);
  22. ck_assert(t != NULL);
  23. ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
  24. }
  25. END_TEST
  26. START_TEST (test_argparse_prefixlen_short)
  27. {
  28. ttail_t *t;
  29. char *args[] = {"foo", "-p", "10"};
  30. t = ttail_init(3, args);
  31. ck_assert(t != NULL);
  32. ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
  33. ck_assert_int_eq(t->prefix_sz, 10);
  34. }
  35. END_TEST
  36. START_TEST (test_argparse_prefixlen_long)
  37. {
  38. ttail_t *t;
  39. char *args[] = {"foo", "--prefix-len", "42"};
  40. t = ttail_init(3, args);
  41. ck_assert(t != NULL);
  42. ck_assert((t->flag & TTAIL_FLAG_PREFIX) == TTAIL_FLAG_PREFIX);
  43. ck_assert_int_eq(t->prefix_sz, 42);
  44. }
  45. END_TEST
  46. START_TEST (test_argparse_prefix_multiple)
  47. {
  48. ttail_t *t;
  49. char *args[] = {"foo", "--re-prefix", "^[^ ]+ ", "-p", "20"};
  50. t = ttail_init(5, args);
  51. ck_assert(t == NULL);
  52. }
  53. END_TEST
  54. TTAIL_CHECK_START( "ttail argument parsing checks",\
  55. "re-prefix arguments parsing")
  56. TTAIL_ADD_TEST(test_argparse_reprefix_short);
  57. TTAIL_ADD_TEST(test_argparse_reprefix_long);
  58. TTAIL_ADD_TEST(test_argparse_prefixlen_short);
  59. TTAIL_ADD_TEST(test_argparse_prefixlen_long);
  60. TTAIL_ADD_TEST(test_argparse_prefix_multiple);
  61. TTAIL_CHECK_END