From 64e800a4375efe3b84c5e64303af10834de11378 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 29 Sep 2013 20:28:05 +0200 Subject: [PATCH] test tool, RESERVE(6) tests: Avoid leaking 'iscsi2' Signed-off-by: Bart Van Assche --- test-tool/test_reserve6_2initiators.c | 4 ++++ test-tool/test_reserve6_itnexus_loss.c | 7 ++++++- test-tool/test_reserve6_logout.c | 4 ++++ test-tool/test_reserve6_target_cold_reset.c | 4 ++++ test-tool/test_reserve6_target_warm_reset.c | 4 ++++ 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test-tool/test_reserve6_2initiators.c b/test-tool/test_reserve6_2initiators.c index 589af26..e0b6b4e 100644 --- a/test-tool/test_reserve6_2initiators.c +++ b/test-tool/test_reserve6_2initiators.c @@ -91,4 +91,8 @@ test_reserve6_2initiators(void) logging(LOG_NORMAL, "RELEASE6 from the second initiator"); ret = release6(iscsic2, tgt_lun); CU_ASSERT_EQUAL(ret, 0); + + iscsi_logout_sync(iscsic2); + iscsi_destroy_context(iscsic2); + iscsic2 = NULL; } diff --git a/test-tool/test_reserve6_itnexus_loss.c b/test-tool/test_reserve6_itnexus_loss.c index 8894c39..7aebbd6 100644 --- a/test-tool/test_reserve6_itnexus_loss.c +++ b/test-tool/test_reserve6_itnexus_loss.c @@ -66,7 +66,7 @@ test_reserve6_itnexus_loss(void) iscsic = iscsi_context_login(initiatorname1, tgt_url, &tgt_lun); if (iscsic == NULL) { logging(LOG_VERBOSE, "Failed to login to target"); - return; + goto finished; } logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now"); @@ -76,4 +76,9 @@ test_reserve6_itnexus_loss(void) logging(LOG_NORMAL, "RELEASE6 from the second initiator"); ret = release6(iscsic2, tgt_lun); CU_ASSERT_EQUAL(ret, 0); + +finished: + iscsi_logout_sync(iscsic2); + iscsi_destroy_context(iscsic2); + iscsic2 = NULL; } diff --git a/test-tool/test_reserve6_logout.c b/test-tool/test_reserve6_logout.c index 3b0ccf6..476b1e7 100644 --- a/test-tool/test_reserve6_logout.c +++ b/test-tool/test_reserve6_logout.c @@ -73,4 +73,8 @@ test_reserve6_logout(void) logging(LOG_NORMAL, "RELEASE6 from the second initiator"); ret = release6(iscsic2, tgt_lun); CU_ASSERT_EQUAL(ret, 0); + + iscsi_logout_sync(iscsic2); + iscsi_destroy_context(iscsic2); + iscsic2 = NULL; } diff --git a/test-tool/test_reserve6_target_cold_reset.c b/test-tool/test_reserve6_target_cold_reset.c index 00a847e..15914c7 100644 --- a/test-tool/test_reserve6_target_cold_reset.c +++ b/test-tool/test_reserve6_target_cold_reset.c @@ -69,4 +69,8 @@ test_reserve6_target_cold_reset(void) logging(LOG_VERBOSE, "RELEASE6 from the second initiator"); ret = release6(iscsic2, tgt_lun); CU_ASSERT_EQUAL(ret, 0); + + iscsi_logout_sync(iscsic2); + iscsi_destroy_context(iscsic2); + iscsic2 = NULL; } diff --git a/test-tool/test_reserve6_target_warm_reset.c b/test-tool/test_reserve6_target_warm_reset.c index 41ed515..db5bdd3 100644 --- a/test-tool/test_reserve6_target_warm_reset.c +++ b/test-tool/test_reserve6_target_warm_reset.c @@ -71,4 +71,8 @@ test_reserve6_target_warm_reset(void) logging(LOG_VERBOSE, "RELEASE6 from the second initiator"); ret = release6(iscsic2, tgt_lun); CU_ASSERT_EQUAL(ret, 0); + + iscsi_logout_sync(iscsic2); + iscsi_destroy_context(iscsic2); + iscsic2 = NULL; }