--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cmake/Modules/FindValgrind.cmake Fri May 08 00:25:54 2009 +0300
@@ -0,0 +1,36 @@
+#
+# This module looks for an installed valgrind executable
+#
+# see:
+# http://valgrind.org/
+#
+# It will set the following variables:
+#
+# Valgrind_FOUND
+# Valgrind_EXECUTABLE
+#
+
+find_program (Valgrind_EXECUTABLE
+ valgrind
+ DOC "Path to `valgrind` binary"
+)
+
+# set Valgrind_FOUND flag
+if (Valgrind_EXECUTABLE)
+ set (Valgrind_FOUND TRUE)
+
+ # status message, unless QUIETLY
+ if (NOT Valgrind_FIND_QUIETLY)
+ message (STATUS "Found valgrind at '${Valgrind_EXECUTABLE}'")
+ endif (NOT Valgrind_FIND_QUIETLY)
+
+else (Valgrind_EXECUTABLE)
+ set (Valgrind_FOUND FALSE)
+
+endif (Valgrind_EXECUTABLE)
+
+# enforce REQUIRED
+if (NOT Valgrind_FOUND AND Valgrind_FIND_REQUIRED)
+ message (FATAL_ERROR "Could not find valgrind executables")
+
+endif (NOT Valgrind_FOUND AND Valgrind_FIND_REQUIRED)
--- a/src/CMakeLists.txt Fri May 08 00:13:38 2009 +0300
+++ b/src/CMakeLists.txt Fri May 08 00:25:54 2009 +0300
@@ -75,12 +75,15 @@
LINK_FLAGS ${TEST_LFLAGS}
)
+ # path to the test harness executable
+ get_target_property (TEST_EXECUTABLE test_harness LOCATION)
+
# path to directory containing the .o/.gcdo/.gcno files for the test harness
- get_target_property (TEST_OBJECT_DIR test_harness LOCATION)
- get_filename_component (TEST_OBJECT_DIR ${TEST_OBJECT_DIR} PATH)
+ get_filename_component (TEST_OBJECT_DIR ${TEST_EXECUTABLE} PATH)
# XXX: ugly hardcoding of CMake internals, but I can't find anything else for this
set (TEST_OBJECT_DIR ${TEST_OBJECT_DIR}/CMakeFiles/test_harness.dir PARENT_SCOPE)
+ set (TEST_EXECUTABLE ${TEST_EXECUTABLE} PARENT_SCOPE)
endif (ENABLE_TEST)
--- a/test/CMakeLists.txt Fri May 08 00:13:38 2009 +0300
+++ b/test/CMakeLists.txt Fri May 08 00:25:54 2009 +0300
@@ -1,8 +1,28 @@
+find_package (Valgrind)
find_package (LCOV)
-# static flags
+# static flags for test harness
set (TEST_FLAGS --debug)
+# valgrind stuff
+if (Valgrind_FOUND)
+ # suppressions file
+ set (VALGRIND_SUPPRESSIONS ${CMAKE_CURRENT_SOURCE_DIR}/valgrind-suppressions)
+
+ # static flags
+ set (VALGRIND_FLAGS --leak-check=yes --num-callers=30 --suppressions=${VALGRIND_SUPPRESSIONS})
+
+ # command
+ set (TEST_COMMAND ${Valgrind_EXECUTABLE})
+ set (TEST_ARGS ${VALGRIND_FLAGS} ${TEST_EXECUTABLE} ${TEST_FLAGS})
+
+else (Valgrind_FOUND)
+ # plain command
+ set (TEST_COMMAND ${TEST_EXECUTABLE})
+ set (TEST_ARGS ${TEST_FLAGS})
+
+endif (Valgrind_FOUND)
+
# add LCOV coverage stuff
if (LCOV_FOUND)
# static flags
@@ -19,7 +39,7 @@
# create the test target with lcov instrumentation
add_custom_target (test
COMMAND ${CMAKE_COMMAND} -DTEST_OBJECT_DIR="${TEST_OBJECT_DIR}" -P "${CMAKE_CURRENT_SOURCE_DIR}/CleanProfileData.cmake"
- COMMAND test_harness ${TEST_FLAGS}
+ COMMAND ${TEST_COMMAND} ${TEST_ARGS}
COMMAND ${LCOV_EXECUTABLE} ${LCOV_FLAGS} --directory ${TEST_OBJECT_DIR} --capture --output-file ${LCOV_CAPTURE_PATH}
COMMAND ${LCOV_GENHTML_EXECUTABLE} ${LCOV_GENHTML_FLAGS} --output-directory ${CMAKE_CURRENT_BINARY_DIR} ${LCOV_CAPTURE_PATH}
)
@@ -31,7 +51,7 @@
if (NOT TEST_TARGET_DEFINED)
# add default `test` target
add_custom_target (test
- COMMAND test_harness ${TEST_FLAGS}
+ COMMAND ${TEST_COMMAND} ${TEST_ARGS}
)
set (TEST_TARGET_DEFINED TRUE)
@@ -40,7 +60,7 @@
# add utility targets to run the test_harness executable
add_custom_target (test_list
- COMMAND test_harness ${TEST_FLAGS} --list
+ COMMAND ${TEST_EXECUTABLE} --list
)
--- a/test/valgrind-suppressions Fri May 08 00:13:38 2009 +0300
+++ b/test/valgrind-suppressions Fri May 08 00:25:54 2009 +0300
@@ -1,7 +1,7 @@
# seems to be a common libc bug:
# https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/213825
{
- sock_tcp_connect_async-getaddrinfo-1
+ resolve_addr-getaddrinfo-1
Memcheck:Addr8
obj:/lib/ld-2.7.so
obj:/lib/ld-2.7.so
@@ -16,12 +16,11 @@
fun:__nss_lookup_function
obj:/lib/libc-2.7.so
fun:getaddrinfo
- fun:sock_tcp_connect_async_begin
- fun:sock_tcp_connect_async
+ fun:resolve_addr
}
{
- sock_tcp_connect_async-getaddrinfo-2
+ resolve_addr-getaddrinfo-2
Memcheck:Addr8
obj:/lib/ld-2.7.so
obj:/lib/ld-2.7.so
@@ -36,8 +35,7 @@
fun:__nss_lookup_function
obj:/lib/libc-2.7.so
fun:getaddrinfo
- fun:sock_tcp_connect_async_begin
- fun:sock_tcp_connect_async
+ fun:resolve_addr
}
# I'm not so sure about this one, but dlopen() seems to do 8-byte reads() at locations 4 bytes from the end of the