Add unit test for full FRU decode
To start refactoring this, it is helpful if we have a representative
unit test that decodes a full FRU.
To simplify this, the internal interfaces have been updated to support
passing values by std::span<const uint8_t> instead of by reference to
std::vector.
Tested: Unit tests pass
Change-Id: If8a618969b99d3d8a32bc7203aa2f57d0f999bdf
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/test/test_fru-utils.cpp b/test/test_fru-utils.cpp
index 70330a7..19aff02 100644
--- a/test/test_fru-utils.cpp
+++ b/test/test_fru-utils.cpp
@@ -4,8 +4,12 @@
#include <array>
#include <iterator>
+#include "gmock/gmock.h"
#include "gtest/gtest.h"
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
+
extern "C"
{
// Include for I2C_SMBUS_BLOCK_MAX
@@ -389,3 +393,45 @@
EXPECT_TRUE(findFRUHeader(reader, "error", blockData, offset));
EXPECT_EQ(0x6000, offset);
}
+
+TEST(formatIPMIFRU, FullDecode)
+{
+ const std::array<uint8_t, 176> bmcFru = {
+ 0x01, 0x00, 0x00, 0x01, 0x0b, 0x00, 0x00, 0xf3, 0x01, 0x0a, 0x19, 0x1f,
+ 0x0f, 0xe6, 0xc6, 0x4e, 0x56, 0x49, 0x44, 0x49, 0x41, 0xc5, 0x50, 0x33,
+ 0x38, 0x30, 0x39, 0xcd, 0x31, 0x35, 0x38, 0x33, 0x33, 0x32, 0x34, 0x38,
+ 0x30, 0x30, 0x31, 0x35, 0x30, 0xd2, 0x36, 0x39, 0x39, 0x2d, 0x31, 0x33,
+ 0x38, 0x30, 0x39, 0x2d, 0x30, 0x34, 0x30, 0x34, 0x2d, 0x36, 0x30, 0x30,
+ 0xc0, 0x01, 0x01, 0xd6, 0x4d, 0x41, 0x43, 0x3a, 0x20, 0x33, 0x43, 0x3a,
+ 0x36, 0x44, 0x3a, 0x36, 0x36, 0x3a, 0x31, 0x34, 0x3a, 0x43, 0x38, 0x3a,
+ 0x37, 0x41, 0xc1, 0x3b, 0x01, 0x09, 0x19, 0xc6, 0x4e, 0x56, 0x49, 0x44,
+ 0x49, 0x41, 0xc9, 0x50, 0x33, 0x38, 0x30, 0x39, 0x2d, 0x42, 0x4d, 0x43,
+ 0xd2, 0x36, 0x39, 0x39, 0x2d, 0x31, 0x33, 0x38, 0x30, 0x39, 0x2d, 0x30,
+ 0x34, 0x30, 0x34, 0x2d, 0x36, 0x30, 0x30, 0xc4, 0x41, 0x45, 0x2e, 0x31,
+ 0xcd, 0x31, 0x35, 0x38, 0x33, 0x33, 0x32, 0x34, 0x38, 0x30, 0x30, 0x31,
+ 0x35, 0x30, 0xc0, 0xc4, 0x76, 0x30, 0x2e, 0x31, 0xc1, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xb4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ boost::container::flat_map<std::string, std::string> result;
+ ASSERT_EQ(formatIPMIFRU(bmcFru, result), resCodes::resOK);
+
+ EXPECT_THAT(
+ result,
+ UnorderedElementsAre(
+ Pair("BOARD_FRU_VERSION_ID", ""), Pair("BOARD_INFO_AM1", "01"),
+ Pair("BOARD_INFO_AM2", "MAC: 3C:6D:66:14:C8:7A"),
+ Pair("BOARD_LANGUAGE_CODE", "25"),
+ Pair("BOARD_MANUFACTURER", "NVIDIA"),
+ Pair("BOARD_MANUFACTURE_DATE", "20240831T055100Z"),
+ Pair("BOARD_PART_NUMBER", "699-13809-0404-600"),
+ Pair("BOARD_PRODUCT_NAME", "P3809"),
+ Pair("BOARD_SERIAL_NUMBER", "1583324800150"),
+ Pair("Common_Format_Version", "1"), Pair("PRODUCT_ASSET_TAG", ""),
+ Pair("PRODUCT_FRU_VERSION_ID", "v0.1"),
+ Pair("PRODUCT_LANGUAGE_CODE", "25"),
+ Pair("PRODUCT_MANUFACTURER", "NVIDIA"),
+ Pair("PRODUCT_PART_NUMBER", "699-13809-0404-600"),
+ Pair("PRODUCT_PRODUCT_NAME", "P3809-BMC"),
+ Pair("PRODUCT_SERIAL_NUMBER", "1583324800150"),
+ Pair("PRODUCT_VERSION", "AE.1")));
+}