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/src/fru_utils.hpp b/src/fru_utils.hpp
index dcd9752..b427c25 100644
--- a/src/fru_utils.hpp
+++ b/src/fru_utils.hpp
@@ -114,25 +114,25 @@
char bcdPlusToChar(uint8_t val);
-bool verifyOffset(const std::vector<uint8_t>& fruBytes, fruAreas currentArea,
+bool verifyOffset(std::span<const uint8_t> fruBytes, fruAreas currentArea,
uint8_t len);
std::pair<DecodeState, std::string> decodeFRUData(
- std::vector<uint8_t>::const_iterator& iter,
- const std::vector<uint8_t>::const_iterator& end, bool isLangEng);
+ std::span<const uint8_t>::const_iterator& iter,
+ std::span<const uint8_t>::const_iterator& end, bool isLangEng);
bool checkLangEng(uint8_t lang);
resCodes formatIPMIFRU(
- const std::vector<uint8_t>& fruBytes,
+ std::span<const uint8_t> fruBytes,
boost::container::flat_map<std::string, std::string>& result);
std::vector<uint8_t>& getFRUInfo(const uint16_t& bus, const uint8_t& address);
-uint8_t calculateChecksum(std::vector<uint8_t>::const_iterator iter,
- std::vector<uint8_t>::const_iterator end);
+uint8_t calculateChecksum(std::span<const uint8_t>::const_iterator iter,
+ std::span<const uint8_t>::const_iterator end);
-uint8_t calculateChecksum(std::vector<uint8_t>& fruAreaData);
+uint8_t calculateChecksum(std::span<const uint8_t> fruAreaData);
unsigned int updateFRUAreaLenAndChecksum(
std::vector<uint8_t>& fruData, size_t fruAreaStart,