blob: 47d8396e706ceeb03cf2bf36660c61e445e0721b [file] [log] [blame]
Unive Tien7ad45b42025-08-18 06:04:53 +00001#include "fw-update/firmware_inventory.hpp"
2
3#include <string>
4
5#include <gtest/gtest.h>
6
7using namespace pldm::fw_update;
8
9class 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
27TEST(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
Unive Tienee2bd8a2025-10-30 08:11:06 +000039 FirmwareInventoryTest inventory(softwareIdentifier, expectedSoftwarePath,
40 expectedSoftwareVersion,
41 expectedEndpointPath, expectedPurpose);
Unive Tien7ad45b42025-08-18 06:04:53 +000042
43 EXPECT_EQ(inventory.getSoftwarePath(), expectedSoftwarePath);
44 auto associationTuples = inventory.getAssociation().associations();
45 ASSERT_FALSE(associationTuples.empty());
46 EXPECT_EQ(std::get<2>(associationTuples[0]), expectedEndpointPath);
47 EXPECT_EQ(inventory.getVersion().version(), expectedSoftwareVersion);
48 EXPECT_EQ(inventory.getVersion().purpose(), expectedPurpose);
49}