mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
81aa1a31a4
Summary: Ensure that we ignore SIGPIPE in unit tests. The `FuseChannel::requestSessionExit()` function sends SIGPIPE to its worker threads, and expects this to wake up the worker threads if they are stuck inside a read() call. In normal program builds folly/Subprocess.cpp causes SIGPIPE to be ignored on startup. However, Subprocess.cpp is not necessarily linked into all of our unit tests. I haven't tracked down exactly why, but SIGPIPE in the unit tests seems to kill the entire process only in opt-ubsan builds. In the future we probably should clean up how requestSessionExit() triggers its worker threads to exit: the current code is still potentially racy, since the worker threads could receive the SIGPIPE just after checking `sessionFinished_` and before calling `read()`, in which case they may go back to sleep rather than exiting. However for now this should be a simple fix to get the tests passing in all build modes. Reviewed By: wez Differential Revision: D7224370 fbshipit-source-id: a56fe3331fc5aa6a49ccbe6b0678b479a44ffc07
26 lines
748 B
C++
26 lines
748 B
C++
/*
|
|
* Copyright (c) 2004-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
*/
|
|
#include <folly/experimental/logging/Init.h>
|
|
#include <folly/init/Init.h>
|
|
#include <gtest/gtest.h>
|
|
|
|
DEFINE_string(logging, "", "folly::logging configuration");
|
|
|
|
int main(int argc, char* argv[]) {
|
|
testing::InitGoogleTest(&argc, argv);
|
|
folly::init(&argc, &argv);
|
|
folly::initLogging(FLAGS_logging);
|
|
|
|
// The FuseChannel code sends SIGPIPE and expects it to be ignored.
|
|
::signal(SIGPIPE, SIG_IGN);
|
|
|
|
return RUN_ALL_TESTS();
|
|
}
|