[llvm] 206343f - [RGT] Disable some tests on Windows at compile-time, not runtime

Paul Robinson via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 9 10:06:00 PDT 2021


Author: Paul Robinson
Date: 2021-04-09T10:05:47-07:00
New Revision: 206343f319da2ac7a6dfab7f35559edadc06d77d

URL: https://github.com/llvm/llvm-project/commit/206343f319da2ac7a6dfab7f35559edadc06d77d
DIFF: https://github.com/llvm/llvm-project/commit/206343f319da2ac7a6dfab7f35559edadc06d77d.diff

LOG: [RGT] Disable some tests on Windows at compile-time, not runtime

These show up as un-executed on non-Windows hosts.

Found by the Rotten Green Tests project.

Added: 
    

Modified: 
    llvm/unittests/Support/ThreadPool.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/Support/ThreadPool.cpp b/llvm/unittests/Support/ThreadPool.cpp
index 6cc62f37d2d5e..30a8924d16c4b 100644
--- a/llvm/unittests/Support/ThreadPool.cpp
+++ b/llvm/unittests/Support/ThreadPool.cpp
@@ -47,14 +47,6 @@ class ThreadPoolTest : public testing::Test {
     return false;
   }
 
-  bool isWindows() {
-    // FIXME: Skip some tests below on non-Windows because multi-socket systems
-    // were not fully tested on Unix yet, and llvm::get_thread_affinity_mask()
-    // isn't implemented for Unix.
-    Triple Host(Triple::normalize(sys::getProcessTriple()));
-    return Host.isOSWindows();
-  }
-
   ThreadPoolTest() {
     // Add unsupported configuration here, example:
     //   UnsupportedArchs.push_back(Triple::x86_64);
@@ -94,12 +86,6 @@ class ThreadPoolTest : public testing::Test {
       return;                                                                  \
   } while (0);
 
-#define SKIP_NON_WINDOWS()                                                     \
-  do {                                                                         \
-    if (!isWindows())                                                          \
-      return;                                                                  \
-  } while (0);
-
 TEST_F(ThreadPoolTest, AsyncBarrier) {
   CHECK_UNSUPPORTED();
   // test that async & barrier work together properly.
@@ -185,6 +171,11 @@ TEST_F(ThreadPoolTest, PoolDestruction) {
 
 #if LLVM_ENABLE_THREADS == 1
 
+// FIXME: Skip some tests below on non-Windows because multi-socket systems
+// were not fully tested on Unix yet, and llvm::get_thread_affinity_mask()
+// isn't implemented for Unix (need AffinityMask in Support/Unix/Program.inc).
+#ifdef _WIN32
+
 std::vector<llvm::BitVector>
 ThreadPoolTest::RunOnAllSockets(ThreadPoolStrategy S) {
   llvm::SetVector<llvm::BitVector> ThreadsUsed;
@@ -221,14 +212,12 @@ ThreadPoolTest::RunOnAllSockets(ThreadPoolStrategy S) {
 
 TEST_F(ThreadPoolTest, AllThreads_UseAllRessources) {
   CHECK_UNSUPPORTED();
-  SKIP_NON_WINDOWS();
   std::vector<llvm::BitVector> ThreadsUsed = RunOnAllSockets({});
   ASSERT_EQ(llvm::get_cpus(), ThreadsUsed.size());
 }
 
 TEST_F(ThreadPoolTest, AllThreads_OneThreadPerCore) {
   CHECK_UNSUPPORTED();
-  SKIP_NON_WINDOWS();
   std::vector<llvm::BitVector> ThreadsUsed =
       RunOnAllSockets(llvm::heavyweight_hardware_concurrency());
   ASSERT_EQ(llvm::get_cpus(), ThreadsUsed.size());
@@ -247,9 +236,6 @@ static cl::opt<std::string> ThreadPoolTestStringArg1("thread-pool-string-arg1");
 TEST_F(ThreadPoolTest, AffinityMask) {
   CHECK_UNSUPPORTED();
 
-  // FIXME: implement AffinityMask in Support/Unix/Program.inc
-  SKIP_NON_WINDOWS();
-
   // Skip this test if less than 4 threads are available.
   if (llvm::hardware_concurrency().compute_thread_count() < 4)
     return;
@@ -258,8 +244,10 @@ TEST_F(ThreadPoolTest, AffinityMask) {
   if (getenv("LLVM_THREADPOOL_AFFINITYMASK")) {
     std::vector<llvm::BitVector> ThreadsUsed = RunOnAllSockets({});
     // Ensure the threads only ran on CPUs 0-3.
+    // NOTE: Don't use ASSERT* here because this runs in a subprocess,
+    // and will show up as un-executed in the parent.
     for (auto &It : ThreadsUsed)
-      ASSERT_LT(It.getData().front(), 16UL);
+      assert(It.getData().front() < 16UL);
     return;
   }
   std::string Executable =
@@ -280,4 +268,5 @@ TEST_F(ThreadPoolTest, AffinityMask) {
   ASSERT_EQ(0, Ret);
 }
 
+#endif // #ifdef _WIN32
 #endif // #if LLVM_ENABLE_THREADS == 1


        


More information about the llvm-commits mailing list