Mir

Merge lp:~andreas-pokorny/mir/fix-null-cmdline-crash into lp:mir

Proposed by Andreas Pokorny
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~andreas-pokorny/mir/fix-null-cmdline-crash
Merge into: lp:mir
Diff against target: 37 lines (+15/-1)
2 files modified
src/platform/options/default_configuration.cpp (+3/-1)
tests/acceptance-tests/server_configuration_options.cpp (+12/-0)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/fix-null-cmdline-crash
Reviewer Review Type Date Requested Status
Alan Griffiths Disapprove
PS Jenkins bot (community) continuous-integration Approve
Daniel van Vugt Approve
Gerry Boland Pending
Review via email: mp+265936@code.launchpad.net

Commit message

merged from 0.14.0: fix to avoid crash within qtmir test suite when accessing missing program parameter

qmir test suite passes an empty (argc == 0) command line to mir. Due to a change in configuration handling we access argv[0] on server construction.

Description of the change

This is one of the small changes that were necessary to release 0.14.0. This change allows providing argc=0 to Server. qtmir does that in a couple of tests.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) :
review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I realize it is low cost, but should we support this usecase? (Or fix qtmir?)

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

setting argc == 0 seems like a user error to me; just because it is well-known how argc/argv works.

I don't mind fixing though so that argc/argv work like a normal array, but while we're fixing zany user errors, we could also fix if someone does:
server.set_command_line(-112, nullptr);

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

.. the necessary change in qtmir would be small too. I made the change in mir because I believe that qtmirs test setup worked with previous versions of mir/

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Given the choice between adding logic to production code just to support test code and fixing the test code not to need it...I recommend fixing the test code.

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

> Given the choice between adding logic to production code just to support test
> code and fixing the test code not to need it...I recommend fixing the test
> code.

+1

Unmerged revisions

2783. By Andreas Pokorny

merged from 0.14.0: fix to avoid crash within qtmir test suite

qmir test suite passes an empty (argc == 0) command line to mir. Due to a change in configuration handling we access argv[0] on server construction.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platform/options/default_configuration.cpp'
2--- src/platform/options/default_configuration.cpp 2015-07-23 02:39:20 +0000
3+++ src/platform/options/default_configuration.cpp 2015-07-27 08:22:32 +0000
4@@ -131,7 +131,9 @@
5 argv(argv),
6 unparsed_arguments_handler{handler},
7 program_options(std::make_shared<boost::program_options::options_description>(
8- description_text(argv[0], config_file)))
9+ description_text(
10+ (argc && argv)?argv[0]:"mir-server",
11+ config_file)))
12 {
13 using namespace options;
14 namespace po = boost::program_options;
15
16=== modified file 'tests/acceptance-tests/server_configuration_options.cpp'
17--- tests/acceptance-tests/server_configuration_options.cpp 2014-11-06 13:26:52 +0000
18+++ tests/acceptance-tests/server_configuration_options.cpp 2015-07-27 08:22:32 +0000
19@@ -123,6 +123,18 @@
20 server.apply_settings();
21 }
22
23+TEST_F(ServerConfigurationOptions, empty_command_line_is_allowed)
24+{
25+ const int argc = 0;
26+ char const** argv = 0;
27+
28+ server.set_command_line(argc, argv);
29+
30+ EXPECT_CALL(*this, command_line_handler(_)).Times(0);
31+
32+ server.apply_settings();
33+}
34+
35 TEST_F(ServerConfigurationOptions, are_read_from_xdg_config_home)
36 {
37 create_config_file_in(fake_xdg_config_home);

Subscribers

People subscribed via source and target branches