BIOS: Implement attribute table with type string
Construct attribute table with type string based on string table.
Tested:
Following are the tables constructed from the sample json file present at
"test/bios_jsons/
$ hexdump -C stringTable
00000000 00 00 07 00 41 6c 6c 6f 77 65 64 01 00 10 00 43 |....Allowed....C|
00000010 6f 64 65 55 70 64 61 74 65 50 6f 6c 69 63 79 02 |odeUpdatePolicy.|
00000020 00 0a 00 43 6f 6e 63 75 72 72 65 6e 74 03 00 0a |...Concurrent...|
00000030 00 44 69 73 72 75 70 74 69 76 65 04 00 0a 00 46 |.Disruptive....F|
00000040 57 42 6f 6f 74 53 69 64 65 05 00 0f 00 48 4d 43 |WBootSide....HMC|
00000050 4d 61 6e 61 67 65 64 53 74 61 74 65 06 00 10 00 |ManagedState....|
00000060 49 6e 62 61 6e 64 43 6f 64 65 55 70 64 61 74 65 |InbandCodeUpdate|
00000070 07 00 0a 00 4e 6f 74 41 6c 6c 6f 77 65 64 08 00 |....NotAllowed..|
00000080 03 00 4f 66 66 09 00 02 00 4f 6e 0a 00 04 00 50 |..Off....On....P|
00000090 65 72 6d 0b 00 04 00 54 65 6d 70 0c 00 0c 00 73 |erm....Temp....s|
000000a0 74 72 5f 65 78 61 6d 70 6c 65 31 0d 00 0c 00 73 |tr_example1....s|
000000b0 74 72 5f 65 78 61 6d 70 6c 65 32 0e 00 0c 00 73 |tr_example2....s|
000000c0 74 72 5f 65 78 61 6d 70 6c 65 33 00 6c 11 89 d4 |tr_example3.l...|
$ hexdump -C attributeTable
00000000 00 00 00 01 00 02 02 00 03 00 01 00 01 00 00 04 |................|
00000010 00 02 0a 00 0b 00 01 00 02 00 00 05 00 02 08 00 |................|
00000020 09 00 01 01 03 00 00 06 00 02 00 00 07 00 01 00 |................|
00000030 04 00 01 0c 00 01 01 00 64 00 03 00 61 62 63 05 |........d...abc.|
00000040 00 01 0d 00 02 00 00 64 00 00 00 06 00 01 0e 00 |.......d........|
00000050 00 01 00 64 00 02 00 65 66 00 00 00 72 ef 0c 2a |...d...ef...r..*|
Change-Id: I272c59b96b5aa14571d01eeeaccd504ca7ac168b
Signed-off-by: Carol Wang <wangkair@cn.ibm.com>
diff --git a/test/bios_jsons/string_attrs.json b/test/bios_jsons/string_attrs.json
new file mode 100644
index 0000000..6133412
--- /dev/null
+++ b/test/bios_jsons/string_attrs.json
@@ -0,0 +1,40 @@
+{
+ "entries" : [
+ {
+ "attribute_name" : "str_example1",
+ "string_type" : "ASCII",
+ "minimum_string_length" : 1,
+ "maximum_string_length" : 100,
+ "default_string_length" : 3,
+ "default_string" : "abc",
+ "dbus" : {
+ "object_path" : "/xyz/abc/def",
+ "interface" : "xyz.openbmc_project.str_example1.value",
+ "property_name" : "Str_example1",
+ "property_type" : "string"
+ }
+ },
+ {
+ "attribute_name" : "str_example2",
+ "string_type" : "Hex",
+ "minimum_string_length" : 0,
+ "maximum_string_length" : 100,
+ "default_string_length" : 0,
+ "default_string" : "",
+ "dbus" : {
+ "object_path" : "/xyz/abc/def",
+ "interface" : "xyz.openbmc_project.str_example2.value",
+ "property_name" : "Str_example2",
+ "property_type" : "string"
+ }
+ },
+ {
+ "attribute_name" : "str_example3",
+ "string_type" : "Unknown",
+ "minimum_string_length" : 1,
+ "maximum_string_length" : 100,
+ "default_string_length" : 2,
+ "default_string" : "ef"
+ }
+ ]
+}
diff --git a/test/libpldmresponder_bios_test.cpp b/test/libpldmresponder_bios_test.cpp
index b5b207b..d54ef2c 100644
--- a/test/libpldmresponder_bios_test.cpp
+++ b/test/libpldmresponder_bios_test.cpp
@@ -55,10 +55,11 @@
{
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"};
+ Strings vec{"HMCManagedState", "On", "Off",
+ "FWBootSide", "Perm", "Temp",
+ "InbandCodeUpdate", "Allowed", "NotAllowed",
+ "CodeUpdatePolicy", "Concurrent", "Disruptive",
+ "str_example1", "str_example2", "str_example3"};
Strings nullVec{};
@@ -67,6 +68,8 @@
ASSERT_EQ(strings == nullVec, true);
strings = bios_parser::getStrings("./bios_jsons");
+ std::sort(strings.begin(), strings.end());
+ std::sort(vec.begin(), vec.end());
ASSERT_EQ(strings == vec, true);
}