summaryrefslogtreecommitdiffstats
path: root/test/util_unittest.cpp
blob: 6e5e548b23cb958cb9a10af0c476785d37d8b8d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "util.hpp"

#include <string>

#include <gmock/gmock.h>
#include <gtest/gtest.h>

TEST(UtilTest, WriteTypeEmptyString_ReturnsNONE)
{
    // Verify it responds to an empty string.

    EXPECT_EQ(IOInterfaceType::NONE, getWriteInterfaceType(""));
}

TEST(UtilTest, WriteTypeNonePath_ReturnsNONE)
{
    // Verify it responds to a path of "None"

    EXPECT_EQ(IOInterfaceType::NONE, getWriteInterfaceType("None"));
}

TEST(UtilTest, WriteTypeSysfs_ReturnsSYSFS)
{
    // Verify the sysfs type is determined with an expected path

    std::string path = "/sys/devices/asfdadsf";
    EXPECT_EQ(IOInterfaceType::SYSFS, getWriteInterfaceType(path));
}

TEST(UtilTest, WriteTypeUnknown_ReturnsUNKNOWN)
{
    // Verify it reports unknown by default.

    std::string path = "/xyz/openbmc_project";
    EXPECT_EQ(IOInterfaceType::UNKNOWN, getWriteInterfaceType(path));
}

TEST(UtilTest, ReadTypeEmptyString_ReturnsNONE)
{
    // Verify it responds to an empty string.

    EXPECT_EQ(IOInterfaceType::NONE, getReadInterfaceType(""));
}

TEST(UtilTest, ReadTypeNonePath_ReturnsNONE)
{
    // Verify it responds to a path of "None"

    EXPECT_EQ(IOInterfaceType::NONE, getReadInterfaceType("None"));
}

TEST(UtilTest, ReadTypeExternalSensors_ReturnsEXTERNAL)
{
    // Verify it responds to a path that represents a host sensor.

    std::string path = "/xyz/openbmc_project/extsensors/temperature/fleeting0";
    EXPECT_EQ(IOInterfaceType::EXTERNAL, getReadInterfaceType(path));
}

TEST(UtilTest, ReadTypeOpenBMCSensor_ReturnsDBUSPASSIVE)
{
    // Verify it responds to a path that represents a dbus sensor.

    std::string path = "/xyz/openbmc_project/sensors/fan_tach/fan1";
    EXPECT_EQ(IOInterfaceType::DBUSPASSIVE, getReadInterfaceType(path));
}

TEST(UtilTest, ReadTypeSysfsPath_ReturnsSYSFS)
{
    // Verify the sysfs type is determined with an expected path

    std::string path = "/sys/devices/asdf/asdf0";
    EXPECT_EQ(IOInterfaceType::SYSFS, getReadInterfaceType(path));
}

TEST(UtilTest, ReadTypeUnknownDefault_ReturnsUNKNOWN)
{
    // Verify it reports unknown by default.

    std::string path = "asdf09as0df9a0fd";
    EXPECT_EQ(IOInterfaceType::UNKNOWN, getReadInterfaceType(path));
}
OpenPOWER on IntegriCloud