Skip to content

Commit 206343f

Browse files
committed
[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.
1 parent 6ce76ff commit 206343f

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

llvm/unittests/Support/ThreadPool.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ class ThreadPoolTest : public testing::Test {
4747
return false;
4848
}
4949

50-
bool isWindows() {
51-
// FIXME: Skip some tests below on non-Windows because multi-socket systems
52-
// were not fully tested on Unix yet, and llvm::get_thread_affinity_mask()
53-
// isn't implemented for Unix.
54-
Triple Host(Triple::normalize(sys::getProcessTriple()));
55-
return Host.isOSWindows();
56-
}
57-
5850
ThreadPoolTest() {
5951
// Add unsupported configuration here, example:
6052
// UnsupportedArchs.push_back(Triple::x86_64);
@@ -94,12 +86,6 @@ class ThreadPoolTest : public testing::Test {
9486
return; \
9587
} while (0);
9688

97-
#define SKIP_NON_WINDOWS() \
98-
do { \
99-
if (!isWindows()) \
100-
return; \
101-
} while (0);
102-
10389
TEST_F(ThreadPoolTest, AsyncBarrier) {
10490
CHECK_UNSUPPORTED();
10591
// test that async & barrier work together properly.
@@ -185,6 +171,11 @@ TEST_F(ThreadPoolTest, PoolDestruction) {
185171

186172
#if LLVM_ENABLE_THREADS == 1
187173

174+
// FIXME: Skip some tests below on non-Windows because multi-socket systems
175+
// were not fully tested on Unix yet, and llvm::get_thread_affinity_mask()
176+
// isn't implemented for Unix (need AffinityMask in Support/Unix/Program.inc).
177+
#ifdef _WIN32
178+
188179
std::vector<llvm::BitVector>
189180
ThreadPoolTest::RunOnAllSockets(ThreadPoolStrategy S) {
190181
llvm::SetVector<llvm::BitVector> ThreadsUsed;
@@ -221,14 +212,12 @@ ThreadPoolTest::RunOnAllSockets(ThreadPoolStrategy S) {
221212

222213
TEST_F(ThreadPoolTest, AllThreads_UseAllRessources) {
223214
CHECK_UNSUPPORTED();
224-
SKIP_NON_WINDOWS();
225215
std::vector<llvm::BitVector> ThreadsUsed = RunOnAllSockets({});
226216
ASSERT_EQ(llvm::get_cpus(), ThreadsUsed.size());
227217
}
228218

229219
TEST_F(ThreadPoolTest, AllThreads_OneThreadPerCore) {
230220
CHECK_UNSUPPORTED();
231-
SKIP_NON_WINDOWS();
232221
std::vector<llvm::BitVector> ThreadsUsed =
233222
RunOnAllSockets(llvm::heavyweight_hardware_concurrency());
234223
ASSERT_EQ(llvm::get_cpus(), ThreadsUsed.size());
@@ -247,9 +236,6 @@ static cl::opt<std::string> ThreadPoolTestStringArg1("thread-pool-string-arg1");
247236
TEST_F(ThreadPoolTest, AffinityMask) {
248237
CHECK_UNSUPPORTED();
249238

250-
// FIXME: implement AffinityMask in Support/Unix/Program.inc
251-
SKIP_NON_WINDOWS();
252-
253239
// Skip this test if less than 4 threads are available.
254240
if (llvm::hardware_concurrency().compute_thread_count() < 4)
255241
return;
@@ -258,8 +244,10 @@ TEST_F(ThreadPoolTest, AffinityMask) {
258244
if (getenv("LLVM_THREADPOOL_AFFINITYMASK")) {
259245
std::vector<llvm::BitVector> ThreadsUsed = RunOnAllSockets({});
260246
// Ensure the threads only ran on CPUs 0-3.
247+
// NOTE: Don't use ASSERT* here because this runs in a subprocess,
248+
// and will show up as un-executed in the parent.
261249
for (auto &It : ThreadsUsed)
262-
ASSERT_LT(It.getData().front(), 16UL);
250+
assert(It.getData().front() < 16UL);
263251
return;
264252
}
265253
std::string Executable =
@@ -280,4 +268,5 @@ TEST_F(ThreadPoolTest, AffinityMask) {
280268
ASSERT_EQ(0, Ret);
281269
}
282270

271+
#endif // #ifdef _WIN32
283272
#endif // #if LLVM_ENABLE_THREADS == 1

0 commit comments

Comments
 (0)