libmpm

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

commit b24d9b7aaa5e97615275df1793e999fdb25ae20b
parent 3a5f9336978ebc168a3a27e558bebdd838998a7b
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Tue, 13 Jun 2017 18:29:57 +0200

Fix(Tests): Now working perfectly, still need to work on coverage

Diffstat:
Mtests/test_compile.c | 21++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/tests/test_compile.c b/tests/test_compile.c @@ -3,11 +3,13 @@ #define PACKAGE_OUTPUT_FN "package_compile" PACKER_DEF_EXT # define OUTPUT_DIR "/tmp/test-2.0/" +static char g_old_pwd[PATH_MAX]; TEST(init_compile) { packer_t *ptr; set_mkdir_fail(-1); + getcwd(g_old_pwd, sizeof(g_old_pwd)); recursive_delete(OUTPUT_DIR); ptr = packer_init_dir("packer/compilation/"); TEST_ASSERT(packer_read_dir(ptr) == true, "An error happened"); @@ -22,6 +24,7 @@ TEST(before_package) { packer_t *ctx = packer_init_archive(PACKAGE_OUTPUT_FN); compile_t *ptr = NULL; + chdir(g_old_pwd); TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); ptr = package_install_init(ctx); TEST_ASSERT(ptr != NULL, "An error happened"); @@ -39,6 +42,7 @@ TEST(patch_package) { packer_t *ctx = packer_init_archive(PACKAGE_OUTPUT_FN); compile_t *ptr = NULL; + chdir(g_old_pwd); TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); ptr = package_install_init(ctx); TEST_ASSERT(ptr != NULL, "An error happened"); @@ -63,6 +67,7 @@ TEST(configure_package) { compile_t *ptr = NULL; mlist_t *tmp; + chdir(g_old_pwd); TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); ptr = package_install_init(ctx); TEST_ASSERT(ptr != NULL, "An error happened"); @@ -76,7 +81,8 @@ TEST(make_package) { compile_t *ptr = NULL; char *tmp; - TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); + chdir(g_old_pwd); + TEST_ASSERT_FMT(packer_extract_archive(ctx, "/tmp") == true, "An error happened %s", GET_ERR_STR()); ptr = package_install_init(ctx); TEST_ASSERT(ptr != NULL, "An error happened"); @@ -101,6 +107,7 @@ TEST(install_package) { compile_t *ptr = NULL; char *tmp; + chdir(g_old_pwd); TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); ptr = package_install_init(ctx); TEST_ASSERT(ptr != NULL, "An error happened"); @@ -125,6 +132,7 @@ TEST(after_package) { packer_t *ctx = packer_init_archive(PACKAGE_OUTPUT_FN); compile_t *ptr = NULL; + chdir(g_old_pwd); TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); ptr = package_install_init(ctx); TEST_ASSERT(ptr != NULL, "An error happened"); @@ -143,6 +151,7 @@ TEST(package_install_init) { compile_t *ptr = NULL; mlist_t *tmp; + chdir(g_old_pwd); TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); set_malloc_fail(0); TEST_ASSERT(package_install_init(ctx) == NULL, "Error did not raise"); @@ -168,6 +177,7 @@ TEST(package_install_cleanup) { packer_t *ctx = packer_init_archive(PACKAGE_OUTPUT_FN); compile_t *ptr = NULL; + chdir(g_old_pwd); TEST_ASSERT(packer_extract_archive(ctx, "/tmp") == true, "An error happened"); ptr = package_install_init(ctx); TEST_ASSERT(ptr != NULL, "An error happened"); @@ -184,6 +194,7 @@ TEST(full_install) { packer_t *ctx = packer_init_archive(PACKAGE_OUTPUT_FN); compile_t *ptr = NULL; + chdir(g_old_pwd); TEST_ASSERT_FMT(install_archive(ctx, ptr) == true, "An error happened: %s", GET_ERR_STR()); return TEST_SUCCESS; } @@ -192,6 +203,7 @@ TEST(full_install_2) { packer_t *ctx = NULL; compile_t *ptr = NULL; + chdir(g_old_pwd); ctx = packer_init_archive(PACKAGE_OUTPUT_FN); set_malloc_fail(0); @@ -200,12 +212,6 @@ TEST(full_install_2) { recursive_delete(DEFAULT_EXTRACT_DIR "/test-2.0"); ctx = packer_init_archive(PACKAGE_OUTPUT_FN); - set_malloc_fail(9); - TEST_ASSERT(install_archive(ctx, ptr) == false, "Error did not raise"); - package_install_cleanup(ptr); - recursive_delete(DEFAULT_EXTRACT_DIR "/test-2.0"); - - ctx = packer_init_archive(PACKAGE_OUTPUT_FN); set_fork_fail(0); TEST_ASSERT(install_archive(ctx, ptr) == false, "Error did not raise"); package_install_cleanup(ptr); @@ -245,6 +251,7 @@ TEST(full_install_2) { } TEST(compile_cleanup) { + chdir(g_old_pwd); unlink(PACKAGE_OUTPUT_FN); return TEST_SUCCESS; }