pldm: Removing default string length
Removing default string length from BIOS json configuration
files.
String BIOS attributes defined in BIOS configuration json file
contains "default_string_length". Providing default string length
manually is error prone. As String length can be calculated and
populated easily in the code, removing json support for
default_string_length.
Tested: Power on/off
Gtests passed.
Change-Id: I7604d8ccedd60a39ba07e1df67ff5712f31e7f6e
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/libpldmresponder/bios_string_attribute.cpp b/libpldmresponder/bios_string_attribute.cpp
index d52cdc4..d55c99a 100644
--- a/libpldmresponder/bios_string_attribute.cpp
+++ b/libpldmresponder/bios_string_attribute.cpp
@@ -33,8 +33,9 @@
stringInfo.minLength = entry.at("minimum_string_length");
stringInfo.maxLength = entry.at("maximum_string_length");
- stringInfo.defLength = entry.at("default_string_length");
stringInfo.defString = entry.at("default_string");
+ stringInfo.defLength =
+ static_cast<uint16_t>((stringInfo.defString).length());
pldm_bios_table_attr_entry_string_info info = {
0,
diff --git a/libpldmresponder/test/bios_jsons/bios_attrs.json b/libpldmresponder/test/bios_jsons/bios_attrs.json
index f02b788..0a4dd69 100644
--- a/libpldmresponder/test/bios_jsons/bios_attrs.json
+++ b/libpldmresponder/test/bios_jsons/bios_attrs.json
@@ -105,7 +105,6 @@
"string_type": "ASCII",
"minimum_string_length": 1,
"maximum_string_length": 100,
- "default_string_length": 3,
"default_string": "abc",
"readOnly": false,
"helpText": "str_example1 HelpText",
@@ -123,7 +122,6 @@
"string_type": "Hex",
"minimum_string_length": 0,
"maximum_string_length": 100,
- "default_string_length": 0,
"default_string": "",
"readOnly": false,
"helpText": "str_example2 HelpText",
@@ -141,7 +139,6 @@
"string_type": "Unknown",
"minimum_string_length": 1,
"maximum_string_length": 100,
- "default_string_length": 2,
"default_string": "ef",
"readOnly": true,
"helpText": "str_example3 HelpText",
diff --git a/libpldmresponder/test/libpldmresponder_bios_config_test.cpp b/libpldmresponder/test/libpldmresponder_bios_config_test.cpp
index 6e7c57a..5c0e779 100644
--- a/libpldmresponder/test/libpldmresponder_bios_config_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_bios_config_test.cpp
@@ -153,11 +153,10 @@
EXPECT_EQ(
stringField.maxLength,
jsonEntry->at("maximum_string_length").get<uint16_t>());
- EXPECT_EQ(
- stringField.defLength,
- jsonEntry->at("default_string_length").get<uint16_t>());
EXPECT_EQ(stringField.defString,
jsonEntry->at("default_string").get<std::string>());
+ EXPECT_EQ(stringField.defLength,
+ (stringField.defString).length());
break;
}
case PLDM_BIOS_INTEGER:
diff --git a/libpldmresponder/test/libpldmresponder_bios_string_attribute_test.cpp b/libpldmresponder/test/libpldmresponder_bios_string_attribute_test.cpp
index c945a68..daeec13 100644
--- a/libpldmresponder/test/libpldmresponder_bios_string_attribute_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_bios_string_attribute_test.cpp
@@ -33,7 +33,6 @@
"string_type" : "ASCII",
"minimum_string_length" : 1,
"maximum_string_length" : 100,
- "default_string_length" : 2,
"default_string" : "ef",
"readOnly" : true,
"helpText" : "HelpText",
@@ -51,25 +50,11 @@
EXPECT_EQ(stringInfo.defLength, 2);
EXPECT_EQ(stringInfo.defString, "ef");
- auto jsonStringReadOnlyError = R"( {
- "attribute_name" : "str_example3",
- "string_type" : "ASCII",
- "minimum_string_length" : 1,
- "maximum_string_length" : 100,
- "default_string" : "ef",
- "helpText" : "HelpText",
- "displayName" : "DisplayName"
- })"_json; // missing default_string_length
-
- EXPECT_THROW((BIOSStringAttribute{jsonStringReadOnlyError, nullptr}),
- Json::exception);
-
auto jsonStringReadWrite = R"({
"attribute_name" : "str_example1",
"string_type" : "ASCII",
"minimum_string_length" : 1,
"maximum_string_length" : 100,
- "default_string_length" : 3,
"default_string" : "abc",
"readOnly" : false,
"helpText" : "HelpText",
@@ -97,7 +82,6 @@
"string_type" : "ASCII",
"minimum_string_length" : 1,
"maximum_string_length" : 100,
- "default_string_length" : 3,
"default_string" : "abc",
"readOnly" : true,
"helpText" : "HelpText",
@@ -134,7 +118,6 @@
"string_type" : "ASCII",
"minimum_string_length" : 1,
"maximum_string_length" : 100,
- "default_string_length" : 3,
"default_string" : "abc",
"readOnly" : false,
"helpText" : "HelpText",
@@ -185,7 +168,6 @@
"string_type" : "ASCII",
"minimum_string_length" : 1,
"maximum_string_length" : 100,
- "default_string_length" : 3,
"default_string" : "abc",
"readOnly" : false,
"helpText" : "HelpText",
diff --git a/libpldmresponder/test/libpldmresponder_systemspecific_bios_test.cpp b/libpldmresponder/test/libpldmresponder_systemspecific_bios_test.cpp
index 6d80b9d..1b84204 100644
--- a/libpldmresponder/test/libpldmresponder_systemspecific_bios_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_systemspecific_bios_test.cpp
@@ -160,11 +160,10 @@
EXPECT_EQ(
stringField.maxLength,
jsonEntry->at("maximum_string_length").get<uint16_t>());
- EXPECT_EQ(
- stringField.defLength,
- jsonEntry->at("default_string_length").get<uint16_t>());
EXPECT_EQ(stringField.defString,
jsonEntry->at("default_string").get<std::string>());
+ EXPECT_EQ(stringField.defLength,
+ (stringField.defString).length());
break;
}
case PLDM_BIOS_INTEGER:
diff --git a/libpldmresponder/test/system_type1/bios_jsons/bios_attrs.json b/libpldmresponder/test/system_type1/bios_jsons/bios_attrs.json
index fc70a5f..7a1f120 100644
--- a/libpldmresponder/test/system_type1/bios_jsons/bios_attrs.json
+++ b/libpldmresponder/test/system_type1/bios_jsons/bios_attrs.json
@@ -105,7 +105,6 @@
"string_type": "ASCII",
"minimum_string_length": 1,
"maximum_string_length": 100,
- "default_string_length": 3,
"default_string": "abc",
"readOnly": false,
"helpText": "str_example1 HelpText",
@@ -123,7 +122,6 @@
"string_type": "Hex",
"minimum_string_length": 0,
"maximum_string_length": 200,
- "default_string_length": 0,
"default_string": "",
"readOnly": false,
"helpText": "str_example2 HelpText",
@@ -141,7 +139,6 @@
"string_type": "Unknown",
"minimum_string_length": 1,
"maximum_string_length": 100,
- "default_string_length": 2,
"default_string": "ef",
"readOnly": true,
"helpText": "str_example3 HelpText",