timed tail for logfiles. Display loglines given a minimum date and/or a maximum date.
c
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ttail_init_check.c 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_init_check_bad1)
  9. {
  10. ck_assert_int_eq(ttail_init_check(ttail), -1);
  11. }
  12. END_TEST
  13. START_TEST (test_init_check_bad2)
  14. {
  15. ttail->flag |= TTAIL_FLAG_DATE_MAX;
  16. ck_assert_int_eq(ttail_init_check(ttail), -1);
  17. }
  18. END_TEST
  19. START_TEST (test_init_check1)
  20. {
  21. char *arg[] = {"88/10/22", NULL};
  22. struct tm zero;
  23. char *arg0;
  24. arg0 = malloc(sizeof(char)*(strlen(arg[0])+1));
  25. if(!arg0)
  26. {
  27. perror("Malloc failed for argument");
  28. ck_abort_msg("Unable to allocate memory");
  29. }
  30. strcpy(arg0, arg[0]);
  31. arg[0]=arg0;
  32. memset(&zero, 0, sizeof(struct tm));
  33. ttail_set_dates(ttail, arg);
  34. ck_assert_int_eq(ttail_init_check(ttail), 0);
  35. }
  36. END_TEST
  37. TTAIL_CHECK_START("ttail init checks", "ttail_init_check() checks")
  38. TTAIL_SET_FIXTURE(setup_ttail_empty, teardown_ttail);
  39. TTAIL_ADD_TEST(test_init_check_bad1);
  40. TTAIL_ADD_TEST(test_init_check_bad2);
  41. TTAIL_ADD_TEST(test_init_check1);
  42. TTAIL_CHECK_END