blob: 39fb56029d1c4da27bebe5feb1db6f5f300d930a [file] [log] [blame]
Alexander Hansene1d49f12025-07-18 15:10:37 +02001
2#include "common/include/software_config.hpp"
3
4#include <fcntl.h>
5#include <inttypes.h>
6#include <unistd.h>
7
8#include <phosphor-logging/lg2.hpp>
9
10#include <gtest/gtest.h>
11
12using namespace phosphor::software;
13using namespace phosphor::software::config;
14
15constexpr uint32_t vendorIANA = 0x0324;
16
17constexpr const char* compatibleHardware =
18 "com.ExampleCorp.Hardware.ExamplePlatform.ExampleDevice";
19constexpr const char* exampleConfigName = "ExampleConfigName";
20constexpr const char* exampleConfigType = "ExampleConfigType";
21
22const std::string objPath =
23 "/xyz/openbmc_project/inventory/system/board/ExampleBoard/ExampleDevice";
24
25TEST(SoftwareConfig, ConfigCreate)
26{
27 SoftwareConfig config(objPath, vendorIANA, compatibleHardware,
28 exampleConfigType, exampleConfigName);
29
30 ASSERT_EQ(config.configName, exampleConfigName);
31 ASSERT_EQ(config.configType, exampleConfigType);
32}
33
34TEST(SoftwareConfig, FailureCompatibleNoDot)
35{
36 try
37 {
38 SoftwareConfig config(objPath, vendorIANA, "comexamplesamplecorp",
39 exampleConfigType, exampleConfigName);
40 ASSERT_FALSE(true);
41 }
42 catch (std::exception& /*unused*/)
43 {}
44}
45
46TEST(SoftwareConfig, FailureCompatibleInvalidChar)
47{
48 try
49 {
50 SoftwareConfig config(objPath, vendorIANA,
51 std::string(compatibleHardware) + "#",
52 exampleConfigType, exampleConfigName);
53 ASSERT_FALSE(true);
54 }
55 catch (std::exception& /*unused*/)
56 {}
57}