Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gloop/base/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,7 @@ cc_test(
":percpu",
":signal_util_subtle",
":time_support",
"//gloop:gloop_test_main",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/base:raw_logging_internal",
"@abseil-cpp//absl/flags:flag",
Expand Down
25 changes: 8 additions & 17 deletions gloop/base/signal_util_subtle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ void sa_alrm(int sig) {
class UtilInternalTest : public ::testing::Test {
protected:
static void SetUpTestSuite() {
// Add SIGALRM to blocked signals so that threads inherit and we can unblock
// on the main test thread. This avoids data races on variables shared
// between the test and the signal handler.
sigset_t blocked_signals;
CHECK_EQ(sigemptyset(&blocked_signals), 0);
CHECK_EQ(sigaddset(&blocked_signals, SIGALRM), 0);
CHECK_EQ(sigprocmask(SIG_BLOCK, &blocked_signals, nullptr), 0);

struct sigaction sig;

// Set up signal handler
Expand Down Expand Up @@ -588,20 +596,3 @@ TEST_F(UtilInternalTest, ScopedAffinityMask) {
}

} // namespace

int main(int argc, char** argv) {
// Add SIGALRM to blocked signals so that threads inherit and we can unblock
// on the main test thread. This avoids data races on variables shared between
// the test and the signal handler.
sigset_t blocked_signals;
CHECK_EQ(sigemptyset(&blocked_signals), 0);
CHECK_EQ(sigaddset(&blocked_signals, SIGALRM), 0);
CHECK_EQ(sigprocmask(SIG_BLOCK, &blocked_signals, nullptr), 0);
// Init and run tests.
::testing::InitGoogleTest(&argc, argv);
if (!benchmark::GetBenchmarkFilter().empty()) {
benchmark::RunSpecifiedBenchmarks();
exit(0);
}
return RUN_ALL_TESTS();
}
Loading