Revamped code for VPD parser
The commit removes all the pre-existing code from the branch
and pushes the revamped code.
Major modification includes:
- Movement from multi exe to single daemon model.
- Multithreaded approach to parse FRU VPD.
- Better error handling.
- Refactored code for performance optimization.
Note: This code supports all the existing functionalities as it is.
Change-Id: I1ddce1f0725ac59020b72709689a1013643bda8b
Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
diff --git a/test/bono.vpd b/test/bono.vpd
deleted file mode 100644
index afc1b8e..0000000
--- a/test/bono.vpd
+++ /dev/null
Binary files differ
diff --git a/test/ipz_parser/parser.cpp b/test/ipz_parser/parser.cpp
deleted file mode 100644
index 0a36ad7..0000000
--- a/test/ipz_parser/parser.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-#include "ipz_parser.hpp"
-
-#include <const.hpp>
-#include <defines.hpp>
-#include <impl.hpp>
-#include <store.hpp>
-
-#include <cassert>
-#include <fstream>
-#include <iterator>
-
-#include <gtest/gtest.h>
-
-using namespace openpower::vpd;
-using namespace openpower::vpd::constants;
-
-constexpr uint32_t vpdOffset = 0;
-
-TEST(IpzVpdParserApp, vpdGoodPath)
-{
- // Create a vpd
- Binary vpd = {
- 0x00, 0x0f, 0x17, 0xba, 0x42, 0xca, 0x82, 0xd7, 0x7b, 0x77, 0x1e, 0x84,
- 0x28, 0x00, 0x52, 0x54, 0x04, 0x56, 0x48, 0x44, 0x52, 0x56, 0x44, 0x02,
- 0x30, 0x31, 0x50, 0x54, 0x0e, 0x56, 0x54, 0x4f, 0x43, 0xd5, 0x00, 0x37,
- 0x00, 0x4c, 0x00, 0x97, 0x05, 0x13, 0x00, 0x50, 0x46, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x84, 0x48, 0x00, 0x52, 0x54,
- 0x04, 0x56, 0x54, 0x4f, 0x43, 0x50, 0x54, 0x0e, 0x56, 0x49, 0x4e, 0x49,
- 0xd5, 0x00, 0x52, 0x00, 0x90, 0x00, 0x73, 0x05, 0x24, 0x00, 0x84, 0x8c,
- 0x00, 0x52, 0x54, 0x04, 0x56, 0x49, 0x4e, 0x49, 0x44, 0x52, 0x10, 0x41,
- 0x50, 0x53, 0x53, 0x20, 0x26, 0x20, 0x54, 0x50, 0x4d, 0x20, 0x20, 0x43,
- 0x41, 0x52, 0x44, 0x43, 0x45, 0x01, 0x31, 0x56, 0x5a, 0x02, 0x30, 0x31,
- 0x46, 0x4e, 0x07, 0x30, 0x31, 0x44, 0x48, 0x32, 0x30, 0x30, 0x50, 0x4e,
- 0x07, 0x30, 0x31, 0x44, 0x48, 0x32, 0x30, 0x31, 0x53, 0x4e, 0x0c, 0x59,
- 0x4c, 0x33, 0x30, 0x42, 0x47, 0x37, 0x43, 0x46, 0x30, 0x33, 0x50, 0x43,
- 0x43, 0x04, 0x36, 0x42, 0x36, 0x36, 0x50, 0x52, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x45, 0x04, 0x30, 0x30, 0x30, 0x31,
- 0x43, 0x54, 0x04, 0x40, 0xb8, 0x02, 0x03, 0x48, 0x57, 0x02, 0x00, 0x01,
- 0x42, 0x33, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x34, 0x01,
- 0x00, 0x42, 0x37, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x50, 0x46, 0x02, 0x00, 0x00, 0x78, 0x84, 0xdc,
- 0x00, 0x52, 0x54, 0x04};
-
- // call app for this vpd
- parser::Impl p(std::move(vpd), std::string{}, systemVpdFilePath, vpdOffset);
- Store vpdStore = p.run();
-
- static const std::string record = "VINI";
- static const std::string keyword = "DR";
-
- // TODO 2: Move this as an utility to store.hpp
- std::string dataFound;
- Parsed st_bin = vpdStore.getVpdMap();
-
- auto kw = st_bin.find(record);
- if (st_bin.end() != kw)
- {
- auto value = (kw->second).find(keyword);
- if ((kw->second).end() != value)
- {
- dataFound = value->second;
- }
- }
-
- ASSERT_EQ(dataFound, "APSS & TPM CARD");
-}
-
-TEST(IpzVpdParserApp, vpdBadPathEmptyVPD)
-{
- Binary vpd = {};
-
- // VPD is empty
- parser::Impl p(std::move(vpd), std::string{}, systemVpdFilePath, vpdOffset);
-
- // Expecting a throw here
- EXPECT_THROW(p.run(), std::runtime_error);
-}
-
-TEST(IpzVpdParserApp, vpdBadPathMissingHeader)
-{
- Binary vpd = {
- 0x00, 0x0f, 0x17, 0xba, 0x42, 0xca, 0x82, 0xd7, 0x7b, 0x77, 0x1e, 0x84,
- 0x28, 0x00, 0x52, 0x54, 0x04, 0x56, 0x48, 0x44, 0x52, 0x56, 0x44, 0x02,
- 0x30, 0x31, 0x50, 0x54, 0x0e, 0x56, 0x54, 0x4f, 0x43, 0xd5, 0x00, 0x37,
- 0x00, 0x4c, 0x00, 0x97, 0x05, 0x13, 0x00, 0x50, 0x46, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x84, 0x48, 0x00, 0x52, 0x54,
- 0x04, 0x56, 0x54, 0x4f, 0x43, 0x50, 0x54, 0x0e, 0x56, 0x49, 0x4e, 0x49,
- 0xd5, 0x00, 0x52, 0x00, 0x90, 0x00, 0x73, 0x05, 0x24, 0x00, 0x84, 0x8c,
- 0x00, 0x52, 0x54, 0x04, 0x56, 0x49, 0x4e, 0x49, 0x44, 0x52, 0x10, 0x41,
- 0x50, 0x53, 0x53, 0x20, 0x26, 0x20, 0x54, 0x50, 0x4d, 0x20, 0x20, 0x43,
- 0x41, 0x52, 0x44, 0x43, 0x45, 0x01, 0x31, 0x56, 0x5a, 0x02, 0x30, 0x31,
- 0x46, 0x4e, 0x07, 0x30, 0x31, 0x44, 0x48, 0x32, 0x30, 0x30, 0x50, 0x4e,
- 0x07, 0x30, 0x31, 0x44, 0x48, 0x32, 0x30, 0x31, 0x53, 0x4e, 0x0c, 0x59,
- 0x4c, 0x33, 0x30, 0x42, 0x47, 0x37, 0x43, 0x46, 0x30, 0x33, 0x50, 0x43,
- 0x43, 0x04, 0x36, 0x42, 0x36, 0x36, 0x50, 0x52, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x45, 0x04, 0x30, 0x30, 0x30, 0x31,
- 0x43, 0x54, 0x04, 0x40, 0xb8, 0x02, 0x03, 0x48, 0x57, 0x02, 0x00, 0x01,
- 0x42, 0x33, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x34, 0x01,
- 0x00, 0x42, 0x37, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x50, 0x46, 0x02, 0x00, 0x00, 0x78, 0x84, 0xdc,
- 0x00, 0x52, 0x54, 0x04};
-
- // corrupt the VHDR
- vpd[17] = 0x00;
-
- parser::Impl p(std::move(vpd), std::string{}, systemVpdFilePath, vpdOffset);
-
- // Expecting a throw here
- EXPECT_THROW(p.run(), std::runtime_error);
-}
-
-TEST(IpzVpdParserApp, vpdBadPathMissingVTOC)
-{
- Binary vpd = {
- 0x00, 0x0f, 0x17, 0xba, 0x42, 0xca, 0x82, 0xd7, 0x7b, 0x77, 0x1e, 0x84,
- 0x28, 0x00, 0x52, 0x54, 0x04, 0x56, 0x48, 0x44, 0x52, 0x56, 0x44, 0x02,
- 0x30, 0x31, 0x50, 0x54, 0x0e, 0x56, 0x54, 0x4f, 0x43, 0xd5, 0x00, 0x37,
- 0x00, 0x4c, 0x00, 0x97, 0x05, 0x13, 0x00, 0x50, 0x46, 0x08, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x84, 0x48, 0x00, 0x52, 0x54,
- 0x04, 0x56, 0x54, 0x4f, 0x43, 0x50, 0x54, 0x0e, 0x56, 0x49, 0x4e, 0x49,
- 0xd5, 0x00, 0x52, 0x00, 0x90, 0x00, 0x73, 0x05, 0x24, 0x00, 0x84, 0x8c,
- 0x00, 0x52, 0x54, 0x04, 0x56, 0x49, 0x4e, 0x49, 0x44, 0x52, 0x10, 0x41,
- 0x50, 0x53, 0x53, 0x20, 0x26, 0x20, 0x54, 0x50, 0x4d, 0x20, 0x20, 0x43,
- 0x41, 0x52, 0x44, 0x43, 0x45, 0x01, 0x31, 0x56, 0x5a, 0x02, 0x30, 0x31,
- 0x46, 0x4e, 0x07, 0x30, 0x31, 0x44, 0x48, 0x32, 0x30, 0x30, 0x50, 0x4e,
- 0x07, 0x30, 0x31, 0x44, 0x48, 0x32, 0x30, 0x31, 0x53, 0x4e, 0x0c, 0x59,
- 0x4c, 0x33, 0x30, 0x42, 0x47, 0x37, 0x43, 0x46, 0x30, 0x33, 0x50, 0x43,
- 0x43, 0x04, 0x36, 0x42, 0x36, 0x36, 0x50, 0x52, 0x08, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x45, 0x04, 0x30, 0x30, 0x30, 0x31,
- 0x43, 0x54, 0x04, 0x40, 0xb8, 0x02, 0x03, 0x48, 0x57, 0x02, 0x00, 0x01,
- 0x42, 0x33, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x34, 0x01,
- 0x00, 0x42, 0x37, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x50, 0x46, 0x02, 0x00, 0x00, 0x78, 0x84, 0xdc,
- 0x00, 0x52, 0x54, 0x04};
-
- // corrupt the VTOC
- vpd[61] = 0x00;
-
- parser::Impl p(std::move(vpd), std::string{}, systemVpdFilePath, vpdOffset);
-
- // Expecting a throw here
- EXPECT_THROW(p.run(), std::runtime_error);
-}
-
-int main(int argc, char** argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/test/keyword_vpd_parser_test/kw_vpd_test.cpp b/test/keyword_vpd_parser_test/kw_vpd_test.cpp
deleted file mode 100644
index dc05358..0000000
--- a/test/keyword_vpd_parser_test/kw_vpd_test.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-#include "keyword_vpd_parser.hpp"
-#include "store.hpp"
-#include "types.hpp"
-
-#include <exception>
-#include <fstream>
-
-#include <gtest/gtest.h>
-
-using namespace vpd::keyword::parser;
-using namespace openpower::vpd;
-using namespace openpower::vpd::inventory;
-using namespace std;
-
-class KeywordVpdParserTest : public ::testing::Test
-{
- protected:
- Binary keywordVpdVector;
- Binary bonoKwVpdVector;
-
- KeywordVpdParserTest()
- {
- // Open the kw VPD file in binary mode
- std::ifstream kwVpdFile("vpd.dat", std::ios::binary);
-
- // Read the content of the binary file into a vector
- keywordVpdVector.assign((std::istreambuf_iterator<char>(kwVpdFile)),
- std::istreambuf_iterator<char>());
- // Open the BONO type kw VPD file in binary mode
- std::ifstream bonoKwVpdFile("bono.vpd", std::ios::binary);
-
- // Read the content of the binary file into a vector
- bonoKwVpdVector.assign((std::istreambuf_iterator<char>(bonoKwVpdFile)),
- std::istreambuf_iterator<char>());
- }
-};
-
-TEST_F(KeywordVpdParserTest, GoodTestCase)
-{
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- KeywordVpdMap map1{
- pair<std::string, Binary>{"WI", {0x00}},
- pair<std::string, Binary>{"FL", {0x50, 0x32, 0x20, 0x20, 0x20}},
- pair<std::string, Binary>{
- "SM",
- {0x82, 0x50, 0x32, 0x2d, 0x44, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x32, 0x53, 0x53, 0x43, 0x81, 0x50, 0x32, 0x2d, 0x44, 0x35,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x53, 0x53, 0x43, 0x80,
- 0x50, 0x32, 0x2d, 0x44, 0x37, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x32, 0x53, 0x53, 0x43, 0x83, 0x50, 0x32, 0x2d, 0x44, 0x38, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x53, 0x53, 0x43}},
- pair<std::string, Binary>{
- "B2",
- {0x50, 0x05, 0x07, 0x60, 0x73, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x00}},
- pair<std::string, Binary>{"MF", {0x00, 0x10}},
- pair<std::string, Binary>{"VZ", {0x30, 0x33}},
- pair<std::string, Binary>{"PN",
- {0x30, 0x31, 0x4b, 0x55, 0x37, 0x32, 0x34}},
- pair<std::string, Binary>{
- "FN", {0x20, 0x30, 0x31, 0x4b, 0x55, 0x37, 0x32, 0x34}},
- pair<std::string, Binary>{"CE", {0x31}},
- pair<std::string, Binary>{"SN",
- {0x59, 0x48, 0x33, 0x30, 0x42, 0x47, 0x37,
- 0x38, 0x42, 0x30, 0x31, 0x34}},
- pair<std::string, Binary>{"CC", {0x32, 0x44, 0x33, 0x37}}};
-
- auto map2 = std::move(get<KeywordVpdMap>(parserObj1.parse()));
- ASSERT_EQ(1, map1 == map2);
-
- // BONO TYPE VPD
- KeywordVpdParser parserObj2(std::move(bonoKwVpdVector));
- map1 = {
- pair<std::string, Binary>{"B2",
- {0x50, 0x0, 0xb3, 0xe0, 0x90, 0x0, 0x2, 0x50,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}},
- pair<std::string, Binary>{"CC", {0x35, 0x39, 0x33, 0x42}},
- pair<std::string, Binary>{"CT", {0x50, 0x37, 0x32, 0x0}},
- pair<std::string, Binary>{"EC", {0x50, 0x34, 0x35, 0x35, 0x33, 0x37}},
- pair<std::string, Binary>{"FN",
- {0x30, 0x32, 0x44, 0x45, 0x33, 0x36, 0x35}},
- pair<std::string, Binary>{"PN",
- {0x30, 0x32, 0x44, 0x45, 0x33, 0x36, 0x36}},
- pair<std::string, Binary>{"RV", {0xa1}},
- pair<std::string, Binary>{
- "SI", {0x31, 0x30, 0x31, 0x34, 0x30, 0x36, 0x37, 0x34}},
- pair<std::string, Binary>{"SN",
- {0x59, 0x4c, 0x35, 0x30, 0x48, 0x54, 0x39,
- 0x36, 0x4a, 0x30, 0x30, 0x38}},
- pair<std::string, Binary>{"Z4", {0x30}},
- pair<std::string, Binary>{"Z5", {0x30}},
- pair<std::string, Binary>{
- "Z6", {0x41, 0x31, 0x38, 0x30, 0x30, 0x32, 0x30, 0x30}}};
-
- map2 = std::move(get<KeywordVpdMap>(parserObj2.parse()));
- ASSERT_EQ(1, map1 == map2);
-}
-
-TEST_F(KeywordVpdParserTest, InvKwVpdTag)
-{
- // Invalid Large resource type Identifier String - corrupted at index[0]
- keywordVpdVector[0] = 0x83;
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-
- // For BONO type VPD
- bonoKwVpdVector[0] = 0x83;
- KeywordVpdParser parserObj2(std::move(bonoKwVpdVector));
- EXPECT_THROW(parserObj2.parse(), std::runtime_error);
-}
-
-TEST_F(KeywordVpdParserTest, InvKwValTag)
-{
- // Invalid Large resource type Vendor Defined - corrupted at index[19]
- keywordVpdVector[19] = 0x85;
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-
- // For BONO type VPD - corruputed at index[33]
- bonoKwVpdVector[33] = 0x91;
- KeywordVpdParser parserObj2(std::move(bonoKwVpdVector));
- EXPECT_THROW(parserObj2.parse(), std::runtime_error);
-}
-
-TEST_F(KeywordVpdParserTest, InvKwValSize)
-{
- // Badly formed keyword VPD data - corrupted at index[20]
- keywordVpdVector[20] = 0x00;
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-
- // For BONO type VPD - corruputed at index[34]
- bonoKwVpdVector[34] = 0x00;
- KeywordVpdParser parserObj2(std::move(bonoKwVpdVector));
- EXPECT_THROW(parserObj2.parse(), std::runtime_error);
-}
-
-TEST_F(KeywordVpdParserTest, InvKwValEndTag)
-{
- // Invalid Small resource type End - corrupted at index[177]
- keywordVpdVector[177] = 0x80;
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-}
-
-TEST_F(KeywordVpdParserTest, InvChecksum)
-{
- // Invalid Check sum - corrupted at index[178]
- keywordVpdVector[178] = 0xb1;
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-}
-
-TEST_F(KeywordVpdParserTest, InvKwVpdEndTag)
-{
- // Invalid Small resource type Last End Of Data - corrupted at index[179]
- keywordVpdVector[179] = 0x79;
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-
- // For BONO type VPD - corrupted at index[147]
- bonoKwVpdVector[147] = 0x79;
- KeywordVpdParser parserObj2(std::move(bonoKwVpdVector));
- EXPECT_THROW(parserObj2.parse(), std::runtime_error);
-}
-
-TEST_F(KeywordVpdParserTest, OutOfBoundGreaterSize)
-{
- // Iterator Out of Bound - size is larger than the actual size - corrupted
- // at index[24]
- keywordVpdVector[24] = 0x32;
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-
- // For BONO type VPD - corrupted at index[38]
- bonoKwVpdVector[38] = 0x4D;
- KeywordVpdParser parserObj2(std::move(bonoKwVpdVector));
- EXPECT_THROW(parserObj2.parse(), std::runtime_error);
-}
-
-TEST_F(KeywordVpdParserTest, OutOfBoundLesserSize)
-{
- // Iterator Out of Bound - size is smaller than the actual size - corrupted
- // at index[24]
- keywordVpdVector[24] = 0x03;
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-
- // For BONO type VPD - corrupted at index[38]
- bonoKwVpdVector[38] = 0x04;
- KeywordVpdParser parserObj2(std::move(bonoKwVpdVector));
- EXPECT_THROW(parserObj2.parse(), std::runtime_error);
-}
-
-TEST_F(KeywordVpdParserTest, BlankVpd)
-{
- // Blank Kw Vpd
- keywordVpdVector.clear();
- KeywordVpdParser parserObj1(std::move(keywordVpdVector));
- EXPECT_THROW(parserObj1.parse(), std::runtime_error);
-
- // Blank Bono Type Vpd
- bonoKwVpdVector.clear();
- KeywordVpdParser parserObj2(std::move(bonoKwVpdVector));
- EXPECT_THROW(parserObj2.parse(), std::runtime_error);
-}
-
-int main(int argc, char** argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/test/meson.build b/test/meson.build
index b400d6a..0def0f8 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -1,53 +1,70 @@
-if get_option('oe-sdk').allowed()
- # Setup OE SYSROOT
- OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
- if OECORE_TARGET_SYSROOT == ''
- error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
+gtest_dep = dependency('gtest', main: true, disabler: true, required: false)
+gmock_dep = dependency('gmock', disabler: true, required: false)
+libgpiodcxx = dependency(
+ 'libgpiodcxx',
+ default_options: ['bindings=cxx'],
+ )
+if not gtest_dep.found() or not gmock_dep.found()
+ cmake = import('cmake')
+ gtest_opts = cmake.subproject_options()
+ gtest_opts.set_override_option('warning_level', '1')
+ gtest_opts.set_override_option('werror', 'false')
+ gtest_proj = cmake.subproject('googletest',
+ options: gtest_opts,
+ required: false)
+ if gtest_proj.found()
+ gtest_dep = declare_dependency(
+ dependencies: [
+ dependency('threads'),
+ gtest_proj.dependency('gtest'),
+ gtest_proj.dependency('gtest_main'),
+ ]
+ )
+ gmock_dep = gtest_proj.dependency('gmock')
+ else
+ assert(
+ not get_option('tests').allowed(),
+ 'Googletest is required if tests are enabled'
+ )
endif
- message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
- rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
- ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
- dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
-else
- dynamic_linker = []
endif
-gmock = dependency('gmock', disabler: true, required: build_tests)
-gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
-libgpiodcxx = dependency('libgpiodcxx', default_options: ['bindings=cxx'])
-dependecy_list = [gtest, gmock, sdbusplus, phosphor_logging, phosphor_dbus_interfaces, libgpiodcxx, nlohmann_json_dep]
-configuration_inc = include_directories('..', '../vpd-manager', 'vpd-manager-test', '../vpd-parser')
+parser_build_arguments = []
+if get_option('ipz_ecc_check').enabled()
+ parser_build_arguments += ['-DIPZ_ECC_CHECK']
+endif
-vpd_test = ['store/store.cpp',
- 'ipz_parser/parser.cpp',
- 'keyword_vpd_parser_test/kw_vpd_test.cpp',
- 'vpd-manager-test/reader_test.cpp',
- 'vpd-manager-test/editor_test.cpp'
+dependency_list = [gtest_dep, gmock_dep, sdbusplus, libgpiodcxx]
+
+configuration_inc = include_directories('..', '../vpd-manager/include', '../vpdecc')
+
+test_sources = [
+ '../vpd-manager/src/logger.cpp',
+ '../vpd-manager/src/ddimm_parser.cpp',
+ '../vpd-manager/src/parser.cpp',
+ '../vpd-manager/src/parser_factory.cpp',
+ '../vpd-manager/src/isdimm_parser.cpp',
+ '../vpd-manager/src/ipz_parser.cpp',
+ '../vpd-manager/src/keyword_vpd_parser.cpp',
+ '../vpd-manager/src/event_logger.cpp',
+ '../vpdecc/vpdecc.c'
]
-application_src =['../impl.cpp',
- '../vpd-parser/ipz_parser.cpp',
- '../ibm_vpd_utils.cpp',
- '../common_utility.cpp',
- '../vpd-manager/reader_impl.cpp',
- '../vpd-parser/keyword_vpd_parser.cpp',
- '../vpd-manager/editor_impl.cpp',
- '../vpd-parser/parser_factory.cpp',
- '../vpd-parser/memory_vpd_parser.cpp',
- '../vpd-parser/isdimm_vpd_parser.cpp'
- ]
+tests = [
+ 'utest_utils.cpp',
+ 'utest_keyword_parser.cpp',
+ 'utest_ddimm_parser.cpp',
+ 'utest_ipz_parser.cpp',
+ 'utest_json_utility.cpp'
+]
-foreach t : vpd_test
- test(t, executable(t.underscorify(),
- [t, application_src],
- build_rpath: get_option('oe-sdk').allowed() ? rpath : '',
- link_args: dynamic_linker,
- cpp_args: ['-DIPZ_PARSER', '-DManagerTest'],
- c_args: ['-Wno-unused-parameter',
- '-Wno-unused-variable'],
- dependencies: dependecy_list,
- include_directories: configuration_inc,
- link_with : libvpdecc,
- ),
- workdir: meson.current_source_dir())
+foreach test_file : tests
+ test(test_file, executable(test_file.underscorify(),
+ test_file,
+ test_sources,
+ include_directories: configuration_inc,
+ dependencies: dependency_list,
+ cpp_args: parser_build_arguments
+ ),
+ workdir: meson.current_source_dir())
endforeach
diff --git a/test/parser/parser.cpp b/test/parser/parser.cpp
deleted file mode 100644
index d9f441e..0000000
--- a/test/parser/parser.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <defines.hpp>
-#include <store.hpp>
-#include <vpd-parser/ipz_parser.hpp>
-
-#include <cassert>
-#include <fstream>
-#include <iterator>
-
-void runTests()
-{
- using namespace openpower::vpd;
- using namespace openpower::vpd::ipz::parser;
- // Test parse() API
- {
- std::ifstream vpdFile("test.vpd", std::ios::binary);
- Binary vpd((std::istreambuf_iterator<char>(vpdFile)),
- std::istreambuf_iterator<char>());
-
- IpzVpdParser ipzParser(std::move(vpd));
- auto vpdStore = std::move(std::get<Store>(ipzParser.parse()));
-
- assert(("P012" == vpdStore.get<Record::VINI, record::Keyword::CC>()));
- assert(("2019-01-01-08:30:00" ==
- vpdStore.get<Record::VINI, record::Keyword::MB>()));
- }
-}
-
-int main()
-{
- runTests();
-
- return 0;
-}
diff --git a/test/parser/test.vpd b/test/parser/test.vpd
deleted file mode 100644
index ba17611..0000000
--- a/test/parser/test.vpd
+++ /dev/null
Binary files differ
diff --git a/test/store/store.cpp b/test/store/store.cpp
deleted file mode 100644
index 4c83ba7..0000000
--- a/test/store/store.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include "store.hpp"
-
-#include "defines.hpp"
-
-#include <cassert>
-#include <string>
-#include <unordered_map>
-#include <utility>
-
-void runTests()
-{
- using namespace openpower::vpd;
-
- // Test Store::get API
- {
- Parsed vpd;
- using inner = Parsed::mapped_type;
- inner i;
-
- i.emplace("SN", "1001");
- i.emplace("PN", "F001");
- i.emplace("DR", "Fake FRU");
- vpd.emplace("VINI", i);
-
- Store s(std::move(vpd));
-
- assert(("1001" == s.get<Record::VINI, record::Keyword::SN>()));
- assert(("F001" == s.get<Record::VINI, record::Keyword::PN>()));
- assert(("Fake FRU" == s.get<Record::VINI, record::Keyword::DR>()));
- }
-}
-
-int main()
-{
- runTests();
-
- return 0;
-}
diff --git a/test/utest_ddimm_parser.cpp b/test/utest_ddimm_parser.cpp
new file mode 100644
index 0000000..6674c51
--- /dev/null
+++ b/test/utest_ddimm_parser.cpp
@@ -0,0 +1,117 @@
+#include "vpdecc.h"
+
+#include "ddimm_parser.hpp"
+#include "exceptions.hpp"
+#include "parser.hpp"
+#include "types.hpp"
+
+#include <cstdint>
+#include <exception>
+#include <fstream>
+
+#include <gtest/gtest.h>
+
+using namespace vpd;
+
+TEST(DdimmVpdParserTest, GoodTestCase)
+{
+ types::DdimmVpdMap l_ddimmMap{
+ std::pair<std::string, size_t>{"MemorySizeInKB", 0x2000000},
+ std::pair<std::string, types::BinaryVector>{
+ "FN", {0x30, 0x33, 0x48, 0x44, 0x37, 0x30, 0x30}},
+ std::pair<std::string, types::BinaryVector>{
+ "PN", {0x30, 0x33, 0x48, 0x44, 0x37, 0x30, 0x30}},
+ std::pair<std::string, types::BinaryVector>{
+ "SN",
+ {0x59, 0x48, 0x33, 0x33, 0x31, 0x54, 0x33, 0x38, 0x34, 0x30, 0x33,
+ 0x46}},
+ std::pair<std::string, types::BinaryVector>{"CC",
+ {0x33, 0x32, 0x41, 0x31}}};
+
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ddr5_ddimm.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ ASSERT_EQ(1,
+ l_ddimmMap == std::get<types::DdimmVpdMap>(l_vpdParser.parse()));
+}
+
+TEST(DdimmVpdParserTest, DDR4GoodTestCase)
+{
+ types::DdimmVpdMap l_ddimmMap{
+ std::pair<std::string, size_t>{"MemorySizeInKB", 0x4000000},
+ std::pair<std::string, types::BinaryVector>{
+ "FN", {0x37, 0x38, 0x50, 0x36, 0x35, 0x37, 0x35}},
+ std::pair<std::string, types::BinaryVector>{
+ "PN", {0x37, 0x38, 0x50, 0x36, 0x35, 0x37, 0x35}},
+ std::pair<std::string, types::BinaryVector>{
+ "SN",
+ {0x59, 0x48, 0x33, 0x35, 0x31, 0x54, 0x31, 0x35, 0x53, 0x30, 0x44,
+ 0x35}},
+ std::pair<std::string, types::BinaryVector>{"CC",
+ {0x33, 0x32, 0x37, 0x42}}};
+
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ddr4_ddimm.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ ASSERT_EQ(1,
+ l_ddimmMap == std::get<types::DdimmVpdMap>(l_vpdParser.parse()));
+}
+
+TEST(DdimmVpdParserTest, InvalidDdrType)
+{
+ // Invalid DDR type, corrupted at index[2]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ddr5_ddimm_corrupted_index_2.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+TEST(DdimmVpdParserTest, ZeroDdimmSize)
+{
+ // Badly formed DDIMM VPD data - corrupted at index[235],
+ // ddimm size calculated a zero
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ddr5_ddimm_corrupted_index_235.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+TEST(DdimmVpdParserTest, InvalidDensityPerDie)
+{
+ // Out of range data, fails to check valid value - corrupted at index[4]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ddr5_ddimm_corrupted_index_4.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+TEST(DdimmVpdParserTest, InvalidVpdType)
+{
+ // Invalid VPD type - corrupted at index[2] & index[3]
+ // Not able to find the VPD type, vpdTypeCheck failed
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ddr5_ddimm_corrupted_index_2_3.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+TEST(DdimmVpdParserTest, EmptyInputVector)
+{
+ // Blank VPD
+ types::BinaryVector emptyVector{};
+
+ EXPECT_THROW(DdimmVpdParser(std::move(emptyVector)), DataException);
+}
+
+int main(int i_argc, char** io_argv)
+{
+ ::testing::InitGoogleTest(&i_argc, io_argv);
+
+ return RUN_ALL_TESTS();
+}
diff --git a/test/utest_ipz_parser.cpp b/test/utest_ipz_parser.cpp
new file mode 100644
index 0000000..2f23060
--- /dev/null
+++ b/test/utest_ipz_parser.cpp
@@ -0,0 +1,135 @@
+#include "ipz_parser.hpp"
+#include "parser.hpp"
+
+#include <exception>
+
+#include <gtest/gtest.h>
+
+TEST(IpzVpdParserTest, GoodTestCase)
+{
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ipz_system.dat");
+ vpd::Parser l_vpdParser(l_vpdFile, l_json);
+
+ vpd::types::IPZVpdMap l_ipzVpdMap;
+ auto l_parsedMap = l_vpdParser.parse();
+ if (auto l_ipzVpdMapPtr = std::get_if<vpd::types::IPZVpdMap>(&l_parsedMap))
+ l_ipzVpdMap = *l_ipzVpdMapPtr;
+
+ std::string l_record("VINI");
+ std::string l_keyword("DR");
+ std::string l_description;
+
+ // check 'DR' keyword value from 'VINI' record
+ auto l_vpdItr = l_ipzVpdMap.find(l_record);
+ if (l_ipzVpdMap.end() != l_vpdItr)
+ {
+ auto l_kwValItr = (l_vpdItr->second).find(l_keyword);
+ if ((l_vpdItr->second).end() != l_kwValItr)
+ {
+ l_description = l_kwValItr->second;
+ }
+ }
+ EXPECT_EQ(l_description, "SYSTEM BACKPLANE");
+
+ // check 'SN' keyword value from 'VINI' record
+ l_record = "VINI";
+ l_keyword = "SN";
+ l_vpdItr = l_ipzVpdMap.find(l_record);
+ if (l_ipzVpdMap.end() != l_vpdItr)
+ {
+ auto l_kwValItr = (l_vpdItr->second).find(l_keyword);
+ if ((l_vpdItr->second).end() != l_kwValItr)
+ {
+ l_description = l_kwValItr->second;
+ }
+ }
+ EXPECT_EQ(l_description, "Y131UF07300L");
+
+ // check 'DR' keyword value of 'VSYS' record
+ l_record = "VSYS";
+ l_keyword = "DR";
+ l_vpdItr = l_ipzVpdMap.find(l_record);
+ if (l_ipzVpdMap.end() != l_vpdItr)
+ {
+ auto l_kwValItr = (l_vpdItr->second).find(l_keyword);
+ if ((l_vpdItr->second).end() != l_kwValItr)
+ {
+ l_description = l_kwValItr->second;
+ }
+ }
+ ASSERT_EQ(l_description, "SYSTEM");
+}
+
+TEST(IpzVpdParserTest, VpdFileDoesNotExist)
+{
+ // Vpd file does not exist
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/xyz.dat");
+
+ EXPECT_THROW(vpd::Parser(l_vpdFile, l_json), std::runtime_error);
+}
+
+TEST(IpzVpdParserTest, MissingHeader)
+{
+ // Missing VHDR tag, failed header check - corrupted at index[17]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ipz_system_corrupted_index_17.dat");
+ vpd::Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+TEST(IpzVpdParserTest, MissingVtoc)
+{
+ // Missing VTOC tag - corrupted at index[61]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ipz_system_corrupted_index_61.dat");
+ vpd::Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+TEST(IpzVpdParserTest, MalformedVpdFile)
+{
+ // Vpd vector size is less than RECORD_MIN(44), fails for checkHeader
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ipz_system_min_record.dat");
+ vpd::Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+#ifdef IPZ_ECC_CHECK
+TEST(IpzVpdParserTest, InvalidRecordOffset)
+{
+ // VTOC ECC check fail
+ // Invalid VINI Record offset, corrupted at index[74]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ipz_system_corrupted_index_74.dat");
+ vpd::Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+TEST(IpzVpdParserTest, InvalidRecordEccOffset)
+{
+ // VTOC ECC check fail
+ // Invalid VINI Record ECC offset, corrupted at index[78] & index[79]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ipz_system_corrupted_index_78_79.dat");
+ vpd::Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+
+TEST(IpzVpdParserTest, TruncatedVpdFile)
+{
+ // Truncated vpd file, VTOC ECC check fail
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/ipz_system_truncated.dat");
+ vpd::Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), std::exception);
+}
+#endif
diff --git a/test/utest_json_utility.cpp b/test/utest_json_utility.cpp
new file mode 100644
index 0000000..4f0b5c5
--- /dev/null
+++ b/test/utest_json_utility.cpp
@@ -0,0 +1,29 @@
+#include "parser.hpp"
+#include "types.hpp"
+#include "utility/json_utility.hpp"
+
+#include <iostream>
+
+#include <gtest/gtest.h>
+
+using namespace vpd;
+
+TEST(IsFruPowerOffOnlyTest, PositiveTestCase)
+{
+ const std::string l_jsonPath{"/usr/local/share/vpd/50001001.json"};
+ const std::string l_vpdPath{"/sys/bus/spi/drivers/at25/spi12.0/eeprom"};
+ const nlohmann::json l_parsedJson = jsonUtility::getParsedJson(l_jsonPath);
+ const bool l_result =
+ jsonUtility::isFruPowerOffOnly(l_parsedJson, l_vpdPath);
+ EXPECT_TRUE(l_result);
+}
+
+TEST(IsFruPowerOffOnlyTest, NegativeTestCase)
+{
+ const std::string l_jsonPath{"/usr/local/share/vpd/50001001.json"};
+ const std::string l_vpdPath{"/sys/bus/i2c/drivers/at24/4-0050/eeprom"};
+ const nlohmann::json l_parsedJson = jsonUtility::getParsedJson(l_jsonPath);
+ const bool l_result =
+ jsonUtility::isFruPowerOffOnly(l_parsedJson, l_vpdPath);
+ EXPECT_FALSE(l_result);
+}
diff --git a/test/utest_keyword_parser.cpp b/test/utest_keyword_parser.cpp
new file mode 100644
index 0000000..1f72829
--- /dev/null
+++ b/test/utest_keyword_parser.cpp
@@ -0,0 +1,145 @@
+#include "exceptions.hpp"
+#include "keyword_vpd_parser.hpp"
+#include "parser.hpp"
+#include "types.hpp"
+
+#include <cstdint>
+#include <exception>
+#include <fstream>
+
+#include <gtest/gtest.h>
+
+using namespace vpd;
+
+TEST(KeywordVpdParserTest, GoodTestCase)
+{
+ types::KeywordVpdMap l_keywordMap{
+ std::pair<std::string, types::BinaryVector>{"WI", {0x00}},
+ std::pair<std::string, types::BinaryVector>{
+ "FL", {0x50, 0x32, 0x20, 0x20, 0x20}},
+ std::pair<std::string, types::BinaryVector>{
+ "SM",
+ {0x82, 0x50, 0x32, 0x2d, 0x44, 0x34, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x32, 0x53, 0x53, 0x43, 0x81, 0x50, 0x32, 0x2d, 0x44, 0x35,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x53, 0x53, 0x43, 0x80,
+ 0x50, 0x32, 0x2d, 0x44, 0x37, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x32, 0x53, 0x53, 0x43, 0x83, 0x50, 0x32, 0x2d, 0x44, 0x38, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x53, 0x53, 0x43}},
+ std::pair<std::string, types::BinaryVector>{
+ "B2",
+ {0x50, 0x05, 0x07, 0x60, 0x73, 0x00, 0x72, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x01, 0x00}},
+ std::pair<std::string, types::BinaryVector>{"MF", {0x00, 0x10}},
+ std::pair<std::string, types::BinaryVector>{"VZ", {0x30, 0x33}},
+ std::pair<std::string, types::BinaryVector>{
+ "PN", {0x30, 0x31, 0x4b, 0x55, 0x37, 0x32, 0x34}},
+ std::pair<std::string, types::BinaryVector>{
+ "FN", {0x20, 0x30, 0x31, 0x4b, 0x55, 0x37, 0x32, 0x34}},
+ std::pair<std::string, types::BinaryVector>{"CE", {0x31}},
+ std::pair<std::string, types::BinaryVector>{
+ "SN",
+ {0x59, 0x48, 0x33, 0x30, 0x42, 0x47, 0x37, 0x38, 0x42, 0x30, 0x31,
+ 0x34}},
+ std::pair<std::string, types::BinaryVector>{"CC",
+ {0x32, 0x44, 0x33, 0x37}}};
+
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/keyword.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ ASSERT_EQ(1, std::get<types::KeywordVpdMap>(l_vpdParser.parse()) ==
+ l_keywordMap);
+}
+
+TEST(KeywordVpdParserTest, InvalidVpd)
+{
+ // Invalid large resource type identifier string - corrupted at index[0]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/keyword_corrupted_index_0.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), DataException);
+}
+
+TEST(KeywordVpdParserTest, InvalidStartTag)
+{
+ // Invalid large resource type vendor defined - corrupted at index[19]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/keyword_corrupted_index_19.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), DataException);
+}
+
+TEST(KeywordVpdParserTest, InvalidSize)
+{
+ // Badly formed keyword VPD data - corrupted at index[20]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/keyword_corrupted_index_20.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), DataException);
+}
+
+TEST(KeywordVpdParserTest, InvalidEndTag)
+{
+ // Invalid small resource type end - corrupted at index[177]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/keyword_corrupted_index_177.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), DataException);
+}
+
+TEST(KeywordVpdParserTest, InvalidChecksum)
+{
+ // Invalid check sum - corrupted at index[178]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/keyword_corrupted_index_178.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), DataException);
+}
+
+TEST(KeywordVpdParserTest, InvalidLastEndTag)
+{
+ // Invalid small resource type last end of data - corrupted at index[179]
+ nlohmann::json l_json;
+ std::string l_vpdFile("vpd_files/keyword_corrupted_index_179.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), DataException);
+}
+
+TEST(KeywordVpdParserTest, OutOfBoundGreaterSize)
+{
+ // Iterator out of bound - size is larger than the actual size - corrupted
+ // at index[24]
+ nlohmann::json l_json;
+ std::string l_vpdFile(
+ "vpd_files/keyword_corrupted_index_24_large_size.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), DataException);
+}
+
+TEST(KeywordVpdParserTest, OutOfBoundLesserSize)
+{
+ // Iterator out of bound - size is smaller than the actual size - corrupted
+ // at index[24]
+ nlohmann::json l_json;
+ std::string l_vpdFile(
+ "vpd_files/keyword_corrupted_index_24_small_size.dat");
+ Parser l_vpdParser(l_vpdFile, l_json);
+
+ EXPECT_THROW(l_vpdParser.parse(), DataException);
+}
+
+TEST(KeywordVpdParserTest, EmptyInput)
+{
+ // Blank keyword VPD
+ types::BinaryVector emptyVector{};
+ KeywordVpdParser l_keywordParser(std::move(emptyVector));
+
+ EXPECT_THROW(l_keywordParser.parse(), std::exception);
+}
diff --git a/test/utest_utils.cpp b/test/utest_utils.cpp
new file mode 100644
index 0000000..6511dcb
--- /dev/null
+++ b/test/utest_utils.cpp
@@ -0,0 +1,23 @@
+#include <utility/vpd_specific_utility.hpp>
+
+#include <cassert>
+#include <string>
+
+#include <gtest/gtest.h>
+
+using namespace vpd;
+
+TEST(UtilsTest, TestValidValue)
+{
+ std::string key = "VINI";
+ std::string encoding = "MAC";
+ std::string expected = "56:49:4e:49";
+ EXPECT_EQ(expected, vpdSpecificUtility::encodeKeyword(key, encoding));
+}
+
+int main(int argc, char** argv)
+{
+ ::testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}
diff --git a/test/vpd-manager-test/editor_test.cpp b/test/vpd-manager-test/editor_test.cpp
deleted file mode 100644
index 53f32ad..0000000
--- a/test/vpd-manager-test/editor_test.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-#include "editor_impl.hpp"
-#include "ipz_parser.hpp"
-
-#include <nlohmann/json.hpp>
-
-#include <algorithm>
-#include <vector>
-
-#include <gtest/gtest.h>
-
-using namespace openpower::vpd;
-using namespace openpower::vpd::manager::editor;
-using namespace openpower::vpd::inventory;
-using namespace openpower::vpd::constants;
-
-class vpdManagerEditorTest : public ::testing::Test
-{
- protected:
- Binary vpd;
-
- nlohmann::json jsonFile;
-
- // map to hold the mapping of location code and inventory path
- inventory::LocationCodeMap fruLocationCode;
-
- public:
- // constructor
- vpdManagerEditorTest()
- {
- processJson();
- }
-
- void processJson();
- void readFile(std::string pathToFile);
-};
-
-void vpdManagerEditorTest::readFile(std::string pathToFile)
-{
- // read the json file and parse it
- std::ifstream vpdFile(pathToFile, std::ios::binary);
-
- if (!vpdFile)
- {
- throw std::runtime_error("json file not found");
- }
-
- vpd.assign((std::istreambuf_iterator<char>(vpdFile)),
- std::istreambuf_iterator<char>());
-}
-
-void vpdManagerEditorTest::processJson()
-{
- // read the json file and parse it
- std::ifstream json("vpd-manager-test/vpd_editor_test.json",
- std::ios::binary);
-
- if (!json)
- {
- throw std::runtime_error("json file not found");
- }
-
- jsonFile = nlohmann::json::parse(json);
-
- const nlohmann::json& groupFRUS =
- jsonFile["frus"].get_ref<const nlohmann::json::object_t&>();
- for (const auto& itemFRUS : groupFRUS.items())
- {
- const std::vector<nlohmann::json>& groupEEPROM =
- itemFRUS.value().get_ref<const nlohmann::json::array_t&>();
- for (const auto& itemEEPROM : groupEEPROM)
- {
- fruLocationCode.emplace(
- itemEEPROM["extraInterfaces"][IBM_LOCATION_CODE_INF]
- ["LocationCode"]
- .get_ref<const nlohmann::json::string_t&>(),
- itemEEPROM["inventoryPath"]
- .get_ref<const nlohmann::json::string_t&>());
- }
- }
-}
-
-TEST_F(vpdManagerEditorTest, InvalidFile)
-{
- Binary dataToUodate{'M', 'O', 'D', 'I', 'F', 'Y',
- 'D', 'A', 'T', 'A', 'O', 'K'};
-
- Binary emptyVpdFile;
- try
- {
- // Invalid kwd name
- EditorImpl edit("VINI", "SN", std::move(emptyVpdFile));
- edit.updateKeyword(dataToUodate, 0, true);
- }
- catch (const std::exception& e)
- {
- EXPECT_EQ(std::string(e.what()), std::string("Invalid File"));
- }
-}
-
-TEST_F(vpdManagerEditorTest, InvalidHeader)
-{
- Binary dataToUodate{'M', 'O', 'D', 'I', 'F', 'Y',
- 'D', 'A', 'T', 'A', 'O', 'K'};
-
- readFile("vpd-manager-test/invalidHeaderFile.dat");
- try
- {
- // the path is dummy
- EditorImpl edit("VINI", "SN", std::move(vpd));
- edit.updateKeyword(dataToUodate, 0, true);
- }
- catch (const std::exception& e)
- {
- EXPECT_EQ(std::string(e.what()), std::string("VHDR record not found"));
- }
-}
-
-TEST_F(vpdManagerEditorTest, InvalidRecordName)
-{
- Binary dataToUodate{'M', 'O', 'D', 'I', 'F', 'Y',
- 'D', 'A', 'T', 'A', 'O', 'K'};
-
- readFile("vpd-manager-test/vpdFile.dat");
-
- try
- {
- // Invalid record name "VIN", path is dummy
- EditorImpl edit("VIN", "SN", std::move(vpd));
- edit.updateKeyword(dataToUodate, 0, true);
- }
- catch (const std::exception& e)
- {
- EXPECT_EQ(std::string(e.what()), std::string("Record not found"));
- }
-}
-
-TEST_F(vpdManagerEditorTest, InvalidKWdName)
-{
- Binary dataToUodate{'M', 'O', 'D', 'I', 'F', 'Y',
- 'D', 'A', 'T', 'A', 'O', 'K'};
-
- readFile("vpd-manager-test/vpdFile.dat");
-
- try
- {
- // All valid data
- EditorImpl edit("VINI", "Sn", std::move(vpd));
- edit.updateKeyword(dataToUodate, 0, true);
- }
- catch (const std::runtime_error& e)
- {
- EXPECT_EQ(std::string(e.what()), std::string("Keyword not found"));
- }
-}
-
-TEST_F(vpdManagerEditorTest, UpdateKwd_Success)
-{
- Binary dataToUodate{'M', 'O', 'D', 'I', 'F', 'Y',
- 'D', 'A', 'T', 'A', 'O', 'K'};
-
- readFile("vpd-manager-test/vpdFile.dat");
-
- try
- {
- // All valid data, but can't update with dummy ECC code
- EditorImpl edit("VINI", "SN", std::move(vpd));
- edit.updateKeyword(dataToUodate, 0, true);
- }
- catch (const std::runtime_error& e)
- {
- EXPECT_EQ(std::string(e.what()), std::string("Ecc update failed"));
- }
-}
-
-int main(int argc, char** argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/test/vpd-manager-test/invalidHeaderFile.dat b/test/vpd-manager-test/invalidHeaderFile.dat
deleted file mode 100644
index 7f8de18..0000000
--- a/test/vpd-manager-test/invalidHeaderFile.dat
+++ /dev/null
Binary files differ
diff --git a/test/vpd-manager-test/reader_test.cpp b/test/vpd-manager-test/reader_test.cpp
deleted file mode 100644
index dd576e6..0000000
--- a/test/vpd-manager-test/reader_test.cpp
+++ /dev/null
@@ -1,256 +0,0 @@
-#include "reader_test.hpp"
-
-#include "const.hpp"
-#include "reader_impl.hpp"
-#include "types.hpp"
-
-#include <nlohmann/json.hpp>
-
-#include <fstream>
-#include <tuple>
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-using namespace openpower::vpd::manager::reader;
-using namespace openpower::vpd::inventory;
-using namespace openpower::vpd::constants;
-
-class vpdManagerReaderTest : public ::testing::Test
-{
- protected:
- nlohmann::json jsonFile;
-
- // map to hold the mapping of location code and inventory path
- LocationCodeMap fruLocationCode;
-
- // dummy value of node number
- const uint8_t nodeNumber = 1;
-
- public:
- // constructor
- vpdManagerReaderTest()
- {
- processJson();
- }
-
- void processJson();
-};
-
-using namespace openpower::vpd;
-
-void vpdManagerReaderTest::processJson()
-{
- // read the json file and parse it
- std::ifstream json("vpd-manager-test/vpd_reader_test.json",
- std::ios::binary);
-
- if (!json)
- {
- throw std::runtime_error("json file not found");
- }
-
- jsonFile = nlohmann::json::parse(json);
-
- if (jsonFile.find("frus") == jsonFile.end())
- {
- throw std::runtime_error("frus group not found in json");
- }
-
- const nlohmann::json& groupFRUS =
- jsonFile["frus"].get_ref<const nlohmann::json::object_t&>();
- for (const auto& itemFRUS : groupFRUS.items())
- {
- const std::vector<nlohmann::json>& groupEEPROM =
- itemFRUS.value().get_ref<const nlohmann::json::array_t&>();
- for (const auto& itemEEPROM : groupEEPROM)
- {
- fruLocationCode.emplace(
- itemEEPROM["extraInterfaces"][IBM_LOCATION_CODE_INF]
- ["LocationCode"]
- .get_ref<const nlohmann::json::string_t&>(),
- itemEEPROM["inventoryPath"]
- .get_ref<const nlohmann::json::string_t&>());
- }
- }
-}
-
-TEST_F(vpdManagerReaderTest, isValidLocationCode_invalid)
-{
- // No MTS or FCS in the collapsed location code
- std::string unexpandedLocationCode_Invalid = "Uabc-X0";
-
- MockUtilCalls uCalls;
- ReaderImpl read(uCalls);
- EXPECT_ANY_THROW({
- read.getExpandedLocationCode(unexpandedLocationCode_Invalid, nodeNumber,
- fruLocationCode);
- });
-
- // not starting with U
- unexpandedLocationCode_Invalid = "Mabc-X0";
- EXPECT_ANY_THROW({
- read.getExpandedLocationCode(unexpandedLocationCode_Invalid, nodeNumber,
- fruLocationCode);
- });
-}
-
-TEST_F(vpdManagerReaderTest, getExpandedLocationCode_Invalid)
-{
- std::string unexpandedLocationCode_Invalid = "Uabc-X0";
-
- MockUtilCalls uCalls;
- ReaderImpl read(uCalls);
- EXPECT_ANY_THROW({
- read.getExpandedLocationCode(unexpandedLocationCode_Invalid, nodeNumber,
- fruLocationCode);
- });
-}
-
-TEST_F(vpdManagerReaderTest, getExpandedLocationCode_Valid)
-{
- // mock the call to read bus property
- MockUtilCalls uCalls;
- EXPECT_CALL(uCalls, readBusProperty(SYSTEM_OBJECT, IBM_LOCATION_CODE_INF,
- "LocationCode"))
- .Times(1)
- .WillOnce(testing::Return("U78DA.ND1.1234567-P0"));
-
- std::string unexpandedLocationCode = "Ufcs-P0";
- ReaderImpl read(uCalls);
- std::string res = read.getExpandedLocationCode(unexpandedLocationCode,
- nodeNumber, fruLocationCode);
-
- EXPECT_EQ(res, "U78DA.ND1.1234567-P0");
-}
-
-TEST_F(vpdManagerReaderTest, getFrusAtLocation_Invalid)
-{
- // invalid location code
- std::string unexpandedLocationCode = "Uabc-X0";
-
- MockUtilCalls uCalls;
- ReaderImpl read(uCalls);
- EXPECT_ANY_THROW({
- read.getFrusAtLocation(unexpandedLocationCode, nodeNumber,
- fruLocationCode);
- });
-
- // map to hold the mapping of location code and inventory path, empty in
- // this case
- LocationCodeMap mapLocationCode;
- unexpandedLocationCode = "Ufcs-P0";
- EXPECT_ANY_THROW({
- read.getFrusAtLocation(unexpandedLocationCode, nodeNumber,
- mapLocationCode);
- });
-}
-
-TEST_F(vpdManagerReaderTest, getFrusAtLocation_Valid)
-{
- std::string LocationCode = "Ufcs-P0";
-
- MockUtilCalls uCalls;
- ReaderImpl read(uCalls);
- ListOfPaths paths =
- read.getFrusAtLocation(LocationCode, nodeNumber, fruLocationCode);
- std::string expected =
- "/xyz/openbmc_project/inventory/system/chassis/motherboard";
- EXPECT_EQ(paths.at(0), expected);
-}
-
-TEST_F(vpdManagerReaderTest, getFRUsByExpandedLocationCode_invalid)
-{
- // not starting from U
- std::string locationCode = "9105.22A.SIMP10R";
-
- MockUtilCalls uCalls;
- ReaderImpl read(uCalls);
- ListOfPaths paths;
- EXPECT_ANY_THROW({
- paths =
- read.getFRUsByExpandedLocationCode(locationCode, fruLocationCode);
- });
-
- // unused variable warning
- (void)paths;
-
- // length is les sthan 17 for expanded location code
- locationCode = "U9105.22A.SIMP10";
- EXPECT_ANY_THROW({
- paths =
- read.getFRUsByExpandedLocationCode(locationCode, fruLocationCode);
- });
-
- // Invalid location code. No "."
- locationCode = "U78DAND11234567-P0";
-
- // Mock readBUsproperty call
- EXPECT_CALL(uCalls,
- readBusProperty(SYSTEM_OBJECT, "com.ibm.ipzvpd.VCEN", "FC"))
- .Times(1)
- .WillOnce(
- testing::Return("78DAPQRS")); // return a dummy value for FC keyword
-
- // unused variable warning
- (void)paths;
- EXPECT_ANY_THROW({
- paths =
- read.getFRUsByExpandedLocationCode(locationCode, fruLocationCode);
- });
-}
-
-TEST_F(vpdManagerReaderTest, getFRUsByExpandedLocationCode_Valid_FC)
-{
- // valid location code with FC kwd.
- std::string validLocationCode = "U78DA.ND1.1234567-P0";
-
- // Mock readBUsproperty call
- MockUtilCalls uCalls;
- EXPECT_CALL(uCalls,
- readBusProperty(SYSTEM_OBJECT, "com.ibm.ipzvpd.VCEN", "FC"))
- .WillRepeatedly(
- testing::Return("78DAPQRS")); // return a dummy value for FC keyword
-
- ReaderImpl read(uCalls);
- ListOfPaths paths =
- read.getFRUsByExpandedLocationCode(validLocationCode, fruLocationCode);
-
- std::string expected =
- "/xyz/openbmc_project/inventory/system/chassis/motherboard";
- EXPECT_EQ(paths.at(0), expected);
-}
-
-TEST_F(vpdManagerReaderTest, getFRUsByExpandedLocationCode_Valid_TM)
-{
- // valid location code with TM kwd.
- std::string validLocationCode = "U9105.22A.SIMP10R";
-
- // Mock readBUsproperty call
- MockUtilCalls uCalls;
- EXPECT_CALL(uCalls,
- readBusProperty(SYSTEM_OBJECT, "com.ibm.ipzvpd.VCEN", "FC"))
- .Times(1)
- .WillOnce(
- testing::Return("78DAPQRS")); // return a dummy value for FC keyword
-
- EXPECT_CALL(uCalls,
- readBusProperty(SYSTEM_OBJECT, "com.ibm.ipzvpd.VSYS", "TM"))
- .Times(1)
- .WillOnce(
- testing::Return("9105PQRS")); // return a dummy value for TM keyword
-
- ReaderImpl read(uCalls);
- ListOfPaths paths =
- read.getFRUsByExpandedLocationCode(validLocationCode, fruLocationCode);
-
- std::string expected = "/xyz/openbmc_project/inventory/system";
- EXPECT_EQ(paths.at(0), expected);
-}
-
-int main(int argc, char** argv)
-{
- ::testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/test/vpd-manager-test/reader_test.hpp b/test/vpd-manager-test/reader_test.hpp
deleted file mode 100644
index b108df2..0000000
--- a/test/vpd-manager-test/reader_test.hpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-
-#include "utilInterface.hpp"
-
-#include <gmock/gmock.h>
-
-using namespace openpower::vpd::utils::interface;
-
-class MockUtilCalls : public UtilityInterface
-{
- public:
- MOCK_METHOD(std::string, readBusProperty,
- (const std::string& obj, const std::string& inf,
- const std::string& prop),
- (override));
-};
diff --git a/test/vpd-manager-test/vpdFile.dat b/test/vpd-manager-test/vpdFile.dat
deleted file mode 100644
index 147f63b..0000000
--- a/test/vpd-manager-test/vpdFile.dat
+++ /dev/null
Binary files differ
diff --git a/test/vpd-manager-test/vpd_editor_test.json b/test/vpd-manager-test/vpd_editor_test.json
deleted file mode 100644
index 516dcad..0000000
--- a/test/vpd-manager-test/vpd_editor_test.json
+++ /dev/null
@@ -1,172 +0,0 @@
-{
- "commonInterfaces": {
- "xyz.openbmc_project.Inventory.Decorator.Asset": {
- "PartNumber": {
- "recordName": "VINI",
- "keywordName": "PN"
- },
- "SerialNumber": {
- "recordName": "VINI",
- "keywordName": "SN"
- },
- "BuildDate": {
- "recordName": "VR10",
- "keywordName": "DC",
- "encoding": "DATE"
- }
- },
- "xyz.openbmc_project.Inventory.Item": {
- "PrettyName": {
- "recordName": "VINI",
- "keywordName": "DR"
- },
- "Present": true
- }
- },
- "frus": {
- "/sys/bus/i2c/drivers/at24/8-0050/eeprom": [
- {
- "inventoryPath": "/system/chassis/motherboard",
- "isSystemVpd": true,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Board.Motherboard": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0"
- }
- }
- },
- {
- "inventoryPath": "/system",
- "inherit": false,
- "isSystemVpd": true,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.System": null,
- "xyz.openbmc_project.Inventory.Decorator.Asset": {
- "SerialNumber": {
- "recordName": "VSYS",
- "keywordName": "SE"
- },
- "Model": {
- "recordName": "VSYS",
- "keywordName": "TM"
- }
- },
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Umts"
- }
- }
- },
- {
- "inventoryPath": "/system/chassis",
- "inherit": false,
- "isSystemVpd": true,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Chassis": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a480.i2c-bus/i2c-8/8-0051/8-00510/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/ebmc_card_bmc",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Bmc": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C5"
- }
- }
- },
- {
- "inventoryPath": "/system/chassis/motherboard/ebmc_card_bmc/ethernet0",
- "inherit": false,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Ethernet": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C5-T0"
- },
- "xyz.openbmc_project.Inventory.Item.NetworkInterface": {
- "MACAddress": {
- "recordName": "VCFG",
- "keywordName": "Z0",
- "encoding": "MAC"
- }
- }
- }
- },
- {
- "inventoryPath": "/system/chassis/motherboard/ebmc_card_bmc/ethernet1",
- "inherit": false,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Ethernet": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C5-T1"
- },
- "xyz.openbmc_project.Inventory.Item.NetworkInterface": {
- "MACAddress": {
- "recordName": "VCFG",
- "keywordName": "Z1",
- "encoding": "MAC"
- }
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a080.i2c-bus/i2c-0/0-0051/0-00510/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/tpm_wilson",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Tpm": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C22"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a400.i2c-bus/i2c-7/7-0050/7-00500/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/base_op_panel_blyth",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Panel": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-D0"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a400.i2c-bus/i2c-7/7-0051/7-00510/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/lcd_op_panel_hill",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Panel": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-D1"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a500.i2c-bus/i2c-9/9-0050/9-00500/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/vdd_vrm0",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Vrm": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C14"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a580.i2c-bus/i2c-10/10-0050/10-00500/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/vdd_vrm1",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Vrm": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C23"
- }
- }
- }
- ]
- }
-}
diff --git a/test/vpd-manager-test/vpd_reader_test.json b/test/vpd-manager-test/vpd_reader_test.json
deleted file mode 100644
index 516dcad..0000000
--- a/test/vpd-manager-test/vpd_reader_test.json
+++ /dev/null
@@ -1,172 +0,0 @@
-{
- "commonInterfaces": {
- "xyz.openbmc_project.Inventory.Decorator.Asset": {
- "PartNumber": {
- "recordName": "VINI",
- "keywordName": "PN"
- },
- "SerialNumber": {
- "recordName": "VINI",
- "keywordName": "SN"
- },
- "BuildDate": {
- "recordName": "VR10",
- "keywordName": "DC",
- "encoding": "DATE"
- }
- },
- "xyz.openbmc_project.Inventory.Item": {
- "PrettyName": {
- "recordName": "VINI",
- "keywordName": "DR"
- },
- "Present": true
- }
- },
- "frus": {
- "/sys/bus/i2c/drivers/at24/8-0050/eeprom": [
- {
- "inventoryPath": "/system/chassis/motherboard",
- "isSystemVpd": true,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Board.Motherboard": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0"
- }
- }
- },
- {
- "inventoryPath": "/system",
- "inherit": false,
- "isSystemVpd": true,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.System": null,
- "xyz.openbmc_project.Inventory.Decorator.Asset": {
- "SerialNumber": {
- "recordName": "VSYS",
- "keywordName": "SE"
- },
- "Model": {
- "recordName": "VSYS",
- "keywordName": "TM"
- }
- },
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Umts"
- }
- }
- },
- {
- "inventoryPath": "/system/chassis",
- "inherit": false,
- "isSystemVpd": true,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Chassis": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a480.i2c-bus/i2c-8/8-0051/8-00510/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/ebmc_card_bmc",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Bmc": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C5"
- }
- }
- },
- {
- "inventoryPath": "/system/chassis/motherboard/ebmc_card_bmc/ethernet0",
- "inherit": false,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Ethernet": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C5-T0"
- },
- "xyz.openbmc_project.Inventory.Item.NetworkInterface": {
- "MACAddress": {
- "recordName": "VCFG",
- "keywordName": "Z0",
- "encoding": "MAC"
- }
- }
- }
- },
- {
- "inventoryPath": "/system/chassis/motherboard/ebmc_card_bmc/ethernet1",
- "inherit": false,
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Ethernet": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C5-T1"
- },
- "xyz.openbmc_project.Inventory.Item.NetworkInterface": {
- "MACAddress": {
- "recordName": "VCFG",
- "keywordName": "Z1",
- "encoding": "MAC"
- }
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a080.i2c-bus/i2c-0/0-0051/0-00510/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/tpm_wilson",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Tpm": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C22"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a400.i2c-bus/i2c-7/7-0050/7-00500/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/base_op_panel_blyth",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Panel": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-D0"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a400.i2c-bus/i2c-7/7-0051/7-00510/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/lcd_op_panel_hill",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Panel": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-D1"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a500.i2c-bus/i2c-9/9-0050/9-00500/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/vdd_vrm0",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Vrm": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C14"
- }
- }
- }
- ],
- "/sys/devices/platform/ahb/ahb:apb/ahb:apb:bus@1e78a000/1e78a580.i2c-bus/i2c-10/10-0050/10-00500/nvmem": [
- {
- "inventoryPath": "/system/chassis/motherboard/vdd_vrm1",
- "extraInterfaces": {
- "xyz.openbmc_project.Inventory.Item.Vrm": null,
- "com.ibm.ipzvpd.Location": {
- "LocationCode": "Ufcs-P0-C23"
- }
- }
- }
- ]
- }
-}
diff --git a/test/vpd_files/ddr4_ddimm.dat b/test/vpd_files/ddr4_ddimm.dat
new file mode 100755
index 0000000..3226bb3
--- /dev/null
+++ b/test/vpd_files/ddr4_ddimm.dat
Binary files differ
diff --git a/test/vpd_files/ddr5_ddimm.dat b/test/vpd_files/ddr5_ddimm.dat
new file mode 100644
index 0000000..b7f4107
--- /dev/null
+++ b/test/vpd_files/ddr5_ddimm.dat
Binary files differ
diff --git a/test/vpd_files/ddr5_ddimm_corrupted_index_2.dat b/test/vpd_files/ddr5_ddimm_corrupted_index_2.dat
new file mode 100644
index 0000000..3ddf5fc
--- /dev/null
+++ b/test/vpd_files/ddr5_ddimm_corrupted_index_2.dat
Binary files differ
diff --git a/test/vpd_files/ddr5_ddimm_corrupted_index_235.dat b/test/vpd_files/ddr5_ddimm_corrupted_index_235.dat
new file mode 100644
index 0000000..dcbb477
--- /dev/null
+++ b/test/vpd_files/ddr5_ddimm_corrupted_index_235.dat
Binary files differ
diff --git a/test/vpd_files/ddr5_ddimm_corrupted_index_2_3.dat b/test/vpd_files/ddr5_ddimm_corrupted_index_2_3.dat
new file mode 100644
index 0000000..9adf253
--- /dev/null
+++ b/test/vpd_files/ddr5_ddimm_corrupted_index_2_3.dat
Binary files differ
diff --git a/test/vpd_files/ddr5_ddimm_corrupted_index_4.dat b/test/vpd_files/ddr5_ddimm_corrupted_index_4.dat
new file mode 100644
index 0000000..cdac642
--- /dev/null
+++ b/test/vpd_files/ddr5_ddimm_corrupted_index_4.dat
Binary files differ
diff --git a/test/vpd_files/ipz_system.dat b/test/vpd_files/ipz_system.dat
new file mode 100644
index 0000000..6c11e60
--- /dev/null
+++ b/test/vpd_files/ipz_system.dat
Binary files differ
diff --git a/test/vpd_files/ipz_system_corrupted_index_17.dat b/test/vpd_files/ipz_system_corrupted_index_17.dat
new file mode 100644
index 0000000..db829a9
--- /dev/null
+++ b/test/vpd_files/ipz_system_corrupted_index_17.dat
Binary files differ
diff --git a/test/vpd_files/ipz_system_corrupted_index_61.dat b/test/vpd_files/ipz_system_corrupted_index_61.dat
new file mode 100644
index 0000000..638b8c8
--- /dev/null
+++ b/test/vpd_files/ipz_system_corrupted_index_61.dat
Binary files differ
diff --git a/test/vpd_files/ipz_system_corrupted_index_74.dat b/test/vpd_files/ipz_system_corrupted_index_74.dat
new file mode 100644
index 0000000..e0b3754
--- /dev/null
+++ b/test/vpd_files/ipz_system_corrupted_index_74.dat
Binary files differ
diff --git a/test/vpd_files/ipz_system_corrupted_index_78_79.dat b/test/vpd_files/ipz_system_corrupted_index_78_79.dat
new file mode 100644
index 0000000..eeff8e3
--- /dev/null
+++ b/test/vpd_files/ipz_system_corrupted_index_78_79.dat
Binary files differ
diff --git a/test/vpd_files/ipz_system_min_record.dat b/test/vpd_files/ipz_system_min_record.dat
new file mode 100644
index 0000000..a3bac3c
--- /dev/null
+++ b/test/vpd_files/ipz_system_min_record.dat
Binary files differ
diff --git a/test/vpd_files/ipz_system_truncated.dat b/test/vpd_files/ipz_system_truncated.dat
new file mode 100644
index 0000000..a9777e1
--- /dev/null
+++ b/test/vpd_files/ipz_system_truncated.dat
Binary files differ
diff --git a/test/vpd.dat b/test/vpd_files/keyword.dat
old mode 100755
new mode 100644
similarity index 100%
rename from test/vpd.dat
rename to test/vpd_files/keyword.dat
Binary files differ
diff --git a/test/vpd_files/keyword_corrupted_index_0.dat b/test/vpd_files/keyword_corrupted_index_0.dat
new file mode 100644
index 0000000..cda52ce
--- /dev/null
+++ b/test/vpd_files/keyword_corrupted_index_0.dat
Binary files differ
diff --git a/test/vpd_files/keyword_corrupted_index_177.dat b/test/vpd_files/keyword_corrupted_index_177.dat
new file mode 100644
index 0000000..69810aa
--- /dev/null
+++ b/test/vpd_files/keyword_corrupted_index_177.dat
Binary files differ
diff --git a/test/vpd_files/keyword_corrupted_index_178.dat b/test/vpd_files/keyword_corrupted_index_178.dat
new file mode 100644
index 0000000..40aab82
--- /dev/null
+++ b/test/vpd_files/keyword_corrupted_index_178.dat
Binary files differ
diff --git a/test/vpd_files/keyword_corrupted_index_179.dat b/test/vpd_files/keyword_corrupted_index_179.dat
new file mode 100644
index 0000000..ac2e89d
--- /dev/null
+++ b/test/vpd_files/keyword_corrupted_index_179.dat
Binary files differ
diff --git a/test/vpd_files/keyword_corrupted_index_19.dat b/test/vpd_files/keyword_corrupted_index_19.dat
new file mode 100644
index 0000000..58f146d
--- /dev/null
+++ b/test/vpd_files/keyword_corrupted_index_19.dat
Binary files differ
diff --git a/test/vpd_files/keyword_corrupted_index_20.dat b/test/vpd_files/keyword_corrupted_index_20.dat
new file mode 100644
index 0000000..f18282f
--- /dev/null
+++ b/test/vpd_files/keyword_corrupted_index_20.dat
Binary files differ
diff --git a/test/vpd_files/keyword_corrupted_index_24_large_size.dat b/test/vpd_files/keyword_corrupted_index_24_large_size.dat
new file mode 100644
index 0000000..03122bb
--- /dev/null
+++ b/test/vpd_files/keyword_corrupted_index_24_large_size.dat
Binary files differ
diff --git a/test/vpd_files/keyword_corrupted_index_24_small_size.dat b/test/vpd_files/keyword_corrupted_index_24_small_size.dat
new file mode 100644
index 0000000..1bb1e26
--- /dev/null
+++ b/test/vpd_files/keyword_corrupted_index_24_small_size.dat
Binary files differ