diff options
Diffstat (limited to 'test/test-lib.h')
-rw-r--r-- | test/test-lib.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/test/test-lib.h b/test/test-lib.h new file mode 100644 index 0000000..54c1472 --- /dev/null +++ b/test/test-lib.h @@ -0,0 +1,65 @@ +#ifndef TEST_LIB +#define TEST_LIB + +#include <config.h> +#include <stdlib.h> + +struct lt_config_shared *config_init(void); +void config_clear(struct lt_config_shared *sh); +int fout_read(struct lt_config_shared *sh, char *buf, int size); + +enum { + RE_TEST_TYPE_STR = 1, + RE_TEST_TYPE_INT = 2, + RE_TEST_TYPE_PID = 3, +}; + +enum { + RE_TEST_OFF_UNDEF = -1, +}; + +enum { + RE_TEST_OK = -1, +}; + +struct re_test_data { + int type; + int so; + int eo; + char *pat; +}; + +int re_test(char *line, struct re_test_data *data, int cnt); + +#define TEST_START() sh->disabled = 0 +#define TEST_STOP() sh->disabled = 1 + +#define PASSED() \ +do { \ + printf("."); \ + fflush(NULL); \ +} while(0) + +#define FAILED(fmt, args...) \ +do { \ + char lpbuf[1024]; \ + sprintf(lpbuf, "%s:%d failed - %s", \ + __FUNCTION__, \ + __LINE__, \ + fmt); \ + printf(lpbuf, ## args); \ + fflush(NULL); \ + exit(-1); \ +} while(0) + +#define TEST(testfn) \ +do { \ + if (testfn(sh)) { \ + printf("FAILED %s\n", #testfn); \ + return -1; \ + } \ +} while(0) + +#define BUFSIZE 1000 + +#endif |