Commit d3443853 authored by Robin Cheng's avatar Robin Cheng Committed by Facebook GitHub Bot

Fix TSAN for FunctionSchedulerTest.

Summary: The pthread_create redefinition also overrides the TSAN-specific pthread_create. This diff deletes this test because the test itself is of little value - see discussion in this diff.

Reviewed By: yfeldblum

Differential Revision: D22735273

fbshipit-source-id: a23089654697b85698f226b1110af3ed1a0b7fce
parent 66e9c658
...@@ -608,60 +608,6 @@ TEST(FunctionScheduler, cancelFunctionAndWait) { ...@@ -608,60 +608,6 @@ TEST(FunctionScheduler, cancelFunctionAndWait) {
fs.shutdown(); fs.shutdown();
} }
#if defined(__linux__)
namespace {
/**
* A helper class that forces our pthread_create() wrapper to fail when
* an PThreadCreateFailure object exists.
*/
class PThreadCreateFailure {
public:
PThreadCreateFailure() {
++forceFailure_;
}
~PThreadCreateFailure() {
--forceFailure_;
}
static bool shouldFail() {
return forceFailure_ > 0;
}
private:
static std::atomic<int> forceFailure_;
};
std::atomic<int> PThreadCreateFailure::forceFailure_{0};
} // namespace
// Replace the system pthread_create() function with our own stub, so we can
// trigger failures in the StartThrows() test.
extern "C" int pthread_create(
pthread_t* thread,
const pthread_attr_t* attr,
void* (*start_routine)(void*),
void* arg) {
static const auto realFunction = reinterpret_cast<decltype(&pthread_create)>(
dlsym(RTLD_NEXT, "pthread_create"));
// For sanity, make sure we didn't find ourself,
// since that would cause infinite recursion.
CHECK_NE(realFunction, pthread_create);
if (PThreadCreateFailure::shouldFail()) {
errno = EINVAL;
return -1;
}
return realFunction(thread, attr, start_routine, arg);
}
TEST(FunctionScheduler, StartThrows) {
FunctionScheduler fs;
PThreadCreateFailure fail;
EXPECT_ANY_THROW(fs.start());
EXPECT_NO_THROW(fs.shutdown());
}
#endif
TEST(FunctionScheduler, cancelAllFunctionsAndWait) { TEST(FunctionScheduler, cancelAllFunctionsAndWait) {
atomic<int> total{0}; atomic<int> total{0};
FunctionScheduler fs; FunctionScheduler fs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment