@@ -281,6 +281,17 @@ The 'TST_EXP_FAIL()' is similar to 'TST_EXP_PASS()' but it fails the test if
the call haven't failed with -1 and 'errno' wasn't set to the expected one
passed as the second argument.
+[source,c]
+-------------------------------------------------------------------------------
+static void test(void)
+{
+ ...
+ TST_EXP_FAIL2(msgget(key, flags), EINVAL, "msgget(%i, %i)", key, flags);
+ ...
+}
+The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL' the only difference is that
+the return value is a non-negative integer if call passes.
+
[source,c]
-------------------------------------------------------------------------------
const char *tst_strsig(int sig);
@@ -120,13 +120,13 @@ extern void *TST_RET_PTR;
TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \
} while (0) \
-#define TST_EXP_FAIL(SCALL, ERRNO, ...) \
+#define TST_EXP_FAIL_(PASS_COND, SCALL, ERRNO, ...) \
do { \
TEST(SCALL); \
\
TST_PASS = 0; \
\
- if (TST_RET == 0) { \
+ if (PASS_COND) { \
TST_MSG_(TFAIL, " succeeded", #SCALL, ##__VA_ARGS__); \
break; \
} \
@@ -150,4 +150,8 @@ extern void *TST_RET_PTR;
} \
} while (0)
+#define TST_EXP_FAIL(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET == 0, SCALL, ERRNO, __VA_ARGS__)
+
+#define TST_EXP_FAIL2(SCALL, ERRNO, ...) TST_EXP_FAIL_(TST_RET >= 0, SCALL, ERRNO, __VA_ARGS__)
+
#endif /* TST_TEST_MACROS_H__ */