bios: Add a configuration parser for integer attribute
Add a configuration parser for integer attribute
and check the fields for string attribute
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: I3be56f4a64373fb442ef58ad9d6693ffb8994917
diff --git a/test/libpldmresponder_bios_test.cpp b/test/libpldmresponder_bios_test.cpp
index f667142..5bfbfb9 100644
--- a/test/libpldmresponder_bios_test.cpp
+++ b/test/libpldmresponder_bios_test.cpp
@@ -19,7 +19,6 @@
using namespace pldm::responder::bios;
using namespace pldm::responder::utils;
using namespace bios_parser;
-using namespace bios_parser::bios_enum;
TEST(epochToBCDTime, testTime)
{
@@ -56,11 +55,24 @@
{
using namespace bios_parser;
// All the BIOS Strings in the BIOS JSON config files.
- Strings vec{"HMCManagedState", "On", "Off",
- "FWBootSide", "Perm", "Temp",
- "InbandCodeUpdate", "Allowed", "NotAllowed",
- "CodeUpdatePolicy", "Concurrent", "Disruptive",
- "str_example1", "str_example2", "str_example3"};
+ Strings vec{"HMCManagedState",
+ "On",
+ "Off",
+ "FWBootSide",
+ "Perm",
+ "Temp",
+ "InbandCodeUpdate",
+ "Allowed",
+ "NotAllowed",
+ "CodeUpdatePolicy",
+ "Concurrent",
+ "Disruptive",
+ "VDD_AVSBUS_RAIL",
+ "SBE_IMAGE_MINIMUM_VALID_ECS",
+ "INTEGER_INVALID_CASE",
+ "str_example1",
+ "str_example2",
+ "str_example3"};
Strings nullVec{};
@@ -78,6 +90,7 @@
TEST(getAttrValue, enumScenarios)
{
+ using namespace bios_parser::bios_enum;
// All the BIOS Strings in the BIOS JSON config files.
AttrValuesMap valueMap{
{"HMCManagedState", {false, {"On", "Off"}, {"On"}}},
@@ -119,6 +132,21 @@
std::out_of_range);
}
+TEST(getAttrValue, integerScenarios)
+{
+ using namespace bios_parser::bios_integer;
+ AttrValuesMap valueMap{
+ {"VDD_AVSBUS_RAIL", {false, 0, 15, 1, 0}},
+ {"SBE_IMAGE_MINIMUM_VALID_ECS", {true, 1, 15, 1, 2}}};
+
+ auto values = getValues();
+ EXPECT_EQ(valueMap, values);
+ auto value = getAttrValue("SBE_IMAGE_MINIMUM_VALID_ECS");
+ EXPECT_EQ(value, 2);
+
+ EXPECT_THROW(getAttrValue("VDM"), std::out_of_range);
+}
+
TEST(traverseBIOSTable, attrTableScenarios)
{
std::vector<uint8_t> enumEntry{
@@ -396,7 +424,7 @@
req->table_type = PLDM_BIOS_ATTR_VAL_TABLE;
std::string attrName("CodeUpdatePolicy");
- CurrentValues currVals = getAttrValue(attrName);
+ bios_enum::CurrentValues currVals = bios_enum::getAttrValue(attrName);
size_t requestPayloadLength = requestPayload.size() - sizeof(pldm_msg_hdr);