[LTP] [PATCH 1/2] open_posix: add SAFE_FUNC macro

Jan Stancek jstancek@redhat.com
Mon Dec 4 16:10:54 CET 2017


Similar macro to SAFE_PFUNC, but instead checks for ret value == -1,
and prints error from 'errno'.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/open_posix_testsuite/include/safe_helpers.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/testcases/open_posix_testsuite/include/safe_helpers.h b/testcases/open_posix_testsuite/include/safe_helpers.h
index 7f945a0280c2..4537fba12263 100644
--- a/testcases/open_posix_testsuite/include/safe_helpers.h
+++ b/testcases/open_posix_testsuite/include/safe_helpers.h
@@ -30,4 +30,15 @@ do {\
 	} \
 } while (0)
 
+#define SAFE_FUNC(op) \
+do {\
+	int ret = (op); \
+	if (ret == -1) { \
+		printf("Test %s unresolved: got %i (%s) on line %i\n  %s\n", \
+			__FILE__, ret, strerror(errno), __LINE__, #op); \
+		fflush(stdout); \
+		exit(PTS_UNRESOLVED); \
+	} \
+} while (0)
+
 #endif
-- 
1.8.3.1



More information about the ltp mailing list