Skip to content

Commit 14b9fce

Browse files
yfeldblummeta-codesync[bot]
authored andcommitted
preprocess away vs skipping in folly/logging/test/AsyncFileWriterTest.cpp
Summary: Skips are intended for runtime failures. But the relevant conditions are detectable at preprocessing time. Reviewed By: lexprfuncall Differential Revision: D85513034 fbshipit-source-id: 82c706519d48481ae81a9f4d3a8e849ed1a1a765
1 parent 0b67fd7 commit 14b9fce

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

third-party/folly/src/folly/logging/test/AsyncFileWriterTest.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -629,14 +629,16 @@ TEST(AsyncFileWriter, discard) {
629629
AsyncFileWriter::setDiscardCallback(nullptr);
630630
}
631631

632-
#ifndef _WIN32
632+
#if !defined(_WIN32) && FOLLY_HAVE_PTHREAD_ATFORK && !FOLLY_SANITIZE_THREAD
633+
633634
/**
634635
* Test that AsyncFileWriter operates correctly after a fork() in both the
635636
* parent and child processes.
637+
*
638+
* Requires pthread_atfork. Not supported for TSAN.
636639
*/
637640
TEST(AsyncFileWriter, fork) {
638-
#if FOLLY_HAVE_PTHREAD_ATFORK
639-
SKIP_IF(folly::kIsSanitizeThread) << "Not supported for TSAN";
641+
static_assert(!kIsWindows && !kIsSanitizeThread);
640642

641643
TemporaryFile tmpFile{"logging_test"};
642644

@@ -737,9 +739,6 @@ TEST(AsyncFileWriter, fork) {
737739
EXPECT_THAT(data, HasSubstr(folly::to<std::string>("parent", n, "\n")));
738740
EXPECT_THAT(data, HasSubstr(folly::to<std::string>("child", n, "\n")));
739741
}
740-
#else
741-
SKIP() << "pthread_atfork() is not supported on this platform";
742-
#endif // FOLLY_HAVE_PTHREAD_ATFORK
743742
}
744743

745744
/**
@@ -748,10 +747,11 @@ TEST(AsyncFileWriter, fork) {
748747
*
749748
* This exercises the synchronization around registration of the AtFork
750749
* handlers and the creation/destruction of the AsyncFileWriter I/O thread.
750+
*
751+
* Requires pthread_atfork. Not supported for TSAN.
751752
*/
752753
TEST(AsyncFileWriter, crazyForks) {
753-
#if FOLLY_HAVE_PTHREAD_ATFORK
754-
SKIP_IF(folly::kIsSanitizeThread) << "Not supported for TSAN";
754+
static_assert(!kIsWindows && !kIsSanitizeThread);
755755

756756
constexpr size_t numAsyncWriterThreads = 10;
757757
constexpr size_t numForkThreads = 5;
@@ -827,8 +827,7 @@ TEST(AsyncFileWriter, crazyForks) {
827827
for (auto& t : asyncWriterThreads) {
828828
t.join();
829829
}
830-
#else
831-
SKIP() << "pthread_atfork() is not supported on this platform";
832-
#endif // FOLLY_HAVE_PTHREAD_ATFORK
833830
}
834-
#endif // !_WIN32
831+
832+
#endif // !defined(_WIN32) && FOLLY_HAVE_PTHREAD_ATFORK &&
833+
// !FOLLY_SANITIZE_THREAD

0 commit comments

Comments
 (0)