123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #ifndef _ttail_check_h__
- #define _ttail_check_h__
-
- #include <check.h>
- #include <errno.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <libgen.h>
-
- #include "ttail.h"
- #include "ttail_init.h"
-
- ttail_t *ttail;
- #define __Fname_sz 5
- #define FNAME_NO_EXIST 0
- #define FNAME_EXIST 1
-
- char *fname[__Fname_sz];
- /*date formats*/
- char *fmt[] = TTAIL_DEFAULT_FORMATS;
-
- void teardown_ttail(void)
- {
- ttail_free(ttail);
- }
-
- void setup_ttail_empty(void)
- {
- ttail = ttail_init(1, (char**)&"foo");
- }
-
- void setup_fname(void)
- {
- int i;
- FILE *fp;
- for(i=0;i<__Fname_sz;i++)
- {
- fname[i] = NULL;
- }
-
- for(i=0; i<__Fname_sz; i++)
- {
- fname[i] = tempnam(NULL, "ttail_check");
- if(i%2)
- {
- if((fp=fopen(fname[i], "w+")) == NULL)
- {
- perror("Unable to create file for testing");
- ck_abort_msg("Unable to create file for testing");
- }
- if(fclose(fp))
- {
- perror("Unable to close file for testing");
- ck_abort_msg("Unable to close file for testing");
-
- }
- }
- }
- }
-
- void teardown_fname(void)
- {
- int i;
- for(i=0; i<__Fname_sz; i++)
- {
- unlink(fname[i]);
- if(fname[i] != NULL)
- {
- free(fname[i]);
- }
- }
- }
-
-
-
-
- #define TTAIL_CHECK_MAIN(suite) int main(int argc, char **argv) {\
- int n_fail;\
- SRunner *sr;\
- chdir(dirname(argv[0])); /* move in ./tests dir */ \
- sr = srunner_create(suite());\
- srunner_set_fork_status(sr, CK_FORK);\
- srunner_run_all(sr, CK_VERBOSE);\
- n_fail = srunner_ntests_failed(sr);\
- srunner_free(sr);\
- return (n_fail == 0) ? EXIT_SUCCESS : EXIT_FAILURE;\
- }
-
- #endif
|