1 #include "server/Test/aserver.hpp"
2 #include "server/Test/common.hpp"
3 #include "server/Test2/aserver.hpp"
4 #include "server/Test2/common.hpp"
5
6 #include <sdbusplus/async/context.hpp>
7 #include <sdbusplus/async/match.hpp>
8 #include <sdbusplus/async/timer.hpp>
9
10 class A : public sdbusplus::aserver::server::Test<A>
11 {};
12
waitForMatch(sdbusplus::async::context & ctx,sdbusplus::async::match & ifcAdded)13 auto waitForMatch(sdbusplus::async::context& ctx,
14 sdbusplus::async::match& ifcAdded) -> sdbusplus::async::task<>
15 {
16 auto x = co_await ifcAdded.next();
17
18 ctx.request_stop();
19 }
20
shouldEmitSignal(sdbusplus::async::context & ctx)21 auto shouldEmitSignal(sdbusplus::async::context& ctx)
22 -> sdbusplus::async::task<>
23 {
24 co_await sdbusplus::async::sleep_for(ctx, std::chrono::seconds(1));
25
26 auto x =
27 std::variant<A::EnumOne, std::string, A::EnumTwo>(A::EnumOne::OneA);
28
29 sdbusplus::common::server::Test::properties_t props{
30 0, 0, 0, 0, 0, 0, 0, std::string("/my/path"), 1.0, 1.0, 1.0, 1.0, x};
31
32 auto t2 = std::make_unique<sdbusplus::aserver::server::Test<A>>(
33 ctx, "/test/something", props);
34
35 t2->emit_added();
36
37 co_await sdbusplus::async::sleep_for(ctx, std::chrono::seconds(1));
38
39 co_return;
40 }
41
main()42 int main()
43 {
44 sdbusplus::async::context ctx;
45
46 std::srand(std::chrono::system_clock::now().time_since_epoch().count());
47 std::string busName =
48 "xyz.openbmc_project.TestingInterfacesAdded" + std::to_string(rand());
49
50 ctx.request_name(busName.c_str());
51
52 sdbusplus::server::manager_t manager(ctx.get_bus(), "/test");
53
54 sdbusplus::async::match ifcAdded(
55 ctx, sdbusplus::bus::match::rules::interfacesAdded() +
56 sdbusplus::bus::match::rules::sender(busName));
57
58 ctx.spawn(waitForMatch(ctx, ifcAdded));
59 ctx.spawn(shouldEmitSignal(ctx));
60
61 ctx.run();
62
63 return 0;
64 }
65