[compiler-rt] [scudo] Add TEST_SKIP macro to skip the current test (PR #96192)

Fabio D'Urso via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 21 08:19:35 PDT 2024


https://github.com/fabio-d updated https://github.com/llvm/llvm-project/pull/96192

>From 3a5e975e1c74fdda9f1393830c781ad7b38a7ac1 Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <fdurso at google.com>
Date: Thu, 20 Jun 2024 15:10:15 +0200
Subject: [PATCH 1/2] [scudo] Add TEST_SKIP macro to skip the current test

---
 compiler-rt/lib/scudo/standalone/tests/scudo_unit_test.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test.h b/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test.h
index 4283416435ba0..f8b658c937889 100644
--- a/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test.h
+++ b/compiler-rt/lib/scudo/standalone/tests/scudo_unit_test.h
@@ -11,9 +11,14 @@
 #if SCUDO_FUCHSIA
 #include <zxtest/zxtest.h>
 using Test = ::zxtest::Test;
+#define TEST_SKIP(message) ZXTEST_SKIP(message)
 #else
 #include "gtest/gtest.h"
 using Test = ::testing::Test;
+#define TEST_SKIP(message)                                                     \
+  do {                                                                         \
+    GTEST_SKIP() << message;                                                   \
+  } while (0)
 #endif
 
 // If EXPECT_DEATH isn't defined, make it a no-op.

>From c4e4f959d742009242a6e971a61c5995a30c0012 Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <fdurso at google.com>
Date: Fri, 21 Jun 2024 17:17:29 +0200
Subject: [PATCH 2/2] Replace existing usages of GTEST_SKIP with the new
 TEST_SKIP

---
 compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp  | 6 +++---
 compiler-rt/lib/scudo/standalone/tests/strings_test.cpp | 2 +-
 compiler-rt/lib/scudo/standalone/tests/vector_test.cpp  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp b/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp
index 37a18858e67c2..0613847f1e203 100644
--- a/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/memtag_test.cpp
@@ -19,10 +19,10 @@ namespace scudo {
 
 TEST(MemtagBasicDeathTest, Unsupported) {
   if (archSupportsMemoryTagging())
-    GTEST_SKIP();
+    TEST_SKIP("Memory tagging is not supported");
   // Skip when running with HWASan.
   if (&__hwasan_init != 0)
-    GTEST_SKIP();
+    TEST_SKIP("Incompatible with HWASan");
 
   EXPECT_DEATH(archMemoryTagGranuleSize(), "not supported");
   EXPECT_DEATH(untagPointer((uptr)0), "not supported");
@@ -48,7 +48,7 @@ class MemtagTest : public Test {
 protected:
   void SetUp() override {
     if (!archSupportsMemoryTagging() || !systemDetectsMemoryTagFaultsTestOnly())
-      GTEST_SKIP() << "Memory tagging is not supported";
+      TEST_SKIP("Memory tagging is not supported");
 
     BufferSize = getPageSizeCached();
     ASSERT_FALSE(MemMap.isAllocated());
diff --git a/compiler-rt/lib/scudo/standalone/tests/strings_test.cpp b/compiler-rt/lib/scudo/standalone/tests/strings_test.cpp
index abb81803f65ee..2c0916d789202 100644
--- a/compiler-rt/lib/scudo/standalone/tests/strings_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/strings_test.cpp
@@ -147,7 +147,7 @@ TEST(ScudoStringsTest, CapacityIncreaseFails) {
                  MAP_ALLOWNOMEM)) {
     MemMap.unmap(MemMap.getBase(), MemMap.getCapacity());
     setrlimit(RLIMIT_AS, &Limit);
-    GTEST_SKIP() << "Limiting address space does not prevent mmap.";
+    TEST_SKIP("Limiting address space does not prevent mmap.");
   }
 
   // Test requires that the default length is at least 6 characters.
diff --git a/compiler-rt/lib/scudo/standalone/tests/vector_test.cpp b/compiler-rt/lib/scudo/standalone/tests/vector_test.cpp
index b612676b7bd79..1547824c11763 100644
--- a/compiler-rt/lib/scudo/standalone/tests/vector_test.cpp
+++ b/compiler-rt/lib/scudo/standalone/tests/vector_test.cpp
@@ -64,7 +64,7 @@ TEST(ScudoVectorTest, ReallocateFails) {
                  MAP_ALLOWNOMEM)) {
     MemMap.unmap(MemMap.getBase(), MemMap.getCapacity());
     setrlimit(RLIMIT_AS, &Limit);
-    GTEST_SKIP() << "Limiting address space does not prevent mmap.";
+    TEST_SKIP("Limiting address space does not prevent mmap.");
   }
 
   V.resize(capacity);



More information about the llvm-commits mailing list