event: Fix watchdog types
diff --git a/src/sdeventplus/event.cpp b/src/sdeventplus/event.cpp
index 96d4190..64dc7ee 100644
--- a/src/sdeventplus/event.cpp
+++ b/src/sdeventplus/event.cpp
@@ -108,14 +108,13 @@
return r;
}
-int Event::exit(int code) const
+void Event::exit(int code) const
{
int r = sdevent->sd_event_exit(event.get(), code);
if (r < 0)
{
throw SdEventError(-r, "sd_event_exit");
}
- return r;
}
int Event::get_exit_code() const
@@ -129,7 +128,7 @@
return code;
}
-int Event::get_watchdog() const
+bool Event::get_watchdog() const
{
int r = sdevent->sd_event_get_watchdog(event.get());
if (r < 0)
@@ -139,7 +138,7 @@
return r;
}
-int Event::set_watchdog(int b) const
+bool Event::set_watchdog(bool b) const
{
int r = sdevent->sd_event_set_watchdog(event.get(), b);
if (r < 0)
diff --git a/src/sdeventplus/event.hpp b/src/sdeventplus/event.hpp
index 2a24161..bcb89fe 100644
--- a/src/sdeventplus/event.hpp
+++ b/src/sdeventplus/event.hpp
@@ -134,7 +134,7 @@
* @return 'true' if the watchdog is supported and enabled
* 'false' otherwise
*/
- int get_watchdog() const;
+ bool get_watchdog() const;
/** @brief Sets the state of the event loop watchdog
*
@@ -143,7 +143,7 @@
* @return 'true' if the watchdog is supported and enabled
* 'false' otherwise
*/
- int set_watchdog(int b) const;
+ bool set_watchdog(bool b) const;
private:
const internal::SdEvent* sdevent;
diff --git a/test/event.cpp b/test/event.cpp
index f5547ae..a9b6439 100644
--- a/test/event.cpp
+++ b/test/event.cpp
@@ -205,15 +205,11 @@
TEST_F(EventMethodTest, ExitSuccess)
{
EXPECT_CALL(mock, sd_event_exit(expected_event, 0)).WillOnce(Return(2));
- EXPECT_EQ(2, event->exit(0));
-}
-
-TEST_F(EventMethodTest, ExitUserError)
-{
- const int user_error = 10;
- EXPECT_CALL(mock, sd_event_exit(expected_event, user_error))
- .WillOnce(Return(user_error));
- EXPECT_EQ(user_error, event->exit(user_error));
+ event->exit(0);
+ EXPECT_CALL(mock, sd_event_exit(expected_event, 0)).WillOnce(Return(0));
+ event->exit(0);
+ EXPECT_CALL(mock, sd_event_exit(expected_event, 10)).WillOnce(Return(0));
+ event->exit(10);
}
TEST_F(EventMethodTest, ExitInternalError)
@@ -245,11 +241,11 @@
{
EXPECT_CALL(mock, sd_event_get_watchdog(expected_event))
.WillOnce(Return(0));
- EXPECT_EQ(0, event->get_watchdog());
+ EXPECT_FALSE(event->get_watchdog());
EXPECT_CALL(mock, sd_event_get_watchdog(expected_event))
.WillOnce(Return(2));
- EXPECT_EQ(2, event->get_watchdog());
+ EXPECT_TRUE(event->get_watchdog());
}
TEST_F(EventMethodTest, GetWatchdogError)
@@ -261,13 +257,20 @@
TEST_F(EventMethodTest, SetWatchdogSuccess)
{
- EXPECT_CALL(mock, sd_event_set_watchdog(expected_event, 0))
+ // Disable
+ EXPECT_CALL(mock, sd_event_set_watchdog(expected_event, false))
.WillOnce(Return(0));
- EXPECT_EQ(0, event->set_watchdog(0));
+ EXPECT_FALSE(event->set_watchdog(false));
- EXPECT_CALL(mock, sd_event_set_watchdog(expected_event, 1))
+ // Enable but not supported
+ EXPECT_CALL(mock, sd_event_set_watchdog(expected_event, true))
+ .WillOnce(Return(0));
+ EXPECT_FALSE(event->set_watchdog(true));
+
+ // Enabled and supported
+ EXPECT_CALL(mock, sd_event_set_watchdog(expected_event, true))
.WillOnce(Return(2));
- EXPECT_EQ(2, event->set_watchdog(1));
+ EXPECT_TRUE(event->set_watchdog(true));
}
TEST_F(EventMethodTest, SetWatchdogError)