From 7de6e9930393694d389d1d1e6db762ac9a76f4a7 Mon Sep 17 00:00:00 2001 From: Rick Barenthin Date: Sat, 30 Jul 2022 12:13:12 +0200 Subject: [PATCH 1/5] 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") { -- 2.45.2 From 84aa980809122c36d8d6f3dfbabddaca6f4a0847 Mon Sep 17 00:00:00 2001 From: Rick Barenthin Date: Sat, 30 Jul 2022 12:38:41 +0200 Subject: [PATCH 2/5] test: rename of plugin param --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 9d4fdfd..9be034a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -69,7 +69,7 @@ steps: settings: input_path: Testing report_output: reports/memory_report.md - verbose: true + debug: true - name: Report test and coverage image: alpine -- 2.45.2 From 8a306324553d4a7177d7e28853d03d58a887d296 Mon Sep 17 00:00:00 2001 From: Rick Barenthin Date: Sat, 30 Jul 2022 12:40:11 +0200 Subject: [PATCH 3/5] test: update of input path --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 9be034a..e0ded85 100644 --- a/.drone.yml +++ b/.drone.yml @@ -67,7 +67,7 @@ steps: - name: Generate memory report image: registry.riba-interactive.de/reportly:latest settings: - input_path: Testing + input_path: cmake-build-ci/Testing report_output: reports/memory_report.md debug: true -- 2.45.2 From 6d84807cc8f1ecb00f9673005dc35647b8ab1fcd Mon Sep 17 00:00:00 2001 From: Rick Barenthin Date: Sat, 30 Jul 2022 22:58:30 +0200 Subject: [PATCH 4/5] build: update pipeline --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index e0ded85..c661642 100644 --- a/.drone.yml +++ b/.drone.yml @@ -67,8 +67,8 @@ steps: - name: Generate memory report image: registry.riba-interactive.de/reportly:latest settings: - input_path: cmake-build-ci/Testing - report_output: reports/memory_report.md + input_path: cmake-build-ci + output_path: .reports debug: true - name: Report test and coverage -- 2.45.2 From ce694d1eed93a66a1947d269b5073016006cce3a Mon Sep 17 00:00:00 2001 From: Rick Barenthin Date: Sat, 30 Jul 2022 22:58:55 +0200 Subject: [PATCH 5/5] test: fix issues in test to fix memleak --- tests/library/hashtable/test_hashtable.c | 6 +----- tests/library/list/test_list.c | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/library/hashtable/test_hashtable.c b/tests/library/hashtable/test_hashtable.c index 9b7c76b..0bd3047 100644 --- a/tests/library/hashtable/test_hashtable.c +++ b/tests/library/hashtable/test_hashtable.c @@ -112,11 +112,7 @@ 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); - free(value); - free(value); - value_new(1234); - free(NULL); + value_destroy(&value); } 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 08aa488..e63718d 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") { -- 2.45.2