Linux Test Project
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 1/2] open_posix: add SAFE_FUNC macro
@ 2017-12-06 14:05 Jan Stancek
  2017-12-06 14:05 ` [LTP] [PATCH v2 2/2] pthread_create-14-1: avoid threads sharing stack Jan Stancek
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Stancek @ 2017-12-06 14:05 UTC (permalink / raw)
  To: ltp

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 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Changes in v2:
- turn it into statement expression, so that we can use return value
  For example in 2/2 patch: ret = SAFE_FUNC(fork());

diff --git a/testcases/open_posix_testsuite/include/safe_helpers.h b/testcases/open_posix_testsuite/include/safe_helpers.h
index 7f945a0280c2..966cb9221a3d 100644
--- a/testcases/open_posix_testsuite/include/safe_helpers.h
+++ b/testcases/open_posix_testsuite/include/safe_helpers.h
@@ -30,4 +30,16 @@ do {\
 	} \
 } while (0)
 
+#define SAFE_FUNC(op) \
+({ \
+	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); \
+	} \
+	ret; \
+})
+
 #endif
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-12-12  9:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-06 14:05 [LTP] [PATCH v2 1/2] open_posix: add SAFE_FUNC macro Jan Stancek
2017-12-06 14:05 ` [LTP] [PATCH v2 2/2] pthread_create-14-1: avoid threads sharing stack Jan Stancek
2017-12-11 14:38   ` Cyril Hrubis
2017-12-12  9:26     ` Jan Stancek
2017-12-12  9:56       ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox