From 60b91c95855eca29a2e74c46eb6a389ce3c514e1 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Thu, 8 Mar 2012 23:45:53 +0100 Subject: [PATCH] wvtest: Add WVERRNO macro It calls perror() if the value == -1. --- src/wvtest/c/wvtest.c | 12 ++++++++++++ src/wvtest/c/wvtest.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/wvtest/c/wvtest.c b/src/wvtest/c/wvtest.c index ec45d634..055b71fb 100644 --- a/src/wvtest/c/wvtest.c +++ b/src/wvtest/c/wvtest.c @@ -424,3 +424,15 @@ bool wvtest_start_check_lt_str(const char *file, int line, wvtest_check(cond, NULL); return cond; } + +int wvtest_start_check_errno(const char *file, int line, + const char *condstr, int retval) +{ + wvtest_start(file, line, condstr); + if (retval == -1) + perror(condstr); + + wvtest_check(retval != -1, NULL); + + return retval; +} diff --git a/src/wvtest/c/wvtest.h b/src/wvtest/c/wvtest.h index 8530ba53..36d3d769 100644 --- a/src/wvtest/c/wvtest.h +++ b/src/wvtest/c/wvtest.h @@ -44,6 +44,8 @@ bool wvtest_start_check_lt_str(const char *file, int line, const char *a, const char *b); int wvtest_start_check_frsh(const char *file, int line, const char *condstr, int frsh_retval); +int wvtest_start_check_errno(const char *file, int line, + const char *condstr, int retval); #define WVPASS(cond) \ @@ -74,6 +76,8 @@ int wvtest_start_check_frsh(const char *file, int line, #define WVFAILNESTR(a, b) WVPASSEQSTR(a, b) #define WVFRSH(frshretval) \ wvtest_start_check_frsh(__FILE__, __LINE__, #frshretval, (frshretval)) +#define WVERRNO(retval) \ + wvtest_start_check_errno(__FILE__, __LINE__, #retval, (retval)) #define WVTEST_MAIN3(_descr, ff, ll, _slowness) \ -- 2.39.2