source/base: Support floating sources

This allows the source to stay attached to the event loop even if all of
the source handles are unreferenced.

Change-Id: I81e97674869ceba3e71479efa6ce38a67c0ba5c7
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/source/base.cpp b/test/source/base.cpp
index 43e70ff..1b2ed1e 100644
--- a/test/source/base.cpp
+++ b/test/source/base.cpp
@@ -426,6 +426,37 @@
     EXPECT_THROW(base->set_enabled(Enabled::OneShot), SdEventError);
 }
 
+TEST_F(BaseMethodTest, GetFloatingSuccess)
+{
+    EXPECT_CALL(mock, sd_event_source_get_floating(expected_source))
+        .WillOnce(Return(2));
+    EXPECT_TRUE(base->get_floating());
+    EXPECT_CALL(mock, sd_event_source_get_floating(expected_source))
+        .WillOnce(Return(0));
+    EXPECT_FALSE(base->get_floating());
+}
+
+TEST_F(BaseMethodTest, GetFloatingError)
+{
+    EXPECT_CALL(mock, sd_event_source_get_floating(expected_source))
+        .WillOnce(Return(-EINVAL));
+    EXPECT_THROW(base->get_floating(), SdEventError);
+}
+
+TEST_F(BaseMethodTest, SetFloatingSuccess)
+{
+    EXPECT_CALL(mock, sd_event_source_set_floating(expected_source, 1))
+        .WillOnce(Return(0));
+    base->set_floating(true);
+}
+
+TEST_F(BaseMethodTest, SetFloatingError)
+{
+    EXPECT_CALL(mock, sd_event_source_set_floating(expected_source, 1))
+        .WillOnce(Return(-EINVAL));
+    EXPECT_THROW(base->set_floating(true), SdEventError);
+}
+
 } // namespace
 } // namespace source
 } // namespace sdeventplus