X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Flite.h;h=36f873e8be6649649e1da6db33003306f830b5bc;hb=b220134a312e2a488810abfef510f5dbf59078a4;hp=52e96380ca60ac873f53e63287ab4058b8db8432;hpb=17690735658d7b44f91579df91e31da9ae185158;p=awesomized%2Flibmemcached diff --git a/libtest/lite.h b/libtest/lite.h index 52e96380..36f873e8 100644 --- a/libtest/lite.h +++ b/libtest/lite.h @@ -51,7 +51,7 @@ # include #endif -#ifdef _WIN32 +#if defined(WIN32) # include #else # include @@ -77,15 +77,7 @@ # define SKIP(__message_format, ...) #endif -static inline bool valgrind_is_caller(void) -{ - if (getenv("TESTS_ENVIRONMENT") && strstr(getenv("TESTS_ENVIRONMENT"), "valgrind")) - { - return true; - } - - return false; -} +#include static inline size_t yatl_strlen(const char *s) { @@ -148,6 +140,34 @@ do \ } \ } while (0) +#define SKIP_UNLESS(__expression) \ +do \ +{ \ + if (! (__expression)) { \ + if (YATL_FULL) { \ + SKIP(#__expression); \ + } \ + fprintf(stdout, "\n%s:%d: %s SKIP '(%s)'\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #__expression); \ + exit(EXIT_SKIP); \ + } \ +} while (0) + +#define SKIP_UNLESS_(__expression, ...) \ +do \ +{ \ + if (! (__expression)) { \ + size_t ask= snprintf(0, 0, __VA_ARGS__); \ + ask++; \ + char *buffer= (char*)alloca(sizeof(char) * ask); \ + snprintf(buffer, ask, __VA_ARGS__); \ + if (YATL_FULL) { \ + SKIP(#__expression, buffer); \ + } \ + fprintf(stdout, "\n%s:%d: %s SKIP '%s' [ %s ]\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #__expression, buffer); \ + exit(EXIT_SKIP); \ + } \ +} while (0) + #define ASSERT_TRUE(__expression) \ do \ { \ @@ -348,7 +368,7 @@ do \ } \ } while (0) -#define ASSERT_NEQ(__expected, __actual, ...) \ +#define ASSERT_NEQ(__expected, __actual) \ do \ { \ if ((__expected) == (__actual)) { \