[llvm-branch-commits] [llvm] 6ea7ecb - [RGT] Don't use EXPECT* macros in a subprocess that exits by signalling

Paul Robinson via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jan 22 15:09:23 PST 2021


Author: Paul Robinson
Date: 2021-01-22T15:04:34-08:00
New Revision: 6ea7ecbb72aa139ebb1a343a6d544b84b99f1f3a

URL: https://github.com/llvm/llvm-project/commit/6ea7ecbb72aa139ebb1a343a6d544b84b99f1f3a
DIFF: https://github.com/llvm/llvm-project/commit/6ea7ecbb72aa139ebb1a343a6d544b84b99f1f3a.diff

LOG: [RGT] Don't use EXPECT* macros in a subprocess that exits by signalling

Found by the Rotten Green Tests project.

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

Added: 
    

Modified: 
    llvm/unittests/Support/CrashRecoveryTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/Support/CrashRecoveryTest.cpp b/llvm/unittests/Support/CrashRecoveryTest.cpp
index c38fa0b4cb25..e95513eb2841 100644
--- a/llvm/unittests/Support/CrashRecoveryTest.cpp
+++ b/llvm/unittests/Support/CrashRecoveryTest.cpp
@@ -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);


        


More information about the llvm-branch-commits mailing list