Mir

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

Proposed by Alan Griffiths
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 2093
Proposed branch: lp:~alan-griffiths/mir/fix-1394221
Merge into: lp:mir
Prerequisite: lp:~alan-griffiths/mir/fix-command-line-handling
Diff against target: 176 lines (+96/-0)
6 files modified
tests/include/mir_test_doubles/null_logger.h (+42/-0)
tests/include/mir_test_framework/stubbed_server_configuration.h (+1/-0)
tests/mir_test_doubles/CMakeLists.txt (+1/-0)
tests/mir_test_doubles/null_logger.cpp (+28/-0)
tests/mir_test_framework/headless_test.cpp (+13/-0)
tests/mir_test_framework/stubbed_server_configuration.cpp (+11/-0)
To merge this branch: bzr merge lp:~alan-griffiths/mir/fix-1394221
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Cemil Azizoglu (community) Approve
Review via email: mp+242477@code.launchpad.net

Commit message

tests: default to no logging with an option to enable it

Description of the change

tests: default to no logging with an option to enable it

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

So now you can do:

$ bin/mir_acceptance_tests --gtest_filter=ServerStartup.creates_endpoint_on_filesystem --logging on --gtest_repeat=10

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

There was some sort of CI glitch. Is back in the queue

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tests/include/mir_test_doubles/null_logger.h'
2--- tests/include/mir_test_doubles/null_logger.h 1970-01-01 00:00:00 +0000
3+++ tests/include/mir_test_doubles/null_logger.h 2014-11-21 11:16:21 +0000
4@@ -0,0 +1,42 @@
5+/*
6+ * Copyright © 2014 Canonical Ltd.
7+ *
8+ * This program is free software: you can redistribute it and/or modify it
9+ * under the terms of the GNU 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 General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ *
20+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
21+ */
22+
23+#ifndef MIR_TEST_DOUBLES_NULL_LOGGER_H_
24+#define MIR_TEST_DOUBLES_NULL_LOGGER_H_
25+
26+#include "mir/logging/logger.h"
27+
28+namespace mir
29+{
30+namespace test
31+{
32+namespace doubles
33+{
34+/// Command line option to enable logging_opt
35+extern char const* const logging_opt;
36+extern char const* const logging_descr;
37+
38+class NullLogger : public mir::logging::Logger
39+{
40+void log(mir::logging::Severity, const std::string&, const std::string&) override;
41+};
42+}
43+}
44+}
45+
46+#endif /* MIR_TEST_DOUBLES_NULL_LOGGER_H_ */
47
48=== modified file 'tests/include/mir_test_framework/stubbed_server_configuration.h'
49--- tests/include/mir_test_framework/stubbed_server_configuration.h 2014-10-21 16:21:14 +0000
50+++ tests/include/mir_test_framework/stubbed_server_configuration.h 2014-11-21 11:16:21 +0000
51@@ -49,6 +49,7 @@
52 std::shared_ptr<input::InputSender> the_input_sender() override;
53
54 std::shared_ptr<graphics::Cursor> the_cursor() override;
55+ std::shared_ptr<logging::Logger> the_logger() override;
56
57 private:
58 std::shared_ptr<graphics::Platform> graphics_platform;
59
60=== modified file 'tests/mir_test_doubles/CMakeLists.txt'
61--- tests/mir_test_doubles/CMakeLists.txt 2014-11-17 17:41:54 +0000
62+++ tests/mir_test_doubles/CMakeLists.txt 2014-11-21 11:16:21 +0000
63@@ -17,6 +17,7 @@
64 test_protobuf_socket_server.cpp
65 mock_timer.cpp
66 mock_frame_dropping_policy_factory.cpp
67+ null_logger.cpp
68 platform_factory.cpp
69 stub_buffer.cpp
70 )
71
72=== added file 'tests/mir_test_doubles/null_logger.cpp'
73--- tests/mir_test_doubles/null_logger.cpp 1970-01-01 00:00:00 +0000
74+++ tests/mir_test_doubles/null_logger.cpp 2014-11-21 11:16:21 +0000
75@@ -0,0 +1,28 @@
76+/*
77+ * Copyright © 2014 Canonical Ltd.
78+ *
79+ * This program is free software: you can redistribute it and/or modify it
80+ * under the terms of the GNU General Public License version 3,
81+ * as published by the Free Software Foundation.
82+ *
83+ * This program is distributed in the hope that it will be useful,
84+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
85+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
86+ * GNU General Public License for more details.
87+ *
88+ * You should have received a copy of the GNU General Public License
89+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
90+ *
91+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
92+ */
93+
94+#include "mir_test_doubles/null_logger.h"
95+
96+namespace mtd = mir::test::doubles;
97+
98+char const* const mtd::logging_opt = "logging";
99+char const* const mtd::logging_descr = "output log during tests";
100+
101+void mtd::NullLogger::log(mir::logging::Severity, const std::string&, const std::string&)
102+{
103+}
104
105=== modified file 'tests/mir_test_framework/headless_test.cpp'
106--- tests/mir_test_framework/headless_test.cpp 2014-11-21 11:16:21 +0000
107+++ tests/mir_test_framework/headless_test.cpp 2014-11-21 11:16:21 +0000
108@@ -22,9 +22,12 @@
109 #include "mir/fd.h"
110 #include "mir/main_loop.h"
111 #include "mir/options/option.h"
112+#include "mir_test_doubles/null_logger.h"
113
114 #include <boost/throw_exception.hpp>
115
116+namespace ml = mir::logging;
117+namespace mtd = mir::test::doubles;
118 namespace mtf = mir_test_framework;
119
120 namespace
121@@ -36,6 +39,16 @@
122 {
123 configure_from_commandline(server);
124 add_to_environment("MIR_SERVER_PLATFORM_GRAPHICS_LIB", "libmirplatformstub.so");
125+ server.add_configuration_option(mtd::logging_opt, mtd::logging_descr, false);
126+ server.override_the_logger([&]()
127+ {
128+ std::shared_ptr<ml::Logger> result{};
129+
130+ if (!server.get_options()->get<bool>(mtd::logging_opt))
131+ result = std::make_shared<mtd::NullLogger>();
132+
133+ return result;
134+ });
135 }
136
137 void mtf::HeadlessTest::add_to_environment(char const* key, char const* value)
138
139=== modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp'
140--- tests/mir_test_framework/stubbed_server_configuration.cpp 2014-10-30 18:37:11 +0000
141+++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-11-21 11:16:21 +0000
142@@ -32,12 +32,14 @@
143 #include "src/server/input/null_input_manager.h"
144 #include "src/server/input/null_input_dispatcher.h"
145 #include "src/server/input/null_input_targeter.h"
146+#include "mir_test_doubles/null_logger.h"
147
148 namespace geom = mir::geometry;
149 namespace mc = mir::compositor;
150 namespace msh = mir::shell;
151 namespace mg = mir::graphics;
152 namespace mi = mir::input;
153+namespace ml = mir::logging;
154 namespace mo = mir::options;
155 namespace mtd = mir::test::doubles;
156 namespace mtf = mir_test_framework;
157@@ -76,6 +78,7 @@
158 namespace po = boost::program_options;
159
160 result->add_options()
161+ (mtd::logging_opt, po::value<bool>()->default_value(false), mtd::logging_descr)
162 ("tests-use-real-graphics", po::value<bool>()->default_value(false), "Use real graphics in tests.")
163 ("tests-use-real-input", po::value<bool>()->default_value(false), "Use real input in tests.");
164
165@@ -153,3 +156,11 @@
166 {
167 return std::make_shared<StubCursor>();
168 }
169+
170+std::shared_ptr<ml::Logger> mtf::StubbedServerConfiguration::the_logger()
171+{
172+ if (the_options()->get<bool>(mtd::logging_opt))
173+ return DefaultServerConfiguration::the_logger();
174+
175+ return std::make_shared<mtd::NullLogger>();
176+}

Subscribers

People subscribed via source and target branches