Mir

Merge lp:~alan-griffiths/mir/fix-1300653 into lp:mir

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1750
Proposed branch: lp:~alan-griffiths/mir/fix-1300653
Merge into: lp:mir
Diff against target: 232 lines (+0/-173)
6 files modified
src/server/frontend/protobuf_message_processor.cpp (+0/-4)
src/shared/protobuf/mir_protobuf.proto (+0/-2)
tests/integration-tests/test_error_reporting.cpp (+0/-9)
tests/unit-tests/frontend/CMakeLists.txt (+0/-12)
tests/unit-tests/frontend/test_protobuf_reports_errors.cpp (+0/-9)
tests/unit-tests/frontend/test_protobuf_sends_fds.cpp (+0/-137)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1300653
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+225692@code.launchpad.net

Commit message

tests: remove a test that was not worth maintaining

Description of the change

tests: remove a test that was not worth maintaining

This test was written to prove we could send FDs over a socket. Even without this test we'd soon notice if that wasn't working!

1. much of the code tested is actually in the test, not production code.
2. this code was failing intermittently lp:1300653 (although I've never been able to reproduce)
3. the code is murky and self-documented as being "a mess"

It really isn't worth the time to fix it.

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
Daniel van Vugt (vanvugt) wrote :

Yep, looks like a redundant test in the least. And removing it will certainly solve LP: #1300653.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/frontend/protobuf_message_processor.cpp'
2--- src/server/frontend/protobuf_message_processor.cpp 2014-06-11 16:11:32 +0000
3+++ src/server/frontend/protobuf_message_processor.cpp 2014-07-04 16:54:18 +0000
4@@ -151,10 +151,6 @@
5 {
6 invoke(this, display_server.get(), &DisplayServer::release_surface, invocation);
7 }
8- else if ("test_file_descriptors" == invocation.method_name())
9- {
10- invoke(this, display_server.get(), &DisplayServer::test_file_descriptors, invocation);
11- }
12 else if ("drm_auth_magic" == invocation.method_name())
13 {
14 invoke(this, display_server.get(), &DisplayServer::drm_auth_magic, invocation);
15
16=== modified file 'src/shared/protobuf/mir_protobuf.proto'
17--- src/shared/protobuf/mir_protobuf.proto 2014-06-12 10:06:11 +0000
18+++ src/shared/protobuf/mir_protobuf.proto 2014-07-04 16:54:18 +0000
19@@ -211,8 +211,6 @@
20 // Platform specific requests
21 rpc drm_auth_magic(DRMMagic) returns (DRMAuthMagicStatus);
22
23- rpc test_file_descriptors(Void) returns (Buffer);
24-
25 rpc configure_surface(SurfaceSetting) returns (SurfaceSetting);
26 rpc configure_display(DisplayConfiguration) returns (DisplayConfiguration);
27
28
29=== modified file 'tests/integration-tests/test_error_reporting.cpp'
30--- tests/integration-tests/test_error_reporting.cpp 2014-06-03 11:04:15 +0000
31+++ tests/integration-tests/test_error_reporting.cpp 2014-07-04 16:54:18 +0000
32@@ -88,15 +88,6 @@
33 {
34 throw std::runtime_error(test_exception_text);
35 }
36-
37- void test_file_descriptors(
38- google::protobuf::RpcController*,
39- const mir::protobuf::Void*,
40- mir::protobuf::Buffer*,
41- google::protobuf::Closure*)
42- {
43- throw std::runtime_error(test_exception_text);
44- }
45 };
46
47 std::string const ErrorServer::test_exception_text{"test exception text"};
48
49=== modified file 'tests/unit-tests/frontend/CMakeLists.txt'
50--- tests/unit-tests/frontend/CMakeLists.txt 2014-06-04 15:31:35 +0000
51+++ tests/unit-tests/frontend/CMakeLists.txt 2014-07-04 16:54:18 +0000
52@@ -13,18 +13,6 @@
53 ${CMAKE_CURRENT_SOURCE_DIR}/test_basic_connector.cpp
54 )
55
56-# TODO this test is a mess - something better is needed.
57-# - it doesn't pass FDs between processes
58-# - it doesn't test that the received FD can be used
59-# - the code it tests [test_file_descriptors()] isn't part of the system proper
60-# - it touches the filesystem
61-# Really, it tests for a side-effect of passing an FD over a socket using libancillary.
62-# So, we should write an integration level test that passes FDs between
63-# processes and get rid of this test and test_file_descriptors()
64-list(APPEND UNIT_TEST_SOURCES
65- ${CMAKE_CURRENT_SOURCE_DIR}/test_protobuf_sends_fds.cpp
66-)
67-
68 if (MIR_TEST_PLATFORM STREQUAL "android")
69 list(APPEND UNIT_TEST_SOURCES
70 ${CMAKE_CURRENT_SOURCE_DIR}/test_session_mediator_android.cpp
71
72=== modified file 'tests/unit-tests/frontend/test_protobuf_reports_errors.cpp'
73--- tests/unit-tests/frontend/test_protobuf_reports_errors.cpp 2014-03-06 06:05:17 +0000
74+++ tests/unit-tests/frontend/test_protobuf_reports_errors.cpp 2014-07-04 16:54:18 +0000
75@@ -72,15 +72,6 @@
76 {
77 throw std::runtime_error(test_exception_text);
78 }
79-
80- void test_file_descriptors(
81- google::protobuf::RpcController*,
82- const protobuf::Void*,
83- protobuf::Buffer*,
84- google::protobuf::Closure*)
85- {
86- throw std::runtime_error(test_exception_text);
87- }
88 };
89
90 std::string const ErrorServer::test_exception_text{"test exception text"};
91
92=== removed file 'tests/unit-tests/frontend/test_protobuf_sends_fds.cpp'
93--- tests/unit-tests/frontend/test_protobuf_sends_fds.cpp 2014-03-06 06:05:17 +0000
94+++ tests/unit-tests/frontend/test_protobuf_sends_fds.cpp 1970-01-01 00:00:00 +0000
95@@ -1,137 +0,0 @@
96-/*
97- * Copyright © 2012 Canonical Ltd.
98- *
99- * This program is free software: you can redistribute it and/or modify
100- * it under the terms of the GNU General Public License version 3 as
101- * published by the Free Software Foundation.
102- *
103- * This program is distributed in the hope that it will be useful,
104- * but WITHOUT ANY WARRANTY; without even the implied warranty of
105- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
106- * GNU General Public License for more details.
107- *
108- * You should have received a copy of the GNU General Public License
109- * along with this program. If not, see <http://www.gnu.org/licenses/>.
110- *
111- * Authored by: Thomas Voss <thomas.voss@canonical.com>
112- * Alan Griffiths <alan@octopull.co.uk>
113- */
114-
115-#include "mir/frontend/connector.h"
116-#include "src/server/frontend/resource_cache.h"
117-
118-#include "mir_protobuf.pb.h"
119-
120-#include "mir_test_doubles/stub_ipc_factory.h"
121-#include "mir_test/stub_server_tool.h"
122-#include "mir_test/test_protobuf_client.h"
123-#include "mir_test/test_protobuf_server.h"
124-
125-#include <gtest/gtest.h>
126-#include <gmock/gmock.h>
127-
128-#include <fcntl.h>
129-
130-#include <stdexcept>
131-#include <memory>
132-#include <string>
133-
134-namespace mf = mir::frontend;
135-namespace mt = mir::test;
136-
137-namespace mir
138-{
139-namespace test
140-{
141-struct StubServerFd : public StubServerTool
142-{
143- static const int file_descriptors = 5;
144- int file_descriptor[file_descriptors];
145-
146- StubServerFd()
147- {
148- for (auto i = file_descriptor; i != file_descriptor+file_descriptors; ++i)
149- *i = 0;
150- }
151-
152- void test_file_descriptors(::google::protobuf::RpcController* ,
153- const ::mir::protobuf::Void* ,
154- ::mir::protobuf::Buffer* buffer,
155- ::google::protobuf::Closure* done)
156- {
157- for (int i = 0; i != file_descriptors; ++i)
158- {
159-
160- static char const test_file_fmt[] = "fd_test_file%d";
161- char test_file[sizeof test_file_fmt];
162- sprintf(test_file, test_file_fmt, i);
163- remove(test_file);
164- file_descriptor[i] = open(test_file, O_CREAT, S_IWUSR|S_IRUSR);
165-
166- buffer->add_fd(file_descriptor[i]);
167- }
168-
169- done->Run();
170- }
171-
172- void close_files()
173- {
174- for (auto i = file_descriptor; i != file_descriptor+file_descriptors; ++i)
175- close(*i), *i = 0;
176- }
177-
178-};
179-const int StubServerFd::file_descriptors;
180-}
181-
182-struct ProtobufSocketCommunicatorFD : public ::testing::Test
183-{
184- void SetUp()
185- {
186- stub_server_tool = std::make_shared<mt::StubServerFd>();
187- stub_server = std::make_shared<mt::TestProtobufServer>("./test_socket", stub_server_tool);
188- stub_server->comm->start();
189-
190- stub_client = std::make_shared<mt::TestProtobufClient>("./test_socket", 500);
191- stub_client->connect_parameters.set_application_name(__PRETTY_FUNCTION__);
192- }
193-
194- void TearDown()
195- {
196- stub_server.reset();
197- }
198-
199- std::shared_ptr<mt::TestProtobufClient> stub_client;
200- std::shared_ptr<mt::StubServerFd> stub_server_tool;
201-
202-private:
203- std::shared_ptr<mt::TestProtobufServer> stub_server;
204-};
205-
206-TEST_F(ProtobufSocketCommunicatorFD, test_file_descriptors)
207-{
208- mir::protobuf::Buffer fds;
209-
210- stub_client->display_server.test_file_descriptors(0, &stub_client->ignored, &fds,
211- google::protobuf::NewCallback(stub_client.get(), &mt::TestProtobufClient::tfd_done));
212-
213- stub_client->wait_for_tfd_done();
214-
215- ASSERT_EQ(stub_server_tool->file_descriptors, fds.fd_size());
216-
217- for (int i = 0; i != stub_server_tool->file_descriptors; ++i)
218- {
219- int const fd = fds.fd(i);
220- EXPECT_NE(-1, fd);
221-
222- for (int j = 0; j != stub_server_tool->file_descriptors; ++j)
223- {
224- EXPECT_NE(stub_server_tool->file_descriptor[j], fd);
225- }
226- }
227-
228- stub_server_tool->close_files();
229- for (int i = 0; i != stub_server_tool->file_descriptors; ++i)
230- close(fds.fd(i));
231-}
232-}

Subscribers

People subscribed via source and target branches