Discussion:
[waffle] [PATCH] cmake: wire up check and check-func with valgrind
Emil Velikov
2014-09-10 00:38:45 UTC
Permalink
Add a valgrind-* counterpart for each target. Note that the
valgrind-check-func seems to leak like a sleeve yet I'm
suspecting that part of it is due to cmocka :P

Signed-off-by: Emil Velikov <***@gmail.com>
---

Would be nice to have some sort of (valgrind) summary for all tests,
but cannot think of anything at the moment.

-Emil

CMakeLists.txt | 15 ++++++++++++++-
src/waffle/CMakeLists.txt | 8 ++++++++
tests/functional/CMakeLists.txt | 9 +++++++++
3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e62e40..ebe42ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,7 +45,7 @@ endif()
find_package(PkgConfig)

# ------------------------------------------------------------------------------
-# Targets: check, check-func
+# Targets: check, check-func, valgrind-check, valgrind-check-func
# ------------------------------------------------------------------------------

#
@@ -63,6 +63,19 @@ add_custom_target(check-func
DEPENDS check
)

+find_program(VALGRIND_EXECUTABLE valgrind)
+if(VALGRIND_EXECUTABLE)
+ # Runs the 'check' target under valgrind.
+ add_custom_target(valgrind-check
+ DEPENDS check
+ )
+
+ # Runs the 'check-func' target under valgrind.
+ add_custom_target(valgrind-check-func
+ DEPENDS valgrind-check check-func
+ )
+endif()
+
# ------------------------------------------------------------------------------
# Add subdirectories
# ------------------------------------------------------------------------------
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index 9b89a17..49ff162 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -231,6 +231,14 @@ function(add_unittest unittest_name)
COMMAND "${CMAKE_BINARY_DIR}/tests/${unittest_name}"
)
add_dependencies(check ${unittest_name}_run)
+
+ if(VALGRIND_EXECUTABLE)
+ add_custom_target(valgrind_${unittest_name}_run
+ DEPENDS ${unittest_name}
+ COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/${unittest_name}
+ )
+ add_dependencies(valgrind-check valgrind_${unittest_name}_run)
+ endif()
endfunction()

add_unittest(wcore_attrib_list_unittest
diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt
index 7a83e39..bc1f9f3 100644
--- a/tests/functional/CMakeLists.txt
+++ b/tests/functional/CMakeLists.txt
@@ -38,3 +38,12 @@ add_custom_target(gl_basic_test_run
)

add_dependencies(check-func gl_basic_test_run)
+
+if(VALGRIND_EXECUTABLE)
+ add_custom_target(valgrind_gl_basic_test_run
+ DEPENDS gl_basic_test
+ COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/functional/gl_basic_test
+ )
+
+ add_dependencies(valgrind-check-func valgrind_gl_basic_test_run)
+endif()
--
2.1.0
Emil Velikov
2014-09-10 12:23:01 UTC
Permalink
Post by Emil Velikov
Add a valgrind-* counterpart for each target. Note that the
valgrind-check-func seems to leak like a sleeve yet I'm
suspecting that part of it is due to cmocka :P
Small update:

Thanks to Nils Gladitz we can drop the hard-coded paths by using a generator
expression like below
Post by Emil Velikov
+ COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/${unittest_name}
COMMAND ${VALGRIND_EXECUTABLE} $<TARGET_FILE:${unittest_name}>
Post by Emil Velikov
+ COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/functional/gl_basic_test
COMMAND ${VALGRIND_EXECUTABLE} $<TARGET_FILE:gl_basic_test>

Cheers,
Emil
Chad Versace
2014-09-17 23:31:10 UTC
Permalink
Post by Emil Velikov
Post by Emil Velikov
Add a valgrind-* counterpart for each target. Note that the
valgrind-check-func seems to leak like a sleeve yet I'm
suspecting that part of it is due to cmocka :P
Thanks to Nils Gladitz we can drop the hard-coded paths by using a generator
expression like below
Post by Emil Velikov
+ COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/${unittest_name}
COMMAND ${VALGRIND_EXECUTABLE} $<TARGET_FILE:${unittest_name}>
Post by Emil Velikov
+ COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/functional/gl_basic_test
COMMAND ${VALGRIND_EXECUTABLE} $<TARGET_FILE:gl_basic_test>
Without or without Nils' changes, this patch is
Reviewed-by: Chad Versace <***@linux.intel.com>

I've already applied Nil's changes in my local branch. Do you mind
if I push with his changes added?
Emil Velikov
2014-09-18 00:48:20 UTC
Permalink
Post by Chad Versace
Post by Emil Velikov
Post by Emil Velikov
Add a valgrind-* counterpart for each target. Note that the
valgrind-check-func seems to leak like a sleeve yet I'm
suspecting that part of it is due to cmocka :P
Thanks to Nils Gladitz we can drop the hard-coded paths by using a generator
expression like below
Post by Emil Velikov
+ COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/${unittest_name}
COMMAND ${VALGRIND_EXECUTABLE} $<TARGET_FILE:${unittest_name}>
Post by Emil Velikov
+ COMMAND ${VALGRIND_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/functional/gl_basic_test
COMMAND ${VALGRIND_EXECUTABLE} $<TARGET_FILE:gl_basic_test>
Without or without Nils' changes, this patch is
I've already applied Nil's changes in my local branch. Do you mind
if I push with his changes added?
I would prefer if we go with Nils suggestion. Not sure if we want this in
master, although I'll leave that decision to you :)


-Emil

P.S. Nils, ngladitz on #cmake - the guy that helped our cleanup the cmocka build.
Post by Chad Versace
_______________________________________________
waffle mailing list
http://lists.freedesktop.org/mailman/listinfo/waffle
Loading...