test: Add sources of static PNOR
Add sources in static dir to test.
It generates a link error about duplcated GardReset::reset().
Then an issue is found that GardReset::~GardReset() is not virtual,
this will casuse the destructor not calling its super class' dtor.
To fix the above link error, add GardReset[Ubi|Static] to make
ubi/static specific implementation in its own class.
Tested: Verify the test build works fine.
Change-Id: I41bd4d522e8b9c4053283c0cf4373807ef4f2d1c
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/item_updater.hpp b/item_updater.hpp
index e27cccc..3260003 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -52,13 +52,13 @@
bus.emit_interfaces_added(path.c_str(), interfaces);
}
- ~GardReset()
+ virtual ~GardReset()
{
std::vector<std::string> interfaces({interface});
bus.emit_interfaces_removed(path.c_str(), interfaces);
}
- private:
+ protected:
// TODO Remove once openbmc/openbmc#1975 is resolved
static constexpr auto interface = "xyz.openbmc_project.Common.FactoryReset";
sdbusplus::bus::bus& bus;
@@ -67,7 +67,7 @@
/**
* @brief GARD factory reset - clears the PNOR GARD partition.
*/
- void reset() override;
+ virtual void reset() = 0;
};
/** @class ItemUpdater
diff --git a/static/item_updater_static.cpp b/static/item_updater_static.cpp
index e4708dd..fe872f0 100644
--- a/static/item_updater_static.cpp
+++ b/static/item_updater_static.cpp
@@ -364,7 +364,7 @@
ItemUpdater::updateFunctionalAssociation(versionId);
}
-void GardReset::reset()
+void GardResetStatic::reset()
{
// Clear gard partition
std::vector<uint8_t> mboxdArgs;
diff --git a/static/item_updater_static.hpp b/static/item_updater_static.hpp
index c3f273d..40f616b 100644
--- a/static/item_updater_static.hpp
+++ b/static/item_updater_static.hpp
@@ -9,6 +9,19 @@
namespace updater
{
+class GardResetStatic : public GardReset
+{
+ public:
+ using GardReset::GardReset;
+ virtual ~GardResetStatic() = default;
+
+ protected:
+ /**
+ * @brief GARD factory reset - clears the PNOR GARD partition.
+ */
+ void reset() override;
+};
+
/** @class ItemUpdaterStatic
* @brief Manages the activation of the host version items for static layout
*/
@@ -19,7 +32,7 @@
ItemUpdater(bus, path)
{
processPNORImage();
- gardReset = std::make_unique<GardReset>(bus, GARD_PATH);
+ gardReset = std::make_unique<GardResetStatic>(bus, GARD_PATH);
volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);
// Emit deferred signal.
diff --git a/test/Makefile.am b/test/Makefile.am
index b58ac66..e0a13f5 100755
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -38,8 +38,9 @@
../ubi/item_updater_ubi.cpp \
../ubi/serialize.cpp \
../ubi/watch.cpp \
+ ../static/item_updater_static.cpp \
+ ../static/activation_static.cpp \
utest.cpp \
msl_verify.cpp
-utest_LDADD = \
- -lstdc++fs
+utest_LDADD = -lstdc++fs
diff --git a/ubi/item_updater_ubi.cpp b/ubi/item_updater_ubi.cpp
index 61a8e01..cf8ffe0 100644
--- a/ubi/item_updater_ubi.cpp
+++ b/ubi/item_updater_ubi.cpp
@@ -419,7 +419,7 @@
return target.substr(PNOR_RO_PREFIX_LEN);
}
-void GardReset::reset()
+void GardResetUbi::reset()
{
// The GARD partition is currently misspelled "GUARD." This file path will
// need to be updated in the future.
diff --git a/ubi/item_updater_ubi.hpp b/ubi/item_updater_ubi.hpp
index ce1b5b8..fb6a6ca 100644
--- a/ubi/item_updater_ubi.hpp
+++ b/ubi/item_updater_ubi.hpp
@@ -9,6 +9,19 @@
namespace updater
{
+class GardResetUbi : public GardReset
+{
+ public:
+ using GardReset::GardReset;
+ virtual ~GardResetUbi() = default;
+
+ protected:
+ /**
+ * @brief GARD factory reset - clears the PNOR GARD partition.
+ */
+ void reset() override;
+};
+
/** @class ItemUpdaterUbi
* @brief Manages the activation of the host version items for ubi layout
*/
@@ -19,7 +32,7 @@
ItemUpdater(bus, path)
{
processPNORImage();
- gardReset = std::make_unique<GardReset>(bus, GARD_PATH);
+ gardReset = std::make_unique<GardResetUbi>(bus, GARD_PATH);
volatileEnable = std::make_unique<ObjectEnable>(bus, volatilePath);
// Emit deferred signal.