00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __event_test_h__
00021 #define __event_test_h__
00022
00039 #include "test-harness.h"
00040 #include "event_int.h"
00041
00042 #include <stdio.h>
00043 #include <string.h>
00044
00056 #define ev_test_init(test) \
00057 do { \
00058 _ev_asflags = (EVAS_LOG | EVAS_ABORT | EVAS_TRACE); \
00059 ev_log(EVAS_LOG, "Test program \"" TEST_NAME(test) "\" initialized..."); \
00060 } while (0)
00061
00073 #define ev_prog_name(prog, argv) \
00074 do { \
00075 char *_t; \
00076 (prog) = (argv)[0]; \
00077 for (_t = (char *)(prog); *_t; _t++) \
00078 if (*_t == '/' || *_t == '\\') \
00079 (prog) = _t + 1; \
00080 } while (0)
00081
00098 #define ev_lib_init(argc, argv, prog, ctx) \
00099 do { \
00100 char *_mod = (argv)[2], *_t; \
00101 const char *_conf = (argv)[1], *_prog = (prog), *_modpath = _mod, *_modname;\
00102 ev_err_t _err; \
00103 ev_attr_t _attrs; \
00104 if ((argc) < 3) { \
00105 fprintf(stderr, "Usage: %s <conf> <module>\n", _prog); \
00106 exit(1); \
00107 } \
00108 if ((_t = strrchr(_mod, '/'))) { \
00109 *(_t++) = '\0'; \
00110 _modname = _t; \
00111 } else { \
00112 _modpath = "."; \
00113 _modname = _t = _mod; \
00114 } \
00115 if ((_t = strchr(_t, '.'))) \
00116 *_t = '\0'; \
00117 if ((_err = event_attr_init(&_attrs)) || \
00118 (_err = event_attr_confpath(&_attrs, &_conf)) || \
00119 (_err = event_attr_libpath(&_attrs, &_modpath)) || \
00120 (_err = event_attr_modlist(&_attrs, &_modname)) || \
00121 (_err = event_init((ctx), &_attrs, 0, _prog, 0)) || \
00122 (_err = event_attr_destroy(&_attrs))) { \
00123 fprintf(stderr, "%s: Unable to initialize library; error %u\n", \
00124 _prog, _err); \
00125 exit(1); \
00126 } \
00127 } while (0)
00128
00129 #endif