drop default internal sys parameter

Long-term this will move to an externally defined sys implementation
library.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I0d882f6af872389be3a0fee5d70736813d3b2759
diff --git a/src/ipmiblob/internal/sys.cpp b/src/ipmiblob/internal/sys.cpp
index 71cd182..bfa37d8 100644
--- a/src/ipmiblob/internal/sys.cpp
+++ b/src/ipmiblob/internal/sys.cpp
@@ -67,7 +67,5 @@
     return ::poll(fds, nfds, timeout);
 }
 
-SysImpl sys_impl;
-
 } // namespace internal
 } // namespace ipmiblob
diff --git a/src/ipmiblob/internal/sys.hpp b/src/ipmiblob/internal/sys.hpp
index ba9bcbe..e80e0d8 100644
--- a/src/ipmiblob/internal/sys.hpp
+++ b/src/ipmiblob/internal/sys.hpp
@@ -57,8 +57,5 @@
     int poll(struct pollfd* fds, nfds_t nfds, int timeout) const override;
 };
 
-/** @brief Default instantiation of sys */
-extern SysImpl sys_impl;
-
 } // namespace internal
 } // namespace ipmiblob
diff --git a/src/ipmiblob/ipmi_handler.cpp b/src/ipmiblob/ipmi_handler.cpp
index 0d7c44e..81a70ca 100644
--- a/src/ipmiblob/ipmi_handler.cpp
+++ b/src/ipmiblob/ipmi_handler.cpp
@@ -36,7 +36,7 @@
 
 std::unique_ptr<IpmiInterface> IpmiHandler::CreateIpmiHandler()
 {
-    return std::make_unique<IpmiHandler>();
+    return std::make_unique<IpmiHandler>(std::make_unique<internal::SysImpl>());
 }
 
 void IpmiHandler::open()
diff --git a/src/ipmiblob/ipmi_handler.hpp b/src/ipmiblob/ipmi_handler.hpp
index 21d0fc7..e98231d 100644
--- a/src/ipmiblob/ipmi_handler.hpp
+++ b/src/ipmiblob/ipmi_handler.hpp
@@ -17,8 +17,8 @@
      */
     static std::unique_ptr<IpmiInterface> CreateIpmiHandler();
 
-    explicit IpmiHandler(const internal::Sys* sys = &internal::sys_impl) :
-        sys(sys){};
+    explicit IpmiHandler(std::unique_ptr<internal::Sys> sys) :
+        sys(std::move(sys)){};
 
     ~IpmiHandler() = default;
     IpmiHandler(const IpmiHandler&) = delete;
@@ -41,7 +41,7 @@
                    std::vector<std::uint8_t>& data) override;
 
   private:
-    const internal::Sys* sys;
+    const std::unique_ptr<internal::Sys> sys;
     /** TODO: Use a smart file descriptor when it's ready.  Until then only
      * allow moving this object.
      */
diff --git a/test/tools_ipmi_unittest.cpp b/test/tools_ipmi_unittest.cpp
index 7a5f6dd..872e08b 100644
--- a/test/tools_ipmi_unittest.cpp
+++ b/test/tools_ipmi_unittest.cpp
@@ -12,10 +12,11 @@
 TEST(IpmiHandlerTest, OpenAllFails)
 {
     /* Open against all device files fail. */
-    internal::InternalSysMock sysMock;
-    IpmiHandler ipmi(&sysMock);
+    std::unique_ptr<internal::InternalSysMock> sysMock =
+        std::make_unique<internal::InternalSysMock>();
+    EXPECT_CALL(*sysMock, open(_, _)).WillRepeatedly(Return(-1));
 
-    EXPECT_CALL(sysMock, open(_, _)).WillRepeatedly(Return(-1));
+    IpmiHandler ipmi(std::move(sysMock));
     EXPECT_THROW(ipmi.open(), IpmiException);
 }