From 0933d1fe3ff822882f02135276f9a5f35df102b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 31 Jan 2014 13:16:30 +0100 Subject: [PATCH 1/5] cmake: coverage flags for clang too --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 558aedf75..1afe78035 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ string(REGEX MATCH "clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER}") if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Wextra -W -Wdeclaration-after-statement") set(CMAKE_C_FLAGS_DEBUG "-g3 -O0") - set(CMAKE_C_FLAGS_COVERAGE "-g3 -O0 -fprofile-arcs -ftest-coverage -lgcov") + set(CMAKE_C_FLAGS_COVERAGE "-g3 -O0 --coverage") set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS} -Werror -Wlogical-op -Wwrite-strings") set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual") endif(CMAKE_COMPILER_IS_GNUCC) @@ -16,16 +16,21 @@ endif(CMAKE_COMPILER_IS_GNUCC) if(CMAKE_COMPILER_IS_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Wextra -W -Wdeclaration-after-statement") set(CMAKE_C_FLAGS_DEBUG "-g3 -O0") + set(CMAKE_C_FLAGS_COVERAGE "-g3 -O0 --coverage") set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS} -Werror -Wpointer-arith -Wwrite-strings -Wdocumentation") endif(CMAKE_COMPILER_IS_CLANG) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build: None Debug Release Coverage Check CheckFull" FORCE) + if(CMAKE_BUILD_TYPE STREQUAL "Coverage") if(CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_SHARED_LINKER_FLAGS "-fprofile-arcs -ftest-coverage") + set(CMAKE_SHARED_LINKER_FLAGS "--coverage") endif(CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_CLANG) + set(CMAKE_SHARED_LINKER_FLAGS "--coverage") + endif(CMAKE_COMPILER_IS_CLANG) endif(CMAKE_BUILD_TYPE STREQUAL "Coverage") option(USE_PKCS11_HELPER_LIBRARY "Build PolarSSL with the pkcs11-helper library." OFF) From 469238a9a5d3e0f554972c9dbff499926527a1cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 31 Jan 2014 13:29:47 +0100 Subject: [PATCH 2/5] cmake: add 'ASan' build type --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1afe78035..5f31abc35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Wextra -W -Wdeclaration-after-statement") set(CMAKE_C_FLAGS_DEBUG "-g3 -O0") set(CMAKE_C_FLAGS_COVERAGE "-g3 -O0 --coverage") + set(CMAKE_C_FLAGS_ASAN "-fsanitize=address -fno-omit-frame-pointer -g3 -O1") set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS} -Werror -Wlogical-op -Wwrite-strings") set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual") endif(CMAKE_COMPILER_IS_GNUCC) @@ -17,11 +18,12 @@ if(CMAKE_COMPILER_IS_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -Wextra -W -Wdeclaration-after-statement") set(CMAKE_C_FLAGS_DEBUG "-g3 -O0") set(CMAKE_C_FLAGS_COVERAGE "-g3 -O0 --coverage") + set(CMAKE_C_FLAGS_ASAN "-fsanitize=address -fno-omit-frame-pointer -g3 -O1") set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS} -Werror -Wpointer-arith -Wwrite-strings -Wdocumentation") endif(CMAKE_COMPILER_IS_CLANG) set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} - CACHE STRING "Choose the type of build: None Debug Release Coverage Check CheckFull" + CACHE STRING "Choose the type of build: None Debug Release Coverage ASan Check CheckFull" FORCE) if(CMAKE_BUILD_TYPE STREQUAL "Coverage") From d75d7cf84472bc57953054397359fd24ebc10635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 31 Jan 2014 13:35:18 +0100 Subject: [PATCH 3/5] make: friendlier test target --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d29d830f6..b73c990a3 100644 --- a/Makefile +++ b/Makefile @@ -49,8 +49,8 @@ clean: cd programs && $(MAKE) clean && cd .. cd tests && $(MAKE) clean && cd .. -check: - ( cd tests && $(MAKE) check ) +check: lib + ( cd tests && $(MAKE) && $(MAKE) check ) apidoc: mkdir -p apidoc From 6529ff0b6ab668c0bd23469f068b627ca05e2775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 31 Jan 2014 13:41:07 +0100 Subject: [PATCH 4/5] make: add a 'test-ref-configs' target --- CMakeLists.txt | 4 ++++ Makefile | 3 +++ 2 files changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f31abc35..c3ae81d9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,10 @@ ADD_CUSTOM_TARGET(apidoc COMMAND doxygen doxygen/polarssl.doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) +ADD_CUSTOM_TARGET(test-ref-config + COMMAND tests/scripts/test-ref-configs.pl + ) + ADD_CUSTOM_TARGET(memcheck COMMAND ctest -O memcheck.log -D ExperimentalMemCheck COMMAND tail -n1 memcheck.log | grep 'Memory checking results:' > /dev/null diff --git a/Makefile b/Makefile index b73c990a3..1a1082a30 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,9 @@ clean: check: lib ( cd tests && $(MAKE) && $(MAKE) check ) +test-ref-configs: + tests/scripts/test-ref-configs.pl + apidoc: mkdir -p apidoc doxygen doxygen/polarssl.doxyfile From 546d86c8ecdf3c710ae98b1d66a23e9857477189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Fri, 31 Jan 2014 16:19:43 +0100 Subject: [PATCH 5/5] Add an 'lcov' target for HTML coverage report --- .gitignore | 1 + CMakeLists.txt | 6 ++++++ Makefile | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/.gitignore b/.gitignore index 07374ec89..02b0a98c5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ CMakeFiles CTestTestfile.cmake cmake_install.cmake Testing +Coverage diff --git a/CMakeLists.txt b/CMakeLists.txt index c3ae81d9e..a4b012c00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,12 @@ ADD_CUSTOM_TARGET(test-ref-config COMMAND tests/scripts/test-ref-configs.pl ) +ADD_CUSTOM_TARGET(lcov + COMMAND geninfo *.gcda + COMMAND genhtml -o ../../../Coverage *.info + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/library/CMakeFiles/polarssl.dir + ) + ADD_CUSTOM_TARGET(memcheck COMMAND ctest -O memcheck.log -D ExperimentalMemCheck COMMAND tail -n1 memcheck.log | grep 'Memory checking results:' > /dev/null diff --git a/Makefile b/Makefile index 1a1082a30..2ca3cf54e 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ clean: cd library && $(MAKE) clean && cd .. cd programs && $(MAKE) clean && cd .. cd tests && $(MAKE) clean && cd .. + find . \( -name \*.gcno -o -name \*.gcda -o -name *.info \) -exec rm {} + check: lib ( cd tests && $(MAKE) && $(MAKE) check ) @@ -55,6 +56,11 @@ check: lib test-ref-configs: tests/scripts/test-ref-configs.pl +lcov: + rm -rf Coverage + ( cd library && geninfo *.gcda ) + ( cd library && genhtml -o ../Coverage *.info ) + apidoc: mkdir -p apidoc doxygen doxygen/polarssl.doxyfile