[zircon][lib][zxtest] EXPECT_* no longer reqs void.
EXPECT_* macros never return, so they no longer require
a void function signature for helper methods.
We just rely on tokenization of fatal boolean to act as a selector for
macro implementation, both in C and CPP.
ZX-3958 #done
TEST=zxtest-integration-test
Change-Id: Ia11fb16895cb8bd979141665af6a032189278226
diff --git a/zircon/system/ulib/zxtest/include/zxtest/c/zxtest.h b/zircon/system/ulib/zxtest/include/zxtest/c/zxtest.h
index b33f690..f95cb1f 100644
--- a/zircon/system/ulib/zxtest/include/zxtest/c/zxtest.h
+++ b/zircon/system/ulib/zxtest/include/zxtest/c/zxtest.h
@@ -183,10 +183,18 @@
snprintf(out_desc + strlen(desc) + 1, req_size, " "__VA_ARGS__); \
} while (0)
-#define _RETURN_IF_FATAL(fatal) \
- if (fatal && _ZXTEST_ABORT_IF_ERROR) { \
- return; \
- }
+#define _RETURN_IF_FATAL_1 \
+ do { \
+ if (_ZXTEST_ABORT_IF_ERROR) { \
+ return; \
+ } \
+ } while (0)
+
+#define _RETURN_IF_FATAL_0 \
+ do { \
+ } while (0)
+
+#define _RETURN_IF_FATAL(fatal) _RETURN_IF_FATAL_##fatal
#define _ASSERT_VAR_BYTES(op, expected, actual, size, fatal, file, line, desc, ...) \
do { \
diff --git a/zircon/system/ulib/zxtest/include/zxtest/cpp/zxtest.h b/zircon/system/ulib/zxtest/include/zxtest/cpp/zxtest.h
index 9b09f71..dd37635 100644
--- a/zircon/system/ulib/zxtest/include/zxtest/cpp/zxtest.h
+++ b/zircon/system/ulib/zxtest/include/zxtest/cpp/zxtest.h
@@ -78,10 +78,18 @@
#define _ZXTEST_TEST_HAS_ERRORS zxtest::Runner::GetInstance()->CurrentTestHasFailures()
-#define _RETURN_IF_FATAL(fatal) \
- if (fatal && _ZXTEST_ABORT_IF_ERROR) { \
- return; \
- }
+#define _RETURN_IF_FATAL_true \
+ do { \
+ if (_ZXTEST_ABORT_IF_ERROR) { \
+ return; \
+ } \
+ } while (0)
+
+#define _RETURN_IF_FATAL_false \
+ do { \
+ } while (0)
+
+#define _RETURN_IF_FATAL(fatal) _RETURN_IF_FATAL_##fatal
namespace zxtest {
namespace internal {
diff --git a/zircon/system/ulib/zxtest/test/integration/assertions_test.c b/zircon/system/ulib/zxtest/test/integration/assertions_test.c
index c5ed52d..32e3438 100644
--- a/zircon/system/ulib/zxtest/test/integration/assertions_test.c
+++ b/zircon/system/ulib/zxtest/test/integration/assertions_test.c
@@ -633,3 +633,14 @@
a, a, a, a, a, a, a);
TEST_CHECKPOINT();
}
+
+static int HasExpects(void) {
+ EXPECT_EQ(1, 2);
+ return 0;
+}
+
+TEST(ZxTestCAssertionTest, NonVoidHelperTestNonFatalFailures) {
+ TEST_EXPECTATION(CHECKPOINT_REACHED, HAS_ERRORS, "Failed to propagate assertion error.");
+ ASSERT_NO_FATAL_FAILURES(HasExpects());
+ TEST_CHECKPOINT();
+}
diff --git a/zircon/system/ulib/zxtest/test/integration/assertions_test.cpp b/zircon/system/ulib/zxtest/test/integration/assertions_test.cpp
index a5859a5..6bae49f 100644
--- a/zircon/system/ulib/zxtest/test/integration/assertions_test.cpp
+++ b/zircon/system/ulib/zxtest/test/integration/assertions_test.cpp
@@ -798,4 +798,15 @@
TEST_CHECKPOINT();
}
+int HasExpects() {
+ EXPECT_EQ(1, 2);
+ return 0;
+}
+
+TEST(ZxTestAssertionTest, NonVoidHelperTestNonFatalFailures) {
+ TEST_EXPECTATION(CHECKPOINT_REACHED, HAS_ERRORS, "Failed to propagate assertion error.");
+ ASSERT_NO_FATAL_FAILURES(HasExpects());
+ TEST_CHECKPOINT();
+}
+
} // namespace