Mir

Merge lp:~albaguirre/mir/fix-1499229 into lp:mir

Proposed by Alberto Aguirre
Status: Merged
Approved by: Alberto Aguirre
Approved revision: no longer in the source branch.
Merged at revision: 3467
Proposed branch: lp:~albaguirre/mir/fix-1499229
Merge into: lp:mir
Diff against target: 77 lines (+25/-3)
3 files modified
include/test/mir_test_framework/process.h (+3/-0)
tests/mir_test_framework/process.cpp (+5/-0)
tests/unit-tests/dispatch/test_threaded_dispatcher.cpp (+17/-3)
To merge this branch: bzr merge lp:~albaguirre/mir/fix-1499229
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+292444@code.launchpad.net

Commit message

Workaround the fact that a child exit code may be modified by valgrind.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

LGTM

review: Approve
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3467
https://mir-jenkins.ubuntu.com/job/mir-ci/877/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/898
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/935
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/926
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/926
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/908
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/908/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/908
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/908/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/908
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/908/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/908
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/908/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/908
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/908/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/877/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/test/mir_test_framework/process.h'
2--- include/test/mir_test_framework/process.h 2016-01-29 08:18:22 +0000
3+++ include/test/mir_test_framework/process.h 2016-04-20 20:58:42 +0000
4@@ -54,6 +54,9 @@
5 // Was the process terminated by a signal?
6 bool signalled() const;
7
8+ // Was the process terminated normally?
9+ bool exited_normally() const;
10+
11 TerminationReason reason;
12 int exit_code;
13 int signal;
14
15=== modified file 'tests/mir_test_framework/process.cpp'
16--- tests/mir_test_framework/process.cpp 2015-02-22 07:46:25 +0000
17+++ tests/mir_test_framework/process.cpp 2016-04-20 20:58:42 +0000
18@@ -73,6 +73,11 @@
19 return reason == TerminationReason::child_terminated_by_signal;
20 }
21
22+bool mtf::Result::exited_normally() const
23+{
24+ return reason == TerminationReason::child_terminated_normally;
25+}
26+
27 mtf::Process::Process(pid_t pid)
28 : pid(pid)
29 , terminated(false)
30
31=== modified file 'tests/unit-tests/dispatch/test_threaded_dispatcher.cpp'
32--- tests/unit-tests/dispatch/test_threaded_dispatcher.cpp 2016-03-23 06:39:56 +0000
33+++ tests/unit-tests/dispatch/test_threaded_dispatcher.cpp 2016-04-20 20:58:42 +0000
34@@ -326,6 +326,7 @@
35 {
36 using namespace std::chrono_literals;
37 mt::CrossProcessAction stop_and_restart_process;
38+ mt::CrossProcessSync exit_success_sync;
39
40 auto child = mir_test_framework::fork_and_run_in_a_different_process(
41 [&]
42@@ -360,11 +361,14 @@
43 dispatchable->trigger();
44 EXPECT_TRUE(dispatched->wait_for(5s));
45
46+ if (!HasFailure())
47+ exit_success_sync.signal_ready();
48+
49 // Because we terminate this process with an explicit call to
50 // exit(), objects on the stack are not destroyed.
51- // We need to destroy the stop_and_restart_process object
52- // manually to avoid fd leaks.
53+ // We need to destroy these objects manually to avoid fd leaks.
54 stop_and_restart_process.~CrossProcessAction();
55+ exit_success_sync.~CrossProcessSync();
56 }
57
58 exit(HasFailure() ? EXIT_FAILURE : EXIT_SUCCESS);
59@@ -383,7 +387,17 @@
60 });
61
62 auto const result = child->wait_for_termination(30s);
63- EXPECT_TRUE(result.succeeded());
64+ EXPECT_TRUE(result.exited_normally());
65+
66+ // The test may run under valgrind which may change the exit code of the
67+ // forked child if it detects any issues. Issues detected by valgrind are
68+ // outside the scope of the test - they are for the parent caller to
69+ // examine and determine their validity; hence here we ignore the exit
70+ // code and instead use a sync object to determine if the child ran the
71+ // test successfully.
72+ // The child has already exited here so there's no reason to wait.
73+ auto const exit_success = exit_success_sync.wait_for_signal_ready_for(0s);
74+ EXPECT_TRUE(exit_success);
75 }
76
77 TEST_F(ThreadedDispatcherDeathTest, destroying_dispatcher_from_a_callback_is_an_error)

Subscribers

People subscribed via source and target branches