libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 0258d526bb1ad23f70001d4d198b3d94b0ab6542
parent 84c7d89485dff5c6c9b58917cb04ed748d48dd85
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Wed, 14 Jun 2017 19:54:16 +0200

Add(Tests): Add tests for frees on packer_header_*

Diffstat:
Minc/packer.h | 4++--
Mtests/test_packer.c | 26++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/inc/packer.h b/inc/packer.h @@ -160,10 +160,10 @@ static inline void packer_header_comp_free(packer_header_t *ptr) { if (ptr == NULL) return ; - if (ptr->compilation.configure) + if (ptr->compilation.configure != NULL) list_free(ptr->compilation.configure, &vector_string_free); - if (ptr->compilation.env) + if (ptr->compilation.env != NULL) list_free(ptr->compilation.env, &vector_string_free); ptr->compilation.env = NULL; diff --git a/tests/test_packer.c b/tests/test_packer.c @@ -532,8 +532,33 @@ TEST(get_file_information) { return TEST_SUCCESS; } +TEST(packer_inlines_frees) { + vector_string_t *str = NULL, *str2 = NULL; + + str = vector_string_init("one", "two"); + str2 = vector_string_init("one", "two"); + + packer_header_package_free(NULL); + packer_header_comp_free(NULL); + packer_header_package_free(NULL); + packer_header_deps_free(NULL); + + packer_header_t ptr; + + + packer_header_comp_init(&ptr); + + list_add(ptr.compilation.configure, str, sizeof(*str)); + list_add(ptr.compilation.env, str2, sizeof(*str2)); + + packer_header_comp_free(&ptr); + + return TEST_SUCCESS; +} + TEST(packer_create_archive_cleanup) { recursive_delete("/tmp/test-2.0"); + set_malloc_fail(-1); unlink(PACKAGE_OUTPUT_FN); return TEST_SUCCESS; } @@ -588,5 +613,6 @@ void register_test_packer(void) { reg_test("packer", packer_read_archive_header); reg_test("packer", packer_file_from_binary_to_disk); reg_test("packer", get_file_information); + reg_test("packer", packer_inlines_frees); reg_test("packer", packer_create_archive_cleanup); }