psu-ng: Move test getUtils and freeUtils to cpp
While debugging an SDK build issue regarding optimization and
_FORTIFY_SORUCE, it was discovered that the tests for
phosphor-power-supply fail to link if meson is run with --buildtype
debugoptimized.
Tested:
Builds with --buildtype debug
Builds with --buildtype debugoptimized
Builds with --buildtype plain
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I095ecd83c85d5ed488f83cb3ede79c20701969a2
diff --git a/phosphor-power-supply/test/mock.cpp b/phosphor-power-supply/test/mock.cpp
index e13db2b..a68628b 100644
--- a/phosphor-power-supply/test/mock.cpp
+++ b/phosphor-power-supply/test/mock.cpp
@@ -1,4 +1,4 @@
-#include <mock.hpp>
+#include "mock.hpp"
namespace phosphor
{
@@ -10,6 +10,28 @@
{
return std::make_unique<MockedPMBus>();
}
-
} // namespace pmbus
+
+namespace power
+{
+namespace psu
+{
+static std::unique_ptr<MockedUtil> util;
+
+const UtilBase& getUtils()
+{
+ if (!util)
+ {
+ util = std::make_unique<MockedUtil>();
+ }
+ return *util;
+}
+
+void freeUtils()
+{
+ util.reset();
+}
+
+} // namespace psu
+} // namespace power
} // namespace phosphor