[libc-commits] [PATCH] D156940: [libc] Use ASSERT_DEATH for EXPECT_DEATH under Fuchsia zxtest

Roland McGrath via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Aug 2 17:55:35 PDT 2023


mcgrathr updated this revision to Diff 546659.
mcgrathr added a comment.
This revision is now accepted and ready to land.

Wrap in a lambda to swallow early returns.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156940/new/

https://reviews.llvm.org/D156940

Files:
  libc/test/UnitTest/FuchsiaTest.h


Index: libc/test/UnitTest/FuchsiaTest.h
===================================================================
--- libc/test/UnitTest/FuchsiaTest.h
+++ 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;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156940.546659.patch
Type: text/x-patch
Size: 606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230803/b6db1a33/attachment.bin>


More information about the libc-commits mailing list