Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

event-test.h

Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2005 by Kevin L. Mitchell <klmitch@mit.edu>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 **
00018 ** @(#)$Id: event-test.h,v 1.5 2005/12/18 00:15:17 klmitch Exp $
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 { /* initialize test suite... */                                           \
00058   _ev_asflags = (EVAS_LOG | EVAS_ABORT | EVAS_TRACE); /* turn on debugging */ \
00059   ev_log(EVAS_LOG, "Test program \"" TEST_NAME(test) "\" initialized...");    \
00060 } while (0)
00061 
00073 #define ev_prog_name(prog, argv)                                              \
00074 do { /* Locate the program name in argv */                                    \
00075   char *_t; /* look for trailing terminators */                               \
00076   (prog) = (argv)[0];                                                         \
00077   for (_t = (char *)(prog); *_t; _t++) /* scan string... */                   \
00078     if (*_t == '/' || *_t == '\\') /* found a terminator? */                  \
00079       (prog) = _t + 1; /* save separator... */                                \
00080 } while (0)
00081 
00098 #define ev_lib_init(argc, argv, prog, ctx)                                    \
00099 do { /* initialize the library */                                             \
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) { /* must have one argument: path to conf file */           \
00105     fprintf(stderr, "Usage: %s <conf> <module>\n", _prog);                    \
00106     exit(1);                                                                  \
00107   }                                                                           \
00108   if ((_t = strrchr(_mod, '/'))) {                                            \
00109     *(_t++) = '\0'; /* terminate path... */                                   \
00110     _modname = _t; /* rest is module name */                                  \
00111   } else {                                                                    \
00112     _modpath = "."; /* no path component, must be current directory */        \
00113     _modname = _t = _mod; /* argument is module name */                       \
00114   }                                                                           \
00115   if ((_t = strchr(_t, '.')))                                                 \
00116     *_t = '\0'; /* remove module extension... */                              \
00117   if ((_err = event_attr_init(&_attrs)) || /* initialize attributes... */     \
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)) || /* init lib */      \
00122       (_err = event_attr_destroy(&_attrs))) { /* destroy attributes... */     \
00123     fprintf(stderr, "%s: Unable to initialize library; error %u\n",           \
00124             _prog, _err);                                                     \
00125     exit(1);                                                                  \
00126   }                                                                           \
00127 } while (0)
00128 
00129 #endif /* __event_test_h__ */

Generated on Wed Dec 28 23:36:56 2005 for event by  doxygen 1.4.4