blob: 8abf1eb1df694ea887f5e43c341f8c4b22fb871a [file] [log] [blame]
Patrick Ventureda064282018-06-12 19:33:47 -07001#include "util.hpp"
2
3#include <gmock/gmock.h>
4#include <gtest/gtest.h>
5#include <string>
6
7TEST(UtilTest, WriteTypeEmptyString_ReturnsNONE) {
8 // Verify it responds to an empty string.
9
10 EXPECT_EQ(IOInterfaceType::NONE, GetWriteInterfaceType(""));
11}
12
13TEST(UtilTest, WriteTypeNonePath_ReturnsNONE) {
14 // Verify it responds to a path of "None"
15
16 EXPECT_EQ(IOInterfaceType::NONE, GetWriteInterfaceType("None"));
17}
18
19TEST(UtilTest, WriteTypeSysfs_ReturnsSYSFS) {
20 // Verify the sysfs type is determined with an expected path
21
22 std::string path = "/sys/devices/asfdadsf";
23 EXPECT_EQ(IOInterfaceType::SYSFS, GetWriteInterfaceType(path));
24}
25
26TEST(UtilTest, WriteTypeUnknown_ReturnsUNKNOWN) {
27 // Verify it reports unknown by default.
28
29 std::string path = "/xyz/openbmc_project";
30 EXPECT_EQ(IOInterfaceType::UNKNOWN, GetWriteInterfaceType(path));
31}
32
33TEST(UtilTest, ReadTypeEmptyString_ReturnsNONE) {
34 // Verify it responds to an empty string.
35
36 EXPECT_EQ(IOInterfaceType::NONE, GetReadInterfaceType(""));
37}
38
39TEST(UtilTest, ReadTypeNonePath_ReturnsNONE) {
40 // Verify it responds to a path of "None"
41
42 EXPECT_EQ(IOInterfaceType::NONE, GetReadInterfaceType("None"));
43}
44
45TEST(UtilTest, ReadTypeExternalSensors_ReturnsEXTERNAL) {
46 // Verify it responds to a path that represents a host sensor.
47
48 std::string path = "/xyz/openbmc_project/extsensors/temperature/fleeting0";
49 EXPECT_EQ(IOInterfaceType::EXTERNAL, GetReadInterfaceType(path));
50}
51
52TEST(UtilTest, ReadTypeOpenBMCSensor_ReturnsDBUSPASSIVE) {
53 // Verify it responds to a path that represents a dbus sensor.
54
55 std::string path = "/xyz/openbmc_project/sensors/fan_tach/fan1";
56 EXPECT_EQ(IOInterfaceType::DBUSPASSIVE, GetReadInterfaceType(path));
57}
58
59TEST(UtilTest, ReadTypeSysfsPath_ReturnsSYSFS) {
60 // Verify the sysfs type is determined with an expected path
61
62 std::string path = "/sys/devices/asdf/asdf0";
63 EXPECT_EQ(IOInterfaceType::SYSFS, GetReadInterfaceType(path));
64}
65
66TEST(UtilTest, ReadTypeUnknownDefault_ReturnsUNKNOWN) {
67 // Verify it reports unknown by default.
68
69 std::string path = "asdf09as0df9a0fd";
70 EXPECT_EQ(IOInterfaceType::UNKNOWN, GetReadInterfaceType(path));
71}