[RGT] Don't use EXPECT* macros in a subprocess that exits by signalling
authorPaul Robinson <paul.robinson@sony.com>
Fri, 15 Jan 2021 16:52:58 +0000 (08:52 -0800)
committerPaul Robinson <paul.robinson@sony.com>
Fri, 22 Jan 2021 23:04:34 +0000 (15:04 -0800)
Found by the Rotten Green Tests project.

Differential Revision: https://reviews.llvm.org/D95256

llvm/unittests/Support/CrashRecoveryTest.cpp

index c38fa0b..e95513e 100644 (file)
@@ -157,8 +157,12 @@ TEST(CrashRecoveryTest, UnixCRCReturnCode) {
   if (getenv("LLVM_CRC_UNIXCRCRETURNCODE")) {
     llvm::CrashRecoveryContext::Enable();
     CrashRecoveryContext CRC;
-    EXPECT_FALSE(CRC.RunSafely(abort));
-    EXPECT_EQ(CRC.RetCode, 128 + SIGABRT);
+    // This path runs in a subprocess that exits by signalling, so don't use
+    // the googletest macros to verify things as they won't report properly.
+    if (CRC.RunSafely(abort))
+      llvm_unreachable("RunSafely returned true!");
+    if (CRC.RetCode != 128 + SIGABRT)
+      llvm_unreachable("Unexpected RetCode!");
     // re-throw signal
     llvm::sys::unregisterHandlers();
     raise(CRC.RetCode - 128);