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
=== added file 'tests/include/mir_test_doubles/null_logger.h'
--- tests/include/mir_test_doubles/null_logger.h 1970-01-01 00:00:00 +0000
+++ tests/include/mir_test_doubles/null_logger.h 2014-11-21 11:16:21 +0000
@@ -0,0 +1,42 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 * Authored By: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#ifndef MIR_TEST_DOUBLES_NULL_LOGGER_H_
20#define MIR_TEST_DOUBLES_NULL_LOGGER_H_
21
22#include "mir/logging/logger.h"
23
24namespace mir
25{
26namespace test
27{
28namespace doubles
29{
30/// Command line option to enable logging_opt
31extern char const* const logging_opt;
32extern char const* const logging_descr;
33
34class NullLogger : public mir::logging::Logger
35{
36void log(mir::logging::Severity, const std::string&, const std::string&) override;
37};
38}
39}
40}
41
42#endif /* MIR_TEST_DOUBLES_NULL_LOGGER_H_ */
043
=== modified file 'tests/include/mir_test_framework/stubbed_server_configuration.h'
--- tests/include/mir_test_framework/stubbed_server_configuration.h 2014-10-21 16:21:14 +0000
+++ tests/include/mir_test_framework/stubbed_server_configuration.h 2014-11-21 11:16:21 +0000
@@ -49,6 +49,7 @@
49 std::shared_ptr<input::InputSender> the_input_sender() override;49 std::shared_ptr<input::InputSender> the_input_sender() override;
5050
51 std::shared_ptr<graphics::Cursor> the_cursor() override;51 std::shared_ptr<graphics::Cursor> the_cursor() override;
52 std::shared_ptr<logging::Logger> the_logger() override;
5253
53private:54private:
54 std::shared_ptr<graphics::Platform> graphics_platform;55 std::shared_ptr<graphics::Platform> graphics_platform;
5556
=== modified file 'tests/mir_test_doubles/CMakeLists.txt'
--- tests/mir_test_doubles/CMakeLists.txt 2014-11-17 17:41:54 +0000
+++ tests/mir_test_doubles/CMakeLists.txt 2014-11-21 11:16:21 +0000
@@ -17,6 +17,7 @@
17 test_protobuf_socket_server.cpp17 test_protobuf_socket_server.cpp
18 mock_timer.cpp18 mock_timer.cpp
19 mock_frame_dropping_policy_factory.cpp19 mock_frame_dropping_policy_factory.cpp
20 null_logger.cpp
20 platform_factory.cpp21 platform_factory.cpp
21 stub_buffer.cpp22 stub_buffer.cpp
22)23)
2324
=== added file 'tests/mir_test_doubles/null_logger.cpp'
--- tests/mir_test_doubles/null_logger.cpp 1970-01-01 00:00:00 +0000
+++ tests/mir_test_doubles/null_logger.cpp 2014-11-21 11:16:21 +0000
@@ -0,0 +1,28 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 * Authored By: Alan Griffiths <alan@octopull.co.uk>
17 */
18
19#include "mir_test_doubles/null_logger.h"
20
21namespace mtd = mir::test::doubles;
22
23char const* const mtd::logging_opt = "logging";
24char const* const mtd::logging_descr = "output log during tests";
25
26void mtd::NullLogger::log(mir::logging::Severity, const std::string&, const std::string&)
27{
28}
029
=== modified file 'tests/mir_test_framework/headless_test.cpp'
--- tests/mir_test_framework/headless_test.cpp 2014-11-21 11:16:21 +0000
+++ tests/mir_test_framework/headless_test.cpp 2014-11-21 11:16:21 +0000
@@ -22,9 +22,12 @@
22#include "mir/fd.h"22#include "mir/fd.h"
23#include "mir/main_loop.h"23#include "mir/main_loop.h"
24#include "mir/options/option.h"24#include "mir/options/option.h"
25#include "mir_test_doubles/null_logger.h"
2526
26#include <boost/throw_exception.hpp>27#include <boost/throw_exception.hpp>
2728
29namespace ml = mir::logging;
30namespace mtd = mir::test::doubles;
28namespace mtf = mir_test_framework;31namespace mtf = mir_test_framework;
2932
30namespace33namespace
@@ -36,6 +39,16 @@
36{39{
37 configure_from_commandline(server);40 configure_from_commandline(server);
38 add_to_environment("MIR_SERVER_PLATFORM_GRAPHICS_LIB", "libmirplatformstub.so");41 add_to_environment("MIR_SERVER_PLATFORM_GRAPHICS_LIB", "libmirplatformstub.so");
42 server.add_configuration_option(mtd::logging_opt, mtd::logging_descr, false);
43 server.override_the_logger([&]()
44 {
45 std::shared_ptr<ml::Logger> result{};
46
47 if (!server.get_options()->get<bool>(mtd::logging_opt))
48 result = std::make_shared<mtd::NullLogger>();
49
50 return result;
51 });
39}52}
4053
41void mtf::HeadlessTest::add_to_environment(char const* key, char const* value)54void mtf::HeadlessTest::add_to_environment(char const* key, char const* value)
4255
=== modified file 'tests/mir_test_framework/stubbed_server_configuration.cpp'
--- tests/mir_test_framework/stubbed_server_configuration.cpp 2014-10-30 18:37:11 +0000
+++ tests/mir_test_framework/stubbed_server_configuration.cpp 2014-11-21 11:16:21 +0000
@@ -32,12 +32,14 @@
32#include "src/server/input/null_input_manager.h"32#include "src/server/input/null_input_manager.h"
33#include "src/server/input/null_input_dispatcher.h"33#include "src/server/input/null_input_dispatcher.h"
34#include "src/server/input/null_input_targeter.h"34#include "src/server/input/null_input_targeter.h"
35#include "mir_test_doubles/null_logger.h"
3536
36namespace geom = mir::geometry;37namespace geom = mir::geometry;
37namespace mc = mir::compositor;38namespace mc = mir::compositor;
38namespace msh = mir::shell;39namespace msh = mir::shell;
39namespace mg = mir::graphics;40namespace mg = mir::graphics;
40namespace mi = mir::input;41namespace mi = mir::input;
42namespace ml = mir::logging;
41namespace mo = mir::options;43namespace mo = mir::options;
42namespace mtd = mir::test::doubles;44namespace mtd = mir::test::doubles;
43namespace mtf = mir_test_framework;45namespace mtf = mir_test_framework;
@@ -76,6 +78,7 @@
76 namespace po = boost::program_options;78 namespace po = boost::program_options;
7779
78 result->add_options()80 result->add_options()
81 (mtd::logging_opt, po::value<bool>()->default_value(false), mtd::logging_descr)
79 ("tests-use-real-graphics", po::value<bool>()->default_value(false), "Use real graphics in tests.")82 ("tests-use-real-graphics", po::value<bool>()->default_value(false), "Use real graphics in tests.")
80 ("tests-use-real-input", po::value<bool>()->default_value(false), "Use real input in tests.");83 ("tests-use-real-input", po::value<bool>()->default_value(false), "Use real input in tests.");
8184
@@ -153,3 +156,11 @@
153{156{
154 return std::make_shared<StubCursor>();157 return std::make_shared<StubCursor>();
155}158}
159
160std::shared_ptr<ml::Logger> mtf::StubbedServerConfiguration::the_logger()
161{
162 if (the_options()->get<bool>(mtd::logging_opt))
163 return DefaultServerConfiguration::the_logger();
164
165 return std::make_shared<mtd::NullLogger>();
166}

Subscribers

People subscribed via source and target branches