Mir

Merge lp:~raof/mir/hate-hate-hate-on-the-cmake into lp:mir

Proposed by Chris Halse Rogers
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 1475
Proposed branch: lp:~raof/mir/hate-hate-hate-on-the-cmake
Merge into: lp:mir
Diff against target: 46 lines (+22/-1)
3 files modified
cmake/MirCommon.cmake (+9/-1)
cmake/src/mir/CMakeLists.txt (+5/-0)
cmake/src/mir/fail_on_success.sh (+8/-0)
To merge this branch: bzr merge lp:~raof/mir/hate-hate-hate-on-the-cmake
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Alan Griffiths Approve
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+210793@code.launchpad.net

Commit message

Make memcheck-test work with DISABLE_GTEST_TEST_DISCOVERY (ie: on the CI infrastructure)

memcheck-test is a test to check that valgrind fails with an error when run against a program that generates a known-bad memory access. So, for the test to pass, valgrind needs to return 1, which it does, but this normally indicates that a test has *failed*, so we need to invert the test success condition.

We were trying to do this by effectively embedding a shell script into CMakeList.txt, but
CMake's escaping rules make this roughly impossible, or at least mind-bendingly awkward.

Use a real, if trivial, shell script to invert the return value instead.

Fixes https://bugs.launchpad.net/mir/+bug/1291876

Description of the change

Make memcheck-test work with DISABLE_GTEST_TEST_DISCOVERY (ie: on the CI infrastructure)

The trick, of course, is to use CMake as little as possible

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
Daniel van Vugt (vanvugt) wrote :

The need for fail_on_success.sh sounds suspicious. Can we not make valgrind emit correct error codes?!

review: Needs Information
Revision history for this message
Chris Halse Rogers (raof) wrote :

Not really, no. We'd want it to emit an error code on _success_, and - surprisingly enough - it doesn't have an option to do that :)

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

What about valgrind --error-exitcode=1 ?

review: Needs Information
Revision history for this message
Chris Halse Rogers (raof) wrote :

Does exactly the *opposite* of what we want. (And we already have that option set)

Revision history for this message
Chris Halse Rogers (raof) wrote :

Specifically: test-memcheck is a test to test that valgrind *fails with an error* when run against a program that generates a known-bad memory access. So, for the test to pass, valgrind needs to return 1; which it does, but this normally indicates that a test has *failed*, so we need to invert the test success condition.

Which fail_on_success.sh does. Is it's name confusing?

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

Fair enough. Just trying to establish the reasoning as it's not explained in the commit message or description...

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

Yeah "fail_on_success.sh" is about implementation, not intent. Maybe "assert_fails.sh" would be better?

review: Approve
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 2014-03-06 06:05:17 +0000
3+++ cmake/MirCommon.cmake 2014-03-13 13:36:06 +0000
4@@ -82,7 +82,15 @@
5 function (mir_add_memcheck_test)
6 if (ENABLE_MEMCHECK_OPTION)
7 if(DISABLE_GTEST_TEST_DISCOVERY)
8- ADD_TEST("memcheck-test" "sh" "-c" "${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} ${CMAKE_BINARY_DIR}/mir_gtest/mir_test_memory_error; if [ $? != 0 ]; then exit 0; else exit 1; fi")
9+ add_custom_target(
10+ memcheck_test ALL
11+ )
12+ ADD_TEST("memcheck-test" ${CMAKE_BINARY_DIR}/mir_gtest/fail_on_success.sh ${VALGRIND_EXECUTABLE} ${VALGRIND_ARGS} ${CMAKE_BINARY_DIR}/mir_gtest/mir_test_memory_error)
13+ add_dependencies(
14+ memcheck_test
15+
16+ mir_test_memory_error
17+ )
18 else()
19 add_custom_target(
20 memcheck_test ALL
21
22=== modified file 'cmake/src/mir/CMakeLists.txt'
23--- cmake/src/mir/CMakeLists.txt 2013-03-13 04:54:15 +0000
24+++ cmake/src/mir/CMakeLists.txt 2014-03-13 13:36:06 +0000
25@@ -17,3 +17,8 @@
26 mir_test_memory_error PROPERTIES
27 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/mir_gtest
28 )
29+
30+file(INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/fail_on_success.sh
31+ DESTINATION ${CMAKE_BINARY_DIR}/mir_gtest
32+ USE_SOURCE_PERMISSIONS
33+)
34
35=== added file 'cmake/src/mir/fail_on_success.sh'
36--- cmake/src/mir/fail_on_success.sh 1970-01-01 00:00:00 +0000
37+++ cmake/src/mir/fail_on_success.sh 2014-03-13 13:36:06 +0000
38@@ -0,0 +1,8 @@
39+#!/bin/sh
40+
41+$@
42+
43+if [ $? -eq 0 ] ; then
44+ exit 1;
45+fi
46+exit 0;

Subscribers

People subscribed via source and target branches