From c186195e240b1b8ba06863efc59c676ff7a88dfa Mon Sep 17 00:00:00 2001 From: Rick Barenthin Date: Sat, 30 Jul 2022 12:13:12 +0200 Subject: [PATCH] test: add memory check reporting --- .drone.yml | 6 ++++++ CMakeLists.txt | 2 ++ tests/library/hashtable/test_hashtable.c | 6 +++++- tests/library/list/test_list.c | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 4a66a99..9d4fdfd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -64,6 +64,12 @@ steps: - cd cmake-build-ci - cmake --build . - make coverage + - name: Generate memory report + image: registry.riba-interactive.de/reportly:latest + settings: + input_path: Testing + report_output: reports/memory_report.md + verbose: true - name: Report test and coverage image: alpine diff --git a/CMakeLists.txt b/CMakeLists.txt index 2656f6c..390833d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,8 @@ if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR MODERN_CMAKE_BUILD_TESTING) if (ENABLE_TEST_COVERAGE) include(CodeCoverage) + set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full") + setup_target_for_coverage_lcov( NAME coverage EXECUTABLE ${CMAKE_CTEST_COMMAND} -T memcheck diff --git a/tests/library/hashtable/test_hashtable.c b/tests/library/hashtable/test_hashtable.c index 0bd3047..9b7c76b 100644 --- a/tests/library/hashtable/test_hashtable.c +++ b/tests/library/hashtable/test_hashtable.c @@ -112,7 +112,11 @@ spec("hashtable") { value *value = value_new(1337); check(value_hashtable_insert(hashtable, key, value) == 0); check(value != NULL, "value should not be NULL"); - value_destroy(&value); + //value_destroy(&value); + free(value); + free(value); + value_new(1234); + free(NULL); } it("should return 0 with NULL as this param") { diff --git a/tests/library/list/test_list.c b/tests/library/list/test_list.c index e63718d..08aa488 100644 --- a/tests/library/list/test_list.c +++ b/tests/library/list/test_list.c @@ -135,7 +135,7 @@ spec("list") { it("should return 0 with NULL as this param") { value *value = value_new(1); check(value_list_unshift(NULL, value) == 0, "return should not be 0"); - value_destroy(&value); + //value_destroy(&value); } it("should return 0 with NULL as valueElement param") {