Skip to content

Commit

Permalink
Add small sleeps since callbacks are now coming from a separate thread
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey committed Jul 26, 2024
1 parent 049d75c commit fc950a8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/SignalHandler_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// comments when upgrading to gz-cmake's "make codecheck"
#include "gz/common/SignalHandler.hh" // NOLINT(*)
#include <gtest/gtest.h> // NOLINT(*)
#include <chrono>
#include <csignal> // NOLINT(*)
#include <condition_variable> // NOLINT(*)
#include <map> // NOLINT(*)
Expand Down Expand Up @@ -79,6 +80,7 @@ TEST(SignalHandler, Single)
common::SignalHandler handler1;
EXPECT_TRUE(handler1.AddCallback(handler1Cb));
std::raise(SIGTERM);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
EXPECT_EQ(SIGTERM, gHandler1Sig);
}

Expand All @@ -98,6 +100,7 @@ TEST(SignalHandler, Multiple)

std::raise(SIGINT);

std::this_thread::sleep_for(std::chrono::milliseconds(1));
EXPECT_EQ(-1, gHandler1Sig);
EXPECT_EQ(-1, gHandler2Sig);

Expand Down

0 comments on commit fc950a8

Please sign in to comment.