regulators: Allow empty expected VPD value
Modify the compare_vpd action to support specifying an empty string or
empty byte vector as the expected keyword value.
The VPD service was modified in a previous commit to return an empty
keyword value if the VPD interface or keyword does not exist on the
specified D-Bus object path. Thus, the actual keyword value may be
empty.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>
Change-Id: If48ab6423c40e5b24d6cff72264dc2efe750c85f
diff --git a/phosphor-regulators/test/config_file_parser_tests.cpp b/phosphor-regulators/test/config_file_parser_tests.cpp
index 38bee22..f477d41 100644
--- a/phosphor-regulators/test/config_file_parser_tests.cpp
+++ b/phosphor-regulators/test/config_file_parser_tests.cpp
@@ -1138,7 +1138,7 @@
TEST(ConfigFileParserTests, ParseCompareVPD)
{
- // Test where works, using "value"
+ // Test where works: value property: Not empty
{
const json element = R"(
{
@@ -1156,7 +1156,24 @@
(std::vector<uint8_t>{0x32, 0x44, 0x33, 0x35}));
}
- // Test where works, using "byte_values"
+ // Test where works: value property: Empty
+ {
+ const json element = R"(
+ {
+ "fru": "system/chassis/disk_backplane",
+ "keyword": "CCIN",
+ "value": ""
+ }
+ )"_json;
+ std::unique_ptr<CompareVPDAction> action = parseCompareVPD(element);
+ EXPECT_EQ(
+ action->getFRU(),
+ "/xyz/openbmc_project/inventory/system/chassis/disk_backplane");
+ EXPECT_EQ(action->getKeyword(), "CCIN");
+ EXPECT_EQ(action->getValue(), (std::vector<uint8_t>{}));
+ }
+
+ // Test where works: byte_values property: Not empty
{
const json element = R"(
{
@@ -1173,6 +1190,23 @@
EXPECT_EQ(action->getValue(), (std::vector<uint8_t>{0x11, 0x22, 0x33}));
}
+ // Test where works: byte_values property: Empty
+ {
+ const json element = R"(
+ {
+ "fru": "system/chassis/disk_backplane",
+ "keyword": "CCIN",
+ "byte_values": []
+ }
+ )"_json;
+ std::unique_ptr<CompareVPDAction> action = parseCompareVPD(element);
+ EXPECT_EQ(
+ action->getFRU(),
+ "/xyz/openbmc_project/inventory/system/chassis/disk_backplane");
+ EXPECT_EQ(action->getKeyword(), "CCIN");
+ EXPECT_EQ(action->getValue(), (std::vector<uint8_t>{}));
+ }
+
// Test where fails: Element is not an object
try
{
@@ -1256,7 +1290,7 @@
"either value or byte_values");
}
- // Test where fails: both value and byte_value specified
+ // Test where fails: both value and byte_values specified
try
{
const json element = R"(