utesthelp.h

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------------
00002  
00003    Copyright (c) 2006-2007, Intellectual Reserve, Inc. All rights reserved.
00004  
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License version 2 as 
00007    published by the Free Software Foundation.
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   --------------------------------------------------------------------------*/
00019 
00028 #include <stdio.h>      // for fprintf
00029 #include <stdlib.h>     // for exit
00030 #include <stdarg.h>     // for va_list, etc.
00031 
00032 #include "dnxError.h"
00033 
00034 /* test-bed helper macros */
00035 #define CHECK_ZERO(expr)                                                      \
00036 do {                                                                          \
00037    int ret;                                                                   \
00038    if ((ret = (expr)) != 0)                                                   \
00039    {                                                                          \
00040       fprintf(stderr, "FAILED: '%s'\n  at %s(%d).\n  error %d: %s\n",         \
00041             #expr, __FILE__, __LINE__, ret, dnxErrorString(ret));             \
00042       exit(1);                                                                \
00043    }                                                                          \
00044 } while (0)
00045 #define CHECK_TRUE(expr)                                                      \
00046 do {                                                                          \
00047    if (!(expr))                                                               \
00048    {                                                                          \
00049       fprintf(stderr, "FAILED: Boolean(%s)\n  at %s(%d).\n",                  \
00050             #expr, __FILE__, __LINE__);                                       \
00051       exit(1);                                                                \
00052    }                                                                          \
00053 } while (0)
00054 #define CHECK_NONZERO(expr)    CHECK_ZERO(!(expr))
00055 #define CHECK_FALSE(expr)      CHECK_TRUE(!(expr))
00056 
00057 #define IMPLEMENT_DNX_DEBUG(v) \
00058 void dnxDebug(int l, char * f, ... ) \
00059 { if (v) { va_list a; va_start(a,f); vprintf(f,a); va_end(a); puts(""); } }
00060 
00061 #define IMPLEMENT_DNX_SYSLOG(v) \
00062 void dnxLog(char * f, ... ) \
00063 { if (v) { va_list a; va_start(a,f); vprintf(f,a); va_end(a); puts(""); } }
00064 
00065 /*--------------------------------------------------------------------------*/
00066 

Generated on Tue Apr 13 15:48:07 2010 for DNX by  doxygen 1.5.6