BIOS: UT for bios attribute tables with string type
In libpldmresponder_bios_test.cpp:
1. Modify some existing UTs to match new implemented types.
2. Add new class TestSingleTypeBIOSTable to test attribute value table
based on single type.
Tested:
/tmp/singleTypeBIOSTable.pnzuaS$ hexdump -C stringTable
00000000 0f 00 0c 00 73 74 72 5f 65 78 61 6d 70 6c 65 31 |....str_example1|
00000010 10 00 0c 00 73 74 72 5f 65 78 61 6d 70 6c 65 32 |....str_example2|
00000020 11 00 0c 00 73 74 72 5f 65 78 61 6d 70 6c 65 33 |....str_example3|
00000030 98 4c 55 cf |.LU.|
00000034
/tmp/singleTypeBIOSTable.pnzuaS$ hexdump -C attributeTable
00000000 07 00 01 0f 00 01 01 00 64 00 03 00 61 62 63 08 |........d...abc.|
00000010 00 01 10 00 02 00 00 64 00 00 00 09 00 01 11 00 |.......d........|
00000020 00 01 00 64 00 02 00 65 66 00 00 00 fb e0 7d 7f |...d...ef.....}.|
00000030
/tmp/singleTypeBIOSTable.pnzuaS$ hexdump -C attributeValueTable
00000000 09 00 01 02 00 65 66 00 6d 81 4a b6 |.....ef.m.J.|
Change-Id: I65316bcbd52c60d2671709632dd567aea0a52593
Signed-off-by: Carol Wang <wangkair@cn.ibm.com>
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index 6454052..8b37e35 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -761,13 +761,13 @@
{bios_parser::bIOSEnumJson, bios_type_enum::constructAttrTable},
{bios_parser::bIOSStrJson, bios_type_string::constructAttrTable}};
-using valueHandler = void (*)(const BIOSTable& BIOSAttributeTable,
+using valueHandler = std::function<void(const BIOSTable& BIOSAttributeTable,
- const BIOSTable& BIOSStringTable,
+ const BIOSTable& BIOSStringTable,
- Table& attributeTable);
+ Table& attributeTable)>;
-std::map<std::string, valueHandler> attrValueHandlers{
+std::map<BIOSJsonName, valueHandler> attrValueHandlers{
{bios_parser::bIOSEnumJson, bios_type_enum::constructAttrValueTable},
{bios_parser::bIOSStrJson, bios_type_string::constructAttrValueTable}};