summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2019-03-01 16:03:53 +0800
committerLei YU <mine260309@gmail.com>2019-03-13 11:01:53 +0800
commit716de5b8e3867fb829a2c1e39ade2b8f6aa1fa39 (patch)
tree800b067a0ede4da694731fa2ada022d12da9da5f
parented1c1dc53ef867a24a57a692334c24506dd470c6 (diff)
downloadopenpower-pnor-code-mgmt-716de5b8e3867fb829a2c1e39ade2b8f6aa1fa39.tar.gz
openpower-pnor-code-mgmt-716de5b8e3867fb829a2c1e39ade2b8f6aa1fa39.zip
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>
-rw-r--r--item_updater.hpp6
-rw-r--r--static/item_updater_static.cpp2
-rw-r--r--static/item_updater_static.hpp15
-rwxr-xr-xtest/Makefile.am5
-rw-r--r--ubi/item_updater_ubi.cpp2
-rw-r--r--ubi/item_updater_ubi.hpp15
6 files changed, 36 insertions, 9 deletions
diff --git a/item_updater.hpp b/item_updater.hpp
index e27cccc79..326000321 100644
--- a/item_updater.hpp
+++ b/item_updater.hpp
@@ -52,13 +52,13 @@ class GardReset : public GardResetInherit
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 @@ class GardReset : public GardResetInherit
/**
* @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 e4708ddee..fe872f0ae 100644
--- a/static/item_updater_static.cpp
+++ b/static/item_updater_static.cpp
@@ -364,7 +364,7 @@ void ItemUpdaterStatic::updateFunctionalAssociation(
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 c3f273d37..40f616bcb 100644
--- a/static/item_updater_static.hpp
+++ b/static/item_updater_static.hpp
@@ -9,6 +9,19 @@ namespace software
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 @@ class ItemUpdaterStatic : public ItemUpdater
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 b58ac6647..e0a13f50d 100755
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -38,8 +38,9 @@ utest_SOURCES = \
../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 61a8e0156..cf8ffe0f9 100644
--- a/ubi/item_updater_ubi.cpp
+++ b/ubi/item_updater_ubi.cpp
@@ -419,7 +419,7 @@ std::string ItemUpdaterUbi::determineId(const std::string& symlinkPath)
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 ce1b5b87d..fb6a6ca9c 100644
--- a/ubi/item_updater_ubi.hpp
+++ b/ubi/item_updater_ubi.hpp
@@ -9,6 +9,19 @@ namespace software
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 @@ class ItemUpdaterUbi : public ItemUpdater
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.
OpenPOWER on IntegriCloud