[libc-commits] [libc] cd328c1 - [libc] Use ASSERT_DEATH for EXPECT_DEATH under Fuchsia zxtest
Roland McGrath via libc-commits
libc-commits at lists.llvm.org
Wed Aug 2 17:58:04 PDT 2023
Author: Roland McGrath
Date: 2023-08-02T17:57:44-07:00
New Revision: cd328c10ad503b243cc333f813c0c6ee66598ffc
URL: https://github.com/llvm/llvm-project/commit/cd328c10ad503b243cc333f813c0c6ee66598ffc
DIFF: https://github.com/llvm/llvm-project/commit/cd328c10ad503b243cc333f813c0c6ee66598ffc.diff
LOG: [libc] Use ASSERT_DEATH for EXPECT_DEATH under Fuchsia zxtest
The Fuchsia zxtest library has ASSERT_DEATH but not EXPECT_DEATH.
The latter may be added in the future, but for now just use the
former as substitute.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D156940
Added:
Modified:
libc/test/UnitTest/FuchsiaTest.h
Removed:
################################################################################
diff --git a/libc/test/UnitTest/FuchsiaTest.h b/libc/test/UnitTest/FuchsiaTest.h
index 5195d4a6082089..f711e83bdf2602 100644
--- a/libc/test/UnitTest/FuchsiaTest.h
+++ b/libc/test/UnitTest/FuchsiaTest.h
@@ -13,6 +13,13 @@
#define WITH_SIGNAL(X) #X
+#ifndef EXPECT_DEATH
+// Since zxtest has ASSERT_DEATH but not EXPECT_DEATH, wrap calling it
+// in a lambda returning void to swallow any early returns so that this
+// can be used in a function that itself returns non-void.
+#define EXPECT_DEATH(FUNC, SIG) ([&] { ASSERT_DEATH(FUNC, SIG); }())
+#endif
+
namespace __llvm_libc::testing {
using Test = ::zxtest::Test;
}
More information about the libc-commits
mailing list