Mir

Merge lp:~albaguirre/mir/no-tsan-ctest-hang into lp:mir

Proposed by Alberto Aguirre
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 2396
Proposed branch: lp:~albaguirre/mir/no-tsan-ctest-hang
Merge into: lp:mir
Diff against target: 160 lines (+42/-15)
3 files modified
cmake/MirCommon.cmake (+4/-2)
cmake/src/mir/mir_discover_gtest_tests.cpp (+37/-12)
tests/unit-tests/test_glib_main_loop.cpp (+1/-1)
To merge this branch: bzr merge lp:~albaguirre/mir/no-tsan-ctest-hang
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+252651@code.launchpad.net

Commit message

Exclude test which causes ThreadSanitizer to deadlock

Description of the change

Exclude a test which causes ThreadSanitizer to deadlock (not clear why).

Also increase timeout in a GlibMainLoop test to fix sporadic failure under ThreadSanitizer.

I can now run this without it hanging:

CXX=/usr/bin/clang++ CC=/usr/bin/clang cmake -DCMAKE_BUILD_TYPE=ThreadSanitizer ../
ctest -j<num threads> --output-on-failure

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
Alan Griffiths (alan-griffiths) wrote :

Looks good.

We should raise a bug about the test deadlocking ThreadSanitizer to reduce the chance of forgetting it.

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

> We should raise a bug about the test deadlocking ThreadSanitizer to reduce the
> chance of forgetting it.

Indeed: https://bugs.launchpad.net/mir/+bug/1431405

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

