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
=== modified file 'cmake/MirCommon.cmake'
--- cmake/MirCommon.cmake 2014-03-06 06:05:17 +0000
+++ cmake/MirCommon.cmake 2014-03-13 13:36:06 +0000
@@ -82,7 +82,15 @@
82function (mir_add_memcheck_test)82function (mir_add_memcheck_test)
83 if (ENABLE_MEMCHECK_OPTION)83 if (ENABLE_MEMCHECK_OPTION)
84 if(DISABLE_GTEST_TEST_DISCOVERY)84 if(DISABLE_GTEST_TEST_DISCOVERY)
85 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")85 add_custom_target(
86 memcheck_test ALL
87 )
88 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)
89 add_dependencies(
90 memcheck_test
91
92 mir_test_memory_error
93 )
86 else()94 else()
87 add_custom_target(95 add_custom_target(
88 memcheck_test ALL96 memcheck_test ALL
8997
=== modified file 'cmake/src/mir/CMakeLists.txt'
--- cmake/src/mir/CMakeLists.txt 2013-03-13 04:54:15 +0000
+++ cmake/src/mir/CMakeLists.txt 2014-03-13 13:36:06 +0000
@@ -17,3 +17,8 @@
17 mir_test_memory_error PROPERTIES17 mir_test_memory_error PROPERTIES
18 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/mir_gtest18 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/mir_gtest
19)19)
20
21file(INSTALL ${CMAKE_CURRENT_SOURCE_DIR}/fail_on_success.sh
22 DESTINATION ${CMAKE_BINARY_DIR}/mir_gtest
23 USE_SOURCE_PERMISSIONS
24)
2025
=== added file 'cmake/src/mir/fail_on_success.sh'
--- cmake/src/mir/fail_on_success.sh 1970-01-01 00:00:00 +0000
+++ cmake/src/mir/fail_on_success.sh 2014-03-13 13:36:06 +0000
@@ -0,0 +1,8 @@
1#!/bin/sh
2
3$@
4
5if [ $? -eq 0 ] ; then
6 exit 1;
7fi
8exit 0;

Subscribers

People subscribed via source and target branches