diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index b66bcd4..a2dde82 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -195,6 +195,20 @@ do { \ CU_ASSERT_EQUAL(_r, 0); \ } while (0); +#define RELEASE6(...) \ + do { \ + int _r; \ + _r = release6(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] RELEASE6 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "RELEASE6. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + #define REPORT_SUPPORTED_OPCODES(...) \ do { \ int _r; \ @@ -210,6 +224,20 @@ do { \ CU_ASSERT_EQUAL(_r, 0); \ } while (0); +#define RESERVE6(...) \ + do { \ + int _r; \ + _r = reserve6(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] RESERVE6 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "RESERVE6. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + #define SANITIZE(...) \ do { \ int _r; \ diff --git a/test-tool/test_reserve6_2initiators.c b/test-tool/test_reserve6_2initiators.c index 7b9a641..080e7ac 100644 --- a/test-tool/test_reserve6_2initiators.c +++ b/test-tool/test_reserve6_2initiators.c @@ -44,18 +44,10 @@ test_reserve6_2initiators(void) } logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); - ret = reserve6(sd); - if (ret == -2) { - logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); - CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); - + RESERVE6(sd); logging(LOG_NORMAL, "Verify that the first initiator can re-RESERVE6 the same reservation"); - ret = reserve6(sd); - CU_ASSERT_EQUAL(ret, 0); + RESERVE6(sd); ret = mpath_sd2_get_or_clone(sd, &sd2); CU_ASSERT_EQUAL(ret, 0); @@ -68,9 +60,7 @@ test_reserve6_2initiators(void) logging(LOG_NORMAL, "Try to RELEASE from the second initiator. Should be a nop"); - ret = release6(sd2); - CU_ASSERT_EQUAL(ret, 0); - + RELEASE6(sd2); logging(LOG_NORMAL, "Test we can still send MODE SENSE from the first initiator"); ret = modesense6(sd, NULL, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255, @@ -87,16 +77,13 @@ test_reserve6_2initiators(void) CU_ASSERT_EQUAL(ret, 0); logging(LOG_NORMAL, "RELEASE6 from the first initiator"); - ret = release6(sd); - CU_ASSERT_EQUAL(ret, 0); + RELEASE6(sd); logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now"); - ret = reserve6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RESERVE6(sd2); logging(LOG_NORMAL, "RELEASE6 from the second initiator"); - ret = release6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RELEASE6(sd2); mpath_sd2_put(sd2); } diff --git a/test-tool/test_reserve6_itnexus_loss.c b/test-tool/test_reserve6_itnexus_loss.c index 825bc1a..ac18055 100644 --- a/test-tool/test_reserve6_itnexus_loss.c +++ b/test-tool/test_reserve6_itnexus_loss.c @@ -44,14 +44,7 @@ test_reserve6_itnexus_loss(void) } logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); - ret = reserve6(sd); - if (ret == -2) { - logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); - CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); - + RESERVE6(sd); logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); @@ -77,12 +70,10 @@ test_reserve6_itnexus_loss(void) } logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now"); - ret = reserve6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RESERVE6(sd2); logging(LOG_NORMAL, "RELEASE6 from the second initiator"); - ret = release6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RELEASE6(sd2); finished: mpath_sd2_put(sd2); diff --git a/test-tool/test_reserve6_logout.c b/test-tool/test_reserve6_logout.c index 4556eff..c662fa2 100644 --- a/test-tool/test_reserve6_logout.c +++ b/test-tool/test_reserve6_logout.c @@ -44,14 +44,7 @@ test_reserve6_logout(void) } logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); - ret = reserve6(sd); - if (ret == -2) { - logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); - CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); - + RESERVE6(sd); logging(LOG_VERBOSE, "Create a second connection to the target"); ret = mpath_sd2_get_or_clone(sd, &sd2); @@ -75,12 +68,10 @@ test_reserve6_logout(void) } logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now"); - ret = reserve6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RESERVE6(sd2); logging(LOG_NORMAL, "RELEASE6 from the second initiator"); - ret = release6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RELEASE6(sd2); mpath_sd2_put(sd2); } diff --git a/test-tool/test_reserve6_lun_reset.c b/test-tool/test_reserve6_lun_reset.c index 824cfb0..7b4ed37 100644 --- a/test-tool/test_reserve6_lun_reset.c +++ b/test-tool/test_reserve6_lun_reset.c @@ -44,14 +44,7 @@ test_reserve6_lun_reset(void) } logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); - ret = reserve6(sd); - if (ret == -2) { - logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); - CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); - + RESERVE6(sd); logging(LOG_VERBOSE, "Send a LUN Reset"); ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun); @@ -75,12 +68,10 @@ test_reserve6_lun_reset(void) } logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now"); - ret = reserve6(&sd2); - CU_ASSERT_EQUAL(ret, 0); + RESERVE6(&sd2); logging(LOG_VERBOSE, "RELEASE6 from the second initiator"); - ret = release6(&sd2); - CU_ASSERT_EQUAL(ret, 0); + RELEASE6(&sd2); iscsi_logout_sync(sd2.iscsi_ctx); iscsi_destroy_context(sd2.iscsi_ctx); diff --git a/test-tool/test_reserve6_simple.c b/test-tool/test_reserve6_simple.c index bec1f52..27f7d19 100644 --- a/test-tool/test_reserve6_simple.c +++ b/test-tool/test_reserve6_simple.c @@ -29,20 +29,10 @@ void test_reserve6_simple(void) { - int ret; - - logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test basic RESERVE6/RELEASE6 commands if supported"); - ret = reserve6(sd); - if (ret == -2) { - logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); - CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); + RESERVE6(sd); - ret = release6(sd); - CU_ASSERT_EQUAL(ret, 0); + RELEASE6(sd); } diff --git a/test-tool/test_reserve6_target_cold_reset.c b/test-tool/test_reserve6_target_cold_reset.c index ff8e4b3..d4b9901 100644 --- a/test-tool/test_reserve6_target_cold_reset.c +++ b/test-tool/test_reserve6_target_cold_reset.c @@ -29,7 +29,7 @@ void test_reserve6_target_cold_reset(void) { - int ret; + int ret; struct scsi_device *sd2; logging(LOG_VERBOSE, LOG_BLANK_LINE); @@ -44,14 +44,7 @@ test_reserve6_target_cold_reset(void) } logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); - ret = reserve6(sd); - if (ret == -2) { - logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); - CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); - + RESERVE6(sd); logging(LOG_VERBOSE, "Send a Cold Reset to the target"); ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx); @@ -70,12 +63,10 @@ test_reserve6_target_cold_reset(void) return; logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now"); - ret = reserve6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RESERVE6(sd2); logging(LOG_VERBOSE, "RELEASE6 from the second initiator"); - ret = release6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RELEASE6(sd2); mpath_sd2_put(sd2); } diff --git a/test-tool/test_reserve6_target_warm_reset.c b/test-tool/test_reserve6_target_warm_reset.c index 7c901d9..6a8b9e2 100644 --- a/test-tool/test_reserve6_target_warm_reset.c +++ b/test-tool/test_reserve6_target_warm_reset.c @@ -44,14 +44,7 @@ test_reserve6_target_warm_reset(void) } logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); - ret = reserve6(sd); - if (ret == -2) { - logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); - CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); - return; - } - CU_ASSERT_EQUAL(ret, 0); - + RESERVE6(sd); logging(LOG_VERBOSE, "Send a Warm Reset to the target"); ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx); @@ -71,12 +64,10 @@ test_reserve6_target_warm_reset(void) return; logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now"); - ret = reserve6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RESERVE6(sd2); logging(LOG_VERBOSE, "RELEASE6 from the second initiator"); - ret = release6(sd2); - CU_ASSERT_EQUAL(ret, 0); + RELEASE6(sd2); mpath_sd2_put(sd2); } diff --git a/test-tool/test_sanitize_readonly.c b/test-tool/test_sanitize_readonly.c index 149dcdd..21183b8 100644 --- a/test-tool/test_sanitize_readonly.c +++ b/test-tool/test_sanitize_readonly.c @@ -121,6 +121,7 @@ test_sanitize_readonly(void) logging(LOG_VERBOSE, "Clear Software Write Protect on the second connection"); ret = clear_swp(sd2); + CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on " "first connection"); diff --git a/test-tool/test_sanitize_reservations.c b/test-tool/test_sanitize_reservations.c index a97eb64..711653e 100644 --- a/test-tool/test_sanitize_reservations.c +++ b/test-tool/test_sanitize_reservations.c @@ -31,7 +31,7 @@ void test_sanitize_reservations(void) { - int ret; + int ret; struct iscsi_data data; struct scsi_command_descriptor *cd; struct scsi_device *sd2; @@ -58,9 +58,7 @@ test_sanitize_reservations(void) logging(LOG_VERBOSE, "Take out a RESERVE6 from the second " "initiator"); - ret = reserve6(sd2); - CU_ASSERT_EQUAL(ret, 0); - + RESERVE6(sd2); logging(LOG_VERBOSE, "Check if SANITIZE OVERWRITE is supported " "in REPORT_SUPPORTED_OPCODES");