tests/helpers: detect unsupported operation directly from assertion
Signed-off-by: Philippe Gerum <rpm@xenomai.org>
This commit is contained in:
parent
bc9df6ac2c
commit
cbf1805fa5
|
@ -31,7 +31,10 @@
|
|||
__FILE__, __LINE__, ##__args)
|
||||
#endif
|
||||
|
||||
#define abort_test() exit(1)
|
||||
static inline int abort_test(int status)
|
||||
{
|
||||
exit(status == -EOPNOTSUPP ? EXIT_NO_SUPPORT : 1);
|
||||
}
|
||||
|
||||
#define __Tcall(__ret, __call) \
|
||||
({ \
|
||||
|
@ -47,7 +50,7 @@
|
|||
#define __Tcall_assert(__ret, __call) \
|
||||
do { \
|
||||
if (!__Tcall(__ret, __call)) \
|
||||
abort_test(); \
|
||||
abort_test(__ret); \
|
||||
} while (0)
|
||||
|
||||
#define __Fcall(__ret, __call) \
|
||||
|
@ -63,7 +66,7 @@
|
|||
#define __Fcall_assert(__ret, __call) \
|
||||
do { \
|
||||
if (!__Fcall(__ret, __call)) \
|
||||
abort_test(); \
|
||||
abort_test(__ret); \
|
||||
} while (0)
|
||||
|
||||
#define __Tcall_errno(__ret, __call) \
|
||||
|
@ -76,25 +79,31 @@
|
|||
(__ret) >= 0; \
|
||||
})
|
||||
|
||||
#define __Tcall_errno_assert(__ret, __call) \
|
||||
do { \
|
||||
if (!__Tcall_errno(__ret, __call)) \
|
||||
abort_test(); \
|
||||
#define __Tcall_errno_assert(__ret, __call) \
|
||||
do { \
|
||||
(__ret) = (__call); \
|
||||
if (__ret < 0) { \
|
||||
int __errval = errno; \
|
||||
warn_failed("%s (=%s)", \
|
||||
__stringify(__call), \
|
||||
strerror(__errval)); \
|
||||
abort_test(-__errval); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define __Texpr(__expr) \
|
||||
({ \
|
||||
int __ret = !!(__expr); \
|
||||
if (!__ret) \
|
||||
warn_failed("%s (=false)", \
|
||||
__stringify(__expr)); \
|
||||
__ret; \
|
||||
#define __Texpr(__expr) \
|
||||
({ \
|
||||
int __ret = !!(__expr); \
|
||||
if (!__ret) \
|
||||
warn_failed("%s (=false)", \
|
||||
__stringify(__expr)); \
|
||||
__ret; \
|
||||
})
|
||||
|
||||
#define __Texpr_assert(__expr) \
|
||||
do { \
|
||||
if (!__Texpr(__expr)) \
|
||||
abort_test(); \
|
||||
abort_test(0); \
|
||||
} while (0)
|
||||
|
||||
#define __Fexpr(__expr) \
|
||||
|
@ -109,7 +118,7 @@
|
|||
#define __Fexpr_assert(__expr) \
|
||||
do { \
|
||||
if (!__Fexpr(__expr)) \
|
||||
abort_test(); \
|
||||
abort_test(0); \
|
||||
} while (0)
|
||||
|
||||
char *get_unique_name_and_path(const char *type,
|
||||
|
|
Loading…
Reference in New Issue