Compare commits

...

6 Commits

Author SHA1 Message Date
ce694d1eed test: fix issues in test to fix memleak
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2022-07-30 23:09:24 +02:00
6d84807cc8 build: update pipeline 2022-07-30 23:09:24 +02:00
8a30632455 test: update of input path 2022-07-30 23:09:24 +02:00
84aa980809 test: rename of plugin param 2022-07-30 23:09:24 +02:00
7de6e99303 test: add memory check reporting 2022-07-30 23:09:24 +02:00
150cca40af test: add memcheck and fix memleaks in test
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #13
PR #13
2022-07-27 21:28:25 +02:00
5 changed files with 44 additions and 11 deletions

View File

@ -38,7 +38,7 @@ name: tag
steps:
- name: Build release
image: registry.riba-interactive.de/alpine-build:3
image: registry.riba-interactive.de/alpine-build:4
commands:
- cmake -S. -Bcmake-build-ci -DCMAKE_BUILD_TYPE=Release
- cd cmake-build-ci
@ -58,12 +58,18 @@ name: Build and Test
steps:
- name: Build and run tests
image: registry.riba-interactive.de/alpine-build:3
image: registry.riba-interactive.de/alpine-build:4
commands:
- cmake -S. -Bcmake-build-ci -DCMAKE_BUILD_TYPE=Debug -DENABLE_TEST_COVERAGE=on
- cd cmake-build-ci
- cmake --build .
- make coverage
- name: Generate memory report
image: registry.riba-interactive.de/reportly:latest
settings:
input_path: cmake-build-ci
output_path: .reports
debug: true
- name: Report test and coverage
image: alpine

View File

@ -33,9 +33,11 @@ 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}
EXECUTABLE ${CMAKE_CTEST_COMMAND} -T memcheck
EXCLUDE "tests/*"
LCOV_ARGS --rc lcov_branch_coverage=1
GENHTML_ARGS --rc genhtml_branch_coverage=1

View File

@ -8,4 +8,5 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/a
flex \
git \
ncurses-dev\
lcov@testing
lcov@testing \
valgrind

View File

@ -109,12 +109,18 @@ spec("hashtable") {
it("should not work with the str having NULL as string") {
str key = STR_NULL_INIT;
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 0);
value *value = value_new(1337);
check(value_hashtable_insert(hashtable, key, value) == 0);
check(value != NULL, "value should not be NULL");
value_destroy(&value);
}
it("should return 0 with NULL as this param") {
str key = STR_STATIC_INIT("leet");
check(value_hashtable_insert(NULL, key, value_new(1)) == 0, "return should be 0");
value *value = value_new(1);
check(value_hashtable_insert(NULL, key, value) == 0, "return should be 0");
check(value != NULL, "value should not be NULL");
value_destroy(&value);
}
it("should not allow double entry") {
@ -124,7 +130,10 @@ spec("hashtable") {
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 1);
check(value_hashtable_has(hashtable, key) == 1, "hashtable should have the key");
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 0);
value *value = value_new(1337);
check(value_hashtable_insert(hashtable, key, value) == 0, "return should be 0");
check(value != NULL, "value should not be NULL");
value_destroy(&value);
}
}
@ -167,7 +176,6 @@ spec("hashtable") {
check(value_hashtable_markStolenCheck(hashtable, key, (value_hashtable_value_check_fn) value_check_counter, &counter) == 1);
check(value_hashtable_isStolenCheck(hashtable, key, (value_hashtable_value_check_fn) value_check_counter, &counter) == 1);
value_destroy(&resultValue);
check(resultValue == NULL, "resultValue should be NULL");
}
}
@ -206,12 +214,15 @@ spec("hashtable") {
describe("value_hashtable_markStolen()") {
it("should mark the value for the given key as stolen") {
str key = STR_STATIC_INIT("leet");
value *value = NULL;
check(value_hashtable_has(hashtable, key) == 0,"hashtable should not have the key already");
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 1);
check(value_hashtable_has(hashtable, key) == 1, "hashtable should have the key");
value = value_hashtable_lookup(hashtable, key);
check(value != NULL, "value should not be NULL");
check(value_hashtable_markStolen(hashtable, key) == 1, "hashtable should mark the value for the key as stolen");
check(value_hashtable_isStolen(hashtable, key) == 1, "hashtable should have the value for the key marked as stolen");
value_destroy(&value);
}
it("should return 0 the given key that is not existing") {
@ -224,8 +235,12 @@ spec("hashtable") {
it("should work with the empty str") {
str key = STR_STATIC_INIT("");
value *value = NULL;
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 1);
value = value_hashtable_lookup(hashtable, key);
check(value != NULL, "value should not be NULL");
check(value_hashtable_markStolen(hashtable, key) == 1, "return should be 1");
value_destroy(&value);
}
it("should not work with the str having NULL as string") {
@ -303,6 +318,7 @@ spec("hashtable") {
str otherKey2 = STR_STATIC_INIT("otherKey2");
str otherKey3 = STR_STATIC_INIT("otherKey3");
str otherKey4 = STR_STATIC_INIT("otherKey4");
value *value = NULL;
check(value_hashtable_has(hashtable, key) == 0,"hashtable should not have the key already");
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 1);
@ -313,8 +329,11 @@ spec("hashtable") {
check(value_hashtable_insert(hashtable, otherKey3, value_new(1337)) == 1);
check(value_hashtable_insert(hashtable, otherKey4, value_new(1337)) == 1);
value = value_hashtable_lookup(hashtable, key);
check(value != NULL, "value should not be NULL");
check(value_hashtable_markStolen(hashtable, key) == 1, "hashtable should mark the value for the key as stolen");
check(value_hashtable_isStolen(hashtable, key) == 1, "hashtable should have the value for the key marked as stolen");
value_destroy(&value);
}
}
}

View File

@ -78,7 +78,10 @@ spec("list") {
for_it_end();
it("should return 0 with NULL as this param") {
check(value_list_push(NULL, value_new(1)) == 0, "return should not be 0");
value *value = value_new(1);
check(value_list_push(NULL, value) == 0, "return should not be 0");
check(value != NULL, "value should not be NULL");
value_destroy(&value);
}
it("should return 0 with NULL as valueElement param") {
@ -130,7 +133,9 @@ spec("list") {
for_it_end();
it("should return 0 with NULL as this param") {
check(value_list_unshift(NULL, value_new(1)) == 0, "return should not be 0");
value *value = value_new(1);
check(value_list_unshift(NULL, value) == 0, "return should not be 0");
value_destroy(&value);
}
it("should return 0 with NULL as valueElement param") {