2
* Copyright © 2014 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored By: Alan Griffiths <alan@octopull.co.uk>
19
#ifndef MIR_TEST_FRAMEWORK_INTERPROCESS_CLIENT_SERVER_TEST_H_
20
#define MIR_TEST_FRAMEWORK_INTERPROCESS_CLIENT_SERVER_TEST_H_
22
#include "mir_test_framework/headless_test.h"
23
#include "mir_test_framework/cross_process_sync.h"
25
namespace mir_test_framework
29
class InterprocessClientServerTest : public HeadlessTest
32
char const* const mir_test_socket = test_socket_file().c_str();
34
~InterprocessClientServerTest();
36
void init_server(std::function<void()> const& init_code);
38
void run_in_server(std::function<void()> const& exec_code);
40
void run_in_client(std::function<void()> const& client_code);
42
bool is_test_process() const;
44
pid_t client_pid() const { return client_process_id; }
46
void TearDown() override;
48
// Convenient [test|server|client] identifier if adding debug messages
49
auto process_type() const -> char const* { return process_tag; }
51
void expect_server_signalled(int signal);
53
bool sigkill_server_process();
57
pid_t test_process_id{getpid()};
58
pid_t server_process_id{0};
59
pid_t client_process_id{0};
60
std::shared_ptr<Process> server_process;
61
CrossProcessSync shutdown_sync;
62
char const* process_tag = "test";
63
std::function<void()> server_setup = []{};
64
bool server_signal_expected{false};
65
int expected_server_failure_signal{0};
69
#endif /* MIR_TEST_FRAMEWORK_INTERPROCESS_CLIENT_SERVER_TEST_H_ */