~thomas-voss/location-service/fix-1447110

« back to all changes in this revision

Viewing changes to tests/acceptance_tests.cpp

  • Committer: CI Train Bot
  • Author(s): Thomas Voß, thomas-voss
  • Date: 2015-11-27 13:00:31 UTC
  • mfrom: (128.1.10 factor-out-runtime)
  • Revision ID: ci-train-bot@canonical.com-20151127130031-2j4fvva6hzvz3g1e
- Factor out service::Runtime from daemon.cpp into its own .h/.cpp pair of files.
- Add test cases around correct operation of service::Runtime.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <com/ubuntu/location/service/stub.h>
39
39
 
40
40
#include <core/dbus/announcer.h>
 
41
#include <core/dbus/bus.h>
41
42
#include <core/dbus/fixture.h>
42
43
#include <core/dbus/resolver.h>
43
44
 
44
45
#include <core/dbus/asio/executor.h>
45
46
 
46
47
#include <core/posix/signal.h>
 
48
#include <core/posix/this_process.h>
47
49
 
48
50
#include <core/testing/cross_process_sync.h>
49
51
#include <core/testing/fork_and_run.h>
812
814
 
813
815
        options.add(Keys::update_period,
814
816
                    "Update period length for dummy::Provider setup.",
815
 
                    std::uint32_t{100});
 
817
                    std::uint32_t{10});
816
818
 
817
819
        options.add(Keys::client_count,
818
820
                    "Number of clients that should be fired up.",
865
867
};
866
868
}
867
869
 
 
870
#include "did_finish_successfully.h"
 
871
 
868
872
TEST_F(LocationServiceStandaloneLoad, MultipleClientsConnectingAndDisconnectingWorks)
869
873
{
870
874
    EXPECT_TRUE(trust_store_is_set_up_for_testing);
905
909
        };
906
910
 
907
911
        cul::service::Daemon::Configuration config;
908
 
        config.incoming = session_bus();
909
 
        config.outgoing = session_bus();
 
912
        config.incoming = std::make_shared<core::dbus::Bus>(core::posix::this_process::env::get_or_throw("DBUS_SESSION_BUS_ADDRESS"));
 
913
        config.outgoing = std::make_shared<core::dbus::Bus>(core::posix::this_process::env::get_or_throw("DBUS_SESSION_BUS_ADDRESS"));
910
914
        config.is_testing_enabled = false;
911
915
        config.providers =
912
916
        {
933
937
                    status;
934
938
    }, core::posix::StandardStream::empty);
935
939
 
936
 
    std::this_thread::sleep_for(std::chrono::seconds{2});
 
940
    std::this_thread::sleep_for(std::chrono::seconds{15});
937
941
 
938
942
    auto client = [this]()
939
943
    {
1061
1065
    {
1062
1066
        VLOG(1) << "Stopping client...: " << client.pid();
1063
1067
        client.send_signal_or_throw(core::posix::Signal::sig_term);
1064
 
        auto result = client.wait_for(core::posix::wait::Flags::untraced);
1065
 
 
1066
 
        EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status);
1067
 
        EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status);
 
1068
        EXPECT_TRUE(did_finish_successfully(client.wait_for(core::posix::wait::Flags::untraced)));
1068
1069
    }
1069
1070
 
1070
1071
    VLOG(1) << "Cleaned up clients, shutting down the service...";
1071
1072
 
1072
1073
    server.send_signal_or_throw(core::posix::Signal::sig_term);
1073
 
    auto result = server.wait_for(core::posix::wait::Flags::untraced);
1074
 
 
1075
 
    EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status);
1076
 
    EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status);
 
1074
    EXPECT_TRUE(did_finish_successfully(server.wait_for(core::posix::wait::Flags::untraced)));
1077
1075
}