Merge lp:~thomas-voss/dbus-cpp/remove-local-fork-and-run-and-cross-process-sync into lp:dbus-cpp

Proposed by Thomas Voß
Status: Merged
Approved by: Thomas Voß
Approved revision: 34
Merged at revision: 37
Proposed branch: lp:~thomas-voss/dbus-cpp/remove-local-fork-and-run-and-cross-process-sync
Merge into: lp:dbus-cpp
Diff against target: 174 lines (+0/-165)
2 files modified
tests/cross_process_sync.h (+0/-64)
tests/fork_and_run.h (+0/-101)
To merge this branch: bzr merge lp:~thomas-voss/dbus-cpp/remove-local-fork-and-run-and-cross-process-sync
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+203271@code.launchpad.net

Commit message

Remove local versions of cross-process-sync and fork-and-run.

Description of the change

Remove local versions of cross-process-sync and fork-and-run.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

OK, seems no tests were using this file.
lgtm.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'tests/cross_process_sync.h'
2--- tests/cross_process_sync.h 2013-06-12 07:48:00 +0000
3+++ tests/cross_process_sync.h 1970-01-01 00:00:00 +0000
4@@ -1,64 +0,0 @@
5-/*
6- * Copyright © 2013 Canonical Ltd.
7- *
8- * This program is free software: you can redistribute it and/or modify it
9- * under the terms of the GNU Lesser General Public License version 3,
10- * as published by the Free Software Foundation.
11- *
12- * This program is distributed in the hope that it will be useful,
13- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- * GNU Lesser General Public License for more details.
16- *
17- * You should have received a copy of the GNU Lesser General Public License
18- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19- *
20- * Authored by: Thomas Voß <thomas.voss@canonical.com>
21- */
22-
23-#ifndef CROSS_PROCESS_SYNC_H_
24-#define CROSS_PROCESS_SYNC_H_
25-
26-#include <cstring>
27-#include <stdexcept>
28-
29-#include <unistd.h>
30-
31-namespace test
32-{
33-struct CrossProcessSync
34-{
35- static const int read_fd = 0;
36- static const int write_fd = 1;
37-
38- CrossProcessSync()
39- {
40- if (pipe(fds) < 0)
41- throw std::runtime_error(strerror(errno));
42- }
43-
44- ~CrossProcessSync() noexcept
45- {
46- ::close(fds[0]);
47- ::close(fds[1]);
48- }
49-
50- void signal_ready()
51- {
52- int value = 42;
53- if (!write(fds[write_fd], std::addressof(value), sizeof(value)))
54- throw std::runtime_error(::strerror(errno));
55- }
56-
57- void wait_for_signal_ready() const
58- {
59- int value;
60- if (!read(fds[read_fd], std::addressof(value), sizeof(value)))
61- throw std::runtime_error(::strerror(errno));
62- }
63-
64- int fds[2];
65-};
66-}
67-
68-#endif // CROSS_PROCESS_SYNC_H_
69
70=== removed file 'tests/fork_and_run.h'
71--- tests/fork_and_run.h 2013-11-25 10:48:57 +0000
72+++ tests/fork_and_run.h 1970-01-01 00:00:00 +0000
73@@ -1,101 +0,0 @@
74-/*
75- * Copyright © 2013 Canonical Ltd.
76- *
77- * This program is free software: you can redistribute it and/or modify it
78- * under the terms of the GNU Lesser General Public License version 3,
79- * as published by the Free Software Foundation.
80- *
81- * This program is distributed in the hope that it will be useful,
82- * but WITHOUT ANY WARRANTY; without even the implied warranty of
83- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84- * GNU Lesser General Public License for more details.
85- *
86- * You should have received a copy of the GNU Lesser General Public License
87- * along with this program. If not, see <http://www.gnu.org/licenses/>.
88- *
89- * Authored by: Thomas Voß <thomas.voss@canonical.com>
90- */
91-
92-#ifndef FORK_AND_RUN_H_
93-#define FORK_AND_RUN_H_
94-
95-#include <gtest/gtest.h>
96-
97-#include <cstring>
98-#include <functional>
99-#include <stdexcept>
100-
101-#include <sys/types.h>
102-#include <signal.h>
103-#include <unistd.h>
104-
105-namespace test
106-{
107-bool is_child(pid_t pid)
108-{
109- return pid == 0;
110-}
111-
112-int fork_and_run(const std::function<void()>& service, const std::function<void()>& client)
113-{
114- auto service_pid = fork();
115-
116- if (service_pid < 0)
117- {
118- throw std::runtime_error(std::string("Could not fork child for service: ") + std::strerror(errno));
119- } else if (is_child(service_pid))
120- {
121- std::cout << "Running the service now: " << getpid() << std::endl;
122- service();
123- exit(EXIT_SUCCESS);
124- } else // parent
125- {
126- auto client_pid = fork();
127-
128- if (client_pid < 0)
129- {
130- throw std::runtime_error(std::string("Could not fork child for client: ") + std::strerror(errno));
131- } else if (is_child(client_pid))
132- {
133- std::cout << "Running the client now: " << getpid() << std::endl;
134-
135- try
136- {
137- client();
138- } catch(...)
139- {
140- exit(EXIT_FAILURE);
141- }
142-
143- exit(::testing::Test::HasFatalFailure() || ::testing::Test::HasNonfatalFailure() ? EXIT_FAILURE : EXIT_SUCCESS);
144- } else // parent
145- {
146- std::cout << "In the test process: " << getpid() << std::endl;
147- int status;
148- auto result = waitpid(client_pid, &status, WUNTRACED);
149-
150- if (result == -1)
151- {
152- throw std::runtime_error(std::string("Error waiting for child to complete: ") + std::strerror(errno));
153- }
154-
155- ::kill(service_pid, SIGKILL);
156-
157- int return_status = EXIT_FAILURE;
158- if (WIFEXITED(status))
159- {
160- std::cout << "Client exited with status: " << WEXITSTATUS(status) << std::endl;
161- return_status = WEXITSTATUS(status) == EXIT_SUCCESS ? EXIT_SUCCESS : EXIT_FAILURE;
162- } else if (WIFSIGNALED(status))
163- {
164- return_status = EXIT_FAILURE;
165- }
166-
167- EXPECT_EQ(EXIT_SUCCESS, return_status);
168- return return_status;
169- }
170- }
171-}
172-}
173-
174-#endif // FORK_AND_RUN_H_

Subscribers

People subscribed via source and target branches