From e9536d333353818eb40a459138cdaeac15f9cbf3 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 6 Oct 2015 13:51:20 -0700 Subject: [PATCH] test-tool: Avoid that login failure causes a segmentation fault Signed-off-by: Bart Van Assche --- test-tool/test_preventallow_2_itnexuses.c | 2 ++ test-tool/test_prout_preempt.c | 3 +++ test-tool/test_prout_reserve_access.c | 12 ++++++++++++ test-tool/test_prout_reserve_ownership.c | 12 ++++++++++++ test-tool/test_reserve6_2initiators.c | 2 ++ test-tool/test_reserve6_itnexus_loss.c | 2 ++ test-tool/test_reserve6_logout.c | 2 ++ test-tool/test_reserve6_target_cold_reset.c | 2 ++ test-tool/test_reserve6_target_warm_reset.c | 2 ++ test-tool/test_sanitize_readonly.c | 2 ++ test-tool/test_sanitize_reservations.c | 2 ++ 11 files changed, 43 insertions(+) diff --git a/test-tool/test_preventallow_2_itnexuses.c b/test-tool/test_preventallow_2_itnexuses.c index e7fa2d3..3ab9ce7 100644 --- a/test-tool/test_preventallow_2_itnexuses.c +++ b/test-tool/test_preventallow_2_itnexuses.c @@ -62,6 +62,8 @@ test_preventallow_2_itnexuses(void) logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; logging(LOG_VERBOSE, "Try to eject the medium on the second connection"); ret = startstopunit(sd2, 0, 0, 0, 0, 1, 0, diff --git a/test-tool/test_prout_preempt.c b/test-tool/test_prout_preempt.c index a411d72..3f5ec3e 100644 --- a/test-tool/test_prout_preempt.c +++ b/test-tool/test_prout_preempt.c @@ -70,6 +70,9 @@ test_prout_preempt_rm_reg(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; + /* register secondary key */ ret = prout_register_and_ignore(sd2, k2); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_prout_reserve_access.c b/test-tool/test_prout_reserve_access.c index 1f1c860..fdba764 100644 --- a/test-tool/test_prout_reserve_access.c +++ b/test-tool/test_prout_reserve_access.c @@ -135,6 +135,8 @@ test_prout_reserve_access_ea(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_access(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS, 0, 0, 0, 0); @@ -157,6 +159,8 @@ test_prout_reserve_access_we(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_access(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE, 1, 0, 1, 0); @@ -179,6 +183,8 @@ test_prout_reserve_access_earo(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_access(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY, 1, 1, 0, 0); @@ -201,6 +207,8 @@ test_prout_reserve_access_wero(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_access(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY, 1, 1, 1, 0); @@ -223,6 +231,8 @@ test_prout_reserve_access_eaar(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_access(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS, 1, 1, 0, 0); @@ -245,6 +255,8 @@ test_prout_reserve_access_wear(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_access(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS, 1, 1, 1, 0); diff --git a/test-tool/test_prout_reserve_ownership.c b/test-tool/test_prout_reserve_ownership.c index 722ade2..19d2268 100644 --- a/test-tool/test_prout_reserve_ownership.c +++ b/test-tool/test_prout_reserve_ownership.c @@ -109,6 +109,8 @@ test_prout_reserve_ownership_ea(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_ownership(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS, 0); mpath_sd2_put(sd2); @@ -130,6 +132,8 @@ test_prout_reserve_ownership_we(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_ownership(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE, 0); mpath_sd2_put(sd2); @@ -151,6 +155,8 @@ test_prout_reserve_ownership_earo(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_ownership(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY, 0); mpath_sd2_put(sd2); @@ -172,6 +178,8 @@ test_prout_reserve_ownership_wero(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_ownership(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY, 0); mpath_sd2_put(sd2); @@ -193,6 +201,8 @@ test_prout_reserve_ownership_eaar(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_ownership(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS, 1); mpath_sd2_put(sd2); @@ -214,6 +224,8 @@ test_prout_reserve_ownership_wear(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; verify_persistent_reserve_ownership(sd, sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS, 1); mpath_sd2_put(sd2); diff --git a/test-tool/test_reserve6_2initiators.c b/test-tool/test_reserve6_2initiators.c index 66f1fec..40fc08c 100644 --- a/test-tool/test_reserve6_2initiators.c +++ b/test-tool/test_reserve6_2initiators.c @@ -58,6 +58,8 @@ test_reserve6_2initiators(void) ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator"); ret = reserve6_conflict(sd2); diff --git a/test-tool/test_reserve6_itnexus_loss.c b/test-tool/test_reserve6_itnexus_loss.c index ed2be15..2c47060 100644 --- a/test-tool/test_reserve6_itnexus_loss.c +++ b/test-tool/test_reserve6_itnexus_loss.c @@ -55,6 +55,8 @@ test_reserve6_itnexus_loss(void) logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator"); ret = reserve6_conflict(sd2); diff --git a/test-tool/test_reserve6_logout.c b/test-tool/test_reserve6_logout.c index a8db854..0f770e6 100644 --- a/test-tool/test_reserve6_logout.c +++ b/test-tool/test_reserve6_logout.c @@ -55,6 +55,8 @@ test_reserve6_logout(void) logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator"); ret = reserve6_conflict(sd2); diff --git a/test-tool/test_reserve6_target_cold_reset.c b/test-tool/test_reserve6_target_cold_reset.c index 1312b5a..926e19b 100644 --- a/test-tool/test_reserve6_target_cold_reset.c +++ b/test-tool/test_reserve6_target_cold_reset.c @@ -65,6 +65,8 @@ test_reserve6_target_cold_reset(void) logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now"); ret = reserve6(sd2); diff --git a/test-tool/test_reserve6_target_warm_reset.c b/test-tool/test_reserve6_target_warm_reset.c index 2218dec..c555bde 100644 --- a/test-tool/test_reserve6_target_warm_reset.c +++ b/test-tool/test_reserve6_target_warm_reset.c @@ -66,6 +66,8 @@ test_reserve6_target_warm_reset(void) logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now"); ret = reserve6(sd2); diff --git a/test-tool/test_sanitize_readonly.c b/test-tool/test_sanitize_readonly.c index 263443d..29ae8fd 100644 --- a/test-tool/test_sanitize_readonly.c +++ b/test-tool/test_sanitize_readonly.c @@ -52,6 +52,8 @@ test_sanitize_readonly(void) logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; logging(LOG_VERBOSE, "Set Software Write Protect on the second connection"); ret = set_swp(sd2); diff --git a/test-tool/test_sanitize_reservations.c b/test-tool/test_sanitize_reservations.c index ce48f6b..0a76ac3 100644 --- a/test-tool/test_sanitize_reservations.c +++ b/test-tool/test_sanitize_reservations.c @@ -52,6 +52,8 @@ test_sanitize_reservations(void) logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); + if (ret < 0) + return; logging(LOG_VERBOSE, "Take out a RESERVE6 from the second " "initiator");