Mir

Merge lp:~vanvugt/mir/test-without-entropy into lp:mir

Proposed by Daniel van Vugt on 2016-02-25
Status: Merged
Approved by: Chris Halse Rogers on 2016-02-26
Approved revision: 3344
Merged at revision: 3340
Proposed branch: lp:~vanvugt/mir/test-without-entropy
Merge into: lp:mir
Diff against target: 86 lines (+52/-0)
2 files modified
tests/acceptance-tests/test_server_startup.cpp (+29/-0)
tests/unit-tests/test_mir_cookie.cpp (+23/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/test-without-entropy
Reviewer Review Type Date Requested Status
Chris Halse Rogers Approve on 2016-02-26
Mir CI Bot continuous-integration Approve on 2016-02-26
Kevin DuBois (community) Approve on 2016-02-25
Cemil Azizoglu (community) 2016-02-25 Approve on 2016-02-25
Review via email: mp+287136@code.launchpad.net

Commit message

Add regression tests for the evil /dev/random hangs and crashes
we see when starting a Mir server (LP: #1536662 and LP: #1541188)

Description of the change

It's not a fix but it is a start.

To post a comment you must log in.
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3342
https://mir-jenkins.ubuntu.com/job/mir-ci/399/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/197
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/215
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/211
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/211
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/202
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/202/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/202
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/202/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/202
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/202/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/202
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/202/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Alan Griffiths (alan-griffiths) wrote :

+TEST(MirCookieAuthority, DISABLED_does_not_hang_or_crash)

Not an informative test name. How about following the BDD "given/when/then" style? Vis:

TEST(MirCookieAuthority, DISABLED_given_low_entropy_when_starting_then_does_not_hang_or_crash)

Cemil Azizoglu (cemil-azizoglu) wrote :

Ok

review: Approve
Kevin DuBois (kdub) wrote :

assuming there's a good reason they're disabled, lgtm.

review: Approve
lp:~vanvugt/mir/test-without-entropy updated on 2016-02-26
3343. By Daniel van Vugt on 2016-02-26

Merge latest trunk

3344. By Daniel van Vugt on 2016-02-26

Improve test case names. Also shorten the tolerance for start-up delays.

Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3344
https://mir-jenkins.ubuntu.com/job/mir-ci/407/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/207
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/231
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/223
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/223
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/213
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/213/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/213
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/213/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/213
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/213/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/213
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/213/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/213
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/213/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Chris Halse Rogers (raof) wrote :

Seems reasonable.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/acceptance-tests/test_server_startup.cpp'
2--- tests/acceptance-tests/test_server_startup.cpp 2015-02-22 07:46:25 +0000
3+++ tests/acceptance-tests/test_server_startup.cpp 2016-02-26 03:39:01 +0000
4@@ -18,11 +18,13 @@
5 */
6
7 #include "mir_test_framework/interprocess_client_server_test.h"
8+#include "mir_test_framework/headless_in_process_server.h"
9 #include "mir_test_framework/detect_server.h"
10
11 #include <chrono>
12 #include <gmock/gmock.h>
13 #include <gtest/gtest.h>
14+#include <fcntl.h>
15
16 namespace mf = mir::frontend;
17 namespace mc = mir::compositor;
18@@ -65,3 +67,30 @@
19 std::chrono::milliseconds(100)));
20 });
21 }
22+
23+TEST(ServerStartupReliability, DISABLED_can_start_with_low_entropy)
24+{ // Regression test for LP: #1536662 and LP: #1541188
25+ using namespace ::testing;
26+
27+ // Flush the entropy pool
28+ int fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
29+ ASSERT_THAT(fd, Ge(0));
30+ char buf[256];
31+ while (read(fd, buf, sizeof buf) > 0) {}
32+ close(fd);
33+
34+ auto start = std::chrono::high_resolution_clock::now();
35+
36+ struct Server : mtf::HeadlessInProcessServer
37+ {
38+ void TestBody() override {}
39+ } server;
40+
41+ EXPECT_NO_THROW(server.SetUp(););
42+
43+ auto duration = std::chrono::high_resolution_clock::now() - start;
44+ int seconds = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
45+ EXPECT_THAT(seconds, Lt(15));
46+
47+ server.TearDown();
48+}
49
50=== modified file 'tests/unit-tests/test_mir_cookie.cpp'
51--- tests/unit-tests/test_mir_cookie.cpp 2016-01-29 08:18:22 +0000
52+++ tests/unit-tests/test_mir_cookie.cpp 2016-02-26 03:39:01 +0000
53@@ -22,6 +22,9 @@
54 #include <gtest/gtest.h>
55 #include <gmock/gmock.h>
56
57+#include <chrono>
58+#include <fcntl.h>
59+
60 TEST(MirCookieAuthority, attests_real_timestamp)
61 {
62 std::vector<uint8_t> secret{ 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0xde, 0x01 };
63@@ -115,3 +118,23 @@
64 EXPECT_THAT(mir::cookie::Authority::optimal_secret_size(),
65 Ge(mir::cookie::Authority::minimum_secret_size));
66 }
67+
68+TEST(MirCookieAuthority, DISABLED_given_low_entropy_does_not_hang_or_crash)
69+{ // Regression test for LP: #1536662 and LP: #1541188
70+ using namespace testing;
71+
72+ // Flush the entropy pool
73+ int fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
74+ ASSERT_THAT(fd, Ge(0));
75+ char buf[256];
76+ while (read(fd, buf, sizeof buf) > 0) {}
77+ close(fd);
78+
79+ auto start = std::chrono::high_resolution_clock::now();
80+
81+ EXPECT_NO_THROW( mir::cookie::Authority::create() );
82+
83+ auto duration = std::chrono::high_resolution_clock::now() - start;
84+ int seconds = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
85+ EXPECT_THAT(seconds, Lt(15));
86+}

Subscribers

People subscribed via source and target branches