Skip to content

Commit dd7f326

Browse files
committed
test: fix Valgrind leaks in AllocationLogTest and drop HelloGTest
- free malloc'd pointers and rows at the end of each AllocationLogTest case (reported as definitely lost by the CI memcheck job) - remove the HelloGTest placeholder test and its CMake registration Signed-off-by: Herbert Rocha <herberthb12@gmail.com>
1 parent 588ba3f commit dd7f326

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

tests/unit/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ function(map2check_test EXECUTABLE)
33
add_test(NAME ${EXECUTABLE} COMMAND ${EXECUTABLE})
44
endfunction(map2check_test)
55

6-
add_executable(HelloGTest
7-
HelloGTest.cpp
8-
)
9-
map2check_test(HelloGTest)
106
add_subdirectory(backend-library)

tests/unit/HelloGTest.cpp

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/unit/backend-library/AllocationLogTest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ TEST_F(AllocationLogTest, IfAddressIsNotReleasedThenAllocationLogIsInvalid) {
6666
mark_allocation_log(&container, (long)a);
6767
long actual = valid_allocation_log(&container);
6868
EXPECT_NE(actual, 0);
69+
free(a);
6970
}
7071

7172
TEST_F(AllocationLogTest, AddressIsInAllocationLog) {
@@ -78,6 +79,8 @@ TEST_F(AllocationLogTest, AddressIsInAllocationLog) {
7879
append_element(&container, row);
7980
long actual = is_valid_allocation_address(&container, ptr, 4);
8081
EXPECT_NE(actual, 0);
82+
free(ptr);
83+
free(row);
8184
}
8285

8386
TEST_F(AllocationLogTest, AddressIsNotInAllocationLog) {
@@ -90,4 +93,6 @@ TEST_F(AllocationLogTest, AddressIsNotInAllocationLog) {
9093
append_element(&container, row);
9194
long actual = is_valid_allocation_address(&container, ptr, size * 2);
9295
EXPECT_EQ(actual, 0);
96+
free(ptr);
97+
free(row);
9398
}

0 commit comments

Comments
 (0)