summaryrefslogtreecommitdiffstats
path: root/src/test/interfaces_added.cpp
blob: 6fbeeadb3487f18c6d96c05c97fc98ab5fb570e6 (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
#include "src/processing.hpp"
#include "src/test/util/asio_server_class.hpp"
#include "src/test/util/association_objects.hpp"
#include "src/test/util/debug_output.hpp"

#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>

#include <gtest/gtest.h>

class TestInterfacesAdded : public AsioServerClassTest
{
};
sdbusplus::asio::object_server*
    TestInterfacesAdded::AsioServerClassTest::server = nullptr;

// This is the data structure that comes in via the InterfacesAdded
// signal
InterfacesAdded createInterfacesAdded()
{
    std::vector<Association> associations = {
        {"inventory", "error",
         "/xyz/openbmc_project/inventory/system/chassis"}};
    sdbusplus::message::variant<std::vector<Association>> sdbVecAssoc = {
        associations};
    std::vector<std::pair<
        std::string, sdbusplus::message::variant<std::vector<Association>>>>
        vecMethToAssoc = {{"associations", sdbVecAssoc}};
    InterfacesAdded intfAdded = {{ASSOCIATIONS_INTERFACE, vecMethToAssoc}};
    return intfAdded;
}

// Verify good path of interfaces added function
TEST_F(TestInterfacesAdded, InterfacesAddedGoodPath)
{
    interface_map_type interfaceMap;
    AssociationOwnersType assocOwners;
    AssociationInterfaces assocInterfaces;
    auto intfAdded = createInterfacesAdded();

    processInterfaceAdded(interfaceMap, DEFAULT_SOURCE_PATH, intfAdded,
                          DEFAULT_DBUS_SVC, assocOwners, assocInterfaces,
                          *server);

    // Interface map will get the following:
    // /logging/entry/1 /logging/entry /logging/ /
    // dump_InterfaceMapType(interfaceMap);
    EXPECT_EQ(interfaceMap.size(), 4);

    // New association ower created so ensure it now contains a single entry
    // dump_AssociationOwnersType(assocOwners);
    EXPECT_EQ(assocOwners.size(), 1);

    // Ensure the 2 association interfaces were created
    // dump_AssociationInterfaces(assocInterfaces);
    EXPECT_EQ(assocInterfaces.size(), 2);
}
OpenPOWER on IntegriCloud