Test: add helpers for reserve6/release6
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -195,6 +195,20 @@ do { \
|
|||||||
CU_ASSERT_EQUAL(_r, 0); \
|
CU_ASSERT_EQUAL(_r, 0); \
|
||||||
} while (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(...) \
|
#define REPORT_SUPPORTED_OPCODES(...) \
|
||||||
do { \
|
do { \
|
||||||
int _r; \
|
int _r; \
|
||||||
@@ -210,6 +224,20 @@ do { \
|
|||||||
CU_ASSERT_EQUAL(_r, 0); \
|
CU_ASSERT_EQUAL(_r, 0); \
|
||||||
} while (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(...) \
|
#define SANITIZE(...) \
|
||||||
do { \
|
do { \
|
||||||
int _r; \
|
int _r; \
|
||||||
|
|||||||
@@ -44,18 +44,10 @@ test_reserve6_2initiators(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
|
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
|
||||||
ret = reserve6(sd);
|
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);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Verify that the first initiator can re-RESERVE6 the same reservation");
|
logging(LOG_NORMAL, "Verify that the first initiator can re-RESERVE6 the same reservation");
|
||||||
ret = reserve6(sd);
|
RESERVE6(sd);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
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");
|
logging(LOG_NORMAL, "Try to RELEASE from the second initiator. Should be a nop");
|
||||||
ret = release6(sd2);
|
RELEASE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Test we can still send MODE SENSE from the first initiator");
|
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,
|
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);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RELEASE6 from the first initiator");
|
logging(LOG_NORMAL, "RELEASE6 from the first initiator");
|
||||||
ret = release6(sd);
|
RELEASE6(sd);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
|
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(sd2);
|
RESERVE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
||||||
ret = release6(sd2);
|
RELEASE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
mpath_sd2_put(sd2);
|
mpath_sd2_put(sd2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,14 +44,7 @@ test_reserve6_itnexus_loss(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
|
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
|
||||||
ret = reserve6(sd);
|
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);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Create a second connection to the target");
|
logging(LOG_VERBOSE, "Create a second connection to the target");
|
||||||
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
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");
|
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(sd2);
|
RESERVE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
||||||
ret = release6(sd2);
|
RELEASE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
finished:
|
finished:
|
||||||
mpath_sd2_put(sd2);
|
mpath_sd2_put(sd2);
|
||||||
|
|||||||
@@ -44,14 +44,7 @@ test_reserve6_logout(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
|
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
|
||||||
ret = reserve6(sd);
|
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);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Create a second connection to the target");
|
logging(LOG_VERBOSE, "Create a second connection to the target");
|
||||||
ret = mpath_sd2_get_or_clone(sd, &sd2);
|
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");
|
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(sd2);
|
RESERVE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
logging(LOG_NORMAL, "RELEASE6 from the second initiator");
|
||||||
ret = release6(sd2);
|
RELEASE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
mpath_sd2_put(sd2);
|
mpath_sd2_put(sd2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,14 +44,7 @@ test_reserve6_lun_reset(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
|
logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
|
||||||
ret = reserve6(sd);
|
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);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send a LUN Reset");
|
logging(LOG_VERBOSE, "Send a LUN Reset");
|
||||||
ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
|
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");
|
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(&sd2);
|
RESERVE6(&sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
||||||
ret = release6(&sd2);
|
RELEASE6(&sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
iscsi_logout_sync(sd2.iscsi_ctx);
|
iscsi_logout_sync(sd2.iscsi_ctx);
|
||||||
iscsi_destroy_context(sd2.iscsi_ctx);
|
iscsi_destroy_context(sd2.iscsi_ctx);
|
||||||
|
|||||||
@@ -29,20 +29,10 @@
|
|||||||
void
|
void
|
||||||
test_reserve6_simple(void)
|
test_reserve6_simple(void)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||||
logging(LOG_VERBOSE, "Test basic RESERVE6/RELEASE6 commands if supported");
|
logging(LOG_VERBOSE, "Test basic RESERVE6/RELEASE6 commands if supported");
|
||||||
|
|
||||||
ret = reserve6(sd);
|
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);
|
|
||||||
|
|
||||||
ret = release6(sd);
|
RELEASE6(sd);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
void
|
void
|
||||||
test_reserve6_target_cold_reset(void)
|
test_reserve6_target_cold_reset(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct scsi_device *sd2;
|
struct scsi_device *sd2;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
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");
|
logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
|
||||||
ret = reserve6(sd);
|
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);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send a Cold Reset to the target");
|
logging(LOG_VERBOSE, "Send a Cold Reset to the target");
|
||||||
ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
|
ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
|
||||||
@@ -70,12 +63,10 @@ test_reserve6_target_cold_reset(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(sd2);
|
RESERVE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
||||||
ret = release6(sd2);
|
RELEASE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
mpath_sd2_put(sd2);
|
mpath_sd2_put(sd2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,14 +44,7 @@ test_reserve6_target_warm_reset(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
|
logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
|
||||||
ret = reserve6(sd);
|
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);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send a Warm Reset to the target");
|
logging(LOG_VERBOSE, "Send a Warm Reset to the target");
|
||||||
ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
|
ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
|
||||||
@@ -71,12 +64,10 @@ test_reserve6_target_warm_reset(void)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
|
||||||
ret = reserve6(sd2);
|
RESERVE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
|
||||||
ret = release6(sd2);
|
RELEASE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
mpath_sd2_put(sd2);
|
mpath_sd2_put(sd2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ test_sanitize_readonly(void)
|
|||||||
|
|
||||||
logging(LOG_VERBOSE, "Clear Software Write Protect on the second connection");
|
logging(LOG_VERBOSE, "Clear Software Write Protect on the second connection");
|
||||||
ret = clear_swp(sd2);
|
ret = clear_swp(sd2);
|
||||||
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on "
|
logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on "
|
||||||
"first connection");
|
"first connection");
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
void
|
void
|
||||||
test_sanitize_reservations(void)
|
test_sanitize_reservations(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct iscsi_data data;
|
struct iscsi_data data;
|
||||||
struct scsi_command_descriptor *cd;
|
struct scsi_command_descriptor *cd;
|
||||||
struct scsi_device *sd2;
|
struct scsi_device *sd2;
|
||||||
@@ -58,9 +58,7 @@ test_sanitize_reservations(void)
|
|||||||
|
|
||||||
logging(LOG_VERBOSE, "Take out a RESERVE6 from the second "
|
logging(LOG_VERBOSE, "Take out a RESERVE6 from the second "
|
||||||
"initiator");
|
"initiator");
|
||||||
ret = reserve6(sd2);
|
RESERVE6(sd2);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
|
||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Check if SANITIZE OVERWRITE is supported "
|
logging(LOG_VERBOSE, "Check if SANITIZE OVERWRITE is supported "
|
||||||
"in REPORT_SUPPORTED_OPCODES");
|
"in REPORT_SUPPORTED_OPCODES");
|
||||||
|
|||||||
Reference in New Issue
Block a user