Mir

Merge lp:~vanvugt/mir/test-1391976 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2699
Proposed branch: lp:~vanvugt/mir/test-1391976
Merge into: lp:mir
Diff against target: 117 lines (+85/-0)
4 files modified
debian/mir-test-tools.install (+1/-0)
tests/CMakeLists.txt (+1/-0)
tests/loader-tests/CMakeLists.txt (+34/-0)
tests/loader-tests/test_reload.c (+49/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/test-1391976
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Alexandros Frantzis (community) Approve
Review via email: mp+262669@code.launchpad.net

Commit message

Add a simple test for protobuf reload crashes (LP: #1391976)

Not enabled by default yet while the bug is still open.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

OK. I am not convinced there is much benefit in distributing this, but it doesn't hurt either.

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

alf: The benefit in distributing the test is that we can check specific distro versions for the bug (and other libraries too using the hidden argv[1] option).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

What do you mean that installing the test allows us to more easier test this on different distro versions? I can't see what it will catch and it seems kind of confusing to a downstream/consumer/user of mir-test-tools not on the Mir team

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

It's no different to the rest of mir-test-tools really. They provide no value in device bring-ups. We just package the tests for completeness.

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=== modified file 'debian/mir-test-tools.install'
2--- debian/mir-test-tools.install 2015-06-17 05:20:42 +0000
3+++ debian/mir-test-tools.install 2015-06-25 03:55:35 +0000
4@@ -4,6 +4,7 @@
5 usr/bin/mir_integration_tests
6 usr/bin/mir_performance_tests
7 usr/bin/mir_privileged_tests
8+usr/bin/mir_test_reload_protobuf
9 usr/lib/*/mir/tools/libmirclientlttng.so
10 usr/lib/*/mir/tools/libmirserverlttng.so
11 usr/lib/*/mir/server-platform/graphics-dummy.so
12
13=== modified file 'tests/CMakeLists.txt'
14--- tests/CMakeLists.txt 2015-06-18 11:59:15 +0000
15+++ tests/CMakeLists.txt 2015-06-25 03:55:35 +0000
16@@ -84,6 +84,7 @@
17 add_subdirectory(mir_test_doubles/)
18 add_subdirectory(client-language/)
19 add_subdirectory(mir-stress/)
20+add_subdirectory(loader-tests/)
21
22 mir_add_memcheck_test()
23 mir_add_detect_fd_leaks_test()
24
25=== added directory 'tests/loader-tests'
26=== added file 'tests/loader-tests/CMakeLists.txt'
27--- tests/loader-tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
28+++ tests/loader-tests/CMakeLists.txt 2015-06-25 03:55:35 +0000
29@@ -0,0 +1,34 @@
30+
31+#
32+# Note: In order for this test to work (crash in the absence of a fix), it
33+# must be a pure C program. This is because putting it in a non-trivial C++
34+# program (like mir_*_tests) somehow provides sufficient preloaded C++ symbols
35+# that the bug does not occur.
36+#
37+mir_add_wrapped_executable(mir_test_reload_protobuf test_reload.c)
38+
39+#
40+# XXX I would like to detect the full file name from the mirprotobuf target
41+# too, but it seems only the "LOCATION" property works (and provides too
42+# much info including full directory path).
43+#
44+get_target_property(mirprotobuf_soname mirprotobuf SOVERSION)
45+
46+#
47+# Being a wrapped executable means we already have the correct LD_LIBRARY_PATH
48+# so can just load the library by file name (which also allows for
49+# directory portability).
50+#
51+target_compile_definitions(mir_test_reload_protobuf PRIVATE
52+ -DDEFAULT_LIB_NAME="libmirprotobuf.so.${mirprotobuf_soname}"
53+)
54+
55+# Only a build-time dependency. Don't link to it!
56+add_dependencies(mir_test_reload_protobuf mirprotobuf)
57+
58+target_link_libraries(mir_test_reload_protobuf dl)
59+
60+# FIXME: Enable this test after LP: #1391976 is fixed.
61+#add_test(NAME Protobuf-can-be-reloaded # LP: #1391976
62+# COMMAND ${CMAKE_BINARY_DIR}/bin/mir_test_reload_protobuf
63+#)
64
65=== added file 'tests/loader-tests/test_reload.c'
66--- tests/loader-tests/test_reload.c 1970-01-01 00:00:00 +0000
67+++ tests/loader-tests/test_reload.c 2015-06-25 03:55:35 +0000
68@@ -0,0 +1,49 @@
69+/*
70+ * Copyright © 2014-2015 Canonical Ltd.
71+ *
72+ * This program is free software: you can redistribute it and/or modify it
73+ * under the terms of the GNU General Public License version 3,
74+ * as published by the Free Software Foundation.
75+ *
76+ * This program is distributed in the hope that it will be useful,
77+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
78+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
79+ * GNU General Public License for more details.
80+ *
81+ * You should have received a copy of the GNU General Public License
82+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
83+ *
84+ * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
85+ * Daniel van Vugt <daniel.van.vugt@canonical.com>
86+ */
87+
88+#include <stdio.h>
89+#include <stdlib.h>
90+#include <dlfcn.h>
91+
92+#ifdef __cplusplus
93+#error "This test only works properly as a C program not linked to C++."
94+#endif
95+
96+int main(int argc, char** argv)
97+{
98+ int i;
99+ char const* libname = argc <= 1 ? DEFAULT_LIB_NAME : argv[1];
100+ for (i = 0; i < 10; i++)
101+ {
102+ void* dl = NULL;
103+ printf("[%d] dlopen `%s' = ", i, libname);
104+ dl = dlopen(libname, RTLD_NOW);
105+ if (dl)
106+ {
107+ printf("%p\n", dl);
108+ dlclose(dl);
109+ }
110+ else
111+ {
112+ printf("NULL (%s)\n", dlerror());
113+ return 1; /* Non-zero means polite test failure */
114+ }
115+ }
116+ return 0;
117+}

Subscribers

People subscribed via source and target branches