Unive Tien | 7ad45b4 | 2025-08-18 06:04:53 +0000 | [diff] [blame^] | 1 | #include "fw-update/firmware_inventory.hpp" |
| 2 | |
| 3 | #include <string> |
| 4 | |
| 5 | #include <gtest/gtest.h> |
| 6 | |
| 7 | using namespace pldm::fw_update; |
| 8 | |
| 9 | class FirmwareInventoryTest : public FirmwareInventory |
| 10 | { |
| 11 | public: |
| 12 | using FirmwareInventory::FirmwareInventory; |
| 13 | const std::string& getSoftwarePath() const |
| 14 | { |
| 15 | return this->softwarePath; |
| 16 | } |
| 17 | const SoftwareAssociationDefinitions& getAssociation() const |
| 18 | { |
| 19 | return this->association; |
| 20 | } |
| 21 | const SoftwareVersion& getVersion() const |
| 22 | { |
| 23 | return this->version; |
| 24 | } |
| 25 | }; |
| 26 | |
| 27 | TEST(FirmwareInventoryTest, ConstructorSetsProperties) |
| 28 | { |
| 29 | SoftwareIdentifier softwareIdentifier{1, 100}; |
| 30 | std::string expectedSoftwarePath = |
| 31 | "/xyz/openbmc_project/software/PLDM_Device_TestDevice_1234"; |
| 32 | std::string expectedSoftwareVersion = "2.3.4"; |
| 33 | std::string expectedEndpointPath = |
| 34 | "/xyz/openbmc_project/inventory/system/board/PLDM_Device"; |
| 35 | Descriptors firmwareDescriptors; |
| 36 | ComponentInfo firmwareComponentInfo; |
| 37 | SoftwareVersionPurpose expectedPurpose = SoftwareVersionPurpose::Unknown; |
| 38 | |
| 39 | FirmwareInventoryTest inventory( |
| 40 | softwareIdentifier, expectedSoftwarePath, expectedSoftwareVersion, |
| 41 | expectedEndpointPath, firmwareDescriptors, firmwareComponentInfo, |
| 42 | expectedPurpose); |
| 43 | |
| 44 | EXPECT_EQ(inventory.getSoftwarePath(), expectedSoftwarePath); |
| 45 | auto associationTuples = inventory.getAssociation().associations(); |
| 46 | ASSERT_FALSE(associationTuples.empty()); |
| 47 | EXPECT_EQ(std::get<2>(associationTuples[0]), expectedEndpointPath); |
| 48 | EXPECT_EQ(inventory.getVersion().version(), expectedSoftwareVersion); |
| 49 | EXPECT_EQ(inventory.getVersion().purpose(), expectedPurpose); |
| 50 | } |