okay

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmake/MirCommon.cmake'
2--- cmake/MirCommon.cmake 2015-03-09 20:42:24 +0000
3+++ cmake/MirCommon.cmake 2015-03-11 19:59:26 +0000
4@@ -94,12 +94,14 @@
5 list(APPEND EXTRA_ENV_FLAGS "--add-environment" "TSAN_OPTIONS='suppressions=${CMAKE_SOURCE_DIR}/tools/tsan-suppressions second_deadlock_stack=1 halt_on_error=1 history_size=7'")
6 # TSan does not support multi-threaded fork
7 # TSan may open fds so "surface_creation_does_not_leak_fds" will not work as written
8- set(EXCLUDED_TESTS "--gtest_filter=-UnresponsiveClient.does_not_hang_server:DemoInProcessServerWithStubClientPlatform.surface_creation_does_not_leak_fds")
9+ # TSan deadlocks when running StreamTransportTest/0.SendsFullMessagesWhenInterrupted - disable it until understood
10+ set(EXCLUDED_TESTS "UnresponsiveClient.does_not_hang_server:DemoInProcessServerWithStubClientPlatform.surface_creation_does_not_leak_fds:StreamTransportTest/0.SendsFullMessagesWhenInterrupted")
11 endif()
12
13+ message("What is this: " "${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} --gtest_list_tests ${EXCLUDED_TESTS}")
14 add_custom_target(
15 ${TEST_DISCOVERY_TARGET_NAME} ALL
16- ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} --gtest_list_tests ${EXCLUDED_TESTS} | ${CMAKE_BINARY_DIR}/mir_gtest/mir_discover_gtest_tests --executable=${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} ${DISCOVER_FLAGS}
17+ ${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} --gtest_list_tests | ${CMAKE_BINARY_DIR}/mir_gtest/mir_discover_gtest_tests --executable=${EXECUTABLE_OUTPUT_PATH}/${EXECUTABLE} --exclusions=${EXCLUDED_TESTS} ${DISCOVER_FLAGS}
18 ${EXTRA_ENV_FLAGS}
19 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
20 COMMENT "Discovering Tests in ${EXECUTABLE}" VERBATIM)
21
22=== modified file 'cmake/src/mir/mir_discover_gtest_tests.cpp'
23--- cmake/src/mir/mir_discover_gtest_tests.cpp 2015-01-21 07:34:50 +0000
24+++ cmake/src/mir/mir_discover_gtest_tests.cpp 2015-03-11 19:59:26 +0000
25@@ -59,7 +59,7 @@
26
27 string ordinary_cmd_line_pattern()
28 {
29- static const char* pattern = "ADD_TEST(\"%s.%s\" \"%s\" \"--gtest_filter=%s\")\n";
30+ static const char* pattern = "ADD_TEST(\"%s.%s\" \"%s\" \"--gtest_filter=%s:-%s\")\n";
31 return pattern;
32 }
33
34@@ -77,7 +77,7 @@
35 vector<string> gtest_patterns{
36 "%s",
37 "--gtest_death_test_use_fork",
38- "--gtest_filter=%s"
39+ "--gtest_filter=%s:-%s"
40 };
41
42 patterns.insert(patterns.end(), gtest_patterns.begin(), gtest_patterns.end());
43@@ -121,11 +121,25 @@
44 {
45 }
46
47+ std::string exclusions_for(string const& test)
48+ {
49+ if (test.size() < 2)
50+ return {};
51+
52+ // assuming test name is Foo.*
53+ std::string test_name{test.substr(0, test.size() - 2)};
54+ if (exclusions.find(test_name) != std::string::npos)
55+ return exclusions;
56+
57+ return {};
58+ }
59+
60 const char* executable;
61 bool enable_memcheck;
62 bool memcheck_test;
63 std::vector<std::pair<std::string, std::string>> extra_environment;
64 std::vector<std::string> suppressions;
65+ std::string exclusions;
66 };
67
68 bool parse_configuration_from_cmd_line(int argc, char** argv, Configuration& config)
69@@ -136,6 +150,7 @@
70 {"memcheck-test", no_argument, 0, 0},
71 {"add-environment", required_argument, 0, 0},
72 {"suppressions", required_argument, 0, 0},
73+ {"exclusions", required_argument, 0, 0},
74 {0, 0, 0, 0}
75 };
76
77@@ -180,6 +195,11 @@
78 {
79 config.suppressions.push_back(std::string(optarg));
80 }
81+ else if (!strcmp(optname, "exclusions"))
82+ {
83+ config.exclusions = optarg;
84+ }
85+
86 }
87
88 return true;
89@@ -237,7 +257,6 @@
90 }
91 }
92 }
93-}
94
95 bool is_death_test(string const& test)
96 {
97@@ -246,11 +265,13 @@
98 bool death_test = false;
99 if (test.size() > strlen("DeathTest.*"))
100 death_test = test.substr(test.size() - strlen("DeathTest.*"),
101- strlen("DeathTest")) == "DeathTest";
102+ strlen("DeathTest")) == "DeathTest";
103
104 return death_test;
105 }
106
107+}
108+
109 int main (int argc, char **argv)
110 {
111 int output_width = get_output_width();
112@@ -316,23 +337,27 @@
113 {
114 static char cmd_line[1024] = "";
115
116- // Don't run AnonymousShmFile.* tests on older kernels
117- if (!kernel_supports_O_TMPFILE && *test == "AnonymousShmFile.*")
118- continue;
119+
120+ if (!kernel_supports_O_TMPFILE)
121+ {
122+ // Don't run AnonymousShmFile.* tests on older kernels
123+ if (*test == "AnonymousShmFile.*")
124+ continue;
125+ if (*test == "MesaBufferAllocatorTest.*")
126+ config.exclusions.append("MesaBufferAllocatorTest.software_buffers_dont_bypass:MesaBufferAllocatorTest.creates_software_rendering_buffer");
127+ }
128
129 snprintf(
130 cmd_line,
131 sizeof(cmd_line),
132 (config.enable_memcheck && !is_death_test(*test)) ?
133- memcheck_cmd_line_pattern(config.suppressions).c_str() :
134+ memcheck_cmd_line_pattern(config.suppressions).c_str() :
135 ordinary_cmd_line_pattern().c_str(),
136 test_suite.c_str(),
137 elide_string_left(*test, output_width/2).c_str(),
138 config.executable,
139- // Don't run MesaBufferAllocatorTest.{software_buffers_dont_bypass|creates_software_rendering_buffer} tests on older kernels
140- ((*test == "MesaBufferAllocatorTest.*") && !kernel_supports_O_TMPFILE)
141- ? "MesaBufferAllocatorTest.*:-MesaBufferAllocatorTest.software_buffers_dont_bypass:MesaBufferAllocatorTest.creates_software_rendering_buffer"
142- : test->c_str());
143+ test->c_str(),
144+ config.exclusions_for(*test).c_str());
145
146 if (testfilecmake.good())
147 {
148
149=== modified file 'tests/unit-tests/test_glib_main_loop.cpp'
150--- tests/unit-tests/test_glib_main_loop.cpp 2015-03-09 17:01:55 +0000
151+++ tests/unit-tests/test_glib_main_loop.cpp 2015-03-11 19:59:26 +0000
152@@ -108,7 +108,7 @@
153
154 ml.stop();
155
156- EXPECT_TRUE(loop_finished.wait_for(std::chrono::seconds{5}));
157+ EXPECT_TRUE(loop_finished.wait_for(std::chrono::seconds{10}));
158 }
159
160 TEST_F(GLibMainLoopTest, ignores_handler_added_after_stop)

Subscribers

People subscribed via source and target branches