diff --git a/test-tool/iscsi-multipath.c b/test-tool/iscsi-multipath.c
index 70e38db..c8e3a6b 100644
--- a/test-tool/iscsi-multipath.c
+++ b/test-tool/iscsi-multipath.c
@@ -54,338 +54,338 @@ struct scsi_device *mp_sds[MPATH_MAX_DEVS];
static void
mpath_des_free(struct scsi_inquiry_device_designator *des)
{
- if (!des) {
- return;
- }
+ if (!des) {
+ return;
+ }
- free(des->designator);
- free(des);
+ free(des->designator);
+ free(des);
}
static int
mpath_des_copy(struct scsi_inquiry_device_designator *des,
- struct scsi_inquiry_device_designator **_des_cp)
+ struct scsi_inquiry_device_designator **_des_cp)
{
- struct scsi_inquiry_device_designator *des_cp;
+ struct scsi_inquiry_device_designator *des_cp;
- if (!_des_cp) {
- return -1;
- }
+ if (!_des_cp) {
+ return -1;
+ }
- des_cp = malloc(sizeof(*des_cp));
- if (des_cp == NULL) {
- return -1;
- }
+ des_cp = malloc(sizeof(*des_cp));
+ if (des_cp == NULL) {
+ return -1;
+ }
- des_cp->protocol_identifier = des->protocol_identifier;
- des_cp->code_set = des->code_set;
- des_cp->piv = des->piv;
- des_cp->association = des->association;
- des_cp->designator_type = des->designator_type;
- des_cp->designator_length = des->designator_length;
- des_cp->designator = malloc(des->designator_length);
- if (des_cp->designator == NULL) {
- free(des_cp);
- return -1;
- }
- memcpy(des_cp->designator, des->designator, des->designator_length);
- *_des_cp = des_cp;
+ des_cp->protocol_identifier = des->protocol_identifier;
+ des_cp->code_set = des->code_set;
+ des_cp->piv = des->piv;
+ des_cp->association = des->association;
+ des_cp->designator_type = des->designator_type;
+ des_cp->designator_length = des->designator_length;
+ des_cp->designator = malloc(des->designator_length);
+ if (des_cp->designator == NULL) {
+ free(des_cp);
+ return -1;
+ }
+ memcpy(des_cp->designator, des->designator, des->designator_length);
+ *_des_cp = des_cp;
- return 0;
+ return 0;
}
static int
mpath_des_cmp(struct scsi_inquiry_device_designator *des1,
- struct scsi_inquiry_device_designator *des2)
+ struct scsi_inquiry_device_designator *des2)
{
- if (des1->protocol_identifier != des2->protocol_identifier) {
- return -1;
- }
+ if (des1->protocol_identifier != des2->protocol_identifier) {
+ return -1;
+ }
- if (des1->code_set != des2->code_set) {
- return -1;
- }
+ if (des1->code_set != des2->code_set) {
+ return -1;
+ }
- if (des1->piv != des2->piv) {
- return -1;
- }
+ if (des1->piv != des2->piv) {
+ return -1;
+ }
- if (des1->association != des2->association) {
- return -1;
- }
+ if (des1->association != des2->association) {
+ return -1;
+ }
- if (des1->designator_type != des2->designator_type) {
- return -1;
- }
+ if (des1->designator_type != des2->designator_type) {
+ return -1;
+ }
- if (des1->designator_length != des2->designator_length) {
- return -1;
- }
+ if (des1->designator_length != des2->designator_length) {
+ return -1;
+ }
- return memcmp(des1->designator, des2->designator,
- des1->designator_length);
+ return memcmp(des1->designator, des2->designator,
+ des1->designator_length);
}
static int
mpath_check_matching_ids_devid_vpd(int num_sds,
- struct scsi_device **sds)
+ struct scsi_device **sds)
{
- int i;
- int num_sds_with_valid_id = 0;
- struct scsi_task *inq_task = NULL;
- struct scsi_inquiry_device_designator *des_saved = NULL;
+ int i;
+ int num_sds_with_valid_id = 0;
+ struct scsi_task *inq_task = NULL;
+ struct scsi_inquiry_device_designator *des_saved = NULL;
- for (i = 0; i < num_sds; i++) {
- int ret;
- int full_size;
- struct scsi_inquiry_device_identification *inq_id_data;
- struct scsi_inquiry_device_designator *des;
+ for (i = 0; i < num_sds; i++) {
+ int ret;
+ int full_size;
+ struct scsi_inquiry_device_identification *inq_id_data;
+ struct scsi_inquiry_device_designator *des;
- /*
- * dev ID inquiry to confirm that all multipath devices carry
- * an identical logical unit identifier.
- */
- inquiry(sds[i], &inq_task, 1,
- SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION,
- 64,
- EXPECT_STATUS_GOOD);
- if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) {
- printf("Inquiry command failed : %s\n",
- sds[i]->error_str);
- goto err_cleanup;
- }
- full_size = scsi_datain_getfullsize(inq_task);
- if (full_size > inq_task->datain.size) {
- /* we need more data */
- scsi_free_scsi_task(inq_task);
- inq_task = NULL;
- inquiry(sds[i], &inq_task, 1,
- SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION,
- full_size,
- EXPECT_STATUS_GOOD);
- if (inq_task == NULL) {
- printf("Inquiry command failed : %s\n",
- sds[i]->error_str);
- goto err_cleanup;
- }
- }
+ /*
+ * dev ID inquiry to confirm that all multipath devices carry
+ * an identical logical unit identifier.
+ */
+ inquiry(sds[i], &inq_task, 1,
+ SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION,
+ 64,
+ EXPECT_STATUS_GOOD);
+ if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) {
+ printf("Inquiry command failed : %s\n",
+ sds[i]->error_str);
+ goto err_cleanup;
+ }
+ full_size = scsi_datain_getfullsize(inq_task);
+ if (full_size > inq_task->datain.size) {
+ /* we need more data */
+ scsi_free_scsi_task(inq_task);
+ inq_task = NULL;
+ inquiry(sds[i], &inq_task, 1,
+ SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION,
+ full_size,
+ EXPECT_STATUS_GOOD);
+ if (inq_task == NULL) {
+ printf("Inquiry command failed : %s\n",
+ sds[i]->error_str);
+ goto err_cleanup;
+ }
+ }
- inq_id_data = scsi_datain_unmarshall(inq_task);
- if (inq_id_data == NULL) {
- printf("failed to unmarshall inquiry ID datain blob\n");
- goto err_cleanup;
- }
+ inq_id_data = scsi_datain_unmarshall(inq_task);
+ if (inq_id_data == NULL) {
+ printf("failed to unmarshall inquiry ID datain blob\n");
+ goto err_cleanup;
+ }
- if (inq_id_data->qualifier
- != SCSI_INQUIRY_PERIPHERAL_QUALIFIER_CONNECTED) {
- printf("error: multipath device not connected\n");
- goto err_cleanup;
- }
+ if (inq_id_data->qualifier
+ != SCSI_INQUIRY_PERIPHERAL_QUALIFIER_CONNECTED) {
+ printf("error: multipath device not connected\n");
+ goto err_cleanup;
+ }
- if (inq_id_data->device_type
- != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
- printf("error: multipath devices must be SBC\n");
- goto err_cleanup;
- }
+ if (inq_id_data->device_type
+ != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
+ printf("error: multipath devices must be SBC\n");
+ goto err_cleanup;
+ }
- /* walk the list of IDs, and find a suitable LU candidate */
- for (des = inq_id_data->designators;
- des != NULL;
- des = des->next) {
- if (des->association != SCSI_ASSOCIATION_LOGICAL_UNIT) {
- printf("skipping non-LU designator: %d\n",
- des->association);
- continue;
- }
+ /* walk the list of IDs, and find a suitable LU candidate */
+ for (des = inq_id_data->designators;
+ des != NULL;
+ des = des->next) {
+ if (des->association != SCSI_ASSOCIATION_LOGICAL_UNIT) {
+ printf("skipping non-LU designator: %d\n",
+ des->association);
+ continue;
+ }
- if ((des->designator_type != SCSI_DESIGNATOR_TYPE_EUI_64)
- && (des->designator_type != SCSI_DESIGNATOR_TYPE_NAA)
- && (des->designator_type != SCSI_DESIGNATOR_TYPE_MD5_LOGICAL_UNIT_IDENTIFIER)
- && (des->designator_type != SCSI_DESIGNATOR_TYPE_SCSI_NAME_STRING)) {
- printf("skipping unsupported des type: %d\n",
- des->designator_type);
- continue;
- }
+ if ((des->designator_type != SCSI_DESIGNATOR_TYPE_EUI_64)
+ && (des->designator_type != SCSI_DESIGNATOR_TYPE_NAA)
+ && (des->designator_type != SCSI_DESIGNATOR_TYPE_MD5_LOGICAL_UNIT_IDENTIFIER)
+ && (des->designator_type != SCSI_DESIGNATOR_TYPE_SCSI_NAME_STRING)) {
+ printf("skipping unsupported des type: %d\n",
+ des->designator_type);
+ continue;
+ }
- if (des->designator_length <= 0) {
- printf("skipping designator with bad len: %d\n",
- des->designator_length);
- continue;
- }
+ if (des->designator_length <= 0) {
+ printf("skipping designator with bad len: %d\n",
+ des->designator_length);
+ continue;
+ }
- if (des_saved == NULL) {
- ret = mpath_des_copy(des, &des_saved);
- if (ret < 0) {
- goto err_cleanup;
- }
- /*
- * we now have a reference to look for in all
- * subsequent paths.
- */
- num_sds_with_valid_id++;
- break;
- } else if (mpath_des_cmp(des, des_saved) == 0) {
- /* found match for previous path designator */
- num_sds_with_valid_id++;
- break;
- }
- /* no match yet, keep checking other designators */
- }
+ if (des_saved == NULL) {
+ ret = mpath_des_copy(des, &des_saved);
+ if (ret < 0) {
+ goto err_cleanup;
+ }
+ /*
+ * we now have a reference to look for in all
+ * subsequent paths.
+ */
+ num_sds_with_valid_id++;
+ break;
+ } else if (mpath_des_cmp(des, des_saved) == 0) {
+ /* found match for previous path designator */
+ num_sds_with_valid_id++;
+ break;
+ }
+ /* no match yet, keep checking other designators */
+ }
- scsi_free_scsi_task(inq_task);
- inq_task = NULL;
- }
- mpath_des_free(des_saved);
+ scsi_free_scsi_task(inq_task);
+ inq_task = NULL;
+ }
+ mpath_des_free(des_saved);
- if (num_sds_with_valid_id != num_sds) {
- printf("failed to find matching LU device ID for all paths\n");
- return -1;
- }
+ if (num_sds_with_valid_id != num_sds) {
+ printf("failed to find matching LU device ID for all paths\n");
+ return -1;
+ }
- printf("found matching LU device identifier for all (%d) paths\n",
- num_sds);
- return 0;
+ printf("found matching LU device identifier for all (%d) paths\n",
+ num_sds);
+ return 0;
err_cleanup:
- mpath_des_free(des_saved);
- scsi_free_scsi_task(inq_task);
- return -1;
+ mpath_des_free(des_saved);
+ scsi_free_scsi_task(inq_task);
+ return -1;
}
static int
mpath_check_matching_ids_serial_vpd(int num_sds,
- struct scsi_device **sds)
+ struct scsi_device **sds)
{
- int i;
- int num_sds_with_valid_id = 0;
- struct scsi_task *inq_task = NULL;
- char *usn_saved = NULL;
+ int i;
+ int num_sds_with_valid_id = 0;
+ struct scsi_task *inq_task = NULL;
+ char *usn_saved = NULL;
- for (i = 0; i < num_sds; i++) {
- int full_size;
- struct scsi_inquiry_unit_serial_number *inq_serial;
+ for (i = 0; i < num_sds; i++) {
+ int full_size;
+ struct scsi_inquiry_unit_serial_number *inq_serial;
- /*
- * inquiry to confirm that all multipath devices carry an
- * identical unit serial number.
- */
- inq_task = NULL;
- inquiry(sds[i], &inq_task, 1,
- SCSI_INQUIRY_PAGECODE_UNIT_SERIAL_NUMBER, 64,
- EXPECT_STATUS_GOOD);
- if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) {
- printf("Inquiry command failed : %s\n",
- sds[i]->error_str);
- goto err_cleanup;
- }
- full_size = scsi_datain_getfullsize(inq_task);
- if (full_size > inq_task->datain.size) {
- scsi_free_scsi_task(inq_task);
+ /*
+ * inquiry to confirm that all multipath devices carry an
+ * identical unit serial number.
+ */
+ inq_task = NULL;
+ inquiry(sds[i], &inq_task, 1,
+ SCSI_INQUIRY_PAGECODE_UNIT_SERIAL_NUMBER, 64,
+ EXPECT_STATUS_GOOD);
+ if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) {
+ printf("Inquiry command failed : %s\n",
+ sds[i]->error_str);
+ goto err_cleanup;
+ }
+ full_size = scsi_datain_getfullsize(inq_task);
+ if (full_size > inq_task->datain.size) {
+ scsi_free_scsi_task(inq_task);
- /* we need more data */
- inq_task = NULL;
- inquiry(sds[i], &inq_task, 1,
- SCSI_INQUIRY_PAGECODE_UNIT_SERIAL_NUMBER,
- full_size,
- EXPECT_STATUS_GOOD);
- if (inq_task == NULL) {
- printf("Inquiry command failed : %s\n",
- sds[i]->error_str);
- goto err_cleanup;
- }
- }
+ /* we need more data */
+ inq_task = NULL;
+ inquiry(sds[i], &inq_task, 1,
+ SCSI_INQUIRY_PAGECODE_UNIT_SERIAL_NUMBER,
+ full_size,
+ EXPECT_STATUS_GOOD);
+ if (inq_task == NULL) {
+ printf("Inquiry command failed : %s\n",
+ sds[i]->error_str);
+ goto err_cleanup;
+ }
+ }
- inq_serial = scsi_datain_unmarshall(inq_task);
- if (inq_serial == NULL) {
- printf("failed to unmarshall inquiry datain blob\n");
- goto err_cleanup;
- }
+ inq_serial = scsi_datain_unmarshall(inq_task);
+ if (inq_serial == NULL) {
+ printf("failed to unmarshall inquiry datain blob\n");
+ goto err_cleanup;
+ }
- if (inq_serial->qualifier
- != SCSI_INQUIRY_PERIPHERAL_QUALIFIER_CONNECTED) {
- printf("error: multipath device not connected\n");
- goto err_cleanup;
- }
+ if (inq_serial->qualifier
+ != SCSI_INQUIRY_PERIPHERAL_QUALIFIER_CONNECTED) {
+ printf("error: multipath device not connected\n");
+ goto err_cleanup;
+ }
- if (inq_serial->device_type
- != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
- printf("error: multipath devices must be SBC\n");
- goto err_cleanup;
- }
+ if (inq_serial->device_type
+ != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {
+ printf("error: multipath devices must be SBC\n");
+ goto err_cleanup;
+ }
- if (inq_serial->usn == NULL) {
- printf("error: empty usn for multipath device\n");
- goto err_cleanup;
- }
+ if (inq_serial->usn == NULL) {
+ printf("error: empty usn for multipath device\n");
+ goto err_cleanup;
+ }
- if (usn_saved == NULL) {
- usn_saved = strdup(inq_serial->usn);
- if (usn_saved == NULL) {
- goto err_cleanup;
- }
- num_sds_with_valid_id++;
- } else if (strcmp(usn_saved, inq_serial->usn) == 0) {
- num_sds_with_valid_id++;
- } else {
- printf("multipath unit serial mismatch: %s != %s\n",
- usn_saved, inq_serial->usn);
- }
+ if (usn_saved == NULL) {
+ usn_saved = strdup(inq_serial->usn);
+ if (usn_saved == NULL) {
+ goto err_cleanup;
+ }
+ num_sds_with_valid_id++;
+ } else if (strcmp(usn_saved, inq_serial->usn) == 0) {
+ num_sds_with_valid_id++;
+ } else {
+ printf("multipath unit serial mismatch: %s != %s\n",
+ usn_saved, inq_serial->usn);
+ }
- scsi_free_scsi_task(inq_task);
- inq_task = NULL;
- }
+ scsi_free_scsi_task(inq_task);
+ inq_task = NULL;
+ }
- if (num_sds_with_valid_id != num_sds) {
- printf("failed to find matching serial number for all paths\n");
- goto err_cleanup;
- }
+ if (num_sds_with_valid_id != num_sds) {
+ printf("failed to find matching serial number for all paths\n");
+ goto err_cleanup;
+ }
- printf("found matching serial number for all (%d) paths: %s\n",
- num_sds, usn_saved);
- free(usn_saved);
+ printf("found matching serial number for all (%d) paths: %s\n",
+ num_sds, usn_saved);
+ free(usn_saved);
- return 0;
+ return 0;
err_cleanup:
- free(usn_saved);
- scsi_free_scsi_task(inq_task);
- return -1;
+ free(usn_saved);
+ scsi_free_scsi_task(inq_task);
+ return -1;
}
int
mpath_check_matching_ids(int num_sds,
- struct scsi_device **sds)
+ struct scsi_device **sds)
{
- int ret;
+ int ret;
- /*
- * first check all devices for a matching LU identifier in the device
- * identification INQUIRY VPD page.
- */
- ret = mpath_check_matching_ids_devid_vpd(num_sds, sds);
- if (ret == 0) {
- return 0; /* found matching */
- }
+ /*
+ * first check all devices for a matching LU identifier in the device
+ * identification INQUIRY VPD page.
+ */
+ ret = mpath_check_matching_ids_devid_vpd(num_sds, sds);
+ if (ret == 0) {
+ return 0; /* found matching */
+ }
- /* fall back to a unit serial number check */
- ret = mpath_check_matching_ids_serial_vpd(num_sds, sds);
- return ret;
+ /* fall back to a unit serial number check */
+ ret = mpath_check_matching_ids_serial_vpd(num_sds, sds);
+ return ret;
}
int
mpath_count_iscsi(int num_sds,
- struct scsi_device **sds)
+ struct scsi_device **sds)
{
- int i;
- int found = 0;
+ int i;
+ int found = 0;
- for (i = 0; i < num_sds; i++) {
- if (sds[i]->iscsi_ctx != NULL) {
- found++;
- }
- }
+ for (i = 0; i < num_sds; i++) {
+ if (sds[i]->iscsi_ctx != NULL) {
+ found++;
+ }
+ }
- return found;
+ return found;
}
/*
@@ -394,52 +394,52 @@ mpath_count_iscsi(int num_sds,
int
mpath_sd2_get_or_clone(struct scsi_device *sd1, struct scsi_device **_sd2)
{
- struct scsi_device *sd2;
+ struct scsi_device *sd2;
- if (mp_num_sds > 1) {
- logging(LOG_VERBOSE, "using multipath dev for second session");
- *_sd2 = mp_sds[1];
- return 0;
- }
+ if (mp_num_sds > 1) {
+ logging(LOG_VERBOSE, "using multipath dev for second session");
+ *_sd2 = mp_sds[1];
+ return 0;
+ }
- if (sd1->iscsi_ctx == NULL) {
- logging(LOG_NORMAL, "can't clone non-iscsi device");
- return -EINVAL;
- }
+ if (sd1->iscsi_ctx == NULL) {
+ logging(LOG_NORMAL, "can't clone non-iscsi device");
+ return -EINVAL;
+ }
- logging(LOG_VERBOSE, "cloning sd1 for second session");
- sd2 = malloc(sizeof(*sd2));
- if (sd2 == NULL) {
- return -ENOMEM;
- }
+ logging(LOG_VERBOSE, "cloning sd1 for second session");
+ sd2 = malloc(sizeof(*sd2));
+ if (sd2 == NULL) {
+ return -ENOMEM;
+ }
- memset(sd2, 0, sizeof(*sd2));
- sd2->iscsi_url = sd1->iscsi_url;
- sd2->iscsi_lun = sd1->iscsi_lun;
- sd2->iscsi_ctx = iscsi_context_login(initiatorname2, sd2->iscsi_url,
- &sd2->iscsi_lun);
- if (sd2->iscsi_ctx == NULL) {
- logging(LOG_VERBOSE, "Failed to login to target");
- free(sd2);
- return -ENOMEM;
- }
- *_sd2 = sd2;
+ memset(sd2, 0, sizeof(*sd2));
+ sd2->iscsi_url = sd1->iscsi_url;
+ sd2->iscsi_lun = sd1->iscsi_lun;
+ sd2->iscsi_ctx = iscsi_context_login(initiatorname2, sd2->iscsi_url,
+ &sd2->iscsi_lun);
+ if (sd2->iscsi_ctx == NULL) {
+ logging(LOG_VERBOSE, "Failed to login to target");
+ free(sd2);
+ return -ENOMEM;
+ }
+ *_sd2 = sd2;
- return 0;
+ return 0;
}
void
mpath_sd2_put(struct scsi_device *sd2)
{
- if (mp_num_sds > 1) {
- if (sd2 != mp_sds[1]) {
- logging(LOG_NORMAL, "Invalid sd2!");
- }
- return;
- }
+ if (mp_num_sds > 1) {
+ if (sd2 != mp_sds[1]) {
+ logging(LOG_NORMAL, "Invalid sd2!");
+ }
+ return;
+ }
- /* sd2 was allocated by mp_get - cleanup */
- iscsi_logout_sync(sd2->iscsi_ctx);
- iscsi_destroy_context(sd2->iscsi_ctx);
- free(sd2);
+ /* sd2 was allocated by mp_get - cleanup */
+ iscsi_logout_sync(sd2->iscsi_ctx);
+ iscsi_destroy_context(sd2->iscsi_ctx);
+ free(sd2);
}
diff --git a/test-tool/iscsi-multipath.h b/test-tool/iscsi-multipath.h
index 7fd6187..696a95e 100644
--- a/test-tool/iscsi-multipath.h
+++ b/test-tool/iscsi-multipath.h
@@ -17,8 +17,8 @@
along with this program; if not, see .
*/
-#ifndef _ISCSI_MULTIPATH_H_
-#define _ISCSI_MULTIPATH_H_
+#ifndef _ISCSI_MULTIPATH_H_
+#define _ISCSI_MULTIPATH_H_
#define MPATH_MAX_DEVS 2
extern int mp_num_sds;
@@ -26,35 +26,35 @@ extern struct scsi_device *mp_sds[MPATH_MAX_DEVS];
int
mpath_check_matching_ids(int num_sds,
- struct scsi_device **sds);
+ struct scsi_device **sds);
int
mpath_count_iscsi(int num_sds,
- struct scsi_device **sds);
+ struct scsi_device **sds);
int
mpath_sd2_get_or_clone(struct scsi_device *sd1, struct scsi_device **_sd2);
void
mpath_sd2_put(struct scsi_device *sd2);
-#define MPATH_SKIP_IF_UNAVAILABLE(_sds, _num_sds) \
-do { \
- if (_num_sds <= 1) { \
- logging(LOG_NORMAL, "[SKIPPED] Multipath unavailable." \
- " Skipping test"); \
- CU_PASS("[SKIPPED] Multipath unavailable." \
- " Skipping test"); \
- return; \
- } \
+#define MPATH_SKIP_IF_UNAVAILABLE(_sds, _num_sds) \
+do { \
+ if (_num_sds <= 1) { \
+ logging(LOG_NORMAL, "[SKIPPED] Multipath unavailable." \
+ " Skipping test"); \
+ CU_PASS("[SKIPPED] Multipath unavailable." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#define MPATH_SKIP_UNLESS_ISCSI(_sds, _num_sds) \
-do { \
- if (mpath_count_iscsi(_num_sds, _sds) != _num_sds) { \
- logging(LOG_NORMAL, "[SKIPPED] Non-iSCSI multipath." \
- " Skipping test"); \
- CU_PASS("[SKIPPED] Non-iSCSI multipath." \
- " Skipping test"); \
- return; \
- } \
+#define MPATH_SKIP_UNLESS_ISCSI(_sds, _num_sds) \
+do { \
+ if (mpath_count_iscsi(_num_sds, _sds) != _num_sds) { \
+ logging(LOG_NORMAL, "[SKIPPED] Non-iSCSI multipath." \
+ " Skipping test"); \
+ CU_PASS("[SKIPPED] Non-iSCSI multipath." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#endif /* _ISCSI_MULTIPATH_H_ */
+#endif /* _ISCSI_MULTIPATH_H_ */
diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c
index 3006461..bb67d50 100644
--- a/test-tool/iscsi-support.c
+++ b/test-tool/iscsi-support.c
@@ -55,51 +55,51 @@
* globals
*****************************************************************/
const char *initiatorname1 =
- "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test";
+ "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test";
const char *initiatorname2 =
- "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2";
+ "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2";
int no_medium_ascqs[3] = {
- SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT,
- SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN,
- SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED
+ SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT,
+ SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN,
+ SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED
};
int lba_oob_ascqs[1] = {
- SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE
+ SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE
};
int invalid_cdb_ascqs[2] = {
- SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB,
- SCSI_SENSE_ASCQ_INVALID_FIELD_IN_PARAMETER_LIST
+ SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB,
+ SCSI_SENSE_ASCQ_INVALID_FIELD_IN_PARAMETER_LIST
};
int param_list_len_err_ascqs[1] = {
- SCSI_SENSE_ASCQ_PARAMETER_LIST_LENGTH_ERROR
+ SCSI_SENSE_ASCQ_PARAMETER_LIST_LENGTH_ERROR
};
int write_protect_ascqs[3] = {
- SCSI_SENSE_ASCQ_WRITE_PROTECTED,
- SCSI_SENSE_ASCQ_HARDWARE_WRITE_PROTECTED,
- SCSI_SENSE_ASCQ_SOFTWARE_WRITE_PROTECTED
+ SCSI_SENSE_ASCQ_WRITE_PROTECTED,
+ SCSI_SENSE_ASCQ_HARDWARE_WRITE_PROTECTED,
+ SCSI_SENSE_ASCQ_SOFTWARE_WRITE_PROTECTED
};
int sanitize_ascqs[1] = {
- SCSI_SENSE_ASCQ_SANITIZE_IN_PROGRESS
+ SCSI_SENSE_ASCQ_SANITIZE_IN_PROGRESS
};
int removal_ascqs[1] = {
- SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED
+ SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED
};
int miscompare_ascqs[1] = {
- SCSI_SENSE_ASCQ_MISCOMPARE_DURING_VERIFY
+ SCSI_SENSE_ASCQ_MISCOMPARE_DURING_VERIFY
};
int too_many_desc_ascqs[2] = {
- SCSI_SENSE_ASCQ_TOO_MANY_TARGET_DESCRIPTORS,
- SCSI_SENSE_ASCQ_TOO_MANY_SEGMENT_DESCRIPTORS,
+ SCSI_SENSE_ASCQ_TOO_MANY_TARGET_DESCRIPTORS,
+ SCSI_SENSE_ASCQ_TOO_MANY_SEGMENT_DESCRIPTORS,
};
int unsupp_desc_code_ascqs[2] = {
- SCSI_SENSE_ASCQ_UNSUPPORTED_TARGET_DESCRIPTOR_TYPE_CODE,
- SCSI_SENSE_ASCQ_UNSUPPORTED_SEGMENT_DESCRIPTOR_TYPE_CODE
+ SCSI_SENSE_ASCQ_UNSUPPORTED_TARGET_DESCRIPTOR_TYPE_CODE,
+ SCSI_SENSE_ASCQ_UNSUPPORTED_SEGMENT_DESCRIPTOR_TYPE_CODE
};
int copy_aborted_ascqs[3] = {
- SCSI_SENSE_ASCQ_NO_ADDL_SENSE,
- SCSI_SENSE_ASCQ_UNREACHABLE_COPY_TARGET,
- SCSI_SENSE_ASCQ_COPY_TARGET_DEVICE_NOT_REACHABLE
+ SCSI_SENSE_ASCQ_NO_ADDL_SENSE,
+ SCSI_SENSE_ASCQ_UNREACHABLE_COPY_TARGET,
+ SCSI_SENSE_ASCQ_COPY_TARGET_DEVICE_NOT_REACHABLE
};
struct scsi_inquiry_standard *inq;
@@ -129,32 +129,32 @@ static const unsigned char zeroBlock[4096];
*/
int all_zeroes(const unsigned char *buf, unsigned size)
{
- unsigned j, e;
+ unsigned j, e;
- for (j = 0; j < size; j += e) {
- e = size - j;
- if (e > sizeof(zeroBlock))
- e = sizeof(zeroBlock);
- if (memcmp(buf + j, zeroBlock, e) != 0)
- return 0;
- }
+ for (j = 0; j < size; j += e) {
+ e = size - j;
+ if (e > sizeof(zeroBlock))
+ e = sizeof(zeroBlock);
+ if (memcmp(buf + j, zeroBlock, e) != 0)
+ return 0;
+ }
- return 1;
+ return 1;
}
static const char *scsi_status_str(int status)
{
- switch(status) {
- case SCSI_STATUS_GOOD: return "SUCCESS";
- case SCSI_STATUS_CHECK_CONDITION: return "CHECK_CONDITION";
- case SCSI_STATUS_CONDITION_MET: return "CONDITIONS_MET";
- case SCSI_STATUS_BUSY: return "BUSY";
- case SCSI_STATUS_RESERVATION_CONFLICT: return "RESERVATION_CONFLICT";
- case SCSI_STATUS_TASK_SET_FULL: return "TASK_SET_FULL";
- case SCSI_STATUS_ACA_ACTIVE: return "ACA_ACTIVE";
- case SCSI_STATUS_TASK_ABORTED: return "TASK_ABORTED";
- }
- return "UNKNOWN";
+ switch(status) {
+ case SCSI_STATUS_GOOD: return "SUCCESS";
+ case SCSI_STATUS_CHECK_CONDITION: return "CHECK_CONDITION";
+ case SCSI_STATUS_CONDITION_MET: return "CONDITIONS_MET";
+ case SCSI_STATUS_BUSY: return "BUSY";
+ case SCSI_STATUS_RESERVATION_CONFLICT: return "RESERVATION_CONFLICT";
+ case SCSI_STATUS_TASK_SET_FULL: return "TASK_SET_FULL";
+ case SCSI_STATUS_ACA_ACTIVE: return "ACA_ACTIVE";
+ case SCSI_STATUS_TASK_ABORTED: return "TASK_ABORTED";
+ }
+ return "UNKNOWN";
}
/*
@@ -167,1464 +167,1464 @@ static const char *scsi_status_str(int status)
*/
static int status_is_invalid_opcode(struct scsi_task *task)
{
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST) {
- if (task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE)
- return 1;
- switch (task->cdb[0]) {
- case SCSI_OPCODE_MAINTENANCE_IN:
- case SCSI_OPCODE_SERVICE_ACTION_IN:
- switch (task->sense.ascq) {
- case SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB:
- case SCSI_SENSE_ASCQ_INVALID_FIELD_IN_PARAMETER_LIST:
- return !task->sense.sense_specific ||
- task->sense.field_pointer == 1;
- }
- }
- }
- return 0;
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST) {
+ if (task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE)
+ return 1;
+ switch (task->cdb[0]) {
+ case SCSI_OPCODE_MAINTENANCE_IN:
+ case SCSI_OPCODE_SERVICE_ACTION_IN:
+ switch (task->sense.ascq) {
+ case SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB:
+ case SCSI_SENSE_ASCQ_INVALID_FIELD_IN_PARAMETER_LIST:
+ return !task->sense.sense_specific ||
+ task->sense.field_pointer == 1;
+ }
+ }
+ }
+ return 0;
}
static int check_result(const char *opcode, struct scsi_device *sdev,
- struct scsi_task *task,
- int status, enum scsi_sense_key key,
- int *ascq, int num_ascq)
+ struct scsi_task *task,
+ int status, enum scsi_sense_key key,
+ int *ascq, int num_ascq)
{
- int ascq_ok = 0;
+ int ascq_ok = 0;
- if (task == NULL) {
- logging(LOG_NORMAL, "[FAILED] Failed to send %s command: "
- "%s", opcode, sdev->error_str);
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- logging(LOG_NORMAL, "[SKIPPED] %s is not implemented.",
- opcode);
- return -2;
- }
- if (status == SCSI_STATUS_GOOD && task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL, "[FAILED] %s command failed with "
- "sense. %s(0x%02x)/%s(0x%04x)",
- opcode,
- scsi_sense_key_str(task->sense.key), task->sense.key,
- scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
- return -1;
- }
- if (status != SCSI_STATUS_GOOD && task->status == SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL, "[FAILED] %s successful but should "
- "have failed with %s(0x%02x)/%s(0x%04x)",
- opcode,
- scsi_sense_key_str(key), key,
- num_ascq ? scsi_sense_ascq_str(ascq[0]) : "NO ASCQ",
- num_ascq ? ascq[0] : 0);
- return -1;
- }
- if (status == SCSI_STATUS_RESERVATION_CONFLICT
- && task->status != SCSI_STATUS_RESERVATION_CONFLICT) {
- logging(LOG_NORMAL, "[FAILED] %s command should have failed "
- "with RESERVATION_CONFLICT.", opcode);
- return -1;
- }
- /* did we get any of the expected ASCQs ?*/
- if (status == SCSI_STATUS_CHECK_CONDITION) {
- int i;
- for (i = 0; i < num_ascq; i++) {
- if (ascq[i] == task->sense.ascq) {
- ascq_ok = 1;
- }
- }
- if (num_ascq == 0) {
- ascq_ok = 1;
- }
- }
- if (status == SCSI_STATUS_CHECK_CONDITION &&
- (task->status != status
- || task->sense.key != key
- || !ascq_ok)) {
- logging(LOG_NORMAL, "[FAILED] %s failed with wrong sense. "
- "Should have failed with %s(0x%02x)/%s(0x%04x) "
- "but failed with Sense: %s(0x%02x)/(0x%04x)\n",
- opcode,
- scsi_sense_key_str(key), key,
- num_ascq ? scsi_sense_ascq_str(ascq[0]) : "NO ASCQ",
- num_ascq ? ascq[0] : 0,
- sdev->error_str,
- task->sense.key, task->sense.ascq);
- return -1;
- }
- logging(LOG_VERBOSE, "[OK] %s returned %s %s(0x%02x) %s(0x%04x)",
- opcode, scsi_status_str(status),
- scsi_sense_key_str(task->sense.key), task->sense.key,
- scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
- return 0;
+ if (task == NULL) {
+ logging(LOG_NORMAL, "[FAILED] Failed to send %s command: "
+ "%s", opcode, sdev->error_str);
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ logging(LOG_NORMAL, "[SKIPPED] %s is not implemented.",
+ opcode);
+ return -2;
+ }
+ if (status == SCSI_STATUS_GOOD && task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL, "[FAILED] %s command failed with "
+ "sense. %s(0x%02x)/%s(0x%04x)",
+ opcode,
+ scsi_sense_key_str(task->sense.key), task->sense.key,
+ scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
+ return -1;
+ }
+ if (status != SCSI_STATUS_GOOD && task->status == SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL, "[FAILED] %s successful but should "
+ "have failed with %s(0x%02x)/%s(0x%04x)",
+ opcode,
+ scsi_sense_key_str(key), key,
+ num_ascq ? scsi_sense_ascq_str(ascq[0]) : "NO ASCQ",
+ num_ascq ? ascq[0] : 0);
+ return -1;
+ }
+ if (status == SCSI_STATUS_RESERVATION_CONFLICT
+ && task->status != SCSI_STATUS_RESERVATION_CONFLICT) {
+ logging(LOG_NORMAL, "[FAILED] %s command should have failed "
+ "with RESERVATION_CONFLICT.", opcode);
+ return -1;
+ }
+ /* did we get any of the expected ASCQs ?*/
+ if (status == SCSI_STATUS_CHECK_CONDITION) {
+ int i;
+ for (i = 0; i < num_ascq; i++) {
+ if (ascq[i] == task->sense.ascq) {
+ ascq_ok = 1;
+ }
+ }
+ if (num_ascq == 0) {
+ ascq_ok = 1;
+ }
+ }
+ if (status == SCSI_STATUS_CHECK_CONDITION &&
+ (task->status != status
+ || task->sense.key != key
+ || !ascq_ok)) {
+ logging(LOG_NORMAL, "[FAILED] %s failed with wrong sense. "
+ "Should have failed with %s(0x%02x)/%s(0x%04x) "
+ "but failed with Sense: %s(0x%02x)/(0x%04x)\n",
+ opcode,
+ scsi_sense_key_str(key), key,
+ num_ascq ? scsi_sense_ascq_str(ascq[0]) : "NO ASCQ",
+ num_ascq ? ascq[0] : 0,
+ sdev->error_str,
+ task->sense.key, task->sense.ascq);
+ return -1;
+ }
+ logging(LOG_VERBOSE, "[OK] %s returned %s %s(0x%02x) %s(0x%04x)",
+ opcode, scsi_status_str(status),
+ scsi_sense_key_str(task->sense.key), task->sense.key,
+ scsi_sense_ascq_str(task->sense.ascq), task->sense.ascq);
+ return 0;
}
#ifdef HAVE_SG_IO
static size_t iov_tot_len(struct scsi_iovec *iov, int niov)
{
- size_t len = 0;
- int i;
+ size_t len = 0;
+ int i;
- for (i = 0; i < niov; i++)
- len += iov[i].iov_len;
- return len;
+ for (i = 0; i < niov; i++)
+ len += iov[i].iov_len;
+ return len;
}
#endif
static struct scsi_task *send_scsi_command(struct scsi_device *sdev, struct scsi_task *task, struct iscsi_data *d)
{
- static time_t last_time = 0;
+ static time_t last_time = 0;
- if (sdev->iscsi_url) {
- time_t current_time = time(NULL);
+ if (sdev->iscsi_url) {
+ time_t current_time = time(NULL);
- if (sdev->error_str != NULL) {
- free(discard_const(sdev->error_str));
- sdev->error_str = NULL;
- }
- task = iscsi_scsi_command_sync(sdev->iscsi_ctx, sdev->iscsi_lun, task, d);
- if (task == NULL) {
- sdev->error_str = strdup(iscsi_get_error(sdev->iscsi_ctx));
- }
+ if (sdev->error_str != NULL) {
+ free(discard_const(sdev->error_str));
+ sdev->error_str = NULL;
+ }
+ task = iscsi_scsi_command_sync(sdev->iscsi_ctx, sdev->iscsi_lun, task, d);
+ if (task == NULL) {
+ sdev->error_str = strdup(iscsi_get_error(sdev->iscsi_ctx));
+ }
- if (current_time > last_time + 1) {
- int i;
+ if (current_time > last_time + 1) {
+ int i;
- /* Device [0] is where we are doing all the I/O
- * so it will always work the socket and respond
- * to NOPs from the target.
- * But we need to trigger a service event every
- * now and then on all the other devices to ensure that
- * we detect and respond to any NOPs.
- */
- for (i = 1; i < mp_num_sds; i++) {
- iscsi_service(mp_sds[i]->iscsi_ctx, POLLIN|POLLOUT);
- }
- last_time = current_time;
- }
+ /* Device [0] is where we are doing all the I/O
+ * so it will always work the socket and respond
+ * to NOPs from the target.
+ * But we need to trigger a service event every
+ * now and then on all the other devices to ensure that
+ * we detect and respond to any NOPs.
+ */
+ for (i = 1; i < mp_num_sds; i++) {
+ iscsi_service(mp_sds[i]->iscsi_ctx, POLLIN|POLLOUT);
+ }
+ last_time = current_time;
+ }
- return task;
- }
+ return task;
+ }
- /* We got an actual buffer from the application. Convert it to
- * a data-out iovector.
- */
- if (d != NULL && d->data != NULL) {
- struct scsi_iovec *iov;
+ /* We got an actual buffer from the application. Convert it to
+ * a data-out iovector.
+ */
+ if (d != NULL && d->data != NULL) {
+ struct scsi_iovec *iov;
- iov = scsi_malloc(task, sizeof(struct scsi_iovec));
- iov->iov_base = d->data;
- iov->iov_len = d->size;
- scsi_task_set_iov_out(task, iov, 1);
- }
+ iov = scsi_malloc(task, sizeof(struct scsi_iovec));
+ iov->iov_base = d->data;
+ iov->iov_len = d->size;
+ scsi_task_set_iov_out(task, iov, 1);
+ }
#ifdef HAVE_SG_IO
- if (sdev->sgio_dev) {
- sg_io_hdr_t io_hdr;
- unsigned int sense_len=32;
- unsigned char sense[sense_len];
- char buf[1024];
+ if (sdev->sgio_dev) {
+ sg_io_hdr_t io_hdr;
+ unsigned int sense_len=32;
+ unsigned char sense[sense_len];
+ char buf[1024];
- memset(sense, 0, sizeof(sense));
- memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
- io_hdr.interface_id = 'S';
+ memset(sense, 0, sizeof(sense));
+ memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
+ io_hdr.interface_id = 'S';
- /* CDB */
- io_hdr.cmdp = task->cdb;
- io_hdr.cmd_len = task->cdb_size;
+ /* CDB */
+ io_hdr.cmdp = task->cdb;
+ io_hdr.cmd_len = task->cdb_size;
- /* Where to store the sense_data, if there was an error */
- io_hdr.sbp = sense;
- io_hdr.mx_sb_len = sense_len;
+ /* Where to store the sense_data, if there was an error */
+ io_hdr.sbp = sense;
+ io_hdr.mx_sb_len = sense_len;
- /* Transfer direction, either in or out. Linux does not yet
- support bidirectional SCSI transfers ?
- */
- switch (task->xfer_dir) {
- case SCSI_XFER_WRITE:
- io_hdr.dxfer_direction = SG_DXFER_TO_DEV;
- io_hdr.iovec_count = task->iovector_out.niov;
- io_hdr.dxferp = task->iovector_out.iov;
- io_hdr.dxfer_len = iov_tot_len(task->iovector_out.iov,
- task->iovector_out.niov);
- break;
- case SCSI_XFER_READ:
- io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
- task->datain.size = task->expxferlen;
- task->datain.data = malloc(task->datain.size);
- memset(task->datain.data, 0, task->datain.size);
- io_hdr.dxferp = task->datain.data;
- io_hdr.dxfer_len = task->datain.size;
- break;
- }
+ /* Transfer direction, either in or out. Linux does not yet
+ support bidirectional SCSI transfers ?
+ */
+ switch (task->xfer_dir) {
+ case SCSI_XFER_WRITE:
+ io_hdr.dxfer_direction = SG_DXFER_TO_DEV;
+ io_hdr.iovec_count = task->iovector_out.niov;
+ io_hdr.dxferp = task->iovector_out.iov;
+ io_hdr.dxfer_len = iov_tot_len(task->iovector_out.iov,
+ task->iovector_out.niov);
+ break;
+ case SCSI_XFER_READ:
+ io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
+ task->datain.size = task->expxferlen;
+ task->datain.data = malloc(task->datain.size);
+ memset(task->datain.data, 0, task->datain.size);
+ io_hdr.dxferp = task->datain.data;
+ io_hdr.dxfer_len = task->datain.size;
+ break;
+ }
- /* SCSI timeout in ms */
- io_hdr.timeout = 5000;
+ /* SCSI timeout in ms */
+ io_hdr.timeout = 5000;
- if(ioctl(sdev->sgio_fd, SG_IO, &io_hdr) < 0){
- if (sdev->error_str != NULL) {
- free(discard_const(sdev->error_str));
- }
- sdev->error_str = strdup("SG_IO ioctl failed");
- return NULL;
- }
+ if(ioctl(sdev->sgio_fd, SG_IO, &io_hdr) < 0){
+ if (sdev->error_str != NULL) {
+ free(discard_const(sdev->error_str));
+ }
+ sdev->error_str = strdup("SG_IO ioctl failed");
+ return NULL;
+ }
- task->residual_status = SCSI_RESIDUAL_NO_RESIDUAL;
- task->residual = 0;
+ task->residual_status = SCSI_RESIDUAL_NO_RESIDUAL;
+ task->residual = 0;
- if (io_hdr.resid) {
- task->residual_status = SCSI_RESIDUAL_UNDERFLOW;
- task->residual = io_hdr.resid;
- }
+ if (io_hdr.resid) {
+ task->residual_status = SCSI_RESIDUAL_UNDERFLOW;
+ task->residual = io_hdr.resid;
+ }
- if (task->xfer_dir == SCSI_XFER_READ)
- task->datain.size -= task->residual;
+ if (task->xfer_dir == SCSI_XFER_READ)
+ task->datain.size -= task->residual;
- /* now for the error processing */
- if(io_hdr.sb_len_wr > 0){
- task->status = SCSI_STATUS_CHECK_CONDITION;
- scsi_parse_sense_data(&task->sense, sense);
- snprintf(buf, sizeof(buf), "SENSE KEY:%s(%d) ASCQ:%s(0x%04x)",
- scsi_sense_key_str(task->sense.key),
- task->sense.key,
- scsi_sense_ascq_str(task->sense.ascq),
- task->sense.ascq);
- if (sdev->error_str != NULL) {
- free(discard_const(sdev->error_str));
- }
- sdev->error_str = strdup(buf);
- return task;
- }
+ /* now for the error processing */
+ if(io_hdr.sb_len_wr > 0){
+ task->status = SCSI_STATUS_CHECK_CONDITION;
+ scsi_parse_sense_data(&task->sense, sense);
+ snprintf(buf, sizeof(buf), "SENSE KEY:%s(%d) ASCQ:%s(0x%04x)",
+ scsi_sense_key_str(task->sense.key),
+ task->sense.key,
+ scsi_sense_ascq_str(task->sense.ascq),
+ task->sense.ascq);
+ if (sdev->error_str != NULL) {
+ free(discard_const(sdev->error_str));
+ }
+ sdev->error_str = strdup(buf);
+ return task;
+ }
- if(io_hdr.masked_status){
- task->status = SCSI_STATUS_ERROR;
- task->sense.key = 0x0f;
- task->sense.ascq = 0xffff;
+ if(io_hdr.masked_status){
+ task->status = SCSI_STATUS_ERROR;
+ task->sense.key = 0x0f;
+ task->sense.ascq = 0xffff;
- if (sdev->error_str != NULL) {
- free(discard_const(sdev->error_str));
- }
- sdev->error_str = strdup("SCSI masked error");
- return NULL;
- }
- if(io_hdr.host_status){
- task->status = SCSI_STATUS_ERROR;
- task->sense.key = 0x0f;
- task->sense.ascq = 0xffff;
+ if (sdev->error_str != NULL) {
+ free(discard_const(sdev->error_str));
+ }
+ sdev->error_str = strdup("SCSI masked error");
+ return NULL;
+ }
+ if(io_hdr.host_status){
+ task->status = SCSI_STATUS_ERROR;
+ task->sense.key = 0x0f;
+ task->sense.ascq = 0xffff;
- snprintf(buf, sizeof(buf), "SCSI host error. Status=0x%x", io_hdr.host_status);
- if (sdev->error_str != NULL) {
- free(discard_const(sdev->error_str));
- }
- sdev->error_str = strdup(buf);
- return task;
- }
- if(io_hdr.driver_status){
- task->status = SCSI_STATUS_ERROR;
- task->sense.key = 0x0f;
- task->sense.ascq = 0xffff;
+ snprintf(buf, sizeof(buf), "SCSI host error. Status=0x%x", io_hdr.host_status);
+ if (sdev->error_str != NULL) {
+ free(discard_const(sdev->error_str));
+ }
+ sdev->error_str = strdup(buf);
+ return task;
+ }
+ if(io_hdr.driver_status){
+ task->status = SCSI_STATUS_ERROR;
+ task->sense.key = 0x0f;
+ task->sense.ascq = 0xffff;
- if (sdev->error_str != NULL) {
- free(discard_const(sdev->error_str));
- }
- sdev->error_str = strdup("SCSI driver error");
- return NULL;
- }
- return task;
- }
+ if (sdev->error_str != NULL) {
+ free(discard_const(sdev->error_str));
+ }
+ sdev->error_str = strdup("SCSI driver error");
+ return NULL;
+ }
+ return task;
+ }
#endif
- return NULL;
+ return NULL;
}
void logging(int level, const char *format, ...)
{
va_list ap;
- static char message[1024];
- int ret;
+ static char message[1024];
+ int ret;
- if (loglevel < level) {
- return;
- }
+ if (loglevel < level) {
+ return;
+ }
- if (strncmp(LOG_BLANK_LINE, format, LOG_BLANK_LINE_CMP_LEN)==0) {
- printf("\n");
- return;
- }
+ if (strncmp(LOG_BLANK_LINE, format, LOG_BLANK_LINE_CMP_LEN)==0) {
+ printf("\n");
+ return;
+ }
va_start(ap, format);
- ret = vsnprintf(message, 1024, format, ap);
+ ret = vsnprintf(message, 1024, format, ap);
va_end(ap);
- if (ret < 0) {
- return;
- }
+ if (ret < 0) {
+ return;
+ }
- printf(" %s\n", message);
+ printf(" %s\n", message);
}
struct iscsi_context *
iscsi_context_login(const char *initiatorname, const char *url, int *lun)
{
- struct iscsi_context *iscsi;
- struct iscsi_url *iscsi_url;
+ struct iscsi_context *iscsi;
+ struct iscsi_url *iscsi_url;
- iscsi = iscsi_create_context(initiatorname);
- if (iscsi == NULL) {
- fprintf(stderr, "Failed to create context\n");
- return NULL;
- }
+ iscsi = iscsi_create_context(initiatorname);
+ if (iscsi == NULL) {
+ fprintf(stderr, "Failed to create context\n");
+ return NULL;
+ }
- iscsi_url = iscsi_parse_full_url(iscsi, url);
- if (iscsi_url == NULL) {
- fprintf(stderr, "Failed to parse URL: %s\n",
- iscsi_get_error(iscsi));
- iscsi_destroy_context(iscsi);
- return NULL;
- }
+ iscsi_url = iscsi_parse_full_url(iscsi, url);
+ if (iscsi_url == NULL) {
+ fprintf(stderr, "Failed to parse URL: %s\n",
+ iscsi_get_error(iscsi));
+ iscsi_destroy_context(iscsi);
+ return NULL;
+ }
- iscsi_set_targetname(iscsi, iscsi_url->target);
- iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL);
- iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
+ iscsi_set_targetname(iscsi, iscsi_url->target);
+ iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL);
+ iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C);
- if (iscsi_url->user[0] != '\0') {
- if (iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user, iscsi_url->passwd) != 0) {
- fprintf(stderr, "Failed to set initiator username and password\n");
- iscsi_destroy_url(iscsi_url);
- iscsi_destroy_context(iscsi);
- return NULL;
- }
- }
+ if (iscsi_url->user[0] != '\0') {
+ if (iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user, iscsi_url->passwd) != 0) {
+ fprintf(stderr, "Failed to set initiator username and password\n");
+ iscsi_destroy_url(iscsi_url);
+ iscsi_destroy_context(iscsi);
+ return NULL;
+ }
+ }
- if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun) != 0) {
- fprintf(stderr, "Login Failed. %s\n", iscsi_get_error(iscsi));
- iscsi_destroy_url(iscsi_url);
- iscsi_destroy_context(iscsi);
- return NULL;
- }
- if (lun != NULL) {
- *lun = iscsi_url->lun;
- }
+ if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun) != 0) {
+ fprintf(stderr, "Login Failed. %s\n", iscsi_get_error(iscsi));
+ iscsi_destroy_url(iscsi_url);
+ iscsi_destroy_context(iscsi);
+ return NULL;
+ }
+ if (lun != NULL) {
+ *lun = iscsi_url->lun;
+ }
- iscsi_destroy_url(iscsi_url);
- return iscsi;
+ iscsi_destroy_url(iscsi_url);
+ return iscsi;
}
void
wait_until_test_finished(struct iscsi_context *iscsi, struct iscsi_async_state *state)
{
- struct pollfd pfd;
- int count = 0;
- int ret;
+ struct pollfd pfd;
+ int count = 0;
+ int ret;
- while (state->finished == 0) {
- pfd.fd = iscsi_get_fd(iscsi);
- pfd.events = iscsi_which_events(iscsi);
+ while (state->finished == 0) {
+ pfd.fd = iscsi_get_fd(iscsi);
+ pfd.events = iscsi_which_events(iscsi);
- ret = poll(&pfd, 1, 1000);
- if (ret < 0) {
- printf("Poll failed");
- exit(10);
- }
- if (ret == 0) {
- if (count++ > 5) {
- struct iscsi_pdu *pdu;
+ ret = poll(&pfd, 1, 1000);
+ if (ret < 0) {
+ printf("Poll failed");
+ exit(10);
+ }
+ if (ret == 0) {
+ if (count++ > 5) {
+ struct iscsi_pdu *pdu;
- state->finished = 1;
- state->status = SCSI_STATUS_CANCELLED;
- state->task->status = SCSI_STATUS_CANCELLED;
- /* this may leak memory since we don't free the pdu */
- while ((pdu = iscsi->outqueue)) {
- ISCSI_LIST_REMOVE(&iscsi->outqueue, pdu);
- }
- while ((pdu = iscsi->waitpdu)) {
- ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
- }
- return;
- }
- continue;
- }
- if (iscsi_service(iscsi, pfd.revents) < 0) {
- printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi));
- break;
- }
- }
+ state->finished = 1;
+ state->status = SCSI_STATUS_CANCELLED;
+ state->task->status = SCSI_STATUS_CANCELLED;
+ /* this may leak memory since we don't free the pdu */
+ while ((pdu = iscsi->outqueue)) {
+ ISCSI_LIST_REMOVE(&iscsi->outqueue, pdu);
+ }
+ while ((pdu = iscsi->waitpdu)) {
+ ISCSI_LIST_REMOVE(&iscsi->waitpdu, pdu);
+ }
+ return;
+ }
+ continue;
+ }
+ if (iscsi_service(iscsi, pfd.revents) < 0) {
+ printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi));
+ break;
+ }
+ }
}
int
iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
{
- if (local_iscsi_queue_pdu != NULL) {
- local_iscsi_queue_pdu(iscsi, pdu);
- }
- return real_iscsi_queue_pdu(iscsi, pdu);
+ if (local_iscsi_queue_pdu != NULL) {
+ local_iscsi_queue_pdu(iscsi, pdu);
+ }
+ return real_iscsi_queue_pdu(iscsi, pdu);
}
int
orwrite(struct scsi_device *sdev, uint64_t lba,
- uint32_t datalen, int blocksize, int wrprotect,
- int dpo, int fua, int fua_nv, int group,
- unsigned char *data,
- int status, enum scsi_sense_key key, int *ascq, int num_ascq)
+ uint32_t datalen, int blocksize, int wrprotect,
+ int dpo, int fua, int fua_nv, int group,
+ unsigned char *data,
+ int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send ORWRITE (Expecting %s) LBA:%" PRIu64
- " blocks:%d wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, wrprotect,
- dpo, fua, fua_nv, group);
+ logging(LOG_VERBOSE, "Send ORWRITE (Expecting %s) LBA:%" PRIu64
+ " blocks:%d wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, wrprotect,
+ dpo, fua, fua_nv, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_orwrite(lba, datalen, blocksize, wrprotect,
- dpo, fua, fua_nv, group);
- assert(task != NULL);
+ task = scsi_cdb_orwrite(lba, datalen, blocksize, wrprotect,
+ dpo, fua, fua_nv, group);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("ORWRITE", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("ORWRITE", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
prin_task(struct scsi_device *sdev, int service_action,
int success_expected)
{
- const int buf_sz = 16384;
- struct scsi_task *task;
- int ret = 0;
+ const int buf_sz = 16384;
+ struct scsi_task *task;
+ int ret = 0;
- logging(LOG_VERBOSE, "Send PRIN/SA=0x%02x, expect %s", service_action,
- success_expected ? "success" : "failure");
+ logging(LOG_VERBOSE, "Send PRIN/SA=0x%02x, expect %s", service_action,
+ success_expected ? "success" : "failure");
- task = scsi_cdb_persistent_reserve_in(service_action, buf_sz);
- assert(task != NULL);
+ task = scsi_cdb_persistent_reserve_in(service_action, buf_sz);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PRIN command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
+ return -2;
+ }
- if (success_expected) {
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PRIN/SA=0x%x failed: %s",
- service_action, iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- }
- } else {
- if (task->status == SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PRIN/SA=0x%x succeeded with invalid serviceaction",
- service_action);
- ret = -1;
- }
- }
+ if (success_expected) {
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN/SA=0x%x failed: %s",
+ service_action, iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ }
+ } else {
+ if (task->status == SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN/SA=0x%x succeeded with invalid serviceaction",
+ service_action);
+ ret = -1;
+ }
+ }
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- return ret;
+ return ret;
}
int
prin_read_keys(struct scsi_device *sdev, struct scsi_task **tp,
- struct scsi_persistent_reserve_in_read_keys **rkp)
+ struct scsi_persistent_reserve_in_read_keys **rkp)
{
- const int buf_sz = 16384;
- struct scsi_persistent_reserve_in_read_keys *rk = NULL;
+ const int buf_sz = 16384;
+ struct scsi_persistent_reserve_in_read_keys *rk = NULL;
- logging(LOG_VERBOSE, "Send PRIN/READ_KEYS");
+ logging(LOG_VERBOSE, "Send PRIN/READ_KEYS");
- *tp = scsi_cdb_persistent_reserve_in(SCSI_PERSISTENT_RESERVE_READ_KEYS,
- buf_sz);
- assert(*tp != NULL);
+ *tp = scsi_cdb_persistent_reserve_in(SCSI_PERSISTENT_RESERVE_READ_KEYS,
+ buf_sz);
+ assert(*tp != NULL);
- *tp = send_scsi_command(sdev, *tp, NULL);
- if (*tp == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PRIN command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(*tp)) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
- return -2;
- }
- if ((*tp)->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PRIN command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
+ *tp = send_scsi_command(sdev, *tp, NULL);
+ if (*tp == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(*tp)) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
+ return -2;
+ }
+ if ((*tp)->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
- rk = scsi_datain_unmarshall(*tp);
- if (rk == NULL) {
- logging(LOG_NORMAL,
- "[FAIL] failed to unmarshall PRIN/READ_KEYS data. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (rkp != NULL)
- *rkp = rk;
+ rk = scsi_datain_unmarshall(*tp);
+ if (rk == NULL) {
+ logging(LOG_NORMAL,
+ "[FAIL] failed to unmarshall PRIN/READ_KEYS data. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (rkp != NULL)
+ *rkp = rk;
- return 0;
+ return 0;
}
int
prout_register_and_ignore(struct scsi_device *sdev,
unsigned long long sark)
{
- struct scsi_persistent_reserve_out_basic poc;
- struct scsi_task *task;
- int ret = 0;
+ struct scsi_persistent_reserve_out_basic poc;
+ struct scsi_task *task;
+ int ret = 0;
- /* register our reservation key with the target */
- logging(LOG_VERBOSE,
- "Send PROUT/REGISTER_AND_IGNORE to register init=%s",
- sdev->iscsi_ctx->initiator_name);
+ /* register our reservation key with the target */
+ logging(LOG_VERBOSE,
+ "Send PROUT/REGISTER_AND_IGNORE to register init=%s",
+ sdev->iscsi_ctx->initiator_name);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping PROUT\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping PROUT\n");
+ return -1;
+ }
- memset(&poc, 0, sizeof (poc));
- poc.service_action_reservation_key = sark;
- task = scsi_cdb_persistent_reserve_out(
- SCSI_PERSISTENT_RESERVE_REGISTER_AND_IGNORE_EXISTING_KEY,
- SCSI_PERSISTENT_RESERVE_SCOPE_LU, 0, &poc);
- assert(task != NULL);
+ memset(&poc, 0, sizeof (poc));
+ poc.service_action_reservation_key = sark;
+ task = scsi_cdb_persistent_reserve_out(
+ SCSI_PERSISTENT_RESERVE_REGISTER_AND_IGNORE_EXISTING_KEY,
+ SCSI_PERSISTENT_RESERVE_SCOPE_LU, 0, &poc);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PROUT command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- logging(LOG_NORMAL, "[SKIPPED] PROUT Not Supported");
- ret = -2;
- goto dun;
- }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PROUT command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ logging(LOG_NORMAL, "[SKIPPED] PROUT Not Supported");
+ ret = -2;
+ goto dun;
+ }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ }
dun:
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prout_register_key(struct scsi_device *sdev,
unsigned long long sark, unsigned long long rk)
{
- struct scsi_persistent_reserve_out_basic poc;
- struct scsi_task *task;
- int ret = 0;
+ struct scsi_persistent_reserve_out_basic poc;
+ struct scsi_task *task;
+ int ret = 0;
- /* register/unregister our reservation key with the target */
+ /* register/unregister our reservation key with the target */
- logging(LOG_VERBOSE, "Send PROUT/REGISTER to %s init=%s",
- sark != 0 ? "register" : "unregister",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE, "Send PROUT/REGISTER to %s init=%s",
+ sark != 0 ? "register" : "unregister",
+ sdev->iscsi_ctx->initiator_name);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping PROUT\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping PROUT\n");
+ return -1;
+ }
- memset(&poc, 0, sizeof (poc));
- poc.service_action_reservation_key = sark;
- poc.reservation_key = rk;
- task = scsi_cdb_persistent_reserve_out(
- SCSI_PERSISTENT_RESERVE_REGISTER,
- SCSI_PERSISTENT_RESERVE_SCOPE_LU, 0, &poc);
- assert(task != NULL);
+ memset(&poc, 0, sizeof (poc));
+ poc.service_action_reservation_key = sark;
+ poc.reservation_key = rk;
+ task = scsi_cdb_persistent_reserve_out(
+ SCSI_PERSISTENT_RESERVE_REGISTER,
+ SCSI_PERSISTENT_RESERVE_SCOPE_LU, 0, &poc);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PROUT command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
- return -2;
- }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PROUT command: failed with sense: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
+ return -2;
+ }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ }
- scsi_free_scsi_task(task);
+ scsi_free_scsi_task(task);
- return ret;
+ return ret;
}
int
prin_verify_key_presence(struct scsi_device *sdev,
unsigned long long key, int present)
{
- struct scsi_task *task;
- const int buf_sz = 16384;
- int i;
- int key_found;
- struct scsi_persistent_reserve_in_read_keys *rk = NULL;
- int ret = 0;
+ struct scsi_task *task;
+ const int buf_sz = 16384;
+ int i;
+ int key_found;
+ struct scsi_persistent_reserve_in_read_keys *rk = NULL;
+ int ret = 0;
- logging(LOG_VERBOSE,
- "Send PRIN/READ_KEYS to verify key %s init=%s... ",
- present ? "present" : "absent",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE,
+ "Send PRIN/READ_KEYS to verify key %s init=%s... ",
+ present ? "present" : "absent",
+ sdev->iscsi_ctx->initiator_name);
- task = scsi_cdb_persistent_reserve_in(SCSI_PERSISTENT_RESERVE_READ_KEYS,
- buf_sz);
- assert(task != NULL);
+ task = scsi_cdb_persistent_reserve_in(SCSI_PERSISTENT_RESERVE_READ_KEYS,
+ buf_sz);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PRIN command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
+ return -2;
+ }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PRIN command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- goto dun;
- }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ goto dun;
+ }
- rk = scsi_datain_unmarshall(task);
- if (rk == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] failed to unmarshall PRIN/READ_KEYS data. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- goto dun;
- }
+ rk = scsi_datain_unmarshall(task);
+ if (rk == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] failed to unmarshall PRIN/READ_KEYS data. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ goto dun;
+ }
- key_found = 0;
- for (i = 0; i < rk->num_keys; i++) {
- if (rk->keys[i] == key)
- key_found = 1;
- }
+ key_found = 0;
+ for (i = 0; i < rk->num_keys; i++) {
+ if (rk->keys[i] == key)
+ key_found = 1;
+ }
- if ((present && !key_found) || (!present && key_found)) {
- if (present)
- logging(LOG_NORMAL,
- "[FAILED] Key found when none expected");
- else
- logging(LOG_NORMAL,
- "[FAILED] Key not found when expected");
- ret = -1;
- }
+ if ((present && !key_found) || (!present && key_found)) {
+ if (present)
+ logging(LOG_NORMAL,
+ "[FAILED] Key found when none expected");
+ else
+ logging(LOG_NORMAL,
+ "[FAILED] Key not found when expected");
+ ret = -1;
+ }
dun:
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prout_reregister_key_fails(struct scsi_device *sdev,
unsigned long long sark)
{
- struct scsi_persistent_reserve_out_basic poc;
- struct scsi_task *task;
- int ret = 0;
+ struct scsi_persistent_reserve_out_basic poc;
+ struct scsi_task *task;
+ int ret = 0;
- logging(LOG_VERBOSE,
- "Send PROUT/REGISTER to ensure reregister fails init=%s",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE,
+ "Send PROUT/REGISTER to ensure reregister fails init=%s",
+ sdev->iscsi_ctx->initiator_name);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping PROUT\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping PROUT\n");
+ return -1;
+ }
- memset(&poc, 0, sizeof (poc));
- poc.service_action_reservation_key = sark;
- task = scsi_cdb_persistent_reserve_out(
- SCSI_PERSISTENT_RESERVE_REGISTER,
- SCSI_PERSISTENT_RESERVE_SCOPE_LU, 0, &poc);
- assert(task != NULL);
+ memset(&poc, 0, sizeof (poc));
+ poc.service_action_reservation_key = sark;
+ task = scsi_cdb_persistent_reserve_out(
+ SCSI_PERSISTENT_RESERVE_REGISTER,
+ SCSI_PERSISTENT_RESERVE_SCOPE_LU, 0, &poc);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PROUT command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
+ return -2;
+ }
- if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) {
- logging(LOG_NORMAL,
- "[FAILED] Expected RESERVATION CONFLICT");
- ret = -1;
- }
+ if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) {
+ logging(LOG_NORMAL,
+ "[FAILED] Expected RESERVATION CONFLICT");
+ ret = -1;
+ }
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prout_reserve(struct scsi_device *sdev,
unsigned long long key, enum scsi_persistent_out_type pr_type)
{
- struct scsi_persistent_reserve_out_basic poc;
- struct scsi_task *task;
- int ret = 0;
+ struct scsi_persistent_reserve_out_basic poc;
+ struct scsi_task *task;
+ int ret = 0;
- /* reserve the target using specified reservation type */
- logging(LOG_VERBOSE,
- "Send PROUT/RESERVE to reserve, type=%d (%s) init=%s",
- pr_type, scsi_pr_type_str(pr_type),
- sdev->iscsi_ctx->initiator_name);
+ /* reserve the target using specified reservation type */
+ logging(LOG_VERBOSE,
+ "Send PROUT/RESERVE to reserve, type=%d (%s) init=%s",
+ pr_type, scsi_pr_type_str(pr_type),
+ sdev->iscsi_ctx->initiator_name);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping PROUT\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping PROUT\n");
+ return -1;
+ }
- memset(&poc, 0, sizeof (poc));
- poc.reservation_key = key;
- task = scsi_cdb_persistent_reserve_out(
- SCSI_PERSISTENT_RESERVE_RESERVE,
- SCSI_PERSISTENT_RESERVE_SCOPE_LU,
- pr_type, &poc);
- assert(task != NULL);
+ memset(&poc, 0, sizeof (poc));
+ poc.reservation_key = key;
+ task = scsi_cdb_persistent_reserve_out(
+ SCSI_PERSISTENT_RESERVE_RESERVE,
+ SCSI_PERSISTENT_RESERVE_SCOPE_LU,
+ pr_type, &poc);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PROUT command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
+ return -2;
+ }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PROUT command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ }
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prout_release(struct scsi_device *sdev,
unsigned long long key, enum scsi_persistent_out_type pr_type)
{
- struct scsi_persistent_reserve_out_basic poc;
- struct scsi_task *task;
- int ret = 0;
+ struct scsi_persistent_reserve_out_basic poc;
+ struct scsi_task *task;
+ int ret = 0;
- logging(LOG_VERBOSE,
- "Send PROUT/RELEASE to release reservation, type=%d init=%s",
- pr_type, sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE,
+ "Send PROUT/RELEASE to release reservation, type=%d init=%s",
+ pr_type, sdev->iscsi_ctx->initiator_name);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping PROUT\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping PROUT\n");
+ return -1;
+ }
- memset(&poc, 0, sizeof (poc));
- poc.reservation_key = key;
- task = scsi_cdb_persistent_reserve_out(
- SCSI_PERSISTENT_RESERVE_RELEASE,
- SCSI_PERSISTENT_RESERVE_SCOPE_LU,
- pr_type, &poc);
- assert(task != NULL);
+ memset(&poc, 0, sizeof (poc));
+ poc.reservation_key = key;
+ task = scsi_cdb_persistent_reserve_out(
+ SCSI_PERSISTENT_RESERVE_RELEASE,
+ SCSI_PERSISTENT_RESERVE_SCOPE_LU,
+ pr_type, &poc);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PROUT command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
+ return -2;
+ }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PROUT command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ }
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prout_clear(struct scsi_device *sdev, unsigned long long key)
{
- struct scsi_persistent_reserve_out_basic poc;
- struct scsi_task *task;
- int ret = 0;
+ struct scsi_persistent_reserve_out_basic poc;
+ struct scsi_task *task;
+ int ret = 0;
- /* reserve the target using specified reservation type */
- logging(LOG_VERBOSE,
- "Send PROUT/CLEAR to clear all registrations and any PR "
- "reservation");
+ /* reserve the target using specified reservation type */
+ logging(LOG_VERBOSE,
+ "Send PROUT/CLEAR to clear all registrations and any PR "
+ "reservation");
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping PROUT\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping PROUT\n");
+ return -1;
+ }
- memset(&poc, 0, sizeof (poc));
- poc.reservation_key = key;
- task = scsi_cdb_persistent_reserve_out(
- SCSI_PERSISTENT_RESERVE_CLEAR,
- SCSI_PERSISTENT_RESERVE_SCOPE_LU,
- 0, &poc);
- assert(task != NULL);
+ memset(&poc, 0, sizeof (poc));
+ poc.reservation_key = key;
+ task = scsi_cdb_persistent_reserve_out(
+ SCSI_PERSISTENT_RESERVE_CLEAR,
+ SCSI_PERSISTENT_RESERVE_SCOPE_LU,
+ 0, &poc);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PROUT command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
+ return -2;
+ }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PROUT command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ }
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prout_preempt(struct scsi_device *sdev,
- unsigned long long sark, unsigned long long rk,
- enum scsi_persistent_out_type pr_type)
+ unsigned long long sark, unsigned long long rk,
+ enum scsi_persistent_out_type pr_type)
{
- struct scsi_persistent_reserve_out_basic poc;
- struct scsi_task *task;
- int ret = 0;
+ struct scsi_persistent_reserve_out_basic poc;
+ struct scsi_task *task;
+ int ret = 0;
- /* reserve the target using specified reservation type */
- logging(LOG_VERBOSE,
- "Send PROUT/PREEMPT to preempt reservation and/or "
- "registration");
+ /* reserve the target using specified reservation type */
+ logging(LOG_VERBOSE,
+ "Send PROUT/PREEMPT to preempt reservation and/or "
+ "registration");
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping PROUT\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping PROUT\n");
+ return -1;
+ }
- memset(&poc, 0, sizeof (poc));
- poc.reservation_key = rk;
- poc.service_action_reservation_key = sark;
- task = scsi_cdb_persistent_reserve_out(
- SCSI_PERSISTENT_RESERVE_PREEMPT,
- SCSI_PERSISTENT_RESERVE_SCOPE_LU,
- pr_type, &poc);
- assert(task != NULL);
+ memset(&poc, 0, sizeof (poc));
+ poc.reservation_key = rk;
+ poc.service_action_reservation_key = sark;
+ task = scsi_cdb_persistent_reserve_out(
+ SCSI_PERSISTENT_RESERVE_PREEMPT,
+ SCSI_PERSISTENT_RESERVE_SCOPE_LU,
+ pr_type, &poc);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PROUT command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
+ return -2;
+ }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PROUT command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ }
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prin_verify_reserved_as(struct scsi_device *sdev,
unsigned long long key, enum scsi_persistent_out_type pr_type)
{
- struct scsi_task *task;
- const int buf_sz = 16384;
- struct scsi_persistent_reserve_in_read_reservation *rr = NULL;
- int ret = 0;
+ struct scsi_task *task;
+ const int buf_sz = 16384;
+ struct scsi_persistent_reserve_in_read_reservation *rr = NULL;
+ int ret = 0;
- logging(LOG_VERBOSE,
- "Send PRIN/READ_RESERVATION to verify type=%d init=%s... ",
- pr_type, sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE,
+ "Send PRIN/READ_RESERVATION to verify type=%d init=%s... ",
+ pr_type, sdev->iscsi_ctx->initiator_name);
- task = scsi_cdb_persistent_reserve_in(
- SCSI_PERSISTENT_RESERVE_READ_RESERVATION, buf_sz);
- assert(task != NULL);
+ task = scsi_cdb_persistent_reserve_in(
+ SCSI_PERSISTENT_RESERVE_READ_RESERVATION, buf_sz);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PRIN command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
+ return -2;
+ }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PRIN command: failed with sense: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- goto dun;
- }
- rr = scsi_datain_unmarshall(task);
- if (rr == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to unmarshall PRIN/READ_RESERVATION data. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- goto dun;
- }
- if (!rr->reserved) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to find Target reserved as expected.");
- ret = -1;
- goto dun;
- }
- if (rr->reservation_key != key) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to find reservation key 0x%llx: found 0x%"
- PRIu64 ".",
- key, rr->reservation_key);
- ret = -1;
- goto dun;
- }
- if (rr->pr_type != pr_type) {
- logging(LOG_NORMAL,
- "Failed to find reservation type %d: found %d.",
- pr_type, rr->pr_type);
- return -1;
- ret = -1;
- goto dun;
- }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN command: failed with sense: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ goto dun;
+ }
+ rr = scsi_datain_unmarshall(task);
+ if (rr == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to unmarshall PRIN/READ_RESERVATION data. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ goto dun;
+ }
+ if (!rr->reserved) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to find Target reserved as expected.");
+ ret = -1;
+ goto dun;
+ }
+ if (rr->reservation_key != key) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to find reservation key 0x%llx: found 0x%"
+ PRIu64 ".",
+ key, rr->reservation_key);
+ ret = -1;
+ goto dun;
+ }
+ if (rr->pr_type != pr_type) {
+ logging(LOG_NORMAL,
+ "Failed to find reservation type %d: found %d.",
+ pr_type, rr->pr_type);
+ return -1;
+ ret = -1;
+ goto dun;
+ }
dun:
- /* ??? free rr? */
- scsi_free_scsi_task(task);
- return ret;
+ /* ??? free rr? */
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prin_verify_not_reserved(struct scsi_device *sdev)
{
- struct scsi_task *task;
- const int buf_sz = 16384;
- struct scsi_persistent_reserve_in_read_reservation *rr = NULL;
- int ret = 0;
+ struct scsi_task *task;
+ const int buf_sz = 16384;
+ struct scsi_persistent_reserve_in_read_reservation *rr = NULL;
+ int ret = 0;
- logging(LOG_VERBOSE,
- "Send PRIN/READ_RESERVATION to verify not reserved init=%s",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE,
+ "Send PRIN/READ_RESERVATION to verify not reserved init=%s",
+ sdev->iscsi_ctx->initiator_name);
- task = scsi_cdb_persistent_reserve_in(
- SCSI_PERSISTENT_RESERVE_READ_RESERVATION, buf_sz);
- assert(task != NULL);
+ task = scsi_cdb_persistent_reserve_in(
+ SCSI_PERSISTENT_RESERVE_READ_RESERVATION, buf_sz);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PRIN command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- scsi_free_scsi_task(task);
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
- return -2;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ scsi_free_scsi_task(task);
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
+ return -2;
+ }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PRIN command: failed with sense: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- goto dun;
- }
- rr = scsi_datain_unmarshall(task);
- if (rr == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to unmarshall PRIN/READ_RESERVATION data: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- goto dun;
- }
- if (rr->reserved) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to find Target not reserved as expected.");
- ret = -1;
- goto dun;
- }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN command: failed with sense: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ goto dun;
+ }
+ rr = scsi_datain_unmarshall(task);
+ if (rr == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to unmarshall PRIN/READ_RESERVATION data: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ goto dun;
+ }
+ if (rr->reserved) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to find Target not reserved as expected.");
+ ret = -1;
+ goto dun;
+ }
dun:
- /* ??? free rr? */
- scsi_free_scsi_task(task);
- return ret;
+ /* ??? free rr? */
+ scsi_free_scsi_task(task);
+ return ret;
}
int
prin_report_caps(struct scsi_device *sdev, struct scsi_task **tp,
- struct scsi_persistent_reserve_in_report_capabilities **_rcaps)
+ struct scsi_persistent_reserve_in_report_capabilities **_rcaps)
{
- const int buf_sz = 16384;
- struct scsi_persistent_reserve_in_report_capabilities *rcaps = NULL;
+ const int buf_sz = 16384;
+ struct scsi_persistent_reserve_in_report_capabilities *rcaps = NULL;
- logging(LOG_VERBOSE, "Send PRIN/REPORT_CAPABILITIES");
+ logging(LOG_VERBOSE, "Send PRIN/REPORT_CAPABILITIES");
- *tp = scsi_cdb_persistent_reserve_in(
- SCSI_PERSISTENT_RESERVE_REPORT_CAPABILITIES,
- buf_sz);
- assert(*tp != NULL);
+ *tp = scsi_cdb_persistent_reserve_in(
+ SCSI_PERSISTENT_RESERVE_REPORT_CAPABILITIES,
+ buf_sz);
+ assert(*tp != NULL);
- *tp = send_scsi_command(sdev, *tp, NULL);
- if (*tp == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send PRIN command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(*tp)) {
- logging(LOG_NORMAL,
- "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
- return -2;
- }
- if ((*tp)->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] PRIN command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
+ *tp = send_scsi_command(sdev, *tp, NULL);
+ if (*tp == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(*tp)) {
+ logging(LOG_NORMAL,
+ "[SKIPPED] PERSISTENT RESERVE IN is not implemented.");
+ return -2;
+ }
+ if ((*tp)->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
- rcaps = scsi_datain_unmarshall(*tp);
- if (rcaps == NULL) {
- logging(LOG_NORMAL,
- "[FAIL] failed to unmarshall PRIN/REPORT_CAPABILITIES "
- "data. %s", iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (_rcaps != NULL)
- *_rcaps = rcaps;
+ rcaps = scsi_datain_unmarshall(*tp);
+ if (rcaps == NULL) {
+ logging(LOG_NORMAL,
+ "[FAIL] failed to unmarshall PRIN/REPORT_CAPABILITIES "
+ "data. %s", iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (_rcaps != NULL)
+ *_rcaps = rcaps;
- return 0;
+ return 0;
}
int
verify_read_works(struct scsi_device *sdev, unsigned char *buf)
{
- struct scsi_task *task;
- const uint32_t lba = 1;
- const int blksize = 512;
- const uint32_t datalen = 1 * blksize;
- int ret = 0;
+ struct scsi_task *task;
+ const uint32_t lba = 1;
+ const int blksize = 512;
+ const uint32_t datalen = 1 * blksize;
+ int ret = 0;
- /*
- * try to read the second 512-byte block
- */
+ /*
+ * try to read the second 512-byte block
+ */
- logging(LOG_VERBOSE, "Send READ10 to verify READ works init=%s",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE, "Send READ10 to verify READ works init=%s",
+ sdev->iscsi_ctx->initiator_name);
- task = scsi_cdb_read10(lba, datalen, blksize, 0, 0, 0, 0, 0);
- assert(task != NULL);
+ task = scsi_cdb_read10(lba, datalen, blksize, 0, 0, 0, 0, 0);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send READ10 command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send READ10 command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] READ10 command: failed with sense: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- goto dun;
- }
- memcpy(buf, task->datain.data, task->datain.size);
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] READ10 command: failed with sense: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ goto dun;
+ }
+ memcpy(buf, task->datain.data, task->datain.size);
dun:
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
verify_write_works(struct scsi_device *sdev, unsigned char *buf)
{
- struct scsi_task *task;
- struct iscsi_data d;
- const uint32_t lba = 1;
- const int blksize = 512;
- const uint32_t datalen = 1 * blksize;
- int ret = 0;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ const uint32_t lba = 1;
+ const int blksize = 512;
+ const uint32_t datalen = 1 * blksize;
+ int ret = 0;
- /*
- * try to write the second 512-byte block
- */
+ /*
+ * try to write the second 512-byte block
+ */
- logging(LOG_VERBOSE, "Send WRITE10 to verify WRITE works init=%s",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE, "Send WRITE10 to verify WRITE works init=%s",
+ sdev->iscsi_ctx->initiator_name);
- task = scsi_cdb_write10(lba, datalen, blksize, 0, 0, 0, 0, 0);
- assert(task != NULL);
+ task = scsi_cdb_write10(lba, datalen, blksize, 0, 0, 0, 0, 0);
+ assert(task != NULL);
- d.data = buf;
- d.size = datalen;
+ d.data = buf;
+ d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send WRITE10 command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] WRITE10 command: failed with sense: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- ret = -1;
- }
- scsi_free_scsi_task(task);
- return ret;
+ task = send_scsi_command(sdev, task, &d);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send WRITE10 command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] WRITE10 command: failed with sense: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ ret = -1;
+ }
+ scsi_free_scsi_task(task);
+ return ret;
}
int
verify_read_fails(struct scsi_device *sdev, unsigned char *buf)
{
- struct scsi_task *task;
- const uint32_t lba = 1;
- const int blksize = 512;
- const uint32_t datalen = 1 * blksize;
- int ret = 0;
+ struct scsi_task *task;
+ const uint32_t lba = 1;
+ const int blksize = 512;
+ const uint32_t datalen = 1 * blksize;
+ int ret = 0;
- /*
- * try to read the second 512-byte block -- should fail
- */
+ /*
+ * try to read the second 512-byte block -- should fail
+ */
- logging(LOG_VERBOSE,
- "Send READ10 to verify READ does not work init=%s",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE,
+ "Send READ10 to verify READ does not work init=%s",
+ sdev->iscsi_ctx->initiator_name);
- task = scsi_cdb_read10(lba, datalen, blksize, 0, 0, 0, 0, 0);
- assert(task != NULL);
+ task = scsi_cdb_read10(lba, datalen, blksize, 0, 0, 0, 0, 0);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send READ10 command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send READ10 command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
- if (task->status == SCSI_STATUS_GOOD) {
- memcpy(buf, task->datain.data, task->datain.size);
- logging(LOG_NORMAL,
- "[FAILED] READ10 command succeeded when expected to fail");
- ret = -1;
- goto dun;
- }
+ if (task->status == SCSI_STATUS_GOOD) {
+ memcpy(buf, task->datain.data, task->datain.size);
+ logging(LOG_NORMAL,
+ "[FAILED] READ10 command succeeded when expected to fail");
+ ret = -1;
+ goto dun;
+ }
- /*
- * XXX should we verify sense data?
- */
+ /*
+ * XXX should we verify sense data?
+ */
dun:
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
verify_write_fails(struct scsi_device *sdev, unsigned char *buf)
{
- struct scsi_task *task;
- struct iscsi_data d;
- const uint32_t lba = 1;
- const int blksize = 512;
- const uint32_t datalen = 1 * blksize;
- int ret = 0;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ const uint32_t lba = 1;
+ const int blksize = 512;
+ const uint32_t datalen = 1 * blksize;
+ int ret = 0;
- /*
- * try to write the second 512-byte block
- */
+ /*
+ * try to write the second 512-byte block
+ */
- logging(LOG_VERBOSE,
- "Send WRITE10 to verify WRITE does not work init=%s",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE,
+ "Send WRITE10 to verify WRITE does not work init=%s",
+ sdev->iscsi_ctx->initiator_name);
- task = scsi_cdb_write10(lba, datalen, blksize, 0, 0, 0, 0, 0);
- assert(task != NULL);
+ task = scsi_cdb_write10(lba, datalen, blksize, 0, 0, 0, 0, 0);
+ assert(task != NULL);
- d.data = buf;
- d.size = datalen;
+ d.data = buf;
+ d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send WRITE10 command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
+ task = send_scsi_command(sdev, task, &d);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send WRITE10 command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
- if (task->status == SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[FAILED] WRITE10 command: succeeded when exptec to fail");
- ret = -1;
- goto dun;
- }
+ if (task->status == SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] WRITE10 command: succeeded when exptec to fail");
+ ret = -1;
+ goto dun;
+ }
- /*
- * XXX should we verify sense data?
- */
+ /*
+ * XXX should we verify sense data?
+ */
dun:
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
int
synchronizecache10(struct scsi_device *sdev, uint32_t lba, int num, int sync_nv, int immed, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send SYNCHRONIZECACHE10 (Expecting %s) LBA:%d"
- " blocks:%d sync_nv:%d immed:%d",
- scsi_status_str(status),
- lba, num, sync_nv, immed);
+ logging(LOG_VERBOSE, "Send SYNCHRONIZECACHE10 (Expecting %s) LBA:%d"
+ " blocks:%d sync_nv:%d immed:%d",
+ scsi_status_str(status),
+ lba, num, sync_nv, immed);
- task = scsi_cdb_synchronizecache10(lba, num_blocks, sync_nv, immed);
- assert(task != NULL);
+ task = scsi_cdb_synchronizecache10(lba, num_blocks, sync_nv, immed);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("SYNCHRONIZECACHE10", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("SYNCHRONIZECACHE10", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
synchronizecache16(struct scsi_device *sdev, uint64_t lba, int num, int sync_nv, int immed, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send SYNCHRONIZECACHE16 (Expecting %s) LBA:%"
- PRIu64 " blocks:%d sync_nv:%d immed:%d",
- scsi_status_str(status),
- lba, num, sync_nv, immed);
+ logging(LOG_VERBOSE, "Send SYNCHRONIZECACHE16 (Expecting %s) LBA:%"
+ PRIu64 " blocks:%d sync_nv:%d immed:%d",
+ scsi_status_str(status),
+ lba, num, sync_nv, immed);
- task = scsi_cdb_synchronizecache16(lba, num_blocks, sync_nv, immed);
- assert(task != NULL);
+ task = scsi_cdb_synchronizecache16(lba, num_blocks, sync_nv, immed);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("SYNCHRONIZECACHE16", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("SYNCHRONIZECACHE16", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int sanitize(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send SANITIZE (Expecting %s) IMMED:%d AUSE:%d "
- "SA:%d PARAM_LEN:%d",
- scsi_status_str(status),
- immed, ause, sa, param_len);
+ logging(LOG_VERBOSE, "Send SANITIZE (Expecting %s) IMMED:%d AUSE:%d "
+ "SA:%d PARAM_LEN:%d",
+ scsi_status_str(status),
+ immed, ause, sa, param_len);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping sanitize\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping sanitize\n");
+ return -1;
+ }
- task = scsi_cdb_sanitize(immed, ause, sa, param_len);
+ task = scsi_cdb_sanitize(immed, ause, sa, param_len);
- assert(task != NULL);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, data);
+ task = send_scsi_command(sdev, task, data);
- ret = check_result("SANITIZE", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("SANITIZE", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int startstopunit(struct scsi_device *sdev, int immed, int pcm, int pc, int no_flush, int loej, int start, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send STARTSTOPUNIT (Expecting %s) IMMED:%d "
- "PCM:%d PC:%d NO_FLUSH:%d LOEJ:%d START:%d",
- scsi_status_str(status),
- immed, pcm, pc, no_flush, loej, start);
+ logging(LOG_VERBOSE, "Send STARTSTOPUNIT (Expecting %s) IMMED:%d "
+ "PCM:%d PC:%d NO_FLUSH:%d LOEJ:%d START:%d",
+ scsi_status_str(status),
+ immed, pcm, pc, no_flush, loej, start);
- task = scsi_cdb_startstopunit(immed, pcm, pc, no_flush, loej, start);
- assert(task != NULL);
+ task = scsi_cdb_startstopunit(immed, pcm, pc, no_flush, loej, start);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("STARTSTOPUNIT", sdev, task, status, key, ascq,
- num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("STARTSTOPUNIT", sdev, task, status, key, ascq,
+ num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
testunitready(struct scsi_device *sdev, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send TESTUNITREADY (Expecting %s)",
- scsi_status_str(status));
+ logging(LOG_VERBOSE, "Send TESTUNITREADY (Expecting %s)",
+ scsi_status_str(status));
- task = scsi_cdb_testunitready();
- assert(task != NULL);
+ task = scsi_cdb_testunitready();
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("TESTUNITREADY", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("TESTUNITREADY", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
testunitready_clear_ua(struct scsi_device *sdev)
{
- struct scsi_task *task;
- int ret = -1;
+ struct scsi_task *task;
+ int ret = -1;
- logging(LOG_VERBOSE,
- "Send TESTUNITREADY (To Clear Possible UA) init=%s",
- sdev->iscsi_ctx->initiator_name);
+ logging(LOG_VERBOSE,
+ "Send TESTUNITREADY (To Clear Possible UA) init=%s",
+ sdev->iscsi_ctx->initiator_name);
- task = scsi_cdb_testunitready();
- assert(task != NULL);
+ task = scsi_cdb_testunitready();
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send TESTUNITREADY command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- goto out;
- }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL,
- "[INFO] TESTUNITREADY command: failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- goto out;
- }
- logging(LOG_VERBOSE, "[OK] TESTUNITREADY does not return unit "
- "attention.");
- ret = 0;
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send TESTUNITREADY command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ goto out;
+ }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[INFO] TESTUNITREADY command: failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ goto out;
+ }
+ logging(LOG_VERBOSE, "[OK] TESTUNITREADY does not return unit "
+ "attention.");
+ ret = 0;
out:
- scsi_free_scsi_task(task);
- return ret;
+ scsi_free_scsi_task(task);
+ return ret;
}
/*
@@ -1633,58 +1633,58 @@ out:
*/
int modesense6(struct scsi_device *sdev, struct scsi_task **out_task, int dbd, enum scsi_modesense_page_control pc, enum scsi_modesense_page_code page_code, int sub_page_code, unsigned char alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send MODESENSE6 (Expecting %s) ",
- scsi_status_str(status));
+ logging(LOG_VERBOSE, "Send MODESENSE6 (Expecting %s) ",
+ scsi_status_str(status));
- task = scsi_cdb_modesense6(dbd, pc, page_code, sub_page_code, alloc_len);
- assert(task != NULL);
+ task = scsi_cdb_modesense6(dbd, pc, page_code, sub_page_code, alloc_len);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("MODESENSE6", sdev, task, status, key, ascq, num_ascq);
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("MODESENSE6", sdev, task, status, key, ascq, num_ascq);
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int modeselect6(struct scsi_device *sdev, int pf, int sp, struct scsi_mode_page *mp, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
- struct scsi_data *data;
- struct iscsi_data d;
+ struct scsi_task *task;
+ int ret;
+ struct scsi_data *data;
+ struct iscsi_data d;
- logging(LOG_VERBOSE, "Send MODESELECT6 (Expecting %s) ",
- scsi_status_str(status));
+ logging(LOG_VERBOSE, "Send MODESELECT6 (Expecting %s) ",
+ scsi_status_str(status));
- task = scsi_cdb_modeselect6(pf, sp, 255);
- assert(task != NULL);
+ task = scsi_cdb_modeselect6(pf, sp, 255);
+ assert(task != NULL);
- data = scsi_modesense_dataout_marshall(task, mp, 1);
- if (data == NULL) {
- logging(LOG_VERBOSE, "Failed to marshall MODESELECT6 data");
- scsi_free_scsi_task(task);
- return -1;
- }
+ data = scsi_modesense_dataout_marshall(task, mp, 1);
+ if (data == NULL) {
+ logging(LOG_VERBOSE, "Failed to marshall MODESELECT6 data");
+ scsi_free_scsi_task(task);
+ return -1;
+ }
- d.data = data->data;
- d.size = data->size;
- task->cdb[4] = data->size;
- task->expxferlen = data->size;
+ d.data = data->data;
+ d.size = data->size;
+ task->cdb[4] = data->size;
+ task->expxferlen = data->size;
- task = send_scsi_command(sdev, task, &d);
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("MODESELECT6", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("MODESELECT6", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int compareandwrite(struct scsi_device *sdev, uint64_t lba,
@@ -1693,135 +1693,135 @@ int compareandwrite(struct scsi_device *sdev, uint64_t lba,
int fua, int group_number,
int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send COMPAREANDWRITE (Expecting %s) LBA:%"
- PRIu64 " LEN:%d WRPROTECT:%d",
- scsi_status_str(status),
- lba, datalen, wrprotect);
+ logging(LOG_VERBOSE, "Send COMPAREANDWRITE (Expecting %s) LBA:%"
+ PRIu64 " LEN:%d WRPROTECT:%d",
+ scsi_status_str(status),
+ lba, datalen, wrprotect);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_compareandwrite(lba, datalen, blocksize, wrprotect,
- dpo, fua, 0, group_number);
- assert(task != NULL);
+ task = scsi_cdb_compareandwrite(lba, datalen, blocksize, wrprotect,
+ dpo, fua, 0, group_number);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("COMPAREANDWRITE", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("COMPAREANDWRITE", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int get_lba_status(struct scsi_device *sdev, struct scsi_task **out_task, uint64_t lba, uint32_t len, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send GET_LBA_STATUS (Expecting %s) LBA:%" PRIu64
- " alloc_len:%d",
- scsi_status_str(status),
- lba, len);
+ logging(LOG_VERBOSE, "Send GET_LBA_STATUS (Expecting %s) LBA:%" PRIu64
+ " alloc_len:%d",
+ scsi_status_str(status),
+ lba, len);
- task = scsi_cdb_get_lba_status(lba, len);
- assert(task != NULL);
+ task = scsi_cdb_get_lba_status(lba, len);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("GET_LBA_STATUS", sdev, task, status, key, ascq, num_ascq);
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("GET_LBA_STATUS", sdev, task, status, key, ascq, num_ascq);
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
prefetch10(struct scsi_device *sdev, uint32_t lba, int num, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send PREFETCH10 (Expecting %s) LBA:%d blocks:%d"
- " immed:%d group:%d",
- scsi_status_str(status),
- lba, num, immed, group);
+ logging(LOG_VERBOSE, "Send PREFETCH10 (Expecting %s) LBA:%d blocks:%d"
+ " immed:%d group:%d",
+ scsi_status_str(status),
+ lba, num, immed, group);
- task = scsi_cdb_prefetch10(lba, num, immed, group);
- assert(task != NULL);
+ task = scsi_cdb_prefetch10(lba, num, immed, group);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("PREFETCH10", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("PREFETCH10", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
prefetch16(struct scsi_device *sdev, uint64_t lba, int num, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send PREFETCH16 (Expecting %s) LBA:%" PRIu64
- " blocks:%d immed:%d group:%d",
- scsi_status_str(status),
- lba, num, immed, group);
+ logging(LOG_VERBOSE, "Send PREFETCH16 (Expecting %s) LBA:%" PRIu64
+ " blocks:%d immed:%d group:%d",
+ scsi_status_str(status),
+ lba, num, immed, group);
- task = scsi_cdb_prefetch16(lba, num, immed, group);
- assert(task != NULL);
+ task = scsi_cdb_prefetch16(lba, num, immed, group);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("PREFETCH16", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("PREFETCH16", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
preventallow(struct scsi_device *sdev, int prevent)
{
- struct scsi_task *task;
+ struct scsi_task *task;
- logging(LOG_VERBOSE, "Send PREVENTALLOW prevent:%d", prevent);
- task = scsi_cdb_preventallow(prevent);
- assert(task != NULL);
+ logging(LOG_VERBOSE, "Send PREVENTALLOW prevent:%d", prevent);
+ task = scsi_cdb_preventallow(prevent);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL, "[FAILED] Failed to send PREVENTALLOW "
- "command: %s", iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- if (status_is_invalid_opcode(task)) {
- logging(LOG_NORMAL, "[SKIPPED] PREVENTALLOW is not implemented on target");
- scsi_free_scsi_task(task);
- return -2;
- }
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL, "[FAILED] PREVENTALLOW command: "
- "failed with sense. %s", iscsi_get_error(sdev->iscsi_ctx));
- scsi_free_scsi_task(task);
- return -1;
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL, "[FAILED] Failed to send PREVENTALLOW "
+ "command: %s", iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ if (status_is_invalid_opcode(task)) {
+ logging(LOG_NORMAL, "[SKIPPED] PREVENTALLOW is not implemented on target");
+ scsi_free_scsi_task(task);
+ return -2;
+ }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL, "[FAILED] PREVENTALLOW command: "
+ "failed with sense. %s", iscsi_get_error(sdev->iscsi_ctx));
+ scsi_free_scsi_task(task);
+ return -1;
+ }
- scsi_free_scsi_task(task);
- logging(LOG_VERBOSE, "[OK] PREVENTALLOW returned SUCCESS.");
- return 0;
+ scsi_free_scsi_task(task);
+ logging(LOG_VERBOSE, "[OK] PREVENTALLOW returned SUCCESS.");
+ return 0;
}
int
@@ -1830,28 +1830,28 @@ read6(struct scsi_device *sdev, struct scsi_task **out_task, uint32_t lba,
unsigned char *data,
int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send READ6 (Expecting %s) LBA:%d blocks:%d",
- scsi_status_str(status),
- lba, datalen / blocksize);
+ logging(LOG_VERBOSE, "Send READ6 (Expecting %s) LBA:%d blocks:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize);
- task = scsi_cdb_read6(lba, datalen, blocksize);
- assert(task != NULL);
+ task = scsi_cdb_read6(lba, datalen, blocksize);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("READ6", sdev, task, status, key, ascq, num_ascq);
- if (data && task) {
- memcpy(data, task->datain.data, task->datain.size);
- }
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("READ6", sdev, task, status, key, ascq, num_ascq);
+ if (data && task) {
+ memcpy(data, task->datain.data, task->datain.size);
+ }
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
@@ -1862,31 +1862,31 @@ read10(struct scsi_device *sdev, struct scsi_task **out_task,
unsigned char *data,
int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send READ10 (Expecting %s) LBA:%d"
- " blocks:%d rdprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, rdprotect,
- dpo, fua, fua_nv, group);
+ logging(LOG_VERBOSE, "Send READ10 (Expecting %s) LBA:%d"
+ " blocks:%d rdprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, rdprotect,
+ dpo, fua, fua_nv, group);
- task = scsi_cdb_read10(lba, datalen, blocksize, rdprotect,
- dpo, fua, fua_nv, group);
- assert(task != NULL);
+ task = scsi_cdb_read10(lba, datalen, blocksize, rdprotect,
+ dpo, fua, fua_nv, group);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("READ10", sdev, task, status, key, ascq, num_ascq);
- if (data && task) {
- memcpy(data, task->datain.data, task->datain.size);
- }
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("READ10", sdev, task, status, key, ascq, num_ascq);
+ if (data && task) {
+ memcpy(data, task->datain.data, task->datain.size);
+ }
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
@@ -1897,31 +1897,31 @@ read12(struct scsi_device *sdev, struct scsi_task **out_task,
unsigned char *data,
int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send READ12 (Expecting %s) LBA:%d"
- " blocks:%d rdprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, rdprotect,
- dpo, fua, fua_nv, group);
+ logging(LOG_VERBOSE, "Send READ12 (Expecting %s) LBA:%d"
+ " blocks:%d rdprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, rdprotect,
+ dpo, fua, fua_nv, group);
- task = scsi_cdb_read12(lba, datalen, blocksize, rdprotect,
- dpo, fua, fua_nv, group);
- assert(task != NULL);
+ task = scsi_cdb_read12(lba, datalen, blocksize, rdprotect,
+ dpo, fua, fua_nv, group);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("READ12", sdev, task, status, key, ascq, num_ascq);
- if (data && task) {
- memcpy(data, task->datain.data, task->datain.size);
- }
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("READ12", sdev, task, status, key, ascq, num_ascq);
+ if (data && task) {
+ memcpy(data, task->datain.data, task->datain.size);
+ }
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
@@ -1932,1061 +1932,1061 @@ read16(struct scsi_device *sdev, struct scsi_task **out_task,
unsigned char *data,
int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send READ16 (Expecting %s) LBA:%" PRIu64
- " blocks:%d rdprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, rdprotect,
- dpo, fua, fua_nv, group);
+ logging(LOG_VERBOSE, "Send READ16 (Expecting %s) LBA:%" PRIu64
+ " blocks:%d rdprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, rdprotect,
+ dpo, fua, fua_nv, group);
- task = scsi_cdb_read16(lba, datalen, blocksize, rdprotect,
- dpo, fua, fua_nv, group);
- assert(task != NULL);
+ task = scsi_cdb_read16(lba, datalen, blocksize, rdprotect,
+ dpo, fua, fua_nv, group);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("READ16", sdev, task, status, key, ascq, num_ascq);
- if (data && task) {
- memcpy(data, task->datain.data, task->datain.size);
- }
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("READ16", sdev, task, status, key, ascq, num_ascq);
+ if (data && task) {
+ memcpy(data, task->datain.data, task->datain.size);
+ }
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
readcapacity10(struct scsi_device *sdev, struct scsi_task **out_task, uint32_t lba, int pmi, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send READCAPACITY10 (Expecting %s) LBA:%d"
- " pmi:%d",
- scsi_status_str(status),
- lba, pmi);
+ logging(LOG_VERBOSE, "Send READCAPACITY10 (Expecting %s) LBA:%d"
+ " pmi:%d",
+ scsi_status_str(status),
+ lba, pmi);
- task = scsi_cdb_readcapacity10(lba, pmi);
- assert(task != NULL);
+ task = scsi_cdb_readcapacity10(lba, pmi);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("READCAPACITY10", sdev, task, status, key, ascq, num_ascq);
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("READCAPACITY10", sdev, task, status, key, ascq, num_ascq);
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
readcapacity16(struct scsi_device *sdev, struct scsi_task **out_task, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send READCAPACITY16 (Expecting %s)",
- scsi_status_str(status));
+ logging(LOG_VERBOSE, "Send READCAPACITY16 (Expecting %s)",
+ scsi_status_str(status));
- task = scsi_cdb_serviceactionin16(SCSI_READCAPACITY16, alloc_len);
- assert(task != NULL);
+ task = scsi_cdb_serviceactionin16(SCSI_READCAPACITY16, alloc_len);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("READCAPACITY16", sdev, task, status, key, ascq, num_ascq);
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("READCAPACITY16", sdev, task, status, key, ascq, num_ascq);
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
release6(struct scsi_device *sdev)
{
- struct scsi_task *task;
- int i, res = 0;
+ struct scsi_task *task;
+ int i, res = 0;
- logging(LOG_VERBOSE, "Send RELEASE6");
+ logging(LOG_VERBOSE, "Send RELEASE6");
- for (i = 0; i < 3 && res == 0; ++i) {
- task = scsi_cdb_release6();
- assert(task != NULL);
+ for (i = 0; i < 3 && res == 0; ++i) {
+ task = scsi_cdb_release6();
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send RELEASE6 command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- res = -1;
- break;
- }
- if (task->status != SCSI_STATUS_GOOD &&
- !(task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_UNIT_ATTENTION
- && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET)) {
- logging(LOG_NORMAL, "[FAILED] RELEASE6 command: "
- "failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- res = -1;
- }
- scsi_free_scsi_task(task);
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send RELEASE6 command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ res = -1;
+ break;
+ }
+ if (task->status != SCSI_STATUS_GOOD &&
+ !(task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_UNIT_ATTENTION
+ && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET)) {
+ logging(LOG_NORMAL, "[FAILED] RELEASE6 command: "
+ "failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ res = -1;
+ }
+ scsi_free_scsi_task(task);
+ }
- if (res == 0)
- logging(LOG_VERBOSE, "[OK] RELEASE6 returned SUCCESS.");
- return res;
+ if (res == 0)
+ logging(LOG_VERBOSE, "[OK] RELEASE6 returned SUCCESS.");
+ return res;
}
int report_supported_opcodes(struct scsi_device *sdev, struct scsi_task **out_task, int rctd, int options, int opcode, int sa, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send REPORT_SUPPORTED_OPCODE (Expecting %s) "
- "RCTD:%d OPTIONS:%d OPCODE:0x%02x SA:%d ALLOC_LEN:%d",
- scsi_status_str(status),
- rctd, options, opcode, sa, alloc_len);
+ logging(LOG_VERBOSE, "Send REPORT_SUPPORTED_OPCODE (Expecting %s) "
+ "RCTD:%d OPTIONS:%d OPCODE:0x%02x SA:%d ALLOC_LEN:%d",
+ scsi_status_str(status),
+ rctd, options, opcode, sa, alloc_len);
- task = scsi_cdb_report_supported_opcodes(rctd, options, opcode, sa,
- alloc_len);
- assert(task != NULL);
+ task = scsi_cdb_report_supported_opcodes(rctd, options, opcode, sa,
+ alloc_len);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("REPORT_SUPPORTED_OPCODES", sdev, task, status, key, ascq, num_ascq);
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("REPORT_SUPPORTED_OPCODES", sdev, task, status, key, ascq, num_ascq);
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
reserve6(struct scsi_device *sdev)
{
- struct scsi_task *task;
- int i, res = 0;
+ struct scsi_task *task;
+ int i, res = 0;
- logging(LOG_VERBOSE, "Send RESERVE6");
+ logging(LOG_VERBOSE, "Send RESERVE6");
- for (i = 0; i < 3 && res == 0; ++i) {
- task = scsi_cdb_reserve6();
- assert(task != NULL);
+ for (i = 0; i < 3 && res == 0; ++i) {
+ task = scsi_cdb_reserve6();
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send RESERVE6 command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- res = -1;
- break;
- }
- if (status_is_invalid_opcode(task)) {
- logging(LOG_NORMAL, "[SKIPPED] RESERVE6 is not "
- "implemented on target");
- res = -2;
- } else if (task->status != SCSI_STATUS_GOOD &&
- !(task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_UNIT_ATTENTION
- && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET)) {
- logging(LOG_NORMAL, "[FAILED] RESERVE6 command: "
- "failed with sense. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- res = -1;
- }
- scsi_free_scsi_task(task);
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send RESERVE6 command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ res = -1;
+ break;
+ }
+ if (status_is_invalid_opcode(task)) {
+ logging(LOG_NORMAL, "[SKIPPED] RESERVE6 is not "
+ "implemented on target");
+ res = -2;
+ } else if (task->status != SCSI_STATUS_GOOD &&
+ !(task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_UNIT_ATTENTION
+ && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET)) {
+ logging(LOG_NORMAL, "[FAILED] RESERVE6 command: "
+ "failed with sense. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ res = -1;
+ }
+ scsi_free_scsi_task(task);
+ }
- if (res == 0)
- logging(LOG_VERBOSE, "[OK] RESERVE6 returned SUCCESS.");
- return res;
+ if (res == 0)
+ logging(LOG_VERBOSE, "[OK] RESERVE6 returned SUCCESS.");
+ return res;
}
int
reserve6_conflict(struct scsi_device *sdev)
{
- struct scsi_task *task;
- int i, res = 0;
+ struct scsi_task *task;
+ int i, res = 0;
- logging(LOG_VERBOSE, "Send RESERVE6 (Expecting RESERVATION_CONFLICT)");
+ logging(LOG_VERBOSE, "Send RESERVE6 (Expecting RESERVATION_CONFLICT)");
- for (i = 0; i < 3 && res == 0; ++i) {
- task = scsi_cdb_reserve6();
- assert(task != NULL);
+ for (i = 0; i < 3 && res == 0; ++i) {
+ task = scsi_cdb_reserve6();
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
- if (task == NULL) {
- logging(LOG_NORMAL,
- "[FAILED] Failed to send RESERVE6 command: %s",
- iscsi_get_error(sdev->iscsi_ctx));
- res = -1;
- break;
- }
- if (status_is_invalid_opcode(task)) {
- logging(LOG_NORMAL, "[SKIPPED] RESERVE6 is not"
- " implemented on target");
- res = -2;
- } else if (task->status != SCSI_STATUS_RESERVATION_CONFLICT &&
- !(task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_UNIT_ATTENTION
- && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET)) {
- logging(LOG_NORMAL, "[FAILED] RESERVE6 command: "
- "should have failed with RESERVATION_CONFLICT");
- res = -1;
- }
- scsi_free_scsi_task(task);
- }
+ task = send_scsi_command(sdev, task, NULL);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send RESERVE6 command: %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ res = -1;
+ break;
+ }
+ if (status_is_invalid_opcode(task)) {
+ logging(LOG_NORMAL, "[SKIPPED] RESERVE6 is not"
+ " implemented on target");
+ res = -2;
+ } else if (task->status != SCSI_STATUS_RESERVATION_CONFLICT &&
+ !(task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_UNIT_ATTENTION
+ && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET)) {
+ logging(LOG_NORMAL, "[FAILED] RESERVE6 command: "
+ "should have failed with RESERVATION_CONFLICT");
+ res = -1;
+ }
+ scsi_free_scsi_task(task);
+ }
- if (res == 0)
- logging(LOG_VERBOSE,
- "[OK] RESERVE6 returned RESERVATION_CONFLICT.");
- return res;
+ if (res == 0)
+ logging(LOG_VERBOSE,
+ "[OK] RESERVE6 returned RESERVATION_CONFLICT.");
+ return res;
}
int
unmap(struct scsi_device *sdev, int anchor, struct unmap_list *list, int list_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- unsigned char *data;
- struct iscsi_data d;
- int xferlen;
- int i;
- int ret;
+ struct scsi_task *task;
+ unsigned char *data;
+ struct iscsi_data d;
+ int xferlen;
+ int i;
+ int ret;
- logging(LOG_VERBOSE, "Send UNMAP (Expecting %s) list_len:%d anchor:%d",
- scsi_status_str(status),
- list_len, anchor);
+ logging(LOG_VERBOSE, "Send UNMAP (Expecting %s) list_len:%d anchor:%d",
+ scsi_status_str(status),
+ list_len, anchor);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping unmap\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping unmap\n");
+ return -1;
+ }
- xferlen = 8 + list_len * 16;
+ xferlen = 8 + list_len * 16;
- task = scsi_cdb_unmap(anchor, 0, xferlen);
- assert(task != NULL);
+ task = scsi_cdb_unmap(anchor, 0, xferlen);
+ assert(task != NULL);
- data = scsi_malloc(task, xferlen);
- if (data == NULL) {
- logging(LOG_NORMAL, "Out-of-memory: Failed to create "
- "unmap parameters.");
- scsi_free_scsi_task(task);
- return -1;
- }
+ data = scsi_malloc(task, xferlen);
+ if (data == NULL) {
+ logging(LOG_NORMAL, "Out-of-memory: Failed to create "
+ "unmap parameters.");
+ scsi_free_scsi_task(task);
+ return -1;
+ }
- scsi_set_uint16(&data[0], xferlen - 2);
- scsi_set_uint16(&data[2], xferlen - 8);
- for (i = 0; i < list_len; i++) {
- scsi_set_uint32(&data[8 + 16 * i], list[i].lba >> 32);
- scsi_set_uint32(&data[8 + 16 * i + 4], list[i].lba & 0xffffffff);
- scsi_set_uint32(&data[8 + 16 * i + 8], list[i].num);
- }
+ scsi_set_uint16(&data[0], xferlen - 2);
+ scsi_set_uint16(&data[2], xferlen - 8);
+ for (i = 0; i < list_len; i++) {
+ scsi_set_uint32(&data[8 + 16 * i], list[i].lba >> 32);
+ scsi_set_uint32(&data[8 + 16 * i + 4], list[i].lba & 0xffffffff);
+ scsi_set_uint32(&data[8 + 16 * i + 8], list[i].num);
+ }
- d.data = data;
- d.size = xferlen;
+ d.data = data;
+ d.size = xferlen;
- task = send_scsi_command(sdev, task, &d);
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("UNMAP", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("UNMAP", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
verify10(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send VERIFY10 (Expecting %s) LBA:%d "
- "blocks:%d vprotect:%d dpo:%d bytchk:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, vprotect, dpo, bytchk);
+ logging(LOG_VERBOSE, "Send VERIFY10 (Expecting %s) LBA:%d "
+ "blocks:%d vprotect:%d dpo:%d bytchk:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, vprotect, dpo, bytchk);
- task = scsi_cdb_verify10(lba, datalen, vprotect, dpo, bytchk, blocksize);
- assert(task != NULL);
+ task = scsi_cdb_verify10(lba, datalen, vprotect, dpo, bytchk, blocksize);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("VERIFY10", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("VERIFY10", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
verify12(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send VERIFY12 (Expecting %s) LBA:%d "
- "blocks:%d vprotect:%d dpo:%d bytchk:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, vprotect, dpo, bytchk);
+ logging(LOG_VERBOSE, "Send VERIFY12 (Expecting %s) LBA:%d "
+ "blocks:%d vprotect:%d dpo:%d bytchk:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, vprotect, dpo, bytchk);
- task = scsi_cdb_verify12(lba, datalen, vprotect, dpo, bytchk, blocksize);
- assert(task != NULL);
+ task = scsi_cdb_verify12(lba, datalen, vprotect, dpo, bytchk, blocksize);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("VERIFY12", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("VERIFY12", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
verify16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send VERIFY16 (Expecting %s) LBA:%" PRIu64
- " blocks:%d vprotect:%d dpo:%d bytchk:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, vprotect, dpo, bytchk);
+ logging(LOG_VERBOSE, "Send VERIFY16 (Expecting %s) LBA:%" PRIu64
+ " blocks:%d vprotect:%d dpo:%d bytchk:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, vprotect, dpo, bytchk);
- task = scsi_cdb_verify16(lba, datalen, vprotect, dpo, bytchk, blocksize);
- assert(task != NULL);
+ task = scsi_cdb_verify16(lba, datalen, vprotect, dpo, bytchk, blocksize);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("VERIFY16", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("VERIFY16", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
write10(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITE10 (Expecting %s) LBA:%d blocks:%d "
- "wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, wrprotect,
- dpo, fua, fua_nv, group);
+ logging(LOG_VERBOSE, "Send WRITE10 (Expecting %s) LBA:%d blocks:%d "
+ "wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, wrprotect,
+ dpo, fua, fua_nv, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_write10(lba, datalen, blocksize, wrprotect,
- dpo, fua, fua_nv, group);
- assert(task != NULL);
+ task = scsi_cdb_write10(lba, datalen, blocksize, wrprotect,
+ dpo, fua, fua_nv, group);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("WRITE10", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("WRITE10", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
write12(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITE12 (Expecting %s) LBA:%d blocks:%d "
- "wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, wrprotect,
- dpo, fua, fua_nv, group);
+ logging(LOG_VERBOSE, "Send WRITE12 (Expecting %s) LBA:%d blocks:%d "
+ "wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, wrprotect,
+ dpo, fua, fua_nv, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_write12(lba, datalen, blocksize, wrprotect,
- dpo, fua, fua_nv, group);
- assert(task != NULL);
+ task = scsi_cdb_write12(lba, datalen, blocksize, wrprotect,
+ dpo, fua, fua_nv, group);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("WRITE12", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("WRITE12", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
write16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITE16 (Expecting %s) LBA:%" PRIu64
- " blocks:%d wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, wrprotect,
- dpo, fua, fua_nv, group);
+ logging(LOG_VERBOSE, "Send WRITE16 (Expecting %s) LBA:%" PRIu64
+ " blocks:%d wrprotect:%d dpo:%d fua:%d fua_nv:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, wrprotect,
+ dpo, fua, fua_nv, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_write16(lba, datalen, blocksize, wrprotect,
- dpo, fua, fua_nv, group);
- assert(task != NULL);
+ task = scsi_cdb_write16(lba, datalen, blocksize, wrprotect,
+ dpo, fua, fua_nv, group);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ send_scsi_command(sdev, task, &d);
- ret = check_result("WRITE16", sdev, task, status, key, ascq, num_ascq);
- scsi_free_scsi_task(task);
+ ret = check_result("WRITE16", sdev, task, status, key, ascq, num_ascq);
+ scsi_free_scsi_task(task);
- return ret;
+ return ret;
}
int
writeatomic16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITEATOMIC16 (Expecting %s) LBA:%" PRIu64
- " blocks:%d wrprotect:%d dpo:%d fua:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, wrprotect,
- dpo, fua, group);
+ logging(LOG_VERBOSE, "Send WRITEATOMIC16 (Expecting %s) LBA:%" PRIu64
+ " blocks:%d wrprotect:%d dpo:%d fua:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, wrprotect,
+ dpo, fua, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_writeatomic16(lba, datalen, blocksize, wrprotect,
- dpo, fua, group);
- assert(task != NULL);
+ task = scsi_cdb_writeatomic16(lba, datalen, blocksize, wrprotect,
+ dpo, fua, group);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ send_scsi_command(sdev, task, &d);
- ret = check_result("WRITEATOMIC16", sdev, task, status, key, ascq, num_ascq);
- scsi_free_scsi_task(task);
+ ret = check_result("WRITEATOMIC16", sdev, task, status, key, ascq, num_ascq);
+ scsi_free_scsi_task(task);
- return ret;
+ return ret;
}
int
writesame10(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int num, int anchor, int unmap_flag, int wrprotect, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITESAME10 (Expecting %s) LBA:%d blocks:%d "
- "wrprotect:%d anchor:%d unmap:%d group:%d",
- scsi_status_str(status),
- lba, num, wrprotect, anchor, unmap_flag, group);
+ logging(LOG_VERBOSE, "Send WRITESAME10 (Expecting %s) LBA:%d blocks:%d "
+ "wrprotect:%d anchor:%d unmap:%d group:%d",
+ scsi_status_str(status),
+ lba, num, wrprotect, anchor, unmap_flag, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_writesame10(wrprotect, anchor, unmap_flag, lba, group,
- num, datalen);
- assert(task != NULL);
+ task = scsi_cdb_writesame10(wrprotect, anchor, unmap_flag, lba, group,
+ num, datalen);
+ assert(task != NULL);
- if (data != NULL) {
- task->expxferlen = datalen;
- } else {
- task->expxferlen = 0;
- task->xfer_dir = SCSI_XFER_NONE;
- }
+ if (data != NULL) {
+ task->expxferlen = datalen;
+ } else {
+ task->expxferlen = 0;
+ task->xfer_dir = SCSI_XFER_NONE;
+ }
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("WRITESAME10", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("WRITESAME10", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
writesame16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int num, int anchor, int unmap_flag, int wrprotect, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITESAME16 (Expecting %s) LBA:%" PRIu64
- " blocks:%d wrprotect:%d anchor:%d unmap:%d group:%d",
- scsi_status_str(status),
- lba, num, wrprotect, anchor, unmap_flag, group);
+ logging(LOG_VERBOSE, "Send WRITESAME16 (Expecting %s) LBA:%" PRIu64
+ " blocks:%d wrprotect:%d anchor:%d unmap:%d group:%d",
+ scsi_status_str(status),
+ lba, num, wrprotect, anchor, unmap_flag, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_writesame16(wrprotect, anchor, unmap_flag, lba, group,
- num, datalen);
- assert(task != NULL);
+ task = scsi_cdb_writesame16(wrprotect, anchor, unmap_flag, lba, group,
+ num, datalen);
+ assert(task != NULL);
- if (data != NULL) {
- task->expxferlen = datalen;
- } else {
- task->expxferlen = 0;
- task->xfer_dir = SCSI_XFER_NONE;
- }
+ if (data != NULL) {
+ task->expxferlen = datalen;
+ } else {
+ task->expxferlen = 0;
+ task->xfer_dir = SCSI_XFER_NONE;
+ }
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("WRITESAME16", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("WRITESAME16", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
writeverify10(struct scsi_device *sdev, uint32_t lba,
- uint32_t datalen, int blocksize, int wrprotect,
- int dpo, int bytchk, int group, unsigned char *data,
- int status, enum scsi_sense_key key, int *ascq, int num_ascq)
+ uint32_t datalen, int blocksize, int wrprotect,
+ int dpo, int bytchk, int group, unsigned char *data,
+ int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITEVERIFY10 (Expecting %s) LBA:%d "
- "blocks:%d wrprotect:%d dpo:%d bytchk:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, wrprotect,
- dpo, bytchk, group);
+ logging(LOG_VERBOSE, "Send WRITEVERIFY10 (Expecting %s) LBA:%d "
+ "blocks:%d wrprotect:%d dpo:%d bytchk:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, wrprotect,
+ dpo, bytchk, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_writeverify10(lba, datalen, blocksize, wrprotect,
- dpo, bytchk, group);
- assert(task != NULL);
+ task = scsi_cdb_writeverify10(lba, datalen, blocksize, wrprotect,
+ dpo, bytchk, group);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("WRITEVERIFY10", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("WRITEVERIFY10", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
writeverify12(struct scsi_device *sdev, uint32_t lba,
- uint32_t datalen, int blocksize, int wrprotect,
- int dpo, int bytchk, int group, unsigned char *data,
- int status, enum scsi_sense_key key, int *ascq, int num_ascq)
+ uint32_t datalen, int blocksize, int wrprotect,
+ int dpo, int bytchk, int group, unsigned char *data,
+ int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITEVERIFY12 (Expecting %s) LBA:%d "
- "blocks:%d wrprotect:%d dpo:%d bytchk:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, wrprotect,
- dpo, bytchk, group);
+ logging(LOG_VERBOSE, "Send WRITEVERIFY12 (Expecting %s) LBA:%d "
+ "blocks:%d wrprotect:%d dpo:%d bytchk:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, wrprotect,
+ dpo, bytchk, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_writeverify12(lba, datalen, blocksize, wrprotect,
- dpo, bytchk, group);
- assert(task != NULL);
+ task = scsi_cdb_writeverify12(lba, datalen, blocksize, wrprotect,
+ dpo, bytchk, group);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("WRITEVERIFY12", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("WRITEVERIFY12", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
writeverify16(struct scsi_device *sdev, uint64_t lba,
- uint32_t datalen, int blocksize, int wrprotect,
- int dpo, int bytchk, int group, unsigned char *data,
- int status, enum scsi_sense_key key, int *ascq, int num_ascq)
+ uint32_t datalen, int blocksize, int wrprotect,
+ int dpo, int bytchk, int group, unsigned char *data,
+ int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- struct iscsi_data d;
- int ret;
+ struct scsi_task *task;
+ struct iscsi_data d;
+ int ret;
- logging(LOG_VERBOSE, "Send WRITEVERIFY16 (Expecting %s) LBA:%" PRIu64
- " blocks:%d wrprotect:%d dpo:%d bytchk:%d group:%d",
- scsi_status_str(status),
- lba, datalen / blocksize, wrprotect,
- dpo, bytchk, group);
+ logging(LOG_VERBOSE, "Send WRITEVERIFY16 (Expecting %s) LBA:%" PRIu64
+ " blocks:%d wrprotect:%d dpo:%d bytchk:%d group:%d",
+ scsi_status_str(status),
+ lba, datalen / blocksize, wrprotect,
+ dpo, bytchk, group);
- if (!data_loss) {
- printf("--dataloss flag is not set in. Skipping write\n");
- return -1;
- }
+ if (!data_loss) {
+ printf("--dataloss flag is not set in. Skipping write\n");
+ return -1;
+ }
- task = scsi_cdb_writeverify16(lba, datalen, blocksize, wrprotect,
- dpo, bytchk, group);
- assert(task != NULL);
+ task = scsi_cdb_writeverify16(lba, datalen, blocksize, wrprotect,
+ dpo, bytchk, group);
+ assert(task != NULL);
- d.data = data;
- d.size = datalen;
- task = send_scsi_command(sdev, task, &d);
+ d.data = data;
+ d.size = datalen;
+ task = send_scsi_command(sdev, task, &d);
- ret = check_result("WRITEVERIFY16", sdev, task, status, key, ascq, num_ascq);
- if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("WRITEVERIFY16", sdev, task, status, key, ascq, num_ascq);
+ if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
int
inquiry(struct scsi_device *sdev, struct scsi_task **out_task, int evpd, int page_code, int maxsize, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send INQUIRY (Expecting %s) evpd:%d "
- "page_code:%02x alloc_len:%d",
- scsi_status_str(status),
- evpd, page_code, maxsize);
+ logging(LOG_VERBOSE, "Send INQUIRY (Expecting %s) evpd:%d "
+ "page_code:%02x alloc_len:%d",
+ scsi_status_str(status),
+ evpd, page_code, maxsize);
- task = scsi_cdb_inquiry(evpd, page_code, maxsize);
- assert(task != NULL);
+ task = scsi_cdb_inquiry(evpd, page_code, maxsize);
+ assert(task != NULL);
- task = send_scsi_command(sdev, task, NULL);
+ task = send_scsi_command(sdev, task, NULL);
- ret = check_result("INQUIRY", sdev, task, status, key, ascq, num_ascq);
- if (out_task) {
- *out_task = task;
- } else if (task) {
- scsi_free_scsi_task(task);
- }
- return ret;
+ ret = check_result("INQUIRY", sdev, task, status, key, ascq, num_ascq);
+ if (out_task) {
+ *out_task = task;
+ } else if (task) {
+ scsi_free_scsi_task(task);
+ }
+ return ret;
}
struct scsi_command_descriptor *
get_command_descriptor(int opcode, int sa)
{
- int i;
+ int i;
- if (rsop == NULL) {
- return NULL;
- }
+ if (rsop == NULL) {
+ return NULL;
+ }
- for (i = 0; i < rsop->num_descriptors; i++) {
- if (rsop->descriptors[i].opcode == opcode
- && rsop->descriptors[i].sa == sa) {
- return &rsop->descriptors[i];
- }
- }
+ for (i = 0; i < rsop->num_descriptors; i++) {
+ if (rsop->descriptors[i].opcode == opcode
+ && rsop->descriptors[i].sa == sa) {
+ return &rsop->descriptors[i];
+ }
+ }
- return NULL;
+ return NULL;
}
int set_swp(struct scsi_device *sdev)
{
- int ret;
- struct scsi_task *sense_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_mode_page *mp;
+ int ret;
+ struct scsi_task *sense_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_mode_page *mp;
- logging(LOG_VERBOSE, "Read CONTROL page");
+ logging(LOG_VERBOSE, "Read CONTROL page");
- /* see if we can even change swp */
- ret = modesense6(sdev, &sense_task, 1, SCSI_MODESENSE_PC_CHANGEABLE,
- SCSI_MODEPAGE_CONTROL, 0, 255,
- EXPECT_STATUS_GOOD);
- if (ret) {
- logging(LOG_NORMAL, "Failed to read CONTROL mode page.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
+ /* see if we can even change swp */
+ ret = modesense6(sdev, &sense_task, 1, SCSI_MODESENSE_PC_CHANGEABLE,
+ SCSI_MODEPAGE_CONTROL, 0, 255,
+ EXPECT_STATUS_GOOD);
+ if (ret) {
+ logging(LOG_NORMAL, "Failed to read CONTROL mode page.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
- ms = scsi_datain_unmarshall(sense_task);
- if (ms == NULL) {
- logging(LOG_NORMAL, "failed to unmarshall mode sense datain "
- "blob");
- ret = -1;
- goto finished;
- }
- /* if we cannot change swp, we are done here */
- if (ms->pages->control.swp == 0) {
- logging(LOG_NORMAL, "SWP is not changeable");
- ret = -2;
- goto finished;
- }
+ ms = scsi_datain_unmarshall(sense_task);
+ if (ms == NULL) {
+ logging(LOG_NORMAL, "failed to unmarshall mode sense datain "
+ "blob");
+ ret = -1;
+ goto finished;
+ }
+ /* if we cannot change swp, we are done here */
+ if (ms->pages->control.swp == 0) {
+ logging(LOG_NORMAL, "SWP is not changeable");
+ ret = -2;
+ goto finished;
+ }
- /* get the current control page */
- ret = modesense6(sdev, &sense_task, 1, SCSI_MODESENSE_PC_CURRENT,
- SCSI_MODEPAGE_CONTROL, 0, 255,
- EXPECT_STATUS_GOOD);
- if (ret) {
- logging(LOG_NORMAL, "Failed to read CONTROL mode page.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
+ /* get the current control page */
+ ret = modesense6(sdev, &sense_task, 1, SCSI_MODESENSE_PC_CURRENT,
+ SCSI_MODEPAGE_CONTROL, 0, 255,
+ EXPECT_STATUS_GOOD);
+ if (ret) {
+ logging(LOG_NORMAL, "Failed to read CONTROL mode page.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
- ms = scsi_datain_unmarshall(sense_task);
- if (ms == NULL) {
- logging(LOG_NORMAL, "failed to unmarshall mode sense datain "
- "blob");
- ret = -1;
- goto finished;
- }
+ ms = scsi_datain_unmarshall(sense_task);
+ if (ms == NULL) {
+ logging(LOG_NORMAL, "failed to unmarshall mode sense datain "
+ "blob");
+ ret = -1;
+ goto finished;
+ }
- mp = scsi_modesense_get_page(ms, SCSI_MODEPAGE_CONTROL, 0);
- if (mp == NULL) {
- logging(LOG_NORMAL, "failed to read control mode page");
- ret = -1;
- goto finished;
- }
+ mp = scsi_modesense_get_page(ms, SCSI_MODEPAGE_CONTROL, 0);
+ if (mp == NULL) {
+ logging(LOG_NORMAL, "failed to read control mode page");
+ ret = -1;
+ goto finished;
+ }
- /* For MODE SELECT PS is reserved and hence must be cleared */
- mp->ps = 0;
+ /* For MODE SELECT PS is reserved and hence must be cleared */
+ mp->ps = 0;
- logging(LOG_VERBOSE, "Turn SWP ON");
- mp->control.swp = 1;
+ logging(LOG_VERBOSE, "Turn SWP ON");
+ mp->control.swp = 1;
- ret = modeselect6(sdev, 1, 0, mp,
- EXPECT_STATUS_GOOD);
- if (ret) {
- logging(LOG_NORMAL, "Failed to write CONTROL mode page.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] CONTROL page written.");
+ ret = modeselect6(sdev, 1, 0, mp,
+ EXPECT_STATUS_GOOD);
+ if (ret) {
+ logging(LOG_NORMAL, "Failed to write CONTROL mode page.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] CONTROL page written.");
finished:
- if (sense_task != NULL) {
- scsi_free_scsi_task(sense_task);
- }
- return ret;
+ if (sense_task != NULL) {
+ scsi_free_scsi_task(sense_task);
+ }
+ return ret;
}
int clear_swp(struct scsi_device *sdev)
{
- int ret;
- struct scsi_task *sense_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_mode_page *mp;
+ int ret;
+ struct scsi_task *sense_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_mode_page *mp;
- logging(LOG_VERBOSE, "Read CONTROL page");
- ret = modesense6(sdev, &sense_task, 1, SCSI_MODESENSE_PC_CURRENT,
- SCSI_MODEPAGE_CONTROL, 0, 255,
- EXPECT_STATUS_GOOD);
- if (ret) {
- logging(LOG_NORMAL, "Failed to read CONTROL mode page.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
+ logging(LOG_VERBOSE, "Read CONTROL page");
+ ret = modesense6(sdev, &sense_task, 1, SCSI_MODESENSE_PC_CURRENT,
+ SCSI_MODEPAGE_CONTROL, 0, 255,
+ EXPECT_STATUS_GOOD);
+ if (ret) {
+ logging(LOG_NORMAL, "Failed to read CONTROL mode page.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
- ms = scsi_datain_unmarshall(sense_task);
- if (ms == NULL) {
- logging(LOG_NORMAL, "failed to unmarshall mode sense datain "
- "blob");
- ret = -1;
- goto finished;
- }
- mp = scsi_modesense_get_page(ms, SCSI_MODEPAGE_CONTROL, 0);
- if (mp == NULL) {
- logging(LOG_NORMAL, "failed to read control mode page");
- ret = -1;
- goto finished;
- }
+ ms = scsi_datain_unmarshall(sense_task);
+ if (ms == NULL) {
+ logging(LOG_NORMAL, "failed to unmarshall mode sense datain "
+ "blob");
+ ret = -1;
+ goto finished;
+ }
+ mp = scsi_modesense_get_page(ms, SCSI_MODEPAGE_CONTROL, 0);
+ if (mp == NULL) {
+ logging(LOG_NORMAL, "failed to read control mode page");
+ ret = -1;
+ goto finished;
+ }
- /* For MODE SELECT PS is reserved and hence must be cleared */
- mp->ps = 0;
+ /* For MODE SELECT PS is reserved and hence must be cleared */
+ mp->ps = 0;
- logging(LOG_VERBOSE, "Turn SWP OFF");
- mp->control.swp = 0;
+ logging(LOG_VERBOSE, "Turn SWP OFF");
+ mp->control.swp = 0;
- ret = modeselect6(sdev, 1, 0, mp,
- EXPECT_STATUS_GOOD);
- if (ret) {
- logging(LOG_NORMAL, "Failed to write CONTROL mode page.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] CONTROL page written.");
+ ret = modeselect6(sdev, 1, 0, mp,
+ EXPECT_STATUS_GOOD);
+ if (ret) {
+ logging(LOG_NORMAL, "Failed to write CONTROL mode page.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] CONTROL page written.");
finished:
- if (sense_task != NULL) {
- scsi_free_scsi_task(sense_task);
- }
- return ret;
+ if (sense_task != NULL) {
+ scsi_free_scsi_task(sense_task);
+ }
+ return ret;
}
/* Extended Copy */
int extendedcopy(struct scsi_device *sdev, struct iscsi_data *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq)
{
- struct scsi_task *task;
- int ret;
+ struct scsi_task *task;
+ int ret;
- logging(LOG_VERBOSE, "Send EXTENDED COPY (Expecting %s)",
- scsi_status_str(status));
+ logging(LOG_VERBOSE, "Send EXTENDED COPY (Expecting %s)",
+ scsi_status_str(status));
- if (!data_loss) {
- logging(LOG_NORMAL, "--dataloss flag is not set in. Skipping extendedcopy\n");
- return -1;
- }
+ if (!data_loss) {
+ logging(LOG_NORMAL, "--dataloss flag is not set in. Skipping extendedcopy\n");
+ return -1;
+ }
- task = scsi_cdb_extended_copy(data->size);
+ task = scsi_cdb_extended_copy(data->size);
- assert(task != NULL);
+ assert(task != NULL);
- send_scsi_command(sdev, task, data);
+ send_scsi_command(sdev, task, data);
- ret = check_result("EXTENDEDCOPY", sdev, task, status, key, ascq, num_ascq);
- scsi_free_scsi_task(task);
+ ret = check_result("EXTENDEDCOPY", sdev, task, status, key, ascq, num_ascq);
+ scsi_free_scsi_task(task);
- return ret;
+ return ret;
}
int get_desc_len(enum ec_descr_type_code desc_type)
{
- int desc_len = 0;
- switch (desc_type) {
- /* Segment Descriptors */
- case BLK_TO_STRM_SEG_DESCR:
- case STRM_TO_BLK_SEG_DESCR:
- desc_len = 0x18;
- break;
- case BLK_TO_BLK_SEG_DESCR:
- desc_len = 0x1C;
- break;
- case STRM_TO_STRM_SEG_DESCR:
- desc_len = 0x14;
- break;
+ int desc_len = 0;
+ switch (desc_type) {
+ /* Segment Descriptors */
+ case BLK_TO_STRM_SEG_DESCR:
+ case STRM_TO_BLK_SEG_DESCR:
+ desc_len = 0x18;
+ break;
+ case BLK_TO_BLK_SEG_DESCR:
+ desc_len = 0x1C;
+ break;
+ case STRM_TO_STRM_SEG_DESCR:
+ desc_len = 0x14;
+ break;
- /* Target Descriptors */
- case IPV6_TGT_DESCR:
- case IP_COPY_SVC_TGT_DESCR:
- desc_len = 64;
- break;
- case IDENT_DESCR_TGT_DESCR:
- default:
- if (desc_type >= 0xE0 && desc_type <= 0xE9)
- desc_len = 32;
- }
+ /* Target Descriptors */
+ case IPV6_TGT_DESCR:
+ case IP_COPY_SVC_TGT_DESCR:
+ desc_len = 64;
+ break;
+ case IDENT_DESCR_TGT_DESCR:
+ default:
+ if (desc_type >= 0xE0 && desc_type <= 0xE9)
+ desc_len = 32;
+ }
- return desc_len;
+ return desc_len;
}
void populate_ident_tgt_desc(unsigned char *buf, struct scsi_device *dev)
{
- int ret;
- struct scsi_task *inq_di_task = NULL;
- struct scsi_inquiry_device_identification *inq_di = NULL;
- struct scsi_inquiry_device_designator *desig, *tgt_desig = NULL;
- enum scsi_designator_type prev_type = 0;
+ int ret;
+ struct scsi_task *inq_di_task = NULL;
+ struct scsi_inquiry_device_identification *inq_di = NULL;
+ struct scsi_inquiry_device_designator *desig, *tgt_desig = NULL;
+ enum scsi_designator_type prev_type = 0;
- ret = inquiry(dev, &inq_di_task, 1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION, 255, EXPECT_STATUS_GOOD);
- if (ret < 0 || inq_di_task == NULL) {
- logging(LOG_NORMAL, "Failed to read Device Identification page");
- goto finished;
- } else {
- inq_di = scsi_datain_unmarshall(inq_di_task);
- if (inq_di == NULL) {
- logging(LOG_NORMAL, "Failed to unmarshall inquiry datain blob");
- goto finished;
- }
- }
+ ret = inquiry(dev, &inq_di_task, 1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION, 255, EXPECT_STATUS_GOOD);
+ if (ret < 0 || inq_di_task == NULL) {
+ logging(LOG_NORMAL, "Failed to read Device Identification page");
+ goto finished;
+ } else {
+ inq_di = scsi_datain_unmarshall(inq_di_task);
+ if (inq_di == NULL) {
+ logging(LOG_NORMAL, "Failed to unmarshall inquiry datain blob");
+ goto finished;
+ }
+ }
- for (desig = inq_di->designators; desig; desig = desig->next) {
- switch (desig->designator_type) {
- case SCSI_DESIGNATOR_TYPE_VENDOR_SPECIFIC:
- case SCSI_DESIGNATOR_TYPE_T10_VENDORT_ID:
- case SCSI_DESIGNATOR_TYPE_EUI_64:
- case SCSI_DESIGNATOR_TYPE_NAA:
- if (prev_type <= desig->designator_type) {
- tgt_desig = desig;
- prev_type = desig->designator_type;
- }
- default:
- continue;
- }
- }
- if (tgt_desig == NULL) {
- logging(LOG_NORMAL, "No suitalble target descriptor format found");
- goto finished;
- }
+ for (desig = inq_di->designators; desig; desig = desig->next) {
+ switch (desig->designator_type) {
+ case SCSI_DESIGNATOR_TYPE_VENDOR_SPECIFIC:
+ case SCSI_DESIGNATOR_TYPE_T10_VENDORT_ID:
+ case SCSI_DESIGNATOR_TYPE_EUI_64:
+ case SCSI_DESIGNATOR_TYPE_NAA:
+ if (prev_type <= desig->designator_type) {
+ tgt_desig = desig;
+ prev_type = desig->designator_type;
+ }
+ default:
+ continue;
+ }
+ }
+ if (tgt_desig == NULL) {
+ logging(LOG_NORMAL, "No suitalble target descriptor format found");
+ goto finished;
+ }
- buf[0] = tgt_desig->code_set;
- buf[1] = (tgt_desig->designator_type & 0xF) | ((tgt_desig->association & 3) << 4);
- buf[3] = tgt_desig->designator_length;
- memcpy(buf + 4, tgt_desig->designator, tgt_desig->designator_length);
+ buf[0] = tgt_desig->code_set;
+ buf[1] = (tgt_desig->designator_type & 0xF) | ((tgt_desig->association & 3) << 4);
+ buf[3] = tgt_desig->designator_length;
+ memcpy(buf + 4, tgt_desig->designator, tgt_desig->designator_length);
finished:
- scsi_free_scsi_task(inq_di_task);
+ scsi_free_scsi_task(inq_di_task);
}
int populate_tgt_desc(unsigned char *desc, enum ec_descr_type_code desc_type, int luid_type, int nul, int peripheral_type, int rel_init_port_id, int pad, struct scsi_device *dev)
{
- desc[0] = desc_type;
- desc[1] = (luid_type << 6) | (nul << 5) | peripheral_type;
- desc[2] = (rel_init_port_id >> 8) & 0xFF;
- desc[3] = rel_init_port_id & 0xFF;
+ desc[0] = desc_type;
+ desc[1] = (luid_type << 6) | (nul << 5) | peripheral_type;
+ desc[2] = (rel_init_port_id >> 8) & 0xFF;
+ desc[3] = rel_init_port_id & 0xFF;
- if (desc_type == IDENT_DESCR_TGT_DESCR)
- populate_ident_tgt_desc(desc+4, dev);
+ if (desc_type == IDENT_DESCR_TGT_DESCR)
+ populate_ident_tgt_desc(desc+4, dev);
- if (peripheral_type == 0) {
- // Issue readcapacity for each sd if testing with different LUs
- // If single LU, use block_size from prior readcapacity involcation
- desc[28] = pad << 2;
- desc[29] = (block_size >> 16) & 0xFF;
- desc[30] = (block_size >> 8) & 0xFF;
- desc[31] = block_size & 0xFF;
- }
- return get_desc_len(desc_type);
+ if (peripheral_type == 0) {
+ // Issue readcapacity for each sd if testing with different LUs
+ // If single LU, use block_size from prior readcapacity involcation
+ desc[28] = pad << 2;
+ desc[29] = (block_size >> 16) & 0xFF;
+ desc[30] = (block_size >> 8) & 0xFF;
+ desc[31] = block_size & 0xFF;
+ }
+ return get_desc_len(desc_type);
}
int populate_seg_desc_hdr(unsigned char *hdr, enum ec_descr_type_code desc_type, int dc, int cat, int src_index, int dst_index)
{
- int desc_len = get_desc_len(desc_type);
+ int desc_len = get_desc_len(desc_type);
- hdr[0] = desc_type;
- hdr[1] = ((dc << 1) | cat) & 0xFF;
- hdr[2] = (desc_len >> 8) & 0xFF;
- hdr[3] = (desc_len - SEG_DESC_SRC_INDEX_OFFSET) & 0xFF; /* don't account for the first 4 bytes in descriptor header*/
- hdr[4] = (src_index >> 8) & 0xFF;
- hdr[5] = src_index & 0xFF;
- hdr[6] = (dst_index >> 8) & 0xFF;
- hdr[7] = dst_index & 0xFF;
+ hdr[0] = desc_type;
+ hdr[1] = ((dc << 1) | cat) & 0xFF;
+ hdr[2] = (desc_len >> 8) & 0xFF;
+ hdr[3] = (desc_len - SEG_DESC_SRC_INDEX_OFFSET) & 0xFF; /* don't account for the first 4 bytes in descriptor header*/
+ hdr[4] = (src_index >> 8) & 0xFF;
+ hdr[5] = src_index & 0xFF;
+ hdr[6] = (dst_index >> 8) & 0xFF;
+ hdr[7] = dst_index & 0xFF;
- return desc_len;
+ return desc_len;
}
int populate_seg_desc_b2b(unsigned char *desc, int dc, int cat, int src_index, int dst_index, int num_blks, uint64_t src_lba, uint64_t dst_lba)
{
- int desc_len = populate_seg_desc_hdr(desc, BLK_TO_BLK_SEG_DESCR, dc, cat, src_index, dst_index);
+ int desc_len = populate_seg_desc_hdr(desc, BLK_TO_BLK_SEG_DESCR, dc, cat, src_index, dst_index);
- desc[10] = (num_blks >> 8) & 0xFF;
- desc[11] = num_blks & 0xFF;
- desc[12] = (src_lba >> 56) & 0xFF;
- desc[13] = (src_lba >> 48) & 0xFF;
- desc[14] = (src_lba >> 40) & 0xFF;
- desc[15] = (src_lba >> 32) & 0xFF;
- desc[16] = (src_lba >> 24) & 0xFF;
- desc[17] = (src_lba >> 16) & 0xFF;
- desc[18] = (src_lba >> 8) & 0xFF;
- desc[19] = src_lba & 0xFF;
- desc[20] = (dst_lba >> 56) & 0xFF;
- desc[21] = (dst_lba >> 48) & 0xFF;
- desc[22] = (dst_lba >> 40) & 0xFF;
- desc[23] = (dst_lba >> 32) & 0xFF;
- desc[24] = (dst_lba >> 24) & 0xFF;
- desc[25] = (dst_lba >> 16) & 0xFF;
- desc[26] = (dst_lba >> 8) & 0xFF;
- desc[27] = dst_lba & 0xFF;
+ desc[10] = (num_blks >> 8) & 0xFF;
+ desc[11] = num_blks & 0xFF;
+ desc[12] = (src_lba >> 56) & 0xFF;
+ desc[13] = (src_lba >> 48) & 0xFF;
+ desc[14] = (src_lba >> 40) & 0xFF;
+ desc[15] = (src_lba >> 32) & 0xFF;
+ desc[16] = (src_lba >> 24) & 0xFF;
+ desc[17] = (src_lba >> 16) & 0xFF;
+ desc[18] = (src_lba >> 8) & 0xFF;
+ desc[19] = src_lba & 0xFF;
+ desc[20] = (dst_lba >> 56) & 0xFF;
+ desc[21] = (dst_lba >> 48) & 0xFF;
+ desc[22] = (dst_lba >> 40) & 0xFF;
+ desc[23] = (dst_lba >> 32) & 0xFF;
+ desc[24] = (dst_lba >> 24) & 0xFF;
+ desc[25] = (dst_lba >> 16) & 0xFF;
+ desc[26] = (dst_lba >> 8) & 0xFF;
+ desc[27] = dst_lba & 0xFF;
- return desc_len;
+ return desc_len;
}
void populate_param_header(unsigned char *buf, int list_id, int str, int list_id_usage, int prio, int tgt_desc_len, int seg_desc_len, int inline_data_len)
{
- buf[0] = list_id;
- buf[1] = ((str & 1) << 5) | ((list_id_usage & 3) << 3) | (prio & 7);
- buf[2] = (tgt_desc_len >> 8) & 0xFF;
- buf[3] = tgt_desc_len & 0xFF;
- buf[8] = (seg_desc_len >> 24) & 0xFF;
- buf[9] = (seg_desc_len >> 16) & 0xFF;
- buf[10] = (seg_desc_len >> 8) & 0xFF;
- buf[11] = seg_desc_len & 0xFF;
- buf[12] = (inline_data_len >> 24) & 0xFF;
- buf[13] = (inline_data_len >> 16) & 0xFF;
- buf[14] = (inline_data_len >> 8) & 0xFF;
- buf[15] = inline_data_len & 0xFF;
+ buf[0] = list_id;
+ buf[1] = ((str & 1) << 5) | ((list_id_usage & 3) << 3) | (prio & 7);
+ buf[2] = (tgt_desc_len >> 8) & 0xFF;
+ buf[3] = tgt_desc_len & 0xFF;
+ buf[8] = (seg_desc_len >> 24) & 0xFF;
+ buf[9] = (seg_desc_len >> 16) & 0xFF;
+ buf[10] = (seg_desc_len >> 8) & 0xFF;
+ buf[11] = seg_desc_len & 0xFF;
+ buf[12] = (inline_data_len >> 24) & 0xFF;
+ buf[13] = (inline_data_len >> 16) & 0xFF;
+ buf[14] = (inline_data_len >> 8) & 0xFF;
+ buf[15] = inline_data_len & 0xFF;
}
int receive_copy_results(struct scsi_task **task, struct scsi_device *sdev,
- enum scsi_copy_results_sa sa, int list_id,
- void **datap, int status, enum scsi_sense_key key,
- int *ascq, int num_ascq)
+ enum scsi_copy_results_sa sa, int list_id,
+ void **datap, int status, enum scsi_sense_key key,
+ int *ascq, int num_ascq)
{
- int ret;
+ int ret;
- logging(LOG_VERBOSE, "Send RECEIVE COPY RESULTS");
+ logging(LOG_VERBOSE, "Send RECEIVE COPY RESULTS");
- *task = scsi_cdb_receive_copy_results(sa, list_id, 1024);
- assert(task != NULL);
+ *task = scsi_cdb_receive_copy_results(sa, list_id, 1024);
+ assert(task != NULL);
- *task = send_scsi_command(sdev, *task, NULL);
+ *task = send_scsi_command(sdev, *task, NULL);
- ret = check_result("RECEIVECOPYRESULT", sdev, *task, status, key, ascq,
- num_ascq);
- if (ret < 0)
- return ret;
+ ret = check_result("RECEIVECOPYRESULT", sdev, *task, status, key, ascq,
+ num_ascq);
+ if (ret < 0)
+ return ret;
- if ((*task)->status == SCSI_STATUS_GOOD && datap != NULL) {
- *datap = scsi_datain_unmarshall(*task);
- if (*datap == NULL) {
- logging(LOG_NORMAL,
- "[FAIL] failed to unmarshall RECEIVE COPY RESULTS data. %s",
- iscsi_get_error(sdev->iscsi_ctx));
- return -1;
- }
- }
+ if ((*task)->status == SCSI_STATUS_GOOD && datap != NULL) {
+ *datap = scsi_datain_unmarshall(*task);
+ if (*datap == NULL) {
+ logging(LOG_NORMAL,
+ "[FAIL] failed to unmarshall RECEIVE COPY RESULTS data. %s",
+ iscsi_get_error(sdev->iscsi_ctx));
+ return -1;
+ }
+ }
- return check_result("RECEIVECOPYRESULT", sdev, *task, status, key, ascq,
- num_ascq);
+ return check_result("RECEIVECOPYRESULT", sdev, *task, status, key, ascq,
+ num_ascq);
}
#define TEST_ISCSI_TUR_MAX_RETRIES 5
@@ -2994,31 +2994,31 @@ int receive_copy_results(struct scsi_task **task, struct scsi_device *sdev,
int
test_iscsi_tur_until_good(struct scsi_device *iscsi_sd, int *num_uas)
{
- int num_turs;
+ int num_turs;
- if (iscsi_sd->iscsi_ctx == NULL) {
- logging(LOG_NORMAL, "invalid sd for tur_until_good");
- return -EINVAL;
- }
+ if (iscsi_sd->iscsi_ctx == NULL) {
+ logging(LOG_NORMAL, "invalid sd for tur_until_good");
+ return -EINVAL;
+ }
- *num_uas = 0;
- for (num_turs = 0; num_turs < TEST_ISCSI_TUR_MAX_RETRIES; num_turs++) {
- struct scsi_task *tsk;
- tsk = iscsi_testunitready_sync(iscsi_sd->iscsi_ctx,
- iscsi_sd->iscsi_lun);
- if (tsk->status == SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "TUR good after %d retries",
- num_turs);
- return 0;
- } else if ((tsk->status == SCSI_STATUS_CHECK_CONDITION)
- && (tsk->sense.key == SCSI_SENSE_UNIT_ATTENTION)) {
- logging(LOG_VERBOSE, "Got UA for TUR");
- (*num_uas)++;
- } else {
- logging(LOG_NORMAL, "unexpected non-UA failure: %d,%d",
- tsk->status, tsk->sense.key);
- }
- }
+ *num_uas = 0;
+ for (num_turs = 0; num_turs < TEST_ISCSI_TUR_MAX_RETRIES; num_turs++) {
+ struct scsi_task *tsk;
+ tsk = iscsi_testunitready_sync(iscsi_sd->iscsi_ctx,
+ iscsi_sd->iscsi_lun);
+ if (tsk->status == SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "TUR good after %d retries",
+ num_turs);
+ return 0;
+ } else if ((tsk->status == SCSI_STATUS_CHECK_CONDITION)
+ && (tsk->sense.key == SCSI_SENSE_UNIT_ATTENTION)) {
+ logging(LOG_VERBOSE, "Got UA for TUR");
+ (*num_uas)++;
+ } else {
+ logging(LOG_NORMAL, "unexpected non-UA failure: %d,%d",
+ tsk->status, tsk->sense.key);
+ }
+ }
- return -ETIMEDOUT;
+ return -ETIMEDOUT;
}
diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h
index f11dacf..88326b4 100644
--- a/test-tool/iscsi-support.h
+++ b/test-tool/iscsi-support.h
@@ -18,8 +18,8 @@
along with this program; if not, see .
*/
-#ifndef _ISCSI_SUPPORT_H_
-#define _ISCSI_SUPPORT_H_
+#ifndef _ISCSI_SUPPORT_H_
+#define _ISCSI_SUPPORT_H_
#include
#include
@@ -70,115 +70,115 @@ void logging(int level, const char *format, ...) _R_(2,3);
* define special flags for logging a blank line, so compiler
* does not commplain when logging a ""
*/
-#define LOG_BLANK_LINE " "
+#define LOG_BLANK_LINE " "
#define LOG_BLANK_LINE_CMP_LEN 2
-#define CHECK_FOR_DATALOSS \
-do { \
- if (!data_loss) { \
- logging(LOG_NORMAL, "[SKIPPED] --dataloss flag is not " \
- "set. Skipping test."); \
- CU_PASS("[SKIPPED] --dataloss flag is not set." \
- " Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_DATALOSS \
+do { \
+ if (!data_loss) { \
+ logging(LOG_NORMAL, "[SKIPPED] --dataloss flag is not " \
+ "set. Skipping test."); \
+ CU_PASS("[SKIPPED] --dataloss flag is not set." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_SANITIZE \
-do { \
- if (!allow_sanitize) { \
- logging(LOG_NORMAL, "[SKIPPED] --allow-sanitize flag " \
- "is not set. Skipping test."); \
- CU_PASS("[SKIPPED] --allow-sanitize flag is not set." \
- " Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_SANITIZE \
+do { \
+ if (!allow_sanitize) { \
+ logging(LOG_NORMAL, "[SKIPPED] --allow-sanitize flag " \
+ "is not set. Skipping test."); \
+ CU_PASS("[SKIPPED] --allow-sanitize flag is not set." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_READONLY \
-do { \
- if (!readonly) { \
- logging(LOG_NORMAL, "[SKIPPED] Logical unit is not " \
- "write-protected. Skipping test."); \
- CU_PASS("[SKIPPED] Logical unit is not write-" \
- "protected. Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_READONLY \
+do { \
+ if (!readonly) { \
+ logging(LOG_NORMAL, "[SKIPPED] Logical unit is not " \
+ "write-protected. Skipping test."); \
+ CU_PASS("[SKIPPED] Logical unit is not write-" \
+ "protected. Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_REMOVABLE \
-do { \
- if (!inq->rmb) { \
- logging(LOG_NORMAL, "[SKIPPED] Logical unit is not " \
- "removable. Skipping test."); \
- CU_PASS("[SKIPPED] Logical unit is not removable" \
- " Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_REMOVABLE \
+do { \
+ if (!inq->rmb) { \
+ logging(LOG_NORMAL, "[SKIPPED] Logical unit is not " \
+ "removable. Skipping test."); \
+ CU_PASS("[SKIPPED] Logical unit is not removable" \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_THIN_PROVISIONING \
-do { \
- if (rc16 == NULL || rc16->lbpme == 0) { \
- logging(LOG_NORMAL, "[SKIPPED] Logical unit is fully" \
- " provisioned. Skipping test"); \
- CU_PASS("[SKIPPED] Logical unit is fully provisioned." \
- " Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_THIN_PROVISIONING \
+do { \
+ if (rc16 == NULL || rc16->lbpme == 0) { \
+ logging(LOG_NORMAL, "[SKIPPED] Logical unit is fully" \
+ " provisioned. Skipping test"); \
+ CU_PASS("[SKIPPED] Logical unit is fully provisioned." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_LBPWS10 \
-do { \
- if (inq_lbp->lbpws10 == 0) { \
- logging(LOG_NORMAL, "[SKIPPED] Logical unit does not" \
- " have LBPWS10. Skipping test"); \
- CU_PASS("[SKIPPED] Logical unit does not have LBPWS10." \
- " Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_LBPWS10 \
+do { \
+ if (inq_lbp->lbpws10 == 0) { \
+ logging(LOG_NORMAL, "[SKIPPED] Logical unit does not" \
+ " have LBPWS10. Skipping test"); \
+ CU_PASS("[SKIPPED] Logical unit does not have LBPWS10." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_LBPWS \
-do { \
- if (inq_lbp->lbpws == 0) { \
- logging(LOG_NORMAL, "[SKIPPED] Logical unit does not" \
- " have LBPWS. Skipping test"); \
- CU_PASS("[SKIPPED] Logical unit does not have LBPWS." \
- " Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_LBPWS \
+do { \
+ if (inq_lbp->lbpws == 0) { \
+ logging(LOG_NORMAL, "[SKIPPED] Logical unit does not" \
+ " have LBPWS. Skipping test"); \
+ CU_PASS("[SKIPPED] Logical unit does not have LBPWS." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_LBPU \
-do { \
- if (inq_lbp->lbpu == 0) { \
- logging(LOG_NORMAL, "[SKIPPED] Logical unit does not" \
- " have LBPU. Skipping test"); \
- CU_PASS("[SKIPPED] Logical unit does not have LBPU." \
- " Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_LBPU \
+do { \
+ if (inq_lbp->lbpu == 0) { \
+ logging(LOG_NORMAL, "[SKIPPED] Logical unit does not" \
+ " have LBPU. Skipping test"); \
+ CU_PASS("[SKIPPED] Logical unit does not have LBPU." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_LBPPB_GT_1 \
-do { \
- if (lbppb < 2) { \
- logging(LOG_NORMAL, "[SKIPPED] LBPPB < 2. Skipping test"); \
- CU_PASS("[SKIPPED] LBPPB < 2. Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_LBPPB_GT_1 \
+do { \
+ if (lbppb < 2) { \
+ logging(LOG_NORMAL, "[SKIPPED] LBPPB < 2. Skipping test"); \
+ CU_PASS("[SKIPPED] LBPPB < 2. Skipping test"); \
+ return; \
+ } \
} while (0);
-#define CHECK_FOR_SBC \
-do { \
- if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {\
- logging(LOG_NORMAL, "[SKIPPED] Not SBC device." \
- " Skipping test"); \
- CU_PASS("[SKIPPED] Not SBC device." \
- " Skipping test"); \
- return; \
- } \
+#define CHECK_FOR_SBC \
+do { \
+ if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {\
+ logging(LOG_NORMAL, "[SKIPPED] Not SBC device." \
+ " Skipping test"); \
+ CU_PASS("[SKIPPED] Not SBC device." \
+ " Skipping test"); \
+ return; \
+ } \
} while (0);
#define COMPAREANDWRITE(...) \
@@ -704,23 +704,23 @@ extern int sbc3_support;
extern int maximum_transfer_length;
struct scsi_device {
- char *error_str;
+ char *error_str;
- struct iscsi_context *iscsi_ctx;
- int iscsi_lun;
- char *iscsi_url;
+ struct iscsi_context *iscsi_ctx;
+ int iscsi_lun;
+ char *iscsi_url;
- char *sgio_dev;
- int sgio_fd;
+ char *sgio_dev;
+ int sgio_fd;
};
extern struct scsi_device *sd;
struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun);
struct iscsi_async_state {
- struct scsi_task *task;
- int status;
- int finished;
+ struct scsi_task *task;
+ int status;
+ int finished;
};
void wait_until_test_finished(struct iscsi_context *iscsi, struct iscsi_async_state *test_state);
@@ -735,32 +735,32 @@ struct scsi_command_descriptor *get_command_descriptor(int opcode, int sa);
static inline long rand_key(void)
{
- static int seed = 0;
+ static int seed = 0;
- if (!seed) {
- struct timeval tv;
- pid_t p;
- unsigned int s;
+ if (!seed) {
+ struct timeval tv;
+ pid_t p;
+ unsigned int s;
- gettimeofday(&tv, NULL);
- p = getpid();
- s = p ^ tv.tv_sec ^ tv.tv_usec;
- srandom(s);
- }
- seed = 1;
- return random();
+ gettimeofday(&tv, NULL);
+ p = getpid();
+ s = p ^ tv.tv_sec ^ tv.tv_usec;
+ srandom(s);
+ }
+ seed = 1;
+ return random();
}
static inline int pr_type_is_all_registrants(
- enum scsi_persistent_out_type pr_type)
+ enum scsi_persistent_out_type pr_type)
{
- switch (pr_type) {
- case SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS:
- case SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS:
- return 1;
- default:
- return 0;
- }
+ switch (pr_type) {
+ case SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS:
+ case SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS:
+ return 1;
+ default:
+ return 0;
+ }
}
int all_zeroes(const unsigned char *buf, unsigned size);
@@ -783,13 +783,13 @@ int prout_release(struct scsi_device *sdev,
unsigned long long key, enum scsi_persistent_out_type pr_type);
int prout_clear(struct scsi_device *sdev, unsigned long long key);
int prout_preempt(struct scsi_device *sdev,
- unsigned long long sark, unsigned long long rk,
- enum scsi_persistent_out_type pr_type);
+ unsigned long long sark, unsigned long long rk,
+ enum scsi_persistent_out_type pr_type);
int prin_verify_not_reserved(struct scsi_device *sdev);
int prin_verify_reserved_as(struct scsi_device *sdev,
unsigned long long key, enum scsi_persistent_out_type pr_type);
int prin_report_caps(struct scsi_device *sdev, struct scsi_task **tp,
- struct scsi_persistent_reserve_in_report_capabilities **_rcaps);
+ struct scsi_persistent_reserve_in_report_capabilities **_rcaps);
int verify_read_works(struct scsi_device *sdev, unsigned char *buf);
int verify_write_works(struct scsi_device *sdev, unsigned char *buf);
int verify_read_fails(struct scsi_device *sdev, unsigned char *buf);
@@ -844,8 +844,8 @@ int populate_seg_desc_hdr(unsigned char *hdr, enum ec_descr_type_code desc_type,
int populate_seg_desc_b2b(unsigned char *desc, int dc, int cat, int src_index, int dst_index, int num_blks, uint64_t src_lba, uint64_t dst_lba);
void populate_param_header(unsigned char *buf, int list_id, int str, int list_id_usage, int prio, int tgt_desc_len, int seg_desc_len, int inline_data_len);
int receive_copy_results(struct scsi_task **task, struct scsi_device *sdev,
- enum scsi_copy_results_sa sa, int list_id,
- void **datap, int status, enum scsi_sense_key key,
- int *ascq, int num_ascq);
+ enum scsi_copy_results_sa sa, int list_id,
+ void **datap, int status, enum scsi_sense_key key,
+ int *ascq, int num_ascq);
int test_iscsi_tur_until_good(struct scsi_device *iscsi_sd, int *num_uas);
-#endif /* _ISCSI_SUPPORT_H_ */
+#endif /* _ISCSI_SUPPORT_H_ */
diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c
index 4fa8b25..a640688 100644
--- a/test-tool/iscsi-test-cu.c
+++ b/test-tool/iscsi-test-cu.c
@@ -54,10 +54,10 @@
#include "iscsi-support.h"
#include "iscsi-multipath.h"
-#define PROG "iscsi-test-cu"
+#define PROG "iscsi-test-cu"
int loglevel = LOG_NORMAL;
-struct scsi_device *sd = NULL; /* mp_sds[0] alias */
+struct scsi_device *sd = NULL; /* mp_sds[0] alias */
static unsigned int maxsectors;
/*
@@ -72,401 +72,401 @@ int (*real_iscsi_queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
*
*****************************************************************/
static CU_TestInfo tests_compareandwrite[] = {
- { (char *)"Simple", test_compareandwrite_simple },
- { (char *)"DpoFua", test_compareandwrite_dpofua },
- { (char *)"Miscompare", test_compareandwrite_miscompare },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_compareandwrite_simple },
+ { (char *)"DpoFua", test_compareandwrite_dpofua },
+ { (char *)"Miscompare", test_compareandwrite_miscompare },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_get_lba_status[] = {
- { (char *)"Simple", test_get_lba_status_simple },
- { (char *)"BeyondEol", test_get_lba_status_beyond_eol },
- { (char *)"UnmapSingle", test_get_lba_status_unmap_single },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_get_lba_status_simple },
+ { (char *)"BeyondEol", test_get_lba_status_beyond_eol },
+ { (char *)"UnmapSingle", test_get_lba_status_unmap_single },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_inquiry[] = {
- { (char *)"Standard", test_inquiry_standard },
- { (char *)"AllocLength", test_inquiry_alloc_length},
- { (char *)"EVPD", test_inquiry_evpd},
- { (char *)"BlockLimits", test_inquiry_block_limits},
- { (char *)"MandatoryVPDSBC", test_inquiry_mandatory_vpd_sbc},
- { (char *)"SupportedVPD", test_inquiry_supported_vpd},
- { (char *)"VersionDescriptors", test_inquiry_version_descriptors},
- CU_TEST_INFO_NULL
+ { (char *)"Standard", test_inquiry_standard },
+ { (char *)"AllocLength", test_inquiry_alloc_length},
+ { (char *)"EVPD", test_inquiry_evpd},
+ { (char *)"BlockLimits", test_inquiry_block_limits},
+ { (char *)"MandatoryVPDSBC", test_inquiry_mandatory_vpd_sbc},
+ { (char *)"SupportedVPD", test_inquiry_supported_vpd},
+ { (char *)"VersionDescriptors", test_inquiry_version_descriptors},
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_mandatory[] = {
- { (char *)"MandatorySBC", test_mandatory_sbc },
- CU_TEST_INFO_NULL
+ { (char *)"MandatorySBC", test_mandatory_sbc },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_modesense6[] = {
- { (char *)"AllPages", test_modesense6_all_pages },
- { (char *)"Control", test_modesense6_control },
- { (char *)"Control-D_SENSE", test_modesense6_control_d_sense },
- { (char *)"Control-SWP", test_modesense6_control_swp },
- { (char *)"Residuals", test_modesense6_residuals },
- CU_TEST_INFO_NULL
+ { (char *)"AllPages", test_modesense6_all_pages },
+ { (char *)"Control", test_modesense6_control },
+ { (char *)"Control-D_SENSE", test_modesense6_control_d_sense },
+ { (char *)"Control-SWP", test_modesense6_control_swp },
+ { (char *)"Residuals", test_modesense6_residuals },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_nomedia[] = {
- { (char *)"NoMediaSBC", test_nomedia_sbc },
- CU_TEST_INFO_NULL
+ { (char *)"NoMediaSBC", test_nomedia_sbc },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_orwrite[] = {
- { (char *)"Simple", test_orwrite_simple },
- { (char *)"BeyondEol", test_orwrite_beyond_eol },
- { (char *)"ZeroBlocks", test_orwrite_0blocks },
- { (char *)"Protect", test_orwrite_wrprotect },
- { (char *)"DpoFua", test_orwrite_dpofua },
- { (char *)"Verify", test_orwrite_verify },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_orwrite_simple },
+ { (char *)"BeyondEol", test_orwrite_beyond_eol },
+ { (char *)"ZeroBlocks", test_orwrite_0blocks },
+ { (char *)"Protect", test_orwrite_wrprotect },
+ { (char *)"DpoFua", test_orwrite_dpofua },
+ { (char *)"Verify", test_orwrite_verify },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prefetch10[] = {
- { (char *)"Simple", test_prefetch10_simple },
- { (char *)"BeyondEol", test_prefetch10_beyond_eol },
- { (char *)"ZeroBlocks", test_prefetch10_0blocks },
- { (char *)"Flags", test_prefetch10_flags },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_prefetch10_simple },
+ { (char *)"BeyondEol", test_prefetch10_beyond_eol },
+ { (char *)"ZeroBlocks", test_prefetch10_0blocks },
+ { (char *)"Flags", test_prefetch10_flags },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prefetch16[] = {
- { (char *)"Simple", test_prefetch16_simple },
- { (char *)"BeyondEol", test_prefetch16_beyond_eol },
- { (char *)"ZeroBlocks", test_prefetch16_0blocks },
- { (char *)"Flags", test_prefetch16_flags },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_prefetch16_simple },
+ { (char *)"BeyondEol", test_prefetch16_beyond_eol },
+ { (char *)"ZeroBlocks", test_prefetch16_0blocks },
+ { (char *)"Flags", test_prefetch16_flags },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_preventallow[] = {
- { (char *)"Simple", test_preventallow_simple },
- { (char *)"Eject", test_preventallow_eject },
- { (char *)"ITNexusLoss", test_preventallow_itnexus_loss },
- { (char *)"Logout", test_preventallow_logout },
- { (char *)"WarmReset", test_preventallow_warm_reset },
- { (char *)"ColdReset", test_preventallow_cold_reset },
- { (char *)"LUNReset", test_preventallow_lun_reset },
- { (char *)"2ITNexuses", test_preventallow_2_itnexuses },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_preventallow_simple },
+ { (char *)"Eject", test_preventallow_eject },
+ { (char *)"ITNexusLoss", test_preventallow_itnexus_loss },
+ { (char *)"Logout", test_preventallow_logout },
+ { (char *)"WarmReset", test_preventallow_warm_reset },
+ { (char *)"ColdReset", test_preventallow_cold_reset },
+ { (char *)"LUNReset", test_preventallow_lun_reset },
+ { (char *)"2ITNexuses", test_preventallow_2_itnexuses },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prin_read_keys[] = {
- { (char *)"Simple", test_prin_read_keys_simple },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_prin_read_keys_simple },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prin_report_caps[] = {
- { (char *)"Simple", test_prin_report_caps_simple },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_prin_report_caps_simple },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prout_register[] = {
- { (char *)"Simple", test_prout_register_simple },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_prout_register_simple },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prout_reserve[] = {
- { (char *)"Simple",
- test_prout_reserve_simple },
- { (char *)"AccessEA",
- test_prout_reserve_access_ea },
- { (char *)"AccessWE",
- test_prout_reserve_access_we },
- { (char *)"AccessEARO",
- test_prout_reserve_access_earo },
- { (char *)"AccessWERO",
- test_prout_reserve_access_wero },
- { (char *)"AccessEAAR",
- test_prout_reserve_access_eaar },
- { (char *)"AccessWEAR",
- test_prout_reserve_access_wear },
- { (char *)"OwnershipEA",
- test_prout_reserve_ownership_ea },
- { (char *)"OwnershipWE",
- test_prout_reserve_ownership_we },
- { (char *)"OwnershipEARO",
- test_prout_reserve_ownership_earo },
- { (char *)"OwnershipWERO",
- test_prout_reserve_ownership_wero },
- { (char *)"OwnershipEAAR",
- test_prout_reserve_ownership_eaar },
- { (char *)"OwnershipWEAR",
- test_prout_reserve_ownership_wear },
- CU_TEST_INFO_NULL
+ { (char *)"Simple",
+ test_prout_reserve_simple },
+ { (char *)"AccessEA",
+ test_prout_reserve_access_ea },
+ { (char *)"AccessWE",
+ test_prout_reserve_access_we },
+ { (char *)"AccessEARO",
+ test_prout_reserve_access_earo },
+ { (char *)"AccessWERO",
+ test_prout_reserve_access_wero },
+ { (char *)"AccessEAAR",
+ test_prout_reserve_access_eaar },
+ { (char *)"AccessWEAR",
+ test_prout_reserve_access_wear },
+ { (char *)"OwnershipEA",
+ test_prout_reserve_ownership_ea },
+ { (char *)"OwnershipWE",
+ test_prout_reserve_ownership_we },
+ { (char *)"OwnershipEARO",
+ test_prout_reserve_ownership_earo },
+ { (char *)"OwnershipWERO",
+ test_prout_reserve_ownership_wero },
+ { (char *)"OwnershipEAAR",
+ test_prout_reserve_ownership_eaar },
+ { (char *)"OwnershipWEAR",
+ test_prout_reserve_ownership_wear },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prout_clear[] = {
- { (char *)"Simple",
- test_prout_clear_simple },
- CU_TEST_INFO_NULL
+ { (char *)"Simple",
+ test_prout_clear_simple },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prout_preempt[] = {
- { (char *)"RemoveRegistration",
- test_prout_preempt_rm_reg },
- CU_TEST_INFO_NULL
+ { (char *)"RemoveRegistration",
+ test_prout_preempt_rm_reg },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prin_serviceaction_range[] = {
- { (char *)"Range", test_prin_serviceaction_range },
- CU_TEST_INFO_NULL
+ { (char *)"Range", test_prin_serviceaction_range },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_read6[] = {
- { (char *)"Simple", test_read6_simple },
- { (char *)"BeyondEol", test_read6_beyond_eol },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_read6_simple },
+ { (char *)"BeyondEol", test_read6_beyond_eol },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_read10[] = {
- { (char *)"Simple", test_read10_simple },
- { (char *)"BeyondEol", test_read10_beyond_eol },
- { (char *)"ZeroBlocks", test_read10_0blocks },
- { (char *)"ReadProtect", test_read10_rdprotect },
- { (char *)"DpoFua", test_read10_dpofua },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_read10_simple },
+ { (char *)"BeyondEol", test_read10_beyond_eol },
+ { (char *)"ZeroBlocks", test_read10_0blocks },
+ { (char *)"ReadProtect", test_read10_rdprotect },
+ { (char *)"DpoFua", test_read10_dpofua },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_read12[] = {
- { (char *)"Simple", test_read12_simple },
- { (char *)"BeyondEol", test_read12_beyond_eol },
- { (char *)"ZeroBlocks", test_read12_0blocks },
- { (char *)"ReadProtect", test_read12_rdprotect },
- { (char *)"DpoFua", test_read12_dpofua },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_read12_simple },
+ { (char *)"BeyondEol", test_read12_beyond_eol },
+ { (char *)"ZeroBlocks", test_read12_0blocks },
+ { (char *)"ReadProtect", test_read12_rdprotect },
+ { (char *)"DpoFua", test_read12_dpofua },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_read16[] = {
- { (char *)"Simple", test_read16_simple },
- { (char *)"BeyondEol", test_read16_beyond_eol },
- { (char *)"ZeroBlocks", test_read16_0blocks },
- { (char *)"ReadProtect", test_read16_rdprotect },
- { (char *)"DpoFua", test_read16_dpofua },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_read16_simple },
+ { (char *)"BeyondEol", test_read16_beyond_eol },
+ { (char *)"ZeroBlocks", test_read16_0blocks },
+ { (char *)"ReadProtect", test_read16_rdprotect },
+ { (char *)"DpoFua", test_read16_dpofua },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_readcapacity10[] = {
- { (char *)"Simple", test_readcapacity10_simple },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_readcapacity10_simple },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_readcapacity16[] = {
- { (char *)"Simple", test_readcapacity16_simple },
- { (char *)"Alloclen", test_readcapacity16_alloclen },
- { (char *)"PI", test_readcapacity16_protection },
- { (char *)"Support", test_readcapacity16_support },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_readcapacity16_simple },
+ { (char *)"Alloclen", test_readcapacity16_alloclen },
+ { (char *)"PI", test_readcapacity16_protection },
+ { (char *)"Support", test_readcapacity16_support },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_readonly[] = {
- { (char *)"ReadOnlySBC", test_readonly_sbc },
- CU_TEST_INFO_NULL
+ { (char *)"ReadOnlySBC", test_readonly_sbc },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_sanitize[] = {
- { (char *)"BlockErase", test_sanitize_block_erase },
- { (char *)"BlockEraseReserved", test_sanitize_block_erase_reserved },
- { (char *)"CryptoErase", test_sanitize_crypto_erase },
- { (char *)"CryptoEraseReserved", test_sanitize_crypto_erase_reserved },
- { (char *)"ExitFailureMode", test_sanitize_exit_failure_mode },
- { (char *)"InvalidServiceAction", test_sanitize_invalid_serviceaction },
- { (char *)"Overwrite", test_sanitize_overwrite },
- { (char *)"OverwriteReserved", test_sanitize_overwrite_reserved },
- { (char *)"Readonly", test_sanitize_readonly },
- { (char *)"Reservations", test_sanitize_reservations },
- { (char *)"Reset", test_sanitize_reset },
- CU_TEST_INFO_NULL
+ { (char *)"BlockErase", test_sanitize_block_erase },
+ { (char *)"BlockEraseReserved", test_sanitize_block_erase_reserved },
+ { (char *)"CryptoErase", test_sanitize_crypto_erase },
+ { (char *)"CryptoEraseReserved", test_sanitize_crypto_erase_reserved },
+ { (char *)"ExitFailureMode", test_sanitize_exit_failure_mode },
+ { (char *)"InvalidServiceAction", test_sanitize_invalid_serviceaction },
+ { (char *)"Overwrite", test_sanitize_overwrite },
+ { (char *)"OverwriteReserved", test_sanitize_overwrite_reserved },
+ { (char *)"Readonly", test_sanitize_readonly },
+ { (char *)"Reservations", test_sanitize_reservations },
+ { (char *)"Reset", test_sanitize_reset },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_extended_copy[] = {
- { (char *)"Simple", test_extendedcopy_simple },
- { (char *)"ParamHdr", test_extendedcopy_param },
- { (char *)"DescrLimits", test_extendedcopy_descr_limits },
- { (char *)"DescrType", test_extendedcopy_descr_type },
- { (char *)"ValidTgtDescr", test_extendedcopy_validate_tgt_descr },
- { (char *)"ValidSegDescr", test_extendedcopy_validate_seg_descr },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_extendedcopy_simple },
+ { (char *)"ParamHdr", test_extendedcopy_param },
+ { (char *)"DescrLimits", test_extendedcopy_descr_limits },
+ { (char *)"DescrType", test_extendedcopy_descr_type },
+ { (char *)"ValidTgtDescr", test_extendedcopy_validate_tgt_descr },
+ { (char *)"ValidSegDescr", test_extendedcopy_validate_seg_descr },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_receive_copy_results[] = {
- { (char *)"CopyStatus", test_receive_copy_results_copy_status },
- { (char *)"OpParams", test_receive_copy_results_op_params },
- CU_TEST_INFO_NULL
+ { (char *)"CopyStatus", test_receive_copy_results_copy_status },
+ { (char *)"OpParams", test_receive_copy_results_op_params },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_report_supported_opcodes[] = {
- { (char *)"Simple", test_report_supported_opcodes_simple },
- { (char *)"OneCommand", test_report_supported_opcodes_one_command },
- { (char *)"RCTD", test_report_supported_opcodes_rctd },
- { (char *)"SERVACTV", test_report_supported_opcodes_servactv },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_report_supported_opcodes_simple },
+ { (char *)"OneCommand", test_report_supported_opcodes_one_command },
+ { (char *)"RCTD", test_report_supported_opcodes_rctd },
+ { (char *)"SERVACTV", test_report_supported_opcodes_servactv },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_reserve6[] = {
- { (char *)"Simple", test_reserve6_simple },
- { (char *)"2Initiators", test_reserve6_2initiators },
- { (char *)"Logout", test_reserve6_logout },
- { (char *)"ITNexusLoss", test_reserve6_itnexus_loss },
- { (char *)"TargetColdReset", test_reserve6_target_cold_reset },
- { (char *)"TargetWarmReset", test_reserve6_target_warm_reset },
- { (char *)"LUNReset", test_reserve6_lun_reset },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_reserve6_simple },
+ { (char *)"2Initiators", test_reserve6_2initiators },
+ { (char *)"Logout", test_reserve6_logout },
+ { (char *)"ITNexusLoss", test_reserve6_itnexus_loss },
+ { (char *)"TargetColdReset", test_reserve6_target_cold_reset },
+ { (char *)"TargetWarmReset", test_reserve6_target_warm_reset },
+ { (char *)"LUNReset", test_reserve6_lun_reset },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_testunitready[] = {
- { (char *)"Simple", test_testunitready_simple },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_testunitready_simple },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_startstopunit[] = {
- { (char *)"Simple", test_startstopunit_simple },
- { (char *)"PwrCnd", test_startstopunit_pwrcnd },
- { (char *)"NoLoej", test_startstopunit_noloej },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_startstopunit_simple },
+ { (char *)"PwrCnd", test_startstopunit_pwrcnd },
+ { (char *)"NoLoej", test_startstopunit_noloej },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_unmap[] = {
- { (char *)"Simple", test_unmap_simple },
- { (char *)"VPD", test_unmap_vpd },
- { (char *)"ZeroBlocks", test_unmap_0blocks },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_unmap_simple },
+ { (char *)"VPD", test_unmap_vpd },
+ { (char *)"ZeroBlocks", test_unmap_0blocks },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_verify10[] = {
- { (char *)"Simple", test_verify10_simple },
- { (char *)"BeyondEol", test_verify10_beyond_eol },
- { (char *)"ZeroBlocks", test_verify10_0blocks },
- { (char *)"VerifyProtect", test_verify10_vrprotect },
- { (char *)"Flags", test_verify10_flags },
- { (char *)"Dpo", test_verify10_dpo },
- { (char *)"Mismatch", test_verify10_mismatch },
- { (char *)"MismatchNoCmp", test_verify10_mismatch_no_cmp },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_verify10_simple },
+ { (char *)"BeyondEol", test_verify10_beyond_eol },
+ { (char *)"ZeroBlocks", test_verify10_0blocks },
+ { (char *)"VerifyProtect", test_verify10_vrprotect },
+ { (char *)"Flags", test_verify10_flags },
+ { (char *)"Dpo", test_verify10_dpo },
+ { (char *)"Mismatch", test_verify10_mismatch },
+ { (char *)"MismatchNoCmp", test_verify10_mismatch_no_cmp },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_verify12[] = {
- { (char *)"Simple", test_verify12_simple },
- { (char *)"BeyondEol", test_verify12_beyond_eol },
- { (char *)"ZeroBlocks", test_verify12_0blocks },
- { (char *)"VerifyProtect", test_verify12_vrprotect },
- { (char *)"Flags", test_verify12_flags },
- { (char *)"Dpo", test_verify12_dpo },
- { (char *)"Mismatch", test_verify12_mismatch },
- { (char *)"MismatchNoCmp", test_verify12_mismatch_no_cmp },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_verify12_simple },
+ { (char *)"BeyondEol", test_verify12_beyond_eol },
+ { (char *)"ZeroBlocks", test_verify12_0blocks },
+ { (char *)"VerifyProtect", test_verify12_vrprotect },
+ { (char *)"Flags", test_verify12_flags },
+ { (char *)"Dpo", test_verify12_dpo },
+ { (char *)"Mismatch", test_verify12_mismatch },
+ { (char *)"MismatchNoCmp", test_verify12_mismatch_no_cmp },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_verify16[] = {
- { (char *)"Simple", test_verify16_simple },
- { (char *)"BeyondEol", test_verify16_beyond_eol },
- { (char *)"ZeroBlocks", test_verify16_0blocks },
- { (char *)"VerifyProtect", test_verify16_vrprotect },
- { (char *)"Flags", test_verify16_flags },
- { (char *)"Dpo", test_verify16_dpo },
- { (char *)"Mismatch", test_verify16_mismatch },
- { (char *)"MismatchNoCmp", test_verify16_mismatch_no_cmp },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_verify16_simple },
+ { (char *)"BeyondEol", test_verify16_beyond_eol },
+ { (char *)"ZeroBlocks", test_verify16_0blocks },
+ { (char *)"VerifyProtect", test_verify16_vrprotect },
+ { (char *)"Flags", test_verify16_flags },
+ { (char *)"Dpo", test_verify16_dpo },
+ { (char *)"Mismatch", test_verify16_mismatch },
+ { (char *)"MismatchNoCmp", test_verify16_mismatch_no_cmp },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_write10[] = {
- { (char *)"Simple", test_write10_simple },
- { (char *)"BeyondEol", test_write10_beyond_eol },
- { (char *)"ZeroBlocks", test_write10_0blocks },
- { (char *)"WriteProtect", test_write10_wrprotect },
- { (char *)"DpoFua", test_write10_dpofua },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_write10_simple },
+ { (char *)"BeyondEol", test_write10_beyond_eol },
+ { (char *)"ZeroBlocks", test_write10_0blocks },
+ { (char *)"WriteProtect", test_write10_wrprotect },
+ { (char *)"DpoFua", test_write10_dpofua },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_write12[] = {
- { (char *)"Simple", test_write12_simple },
- { (char *)"BeyondEol", test_write12_beyond_eol },
- { (char *)"ZeroBlocks", test_write12_0blocks },
- { (char *)"WriteProtect", test_write12_wrprotect },
- { (char *)"DpoFua", test_write12_dpofua },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_write12_simple },
+ { (char *)"BeyondEol", test_write12_beyond_eol },
+ { (char *)"ZeroBlocks", test_write12_0blocks },
+ { (char *)"WriteProtect", test_write12_wrprotect },
+ { (char *)"DpoFua", test_write12_dpofua },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_write16[] = {
- { (char *)"Simple", test_write16_simple },
- { (char *)"BeyondEol", test_write16_beyond_eol },
- { (char *)"ZeroBlocks", test_write16_0blocks },
- { (char *)"WriteProtect", test_write16_wrprotect },
- { (char *)"DpoFua", test_write16_dpofua },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_write16_simple },
+ { (char *)"BeyondEol", test_write16_beyond_eol },
+ { (char *)"ZeroBlocks", test_write16_0blocks },
+ { (char *)"WriteProtect", test_write16_wrprotect },
+ { (char *)"DpoFua", test_write16_dpofua },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_writeatomic16[] = {
- { (char *)"Simple", test_writeatomic16_simple },
- { (char *)"BeyondEol", test_writeatomic16_beyond_eol },
- { (char *)"ZeroBlocks", test_writeatomic16_0blocks },
- { (char *)"WriteProtect", test_writeatomic16_wrprotect },
- { (char *)"DpoFua", test_writeatomic16_dpofua },
- { (char *)"VPD", test_writeatomic16_vpd },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_writeatomic16_simple },
+ { (char *)"BeyondEol", test_writeatomic16_beyond_eol },
+ { (char *)"ZeroBlocks", test_writeatomic16_0blocks },
+ { (char *)"WriteProtect", test_writeatomic16_wrprotect },
+ { (char *)"DpoFua", test_writeatomic16_dpofua },
+ { (char *)"VPD", test_writeatomic16_vpd },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_writesame10[] = {
- { (char *)"Simple", test_writesame10_simple },
- { (char *)"BeyondEol", test_writesame10_beyond_eol },
- { (char *)"ZeroBlocks", test_writesame10_0blocks },
- { (char *)"WriteProtect", test_writesame10_wrprotect },
- { (char *)"Unmap", test_writesame10_unmap },
- { (char *)"UnmapUnaligned", test_writesame10_unmap_unaligned },
- { (char *)"UnmapUntilEnd", test_writesame10_unmap_until_end },
- { (char *)"UnmapVPD", test_writesame10_unmap_vpd },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_writesame10_simple },
+ { (char *)"BeyondEol", test_writesame10_beyond_eol },
+ { (char *)"ZeroBlocks", test_writesame10_0blocks },
+ { (char *)"WriteProtect", test_writesame10_wrprotect },
+ { (char *)"Unmap", test_writesame10_unmap },
+ { (char *)"UnmapUnaligned", test_writesame10_unmap_unaligned },
+ { (char *)"UnmapUntilEnd", test_writesame10_unmap_until_end },
+ { (char *)"UnmapVPD", test_writesame10_unmap_vpd },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_writesame16[] = {
- { (char *)"Simple", test_writesame16_simple },
- { (char *)"BeyondEol", test_writesame16_beyond_eol },
- { (char *)"ZeroBlocks", test_writesame16_0blocks },
- { (char *)"WriteProtect", test_writesame16_wrprotect },
- { (char *)"Unmap", test_writesame16_unmap },
- { (char *)"UnmapUnaligned", test_writesame16_unmap_unaligned },
- { (char *)"UnmapUntilEnd", test_writesame16_unmap_until_end },
- { (char *)"UnmapVPD", test_writesame16_unmap_vpd },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_writesame16_simple },
+ { (char *)"BeyondEol", test_writesame16_beyond_eol },
+ { (char *)"ZeroBlocks", test_writesame16_0blocks },
+ { (char *)"WriteProtect", test_writesame16_wrprotect },
+ { (char *)"Unmap", test_writesame16_unmap },
+ { (char *)"UnmapUnaligned", test_writesame16_unmap_unaligned },
+ { (char *)"UnmapUntilEnd", test_writesame16_unmap_until_end },
+ { (char *)"UnmapVPD", test_writesame16_unmap_vpd },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_writeverify10[] = {
- { (char *)"Simple", test_writeverify10_simple },
- { (char *)"BeyondEol", test_writeverify10_beyond_eol },
- { (char *)"ZeroBlocks", test_writeverify10_0blocks },
- { (char *)"WriteProtect", test_writeverify10_wrprotect },
- { (char *)"Flags", test_writeverify10_flags },
- { (char *)"Dpo", test_writeverify10_dpo },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_writeverify10_simple },
+ { (char *)"BeyondEol", test_writeverify10_beyond_eol },
+ { (char *)"ZeroBlocks", test_writeverify10_0blocks },
+ { (char *)"WriteProtect", test_writeverify10_wrprotect },
+ { (char *)"Flags", test_writeverify10_flags },
+ { (char *)"Dpo", test_writeverify10_dpo },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_writeverify12[] = {
- { (char *)"Simple", test_writeverify12_simple },
- { (char *)"BeyondEol", test_writeverify12_beyond_eol },
- { (char *)"ZeroBlocks", test_writeverify12_0blocks },
- { (char *)"WriteProtect", test_writeverify12_wrprotect },
- { (char *)"Flags", test_writeverify12_flags },
- { (char *)"Dpo", test_writeverify12_dpo },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_writeverify12_simple },
+ { (char *)"BeyondEol", test_writeverify12_beyond_eol },
+ { (char *)"ZeroBlocks", test_writeverify12_0blocks },
+ { (char *)"WriteProtect", test_writeverify12_wrprotect },
+ { (char *)"Flags", test_writeverify12_flags },
+ { (char *)"Dpo", test_writeverify12_dpo },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_writeverify16[] = {
- { (char *)"Simple", test_writeverify16_simple },
- { (char *)"BeyondEol", test_writeverify16_beyond_eol },
- { (char *)"ZeroBlocks", test_writeverify16_0blocks },
- { (char *)"WriteProtect", test_writeverify16_wrprotect },
- { (char *)"Flags", test_writeverify16_flags },
- { (char *)"Dpo", test_writeverify16_dpo },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_writeverify16_simple },
+ { (char *)"BeyondEol", test_writeverify16_beyond_eol },
+ { (char *)"ZeroBlocks", test_writeverify16_0blocks },
+ { (char *)"WriteProtect", test_writeverify16_wrprotect },
+ { (char *)"Flags", test_writeverify16_flags },
+ { (char *)"Dpo", test_writeverify16_dpo },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_multipathio[] = {
- { (char *)"Simple", test_multipathio_simple },
- { (char *)"Reset", test_multipathio_reset },
- { (char *)"CompareAndWrite", test_multipathio_compareandwrite },
- CU_TEST_INFO_NULL
+ { (char *)"Simple", test_multipathio_simple },
+ { (char *)"Reset", test_multipathio_reset },
+ { (char *)"CompareAndWrite", test_multipathio_compareandwrite },
+ CU_TEST_INFO_NULL
};
typedef struct libiscsi_suite_info {
@@ -482,179 +482,179 @@ typedef struct libiscsi_suite_info {
/* SCSI protocol tests */
static libiscsi_suite_info scsi_suites[] = {
- { "CompareAndWrite", NON_PGR_FUNCS, tests_compareandwrite },
- { "ExtendedCopy", NON_PGR_FUNCS, tests_extended_copy },
- { "GetLBAStatus", NON_PGR_FUNCS, tests_get_lba_status },
- { "Inquiry", NON_PGR_FUNCS, tests_inquiry },
- { "Mandatory", NON_PGR_FUNCS, tests_mandatory },
- { "ModeSense6", NON_PGR_FUNCS, tests_modesense6 },
- { "NoMedia", NON_PGR_FUNCS, tests_nomedia },
- { "OrWrite", NON_PGR_FUNCS, tests_orwrite },
- { "Prefetch10", NON_PGR_FUNCS, tests_prefetch10 },
- { "Prefetch16", NON_PGR_FUNCS, tests_prefetch16 },
- { "PreventAllow", NON_PGR_FUNCS, tests_preventallow },
- { "PrinReadKeys", NON_PGR_FUNCS, tests_prin_read_keys },
- { "PrinServiceactionRange", NON_PGR_FUNCS, tests_prin_serviceaction_range },
- { "PrinReportCapabilities", NON_PGR_FUNCS, tests_prin_report_caps },
- { "ProutRegister", NON_PGR_FUNCS, tests_prout_register },
- { "ProutReserve", NON_PGR_FUNCS, tests_prout_reserve },
- { "ProutClear", NON_PGR_FUNCS, tests_prout_clear },
- { "ProutPreempt", NON_PGR_FUNCS, tests_prout_preempt },
- { "Read6", NON_PGR_FUNCS, tests_read6 },
- { "Read10", NON_PGR_FUNCS, tests_read10 },
- { "Read12", NON_PGR_FUNCS, tests_read12 },
- { "Read16", NON_PGR_FUNCS, tests_read16 },
- { "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
- { "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
- { "ReadOnly", NON_PGR_FUNCS, tests_readonly },
- { "ReceiveCopyResults", NON_PGR_FUNCS, tests_receive_copy_results },
- { "ReportSupportedOpcodes", NON_PGR_FUNCS,
- tests_report_supported_opcodes },
- { "Reserve6", NON_PGR_FUNCS, tests_reserve6 },
- { "Sanitize", NON_PGR_FUNCS, tests_sanitize },
- { "StartStopUnit", NON_PGR_FUNCS, tests_startstopunit },
- { "TestUnitReady", NON_PGR_FUNCS, tests_testunitready },
- { "Unmap", NON_PGR_FUNCS, tests_unmap },
- { "Verify10", NON_PGR_FUNCS, tests_verify10 },
- { "Verify12", NON_PGR_FUNCS, tests_verify12 },
- { "Verify16", NON_PGR_FUNCS, tests_verify16 },
- { "Write10", NON_PGR_FUNCS, tests_write10 },
- { "Write12", NON_PGR_FUNCS, tests_write12 },
- { "Write16", NON_PGR_FUNCS, tests_write16 },
- { "WriteAtomic16", NON_PGR_FUNCS, tests_writeatomic16 },
- { "WriteSame10", NON_PGR_FUNCS, tests_writesame10 },
- { "WriteSame16", NON_PGR_FUNCS, tests_writesame16 },
- { "WriteVerify10", NON_PGR_FUNCS, tests_writeverify10 },
- { "WriteVerify12", NON_PGR_FUNCS, tests_writeverify12 },
- { "WriteVerify16", NON_PGR_FUNCS, tests_writeverify16 },
- { "MultipathIO", NON_PGR_FUNCS, tests_multipathio },
- { NULL, NULL, NULL, NULL, NULL, NULL }
+ { "CompareAndWrite", NON_PGR_FUNCS, tests_compareandwrite },
+ { "ExtendedCopy", NON_PGR_FUNCS, tests_extended_copy },
+ { "GetLBAStatus", NON_PGR_FUNCS, tests_get_lba_status },
+ { "Inquiry", NON_PGR_FUNCS, tests_inquiry },
+ { "Mandatory", NON_PGR_FUNCS, tests_mandatory },
+ { "ModeSense6", NON_PGR_FUNCS, tests_modesense6 },
+ { "NoMedia", NON_PGR_FUNCS, tests_nomedia },
+ { "OrWrite", NON_PGR_FUNCS, tests_orwrite },
+ { "Prefetch10", NON_PGR_FUNCS, tests_prefetch10 },
+ { "Prefetch16", NON_PGR_FUNCS, tests_prefetch16 },
+ { "PreventAllow", NON_PGR_FUNCS, tests_preventallow },
+ { "PrinReadKeys", NON_PGR_FUNCS, tests_prin_read_keys },
+ { "PrinServiceactionRange", NON_PGR_FUNCS, tests_prin_serviceaction_range },
+ { "PrinReportCapabilities", NON_PGR_FUNCS, tests_prin_report_caps },
+ { "ProutRegister", NON_PGR_FUNCS, tests_prout_register },
+ { "ProutReserve", NON_PGR_FUNCS, tests_prout_reserve },
+ { "ProutClear", NON_PGR_FUNCS, tests_prout_clear },
+ { "ProutPreempt", NON_PGR_FUNCS, tests_prout_preempt },
+ { "Read6", NON_PGR_FUNCS, tests_read6 },
+ { "Read10", NON_PGR_FUNCS, tests_read10 },
+ { "Read12", NON_PGR_FUNCS, tests_read12 },
+ { "Read16", NON_PGR_FUNCS, tests_read16 },
+ { "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
+ { "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
+ { "ReadOnly", NON_PGR_FUNCS, tests_readonly },
+ { "ReceiveCopyResults", NON_PGR_FUNCS, tests_receive_copy_results },
+ { "ReportSupportedOpcodes", NON_PGR_FUNCS,
+ tests_report_supported_opcodes },
+ { "Reserve6", NON_PGR_FUNCS, tests_reserve6 },
+ { "Sanitize", NON_PGR_FUNCS, tests_sanitize },
+ { "StartStopUnit", NON_PGR_FUNCS, tests_startstopunit },
+ { "TestUnitReady", NON_PGR_FUNCS, tests_testunitready },
+ { "Unmap", NON_PGR_FUNCS, tests_unmap },
+ { "Verify10", NON_PGR_FUNCS, tests_verify10 },
+ { "Verify12", NON_PGR_FUNCS, tests_verify12 },
+ { "Verify16", NON_PGR_FUNCS, tests_verify16 },
+ { "Write10", NON_PGR_FUNCS, tests_write10 },
+ { "Write12", NON_PGR_FUNCS, tests_write12 },
+ { "Write16", NON_PGR_FUNCS, tests_write16 },
+ { "WriteAtomic16", NON_PGR_FUNCS, tests_writeatomic16 },
+ { "WriteSame10", NON_PGR_FUNCS, tests_writesame10 },
+ { "WriteSame16", NON_PGR_FUNCS, tests_writesame16 },
+ { "WriteVerify10", NON_PGR_FUNCS, tests_writeverify10 },
+ { "WriteVerify12", NON_PGR_FUNCS, tests_writeverify12 },
+ { "WriteVerify16", NON_PGR_FUNCS, tests_writeverify16 },
+ { "MultipathIO", NON_PGR_FUNCS, tests_multipathio },
+ { NULL, NULL, NULL, NULL, NULL, NULL }
};
static CU_TestInfo tests_iscsi_cmdsn[] = {
- { (char *)"iSCSICmdSnTooHigh", test_iscsi_cmdsn_toohigh },
- { (char *)"iSCSICmdSnTooLow", test_iscsi_cmdsn_toolow },
- CU_TEST_INFO_NULL
+ { (char *)"iSCSICmdSnTooHigh", test_iscsi_cmdsn_toohigh },
+ { (char *)"iSCSICmdSnTooLow", test_iscsi_cmdsn_toolow },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_iscsi_datasn[] = {
- { (char *)"iSCSIDataSnInvalid", test_iscsi_datasn_invalid },
- CU_TEST_INFO_NULL
+ { (char *)"iSCSIDataSnInvalid", test_iscsi_datasn_invalid },
+ CU_TEST_INFO_NULL
};
static CU_TestInfo tests_iscsi_residuals[] = {
- { (char *)"Read10Invalid", test_read10_invalid },
- { (char *)"Read10Residuals", test_read10_residuals },
- { (char *)"Read12Residuals", test_read12_residuals },
- { (char *)"Read16Residuals", test_read16_residuals },
- { (char *)"Write10Residuals", test_write10_residuals },
- { (char *)"Write12Residuals", test_write12_residuals },
- { (char *)"Write16Residuals", test_write16_residuals },
- { (char *)"WriteVerify10Residuals", test_writeverify10_residuals },
- { (char *)"WriteVerify12Residuals", test_writeverify12_residuals },
- { (char *)"WriteVerify16Residuals", test_writeverify16_residuals },
- CU_TEST_INFO_NULL
+ { (char *)"Read10Invalid", test_read10_invalid },
+ { (char *)"Read10Residuals", test_read10_residuals },
+ { (char *)"Read12Residuals", test_read12_residuals },
+ { (char *)"Read16Residuals", test_read16_residuals },
+ { (char *)"Write10Residuals", test_write10_residuals },
+ { (char *)"Write12Residuals", test_write12_residuals },
+ { (char *)"Write16Residuals", test_write16_residuals },
+ { (char *)"WriteVerify10Residuals", test_writeverify10_residuals },
+ { (char *)"WriteVerify12Residuals", test_writeverify12_residuals },
+ { (char *)"WriteVerify16Residuals", test_writeverify16_residuals },
+ CU_TEST_INFO_NULL
};
/* iSCSI protocol tests */
static libiscsi_suite_info iscsi_suites[] = {
- { "iSCSIcmdsn", NON_PGR_FUNCS,
- tests_iscsi_cmdsn },
- { "iSCSIdatasn", NON_PGR_FUNCS,
- tests_iscsi_datasn },
- { "iSCSIResiduals", NON_PGR_FUNCS,
- tests_iscsi_residuals },
- { NULL, NULL, NULL, NULL, NULL, NULL }
+ { "iSCSIcmdsn", NON_PGR_FUNCS,
+ tests_iscsi_cmdsn },
+ { "iSCSIdatasn", NON_PGR_FUNCS,
+ tests_iscsi_datasn },
+ { "iSCSIResiduals", NON_PGR_FUNCS,
+ tests_iscsi_residuals },
+ { NULL, NULL, NULL, NULL, NULL, NULL }
};
/* All tests */
static libiscsi_suite_info all_suites[] = {
- { "CompareAndWrite", NON_PGR_FUNCS, tests_compareandwrite },
- { "ExtendedCopy", NON_PGR_FUNCS, tests_extended_copy },
- { "GetLBAStatus", NON_PGR_FUNCS, tests_get_lba_status },
- { "Inquiry", NON_PGR_FUNCS, tests_inquiry },
- { "Mandatory", NON_PGR_FUNCS, tests_mandatory },
- { "ModeSense6", NON_PGR_FUNCS, tests_modesense6 },
- { "NoMedia", NON_PGR_FUNCS, tests_nomedia },
- { "OrWrite", NON_PGR_FUNCS, tests_orwrite },
- { "Prefetch10", NON_PGR_FUNCS, tests_prefetch10 },
- { "Prefetch16", NON_PGR_FUNCS, tests_prefetch16 },
- { "PreventAllow", NON_PGR_FUNCS, tests_preventallow },
- { "PrinReadKeys", NON_PGR_FUNCS, tests_prin_read_keys },
- { "PrinServiceactionRange", NON_PGR_FUNCS,
- tests_prin_serviceaction_range },
- { "PrinReportCapabilities", NON_PGR_FUNCS, tests_prin_report_caps },
- { "ProutRegister", NON_PGR_FUNCS, tests_prout_register },
- { "ProutReserve", NON_PGR_FUNCS, tests_prout_reserve },
- { "ProutClear", NON_PGR_FUNCS, tests_prout_clear },
- { "ProutPreempt", NON_PGR_FUNCS, tests_prout_preempt },
- { "Read6", NON_PGR_FUNCS, tests_read6 },
- { "Read10", NON_PGR_FUNCS, tests_read10 },
- { "Read12", NON_PGR_FUNCS, tests_read12 },
- { "Read16", NON_PGR_FUNCS, tests_read16 },
- { "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
- { "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
- { "ReadOnly", NON_PGR_FUNCS, tests_readonly },
- { "ReceiveCopyResults", NON_PGR_FUNCS, tests_receive_copy_results },
- { "ReportSupportedOpcodes", NON_PGR_FUNCS,
- tests_report_supported_opcodes },
- { "Reserve6", NON_PGR_FUNCS, tests_reserve6 },
- { "Sanitize", NON_PGR_FUNCS, tests_sanitize },
- { "StartStopUnit", NON_PGR_FUNCS, tests_startstopunit },
- { "TestUnitReady", NON_PGR_FUNCS, tests_testunitready },
- { "Unmap", NON_PGR_FUNCS, tests_unmap },
- { "Verify10", NON_PGR_FUNCS, tests_verify10 },
- { "Verify12", NON_PGR_FUNCS, tests_verify12 },
- { "Verify16", NON_PGR_FUNCS, tests_verify16 },
- { "Write10", NON_PGR_FUNCS, tests_write10 },
- { "Write12", NON_PGR_FUNCS, tests_write12 },
- { "Write16", NON_PGR_FUNCS, tests_write16 },
- { "WriteAtomic16", NON_PGR_FUNCS, tests_writeatomic16 },
- { "WriteSame10", NON_PGR_FUNCS, tests_writesame10 },
- { "WriteSame16", NON_PGR_FUNCS, tests_writesame16 },
- { "WriteVerify10", NON_PGR_FUNCS, tests_writeverify10 },
- { "WriteVerify12", NON_PGR_FUNCS, tests_writeverify12 },
- { "WriteVerify16", NON_PGR_FUNCS, tests_writeverify16 },
- { "iSCSIcmdsn", NON_PGR_FUNCS, tests_iscsi_cmdsn },
- { "iSCSIdatasn", NON_PGR_FUNCS, tests_iscsi_datasn },
- { "iSCSIResiduals", NON_PGR_FUNCS, tests_iscsi_residuals },
- { "MultipathIO", NON_PGR_FUNCS, tests_multipathio },
- { NULL, NULL, NULL, NULL, NULL, NULL },
+ { "CompareAndWrite", NON_PGR_FUNCS, tests_compareandwrite },
+ { "ExtendedCopy", NON_PGR_FUNCS, tests_extended_copy },
+ { "GetLBAStatus", NON_PGR_FUNCS, tests_get_lba_status },
+ { "Inquiry", NON_PGR_FUNCS, tests_inquiry },
+ { "Mandatory", NON_PGR_FUNCS, tests_mandatory },
+ { "ModeSense6", NON_PGR_FUNCS, tests_modesense6 },
+ { "NoMedia", NON_PGR_FUNCS, tests_nomedia },
+ { "OrWrite", NON_PGR_FUNCS, tests_orwrite },
+ { "Prefetch10", NON_PGR_FUNCS, tests_prefetch10 },
+ { "Prefetch16", NON_PGR_FUNCS, tests_prefetch16 },
+ { "PreventAllow", NON_PGR_FUNCS, tests_preventallow },
+ { "PrinReadKeys", NON_PGR_FUNCS, tests_prin_read_keys },
+ { "PrinServiceactionRange", NON_PGR_FUNCS,
+ tests_prin_serviceaction_range },
+ { "PrinReportCapabilities", NON_PGR_FUNCS, tests_prin_report_caps },
+ { "ProutRegister", NON_PGR_FUNCS, tests_prout_register },
+ { "ProutReserve", NON_PGR_FUNCS, tests_prout_reserve },
+ { "ProutClear", NON_PGR_FUNCS, tests_prout_clear },
+ { "ProutPreempt", NON_PGR_FUNCS, tests_prout_preempt },
+ { "Read6", NON_PGR_FUNCS, tests_read6 },
+ { "Read10", NON_PGR_FUNCS, tests_read10 },
+ { "Read12", NON_PGR_FUNCS, tests_read12 },
+ { "Read16", NON_PGR_FUNCS, tests_read16 },
+ { "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
+ { "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
+ { "ReadOnly", NON_PGR_FUNCS, tests_readonly },
+ { "ReceiveCopyResults", NON_PGR_FUNCS, tests_receive_copy_results },
+ { "ReportSupportedOpcodes", NON_PGR_FUNCS,
+ tests_report_supported_opcodes },
+ { "Reserve6", NON_PGR_FUNCS, tests_reserve6 },
+ { "Sanitize", NON_PGR_FUNCS, tests_sanitize },
+ { "StartStopUnit", NON_PGR_FUNCS, tests_startstopunit },
+ { "TestUnitReady", NON_PGR_FUNCS, tests_testunitready },
+ { "Unmap", NON_PGR_FUNCS, tests_unmap },
+ { "Verify10", NON_PGR_FUNCS, tests_verify10 },
+ { "Verify12", NON_PGR_FUNCS, tests_verify12 },
+ { "Verify16", NON_PGR_FUNCS, tests_verify16 },
+ { "Write10", NON_PGR_FUNCS, tests_write10 },
+ { "Write12", NON_PGR_FUNCS, tests_write12 },
+ { "Write16", NON_PGR_FUNCS, tests_write16 },
+ { "WriteAtomic16", NON_PGR_FUNCS, tests_writeatomic16 },
+ { "WriteSame10", NON_PGR_FUNCS, tests_writesame10 },
+ { "WriteSame16", NON_PGR_FUNCS, tests_writesame16 },
+ { "WriteVerify10", NON_PGR_FUNCS, tests_writeverify10 },
+ { "WriteVerify12", NON_PGR_FUNCS, tests_writeverify12 },
+ { "WriteVerify16", NON_PGR_FUNCS, tests_writeverify16 },
+ { "iSCSIcmdsn", NON_PGR_FUNCS, tests_iscsi_cmdsn },
+ { "iSCSIdatasn", NON_PGR_FUNCS, tests_iscsi_datasn },
+ { "iSCSIResiduals", NON_PGR_FUNCS, tests_iscsi_residuals },
+ { "MultipathIO", NON_PGR_FUNCS, tests_multipathio },
+ { NULL, NULL, NULL, NULL, NULL, NULL },
};
static libiscsi_suite_info linux_suites[] = {
- { "CompareAndWrite", NON_PGR_FUNCS, tests_compareandwrite },
- { "GetLBAStatus", NON_PGR_FUNCS, tests_get_lba_status },
- { "Inquiry", NON_PGR_FUNCS, tests_inquiry },
- { "Mandatory", NON_PGR_FUNCS, tests_mandatory },
- { "ModeSense6", NON_PGR_FUNCS, tests_modesense6 },
- { "OrWrite", NON_PGR_FUNCS, tests_orwrite },
- { "Prefetch10", NON_PGR_FUNCS, tests_prefetch10 },
- { "Prefetch16", NON_PGR_FUNCS, tests_prefetch16 },
- { "Read10", NON_PGR_FUNCS, tests_read10 },
- { "Read12", NON_PGR_FUNCS, tests_read12 },
- { "Read16", NON_PGR_FUNCS, tests_read16 },
- { "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
- { "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
- { "ReadOnly", NON_PGR_FUNCS, tests_readonly },
- { "ReportSupportedOpcodes", NON_PGR_FUNCS,
- tests_report_supported_opcodes },
- { "TestUnitReady", NON_PGR_FUNCS, tests_testunitready },
- { "Unmap", NON_PGR_FUNCS, tests_unmap },
- { "Verify10", NON_PGR_FUNCS, tests_verify10 },
- { "Verify12", NON_PGR_FUNCS, tests_verify12 },
- { "Verify16", NON_PGR_FUNCS, tests_verify16 },
- { "Write10", NON_PGR_FUNCS, tests_write10 },
- { "Write12", NON_PGR_FUNCS, tests_write12 },
- { "Write16", NON_PGR_FUNCS, tests_write16 },
- { "WriteAtomic16", NON_PGR_FUNCS, tests_writeatomic16 },
- { "WriteSame10", NON_PGR_FUNCS, tests_writesame10 },
- { "WriteSame16", NON_PGR_FUNCS, tests_writesame16 },
- { "WriteVerify10", NON_PGR_FUNCS, tests_writeverify10 },
- { "WriteVerify12", NON_PGR_FUNCS, tests_writeverify12 },
- { "WriteVerify16", NON_PGR_FUNCS, tests_writeverify16 },
- { "MultipathIO", NON_PGR_FUNCS, tests_multipathio },
- { NULL, NULL, NULL, NULL, NULL, NULL },
+ { "CompareAndWrite", NON_PGR_FUNCS, tests_compareandwrite },
+ { "GetLBAStatus", NON_PGR_FUNCS, tests_get_lba_status },
+ { "Inquiry", NON_PGR_FUNCS, tests_inquiry },
+ { "Mandatory", NON_PGR_FUNCS, tests_mandatory },
+ { "ModeSense6", NON_PGR_FUNCS, tests_modesense6 },
+ { "OrWrite", NON_PGR_FUNCS, tests_orwrite },
+ { "Prefetch10", NON_PGR_FUNCS, tests_prefetch10 },
+ { "Prefetch16", NON_PGR_FUNCS, tests_prefetch16 },
+ { "Read10", NON_PGR_FUNCS, tests_read10 },
+ { "Read12", NON_PGR_FUNCS, tests_read12 },
+ { "Read16", NON_PGR_FUNCS, tests_read16 },
+ { "ReadCapacity10", NON_PGR_FUNCS, tests_readcapacity10 },
+ { "ReadCapacity16", NON_PGR_FUNCS, tests_readcapacity16 },
+ { "ReadOnly", NON_PGR_FUNCS, tests_readonly },
+ { "ReportSupportedOpcodes", NON_PGR_FUNCS,
+ tests_report_supported_opcodes },
+ { "TestUnitReady", NON_PGR_FUNCS, tests_testunitready },
+ { "Unmap", NON_PGR_FUNCS, tests_unmap },
+ { "Verify10", NON_PGR_FUNCS, tests_verify10 },
+ { "Verify12", NON_PGR_FUNCS, tests_verify12 },
+ { "Verify16", NON_PGR_FUNCS, tests_verify16 },
+ { "Write10", NON_PGR_FUNCS, tests_write10 },
+ { "Write12", NON_PGR_FUNCS, tests_write12 },
+ { "Write16", NON_PGR_FUNCS, tests_write16 },
+ { "WriteAtomic16", NON_PGR_FUNCS, tests_writeatomic16 },
+ { "WriteSame10", NON_PGR_FUNCS, tests_writesame10 },
+ { "WriteSame16", NON_PGR_FUNCS, tests_writesame16 },
+ { "WriteVerify10", NON_PGR_FUNCS, tests_writeverify10 },
+ { "WriteVerify12", NON_PGR_FUNCS, tests_writeverify12 },
+ { "WriteVerify16", NON_PGR_FUNCS, tests_writeverify16 },
+ { "MultipathIO", NON_PGR_FUNCS, tests_multipathio },
+ { NULL, NULL, NULL, NULL, NULL, NULL },
};
struct test_family {
@@ -663,11 +663,11 @@ struct test_family {
};
static struct test_family families[] = {
- { "ALL", all_suites },
- { "SCSI", scsi_suites },
- { "iSCSI", iscsi_suites },
- { "LINUX", linux_suites },
- { NULL, NULL}
+ { "ALL", all_suites },
+ { "SCSI", scsi_suites },
+ { "iSCSI", iscsi_suites },
+ { "LINUX", linux_suites },
+ { NULL, NULL}
};
/*
@@ -679,790 +679,790 @@ unsigned char *read_write_buf;
static void
print_usage(void)
{
- fprintf(stderr,
- "Usage: %s [-?|--help] print this message and exit\n",
- PROG);
- fprintf(stderr,
- "or %s [OPTIONS] [multipath-iscsi-url]\n", PROG);
- fprintf(stderr,
- "Where OPTIONS are from:\n");
- fprintf(stderr,
- " -i|--initiator-name=iqn-name Initiatorname to use [%s]\n",
- initiatorname1);
- fprintf(stderr,
- " -I|--initiator-name-2=iqn-name 2nd Initiatorname to use [%s]\n",
- initiatorname2);
- fprintf(stderr,
- " -t|--test=test-name-reg-exp Test(s) to run [ALL] \n");
- fprintf(stderr,
- " -l|--list List all tests and exit\n");
- fprintf(stderr,
- " -d|--dataloss Allow destructive tests\n");
- fprintf(stderr,
- " -S|--allow-sanitize Allow sanitize-opcode tests\n");
- fprintf(stderr,
- " -g|--ignore Error Action: Ignore test errors [DEFAULT]\n");
- fprintf(stderr,
- " -f|--fail Error Action: FAIL if any tests fail\n");
- fprintf(stderr,
- " -A|--abort Error Action: ABORT if any tests fail\n");
- fprintf(stderr,
- " -s|--silent Test Mode: Silent\n");
- fprintf(stderr,
- " -n|--normal Test Mode: Normal\n");
- fprintf(stderr,
- " -v|--verbose Test Mode: Verbose [DEFAULT]\n");
- fprintf(stderr,
- " -x|--xml Test Mode: XML\n");
- fprintf(stderr,
- " -V|--Verbose-scsi Enable verbose SCSI logging [default SILENT]\n");
- fprintf(stderr, "\n");
- fprintf(stderr,
- "Where iSCSI URL format is: %s\n", ISCSI_URL_SYNTAX);
- fprintf(stderr, "\n");
- fprintf(stderr,
- " is one of:\n");
- fprintf(stderr,
- " \"hostname\" e.g. iscsi.example\n");
- fprintf(stderr,
- " \"ipv4-address\" e.g. 10.1.1.27\n");
- fprintf(stderr,
- " \"ipv6-address\" e.g. [fce0::1]\n");
- fprintf(stderr, "\n");
- fprintf(stderr,
- "and is of the form: FAMILY[.SUITE[.TEST]]\n");
- fprintf(stderr, "\n");
+ fprintf(stderr,
+ "Usage: %s [-?|--help] print this message and exit\n",
+ PROG);
+ fprintf(stderr,
+ "or %s [OPTIONS] [multipath-iscsi-url]\n", PROG);
+ fprintf(stderr,
+ "Where OPTIONS are from:\n");
+ fprintf(stderr,
+ " -i|--initiator-name=iqn-name Initiatorname to use [%s]\n",
+ initiatorname1);
+ fprintf(stderr,
+ " -I|--initiator-name-2=iqn-name 2nd Initiatorname to use [%s]\n",
+ initiatorname2);
+ fprintf(stderr,
+ " -t|--test=test-name-reg-exp Test(s) to run [ALL] \n");
+ fprintf(stderr,
+ " -l|--list List all tests and exit\n");
+ fprintf(stderr,
+ " -d|--dataloss Allow destructive tests\n");
+ fprintf(stderr,
+ " -S|--allow-sanitize Allow sanitize-opcode tests\n");
+ fprintf(stderr,
+ " -g|--ignore Error Action: Ignore test errors [DEFAULT]\n");
+ fprintf(stderr,
+ " -f|--fail Error Action: FAIL if any tests fail\n");
+ fprintf(stderr,
+ " -A|--abort Error Action: ABORT if any tests fail\n");
+ fprintf(stderr,
+ " -s|--silent Test Mode: Silent\n");
+ fprintf(stderr,
+ " -n|--normal Test Mode: Normal\n");
+ fprintf(stderr,
+ " -v|--verbose Test Mode: Verbose [DEFAULT]\n");
+ fprintf(stderr,
+ " -x|--xml Test Mode: XML\n");
+ fprintf(stderr,
+ " -V|--Verbose-scsi Enable verbose SCSI logging [default SILENT]\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr,
+ "Where iSCSI URL format is: %s\n", ISCSI_URL_SYNTAX);
+ fprintf(stderr, "\n");
+ fprintf(stderr,
+ " is one of:\n");
+ fprintf(stderr,
+ " \"hostname\" e.g. iscsi.example\n");
+ fprintf(stderr,
+ " \"ipv4-address\" e.g. 10.1.1.27\n");
+ fprintf(stderr,
+ " \"ipv6-address\" e.g. [fce0::1]\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr,
+ "and is of the form: FAMILY[.SUITE[.TEST]]\n");
+ fprintf(stderr, "\n");
}
void
test_setup(void)
{
- task = NULL;
- read_write_buf = NULL;
+ task = NULL;
+ read_write_buf = NULL;
}
void
test_teardown(void)
{
- free(read_write_buf);
- read_write_buf = NULL;
- scsi_free_scsi_task(task);
- task = NULL;
+ free(read_write_buf);
+ read_write_buf = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
}
int
suite_init(void)
{
- int i;
+ int i;
- for (i = 0; i < mp_num_sds; i++) {
- if (!mp_sds[i]->iscsi_url) {
- continue;
- }
- if (mp_sds[i]->iscsi_ctx) {
- iscsi_logout_sync(mp_sds[i]->iscsi_ctx);
- iscsi_destroy_context(mp_sds[i]->iscsi_ctx);
- }
- mp_sds[i]->iscsi_ctx = iscsi_context_login(initiatorname1,
- mp_sds[i]->iscsi_url,
- &mp_sds[i]->iscsi_lun);
- if (mp_sds[i]->iscsi_ctx == NULL) {
- fprintf(stderr,
- "error: Failed to login to target for test set-up\n");
- return 1;
- }
- iscsi_set_no_ua_on_reconnect(mp_sds[i]->iscsi_ctx, 1);
- }
+ for (i = 0; i < mp_num_sds; i++) {
+ if (!mp_sds[i]->iscsi_url) {
+ continue;
+ }
+ if (mp_sds[i]->iscsi_ctx) {
+ iscsi_logout_sync(mp_sds[i]->iscsi_ctx);
+ iscsi_destroy_context(mp_sds[i]->iscsi_ctx);
+ }
+ mp_sds[i]->iscsi_ctx = iscsi_context_login(initiatorname1,
+ mp_sds[i]->iscsi_url,
+ &mp_sds[i]->iscsi_lun);
+ if (mp_sds[i]->iscsi_ctx == NULL) {
+ fprintf(stderr,
+ "error: Failed to login to target for test set-up\n");
+ return 1;
+ }
+ iscsi_set_no_ua_on_reconnect(mp_sds[i]->iscsi_ctx, 1);
+ }
#ifndef HAVE_CU_SUITEINFO_PSETUPFUNC
- /* libcunit version 1 */
- test_setup();
+ /* libcunit version 1 */
+ test_setup();
#endif
- return 0;
+ return 0;
}
int
suite_cleanup(void)
{
- int i;
+ int i;
#ifndef HAVE_CU_SUITEINFO_PSETUPFUNC
- /* libcunit version 1 */
- test_teardown();
+ /* libcunit version 1 */
+ test_teardown();
#endif
- for (i = 0; i < mp_num_sds; i++) {
- if (mp_sds[i]->iscsi_url) {
- if (mp_sds[i]->iscsi_ctx) {
- iscsi_logout_sync(mp_sds[i]->iscsi_ctx);
- iscsi_destroy_context(mp_sds[i]->iscsi_ctx);
- mp_sds[i]->iscsi_ctx = NULL;
- }
- }
- }
- return 0;
+ for (i = 0; i < mp_num_sds; i++) {
+ if (mp_sds[i]->iscsi_url) {
+ if (mp_sds[i]->iscsi_ctx) {
+ iscsi_logout_sync(mp_sds[i]->iscsi_ctx);
+ iscsi_destroy_context(mp_sds[i]->iscsi_ctx);
+ mp_sds[i]->iscsi_ctx = NULL;
+ }
+ }
+ }
+ return 0;
}
static void
list_all_tests(void)
{
- struct test_family *fp;
- libiscsi_suite_info *sp;
- CU_TestInfo *tp;
+ struct test_family *fp;
+ libiscsi_suite_info *sp;
+ CU_TestInfo *tp;
- for (fp = families; fp->name; fp++) {
- printf("%s\n", fp->name);
- for (sp = fp->suites; sp->pName != NULL; sp++) {
- printf("%s.%s\n", fp->name,sp->pName);
- for (tp = sp->pTests; tp->pName != NULL; tp++) {
- printf("%s.%s.%s\n", fp->name,sp->pName,
- tp->pName);
- }
- }
- }
+ for (fp = families; fp->name; fp++) {
+ printf("%s\n", fp->name);
+ for (sp = fp->suites; sp->pName != NULL; sp++) {
+ printf("%s.%s\n", fp->name,sp->pName);
+ for (tp = sp->pTests; tp->pName != NULL; tp++) {
+ printf("%s.%s.%s\n", fp->name,sp->pName,
+ tp->pName);
+ }
+ }
+ }
}
static CU_ErrorCode
add_tests(const char *testname_re)
{
- char *family_re = NULL;
- char *suite_re = NULL;
- char *test_re = NULL;
- char *cp;
- struct test_family *fp;
- libiscsi_suite_info *sp;
- CU_TestInfo *tp;
+ char *family_re = NULL;
+ char *suite_re = NULL;
+ char *test_re = NULL;
+ char *cp;
+ struct test_family *fp;
+ libiscsi_suite_info *sp;
+ CU_TestInfo *tp;
- /* if not testname(s) register all tests */
- if (!testname_re) {
- family_re = strdup("*");
- suite_re = strdup("*");
- test_re = strdup("*");
- } else {
- /*
- * break testname_re into family/suite/test
- *
- * syntax is: FAMILY[.SUITE[.TEST]]
- */
- family_re = strdup(testname_re);
- if ((cp = strchr(family_re, '.')) != NULL) {
- *cp++ = 0;
- suite_re = strdup(cp);
- if ((cp = strchr(suite_re, '.')) != NULL) {
- *cp++ = 0;
- test_re = strdup(cp);
- }
- }
- if (!suite_re)
- suite_re = strdup("*");
- if (!test_re)
- test_re = strdup("*");
- if (!family_re) {
- fprintf(stderr,
- "error: can't parse test family name: %s\n",
- family_re);
- return CUE_NOTEST;
- }
- }
+ /* if not testname(s) register all tests */
+ if (!testname_re) {
+ family_re = strdup("*");
+ suite_re = strdup("*");
+ test_re = strdup("*");
+ } else {
+ /*
+ * break testname_re into family/suite/test
+ *
+ * syntax is: FAMILY[.SUITE[.TEST]]
+ */
+ family_re = strdup(testname_re);
+ if ((cp = strchr(family_re, '.')) != NULL) {
+ *cp++ = 0;
+ suite_re = strdup(cp);
+ if ((cp = strchr(suite_re, '.')) != NULL) {
+ *cp++ = 0;
+ test_re = strdup(cp);
+ }
+ }
+ if (!suite_re)
+ suite_re = strdup("*");
+ if (!test_re)
+ test_re = strdup("*");
+ if (!family_re) {
+ fprintf(stderr,
+ "error: can't parse test family name: %s\n",
+ family_re);
+ return CUE_NOTEST;
+ }
+ }
- /*
- * cycle through the test families/suites/tests, adding
- * ones that match
- */
- for (fp = families; fp->name; fp++) {
- if (fnmatch(family_re, fp->name, 0) != 0)
- continue;
+ /*
+ * cycle through the test families/suites/tests, adding
+ * ones that match
+ */
+ for (fp = families; fp->name; fp++) {
+ if (fnmatch(family_re, fp->name, 0) != 0)
+ continue;
- for (sp = fp->suites; sp->pName != NULL; sp++) {
- int suite_added = 0;
- CU_pSuite pSuite = NULL;
+ for (sp = fp->suites; sp->pName != NULL; sp++) {
+ int suite_added = 0;
+ CU_pSuite pSuite = NULL;
- if (fnmatch(suite_re, sp->pName, 0) != 0)
- continue;
+ if (fnmatch(suite_re, sp->pName, 0) != 0)
+ continue;
- for (tp = sp->pTests; tp->pName != NULL; tp++) {
- if (fnmatch(test_re, tp->pName, 0) != 0) {
- continue;
- }
- if (!suite_added) {
- suite_added++;
+ for (tp = sp->pTests; tp->pName != NULL; tp++) {
+ if (fnmatch(test_re, tp->pName, 0) != 0) {
+ continue;
+ }
+ if (!suite_added) {
+ suite_added++;
#ifdef HAVE_CU_SUITEINFO_PSETUPFUNC
- pSuite = CU_add_suite_with_setup_and_teardown(sp->pName,
- sp->pInitFunc, sp->pCleanupFunc,
- sp->pSetUpFunc, sp->pTearDownFunc);
+ pSuite = CU_add_suite_with_setup_and_teardown(sp->pName,
+ sp->pInitFunc, sp->pCleanupFunc,
+ sp->pSetUpFunc, sp->pTearDownFunc);
#else
- pSuite = CU_add_suite(sp->pName,
- sp->pInitFunc, sp->pCleanupFunc);
+ pSuite = CU_add_suite(sp->pName,
+ sp->pInitFunc, sp->pCleanupFunc);
#endif
- }
- CU_add_test(pSuite, tp->pName, tp->pTestFunc);
- }
- }
- }
+ }
+ CU_add_test(pSuite, tp->pName, tp->pTestFunc);
+ }
+ }
+ }
- /* all done -- clean up */
- free(family_re);
- free(suite_re);
- free(test_re);
+ /* all done -- clean up */
+ free(family_re);
+ free(suite_re);
+ free(test_re);
- return CUE_SUCCESS;
+ return CUE_SUCCESS;
}
static void parse_and_add_tests(char *testname_re);
static void parse_and_add_test(const char *test)
{
- if (test && access(test, F_OK) == 0) {
- FILE *fh;
- char t[256];
+ if (test && access(test, F_OK) == 0) {
+ FILE *fh;
+ char t[256];
- if ((fh = fopen(test, "r")) == NULL) {
- printf("Failed to open test-list file %s\n", test);
- exit(10);
- }
- while (fgets(t, sizeof(t), fh) != NULL) {
- while (1) {
- int len = strlen(t);
- if (len == 0) {
- break;
- }
- if (!isprint(t[--len])) {
- t[len] = 0;
- continue;
- }
- break;
- }
- parse_and_add_tests(t);
- }
- fclose(fh);
- return;
- }
+ if ((fh = fopen(test, "r")) == NULL) {
+ printf("Failed to open test-list file %s\n", test);
+ exit(10);
+ }
+ while (fgets(t, sizeof(t), fh) != NULL) {
+ while (1) {
+ int len = strlen(t);
+ if (len == 0) {
+ break;
+ }
+ if (!isprint(t[--len])) {
+ t[len] = 0;
+ continue;
+ }
+ break;
+ }
+ parse_and_add_tests(t);
+ }
+ fclose(fh);
+ return;
+ }
- if (add_tests(test) != CUE_SUCCESS) {
- fprintf(stderr, "error: suite registration failed: %s\n",
- CU_get_error_msg());
- exit(1);
- }
+ if (add_tests(test) != CUE_SUCCESS) {
+ fprintf(stderr, "error: suite registration failed: %s\n",
+ CU_get_error_msg());
+ exit(1);
+ }
}
static void parse_and_add_tests(char *testname_re)
{
- if (testname_re != NULL) {
- char *testname;
- while ((testname = strrchr(testname_re, ',')) != NULL) {
- parse_and_add_test(testname + 1);
- *testname = 0;
- }
- }
- parse_and_add_test(testname_re);
+ if (testname_re != NULL) {
+ char *testname;
+ while ((testname = strrchr(testname_re, ',')) != NULL) {
+ parse_and_add_test(testname + 1);
+ *testname = 0;
+ }
+ }
+ parse_and_add_test(testname_re);
}
static int connect_scsi_device(struct scsi_device *sdev, const char *initiatorname)
{
- if (sdev->iscsi_url) {
- sdev->iscsi_ctx = iscsi_context_login(initiatorname, sdev->iscsi_url, &sdev->iscsi_lun);
- if (sdev->iscsi_ctx == NULL) {
- return -1;
- }
- iscsi_set_no_ua_on_reconnect(sdev->iscsi_ctx, 1);
- return 0;
- }
+ if (sdev->iscsi_url) {
+ sdev->iscsi_ctx = iscsi_context_login(initiatorname, sdev->iscsi_url, &sdev->iscsi_lun);
+ if (sdev->iscsi_ctx == NULL) {
+ return -1;
+ }
+ iscsi_set_no_ua_on_reconnect(sdev->iscsi_ctx, 1);
+ return 0;
+ }
#ifdef HAVE_SG_IO
- if (sdev->sgio_dev) {
- int version;
+ if (sdev->sgio_dev) {
+ int version;
- if ((sdev->sgio_fd = open(sdev->sgio_dev, O_RDWR|O_NONBLOCK)) == -1) {
- fprintf(stderr, "Failed to open SG_IO device %s. Error:%s\n", sdev->sgio_dev,
- strerror(errno));
- return -1;
- }
- if ((ioctl(sdev->sgio_fd, SG_GET_VERSION_NUM, &version) < 0) || (version < 30000)) {
- fprintf(stderr, "%s is not a SCSI device node\n", sdev->sgio_dev);
- close(sdev->sgio_fd);
- return -1;
- }
- if (ioctl(sdev->sgio_fd, BLKSECTGET, &maxsectors) < 0) {
- fprintf(stderr, "%s failed to read BLKMAXSECT\n", sdev->sgio_dev);
- close(sdev->sgio_fd);
- return -1;
- }
- return 0;
- }
+ if ((sdev->sgio_fd = open(sdev->sgio_dev, O_RDWR|O_NONBLOCK)) == -1) {
+ fprintf(stderr, "Failed to open SG_IO device %s. Error:%s\n", sdev->sgio_dev,
+ strerror(errno));
+ return -1;
+ }
+ if ((ioctl(sdev->sgio_fd, SG_GET_VERSION_NUM, &version) < 0) || (version < 30000)) {
+ fprintf(stderr, "%s is not a SCSI device node\n", sdev->sgio_dev);
+ close(sdev->sgio_fd);
+ return -1;
+ }
+ if (ioctl(sdev->sgio_fd, BLKSECTGET, &maxsectors) < 0) {
+ fprintf(stderr, "%s failed to read BLKMAXSECT\n", sdev->sgio_dev);
+ close(sdev->sgio_fd);
+ return -1;
+ }
+ return 0;
+ }
#endif
- return -1;
+ return -1;
}
static void free_scsi_device(struct scsi_device *sdev)
{
- if (sdev->error_str) {
- free(sdev->error_str);
- sdev->error_str = NULL;
- }
- if (sdev->iscsi_url) {
- free(sdev->iscsi_url);
- sdev->iscsi_url = NULL;
- }
- if (sdev->iscsi_ctx) {
- iscsi_logout_sync(sdev->iscsi_ctx);
- iscsi_destroy_context(sdev->iscsi_ctx);
- sdev->iscsi_ctx = NULL;
- }
+ if (sdev->error_str) {
+ free(sdev->error_str);
+ sdev->error_str = NULL;
+ }
+ if (sdev->iscsi_url) {
+ free(sdev->iscsi_url);
+ sdev->iscsi_url = NULL;
+ }
+ if (sdev->iscsi_ctx) {
+ iscsi_logout_sync(sdev->iscsi_ctx);
+ iscsi_destroy_context(sdev->iscsi_ctx);
+ sdev->iscsi_ctx = NULL;
+ }
- if (sdev->sgio_dev) {
- free(sdev->sgio_dev);
- sdev->sgio_dev = NULL;
- }
- if (sdev->sgio_fd != -1) {
- close(sdev->sgio_fd);
- sdev->sgio_fd = -1;
- }
- free(sdev);
+ if (sdev->sgio_dev) {
+ free(sdev->sgio_dev);
+ sdev->sgio_dev = NULL;
+ }
+ if (sdev->sgio_fd != -1) {
+ close(sdev->sgio_fd);
+ sdev->sgio_fd = -1;
+ }
+ free(sdev);
}
/* Clear persistent reservations and reservation keys left by a previous run */
static int clear_pr(struct scsi_device *sdev)
{
- int i, res;
- struct scsi_task *pr_task;
- struct scsi_persistent_reserve_in_read_keys *rk;
+ int i, res;
+ struct scsi_task *pr_task;
+ struct scsi_persistent_reserve_in_read_keys *rk;
- res = 0;
- if (prin_read_keys(sdev, &pr_task, &rk) != 0)
- goto out;
+ res = 0;
+ if (prin_read_keys(sdev, &pr_task, &rk) != 0)
+ goto out;
- res = -1;
- if (rk->num_keys && data_loss == 0)
- goto out;
+ res = -1;
+ if (rk->num_keys && data_loss == 0)
+ goto out;
- res = 0;
- for (i = 0; i < rk->num_keys; i++) {
- prout_register_and_ignore(sdev, rk->keys[i]);
- prout_register_key(sdev, 0, rk->keys[i]);
- }
+ res = 0;
+ for (i = 0; i < rk->num_keys; i++) {
+ prout_register_and_ignore(sdev, rk->keys[i]);
+ prout_register_key(sdev, 0, rk->keys[i]);
+ }
- scsi_free_scsi_task(pr_task);
+ scsi_free_scsi_task(pr_task);
out:
- return res;
+ return res;
}
int
main(int argc, char *argv[])
{
- char *testname_re = NULL;
- CU_BasicRunMode mode = CU_BRM_VERBOSE;
- CU_ErrorAction error_action = CUEA_IGNORE;
- int res;
- struct scsi_readcapacity10 *rc10;
- struct scsi_task *inq_task = NULL;
- struct scsi_task *inq_lbp_task = NULL;
- struct scsi_task *inq_bdc_task = NULL;
- struct scsi_task *inq_bl_task = NULL;
- struct scsi_task *rc16_task = NULL;
- struct scsi_task *rsop_task = NULL;
- int full_size;
- int xml_mode = 0;
- static struct option long_opts[] = {
- { "help", no_argument, 0, '?' },
- { "list", no_argument, 0, 'l' },
- { "initiator-name", required_argument, 0, 'i' },
- { "initiator-name-2", required_argument, 0, 'I' },
- { "test", required_argument, 0, 't' },
- { "dataloss", no_argument, 0, 'd' },
- { "allow-sanitize", no_argument, 0, 'S' },
- { "ignore", no_argument, 0, 'g' },
- { "fail", no_argument, 0, 'f' },
- { "abort", no_argument, 0, 'A' },
- { "silent", no_argument, 0, 's' },
- { "normal", no_argument, 0, 'n' },
- { "verbose", no_argument, 0, 'v' },
- { "xml", no_argument, 0, 'x' },
- { "Verbose-scsi", no_argument, 0, 'V' },
- { NULL, 0, 0, 0 }
- };
- int i, c;
- int opt_idx = 0;
+ char *testname_re = NULL;
+ CU_BasicRunMode mode = CU_BRM_VERBOSE;
+ CU_ErrorAction error_action = CUEA_IGNORE;
+ int res;
+ struct scsi_readcapacity10 *rc10;
+ struct scsi_task *inq_task = NULL;
+ struct scsi_task *inq_lbp_task = NULL;
+ struct scsi_task *inq_bdc_task = NULL;
+ struct scsi_task *inq_bl_task = NULL;
+ struct scsi_task *rc16_task = NULL;
+ struct scsi_task *rsop_task = NULL;
+ int full_size;
+ int xml_mode = 0;
+ static struct option long_opts[] = {
+ { "help", no_argument, 0, '?' },
+ { "list", no_argument, 0, 'l' },
+ { "initiator-name", required_argument, 0, 'i' },
+ { "initiator-name-2", required_argument, 0, 'I' },
+ { "test", required_argument, 0, 't' },
+ { "dataloss", no_argument, 0, 'd' },
+ { "allow-sanitize", no_argument, 0, 'S' },
+ { "ignore", no_argument, 0, 'g' },
+ { "fail", no_argument, 0, 'f' },
+ { "abort", no_argument, 0, 'A' },
+ { "silent", no_argument, 0, 's' },
+ { "normal", no_argument, 0, 'n' },
+ { "verbose", no_argument, 0, 'v' },
+ { "xml", no_argument, 0, 'x' },
+ { "Verbose-scsi", no_argument, 0, 'V' },
+ { NULL, 0, 0, 0 }
+ };
+ int i, c;
+ int opt_idx = 0;
- while ((c = getopt_long(argc, argv, "?hli:I:t:sdgfAsSnvxV", long_opts,
- &opt_idx)) > 0) {
- switch (c) {
- case 'h':
- case '?':
- print_usage();
- return 0;
- case 'l':
- list_all_tests();
- return 0;
- case 'i':
- initiatorname1 = strdup(optarg);
- break;
- case 'I':
- initiatorname2 = strdup(optarg);
- break;
- case 't':
- testname_re = strdup(optarg);
- break;
- case 'd':
- data_loss++;
- break;
- case 'g':
- error_action = CUEA_IGNORE; /* default */
- break;
- case 'f':
- error_action = CUEA_FAIL;
- break;
- case 'A':
- error_action = CUEA_ABORT;
- break;
- case 's':
- mode = CU_BRM_SILENT;
- break;
- case 'S':
- allow_sanitize = 1;
- break;
- case 'n':
- mode = CU_BRM_NORMAL;
- break;
- case 'v':
- mode = CU_BRM_VERBOSE; /* default */
- break;
- case 'x':
- xml_mode = 1;
- break;
- case 'V':
- loglevel = LOG_VERBOSE;
- break;
- default:
- fprintf(stderr,
- "error: unknown option return: %c (option %s)\n",
- c, argv[optind]);
- return 1;
- }
- }
+ while ((c = getopt_long(argc, argv, "?hli:I:t:sdgfAsSnvxV", long_opts,
+ &opt_idx)) > 0) {
+ switch (c) {
+ case 'h':
+ case '?':
+ print_usage();
+ return 0;
+ case 'l':
+ list_all_tests();
+ return 0;
+ case 'i':
+ initiatorname1 = strdup(optarg);
+ break;
+ case 'I':
+ initiatorname2 = strdup(optarg);
+ break;
+ case 't':
+ testname_re = strdup(optarg);
+ break;
+ case 'd':
+ data_loss++;
+ break;
+ case 'g':
+ error_action = CUEA_IGNORE; /* default */
+ break;
+ case 'f':
+ error_action = CUEA_FAIL;
+ break;
+ case 'A':
+ error_action = CUEA_ABORT;
+ break;
+ case 's':
+ mode = CU_BRM_SILENT;
+ break;
+ case 'S':
+ allow_sanitize = 1;
+ break;
+ case 'n':
+ mode = CU_BRM_NORMAL;
+ break;
+ case 'v':
+ mode = CU_BRM_VERBOSE; /* default */
+ break;
+ case 'x':
+ xml_mode = 1;
+ break;
+ case 'V':
+ loglevel = LOG_VERBOSE;
+ break;
+ default:
+ fprintf(stderr,
+ "error: unknown option return: %c (option %s)\n",
+ c, argv[optind]);
+ return 1;
+ }
+ }
- /* parse all trailing arguments as device paths */
- mp_num_sds = 0;
- while (optind < argc) {
- if (mp_num_sds >= MPATH_MAX_DEVS) {
- fprintf(stderr, "Too many multipath device URLs\n");
- print_usage();
- free(testname_re);
- return 10;
- }
+ /* parse all trailing arguments as device paths */
+ mp_num_sds = 0;
+ while (optind < argc) {
+ if (mp_num_sds >= MPATH_MAX_DEVS) {
+ fprintf(stderr, "Too many multipath device URLs\n");
+ print_usage();
+ free(testname_re);
+ return 10;
+ }
- mp_sds[mp_num_sds] = malloc(sizeof(struct scsi_device));
- memset(mp_sds[mp_num_sds], '\0', sizeof(struct scsi_device));
- mp_sds[mp_num_sds]->sgio_fd = -1;
+ mp_sds[mp_num_sds] = malloc(sizeof(struct scsi_device));
+ memset(mp_sds[mp_num_sds], '\0', sizeof(struct scsi_device));
+ mp_sds[mp_num_sds]->sgio_fd = -1;
- if (!strncmp(argv[optind], "iscsi://", 8)) {
- mp_sds[mp_num_sds]->iscsi_url = strdup(argv[optind++]);
+ if (!strncmp(argv[optind], "iscsi://", 8)) {
+ mp_sds[mp_num_sds]->iscsi_url = strdup(argv[optind++]);
#ifdef HAVE_SG_IO
- } else {
- mp_sds[mp_num_sds]->sgio_dev = strdup(argv[optind++]);
+ } else {
+ mp_sds[mp_num_sds]->sgio_dev = strdup(argv[optind++]);
#endif
- }
- mp_num_sds++;
- }
+ }
+ mp_num_sds++;
+ }
- /* So that we can override iscsi_queue_pdu in tests
- * and replace or mutate the blob that we are about to write to the
- * wire.
- * This allows such tests to do their mutates and then call out
- * to the real queueing function once they have modified the data.
- */
- real_iscsi_queue_pdu = dlsym(RTLD_NEXT, "iscsi_queue_pdu");
+ /* So that we can override iscsi_queue_pdu in tests
+ * and replace or mutate the blob that we are about to write to the
+ * wire.
+ * This allows such tests to do their mutates and then call out
+ * to the real queueing function once they have modified the data.
+ */
+ real_iscsi_queue_pdu = dlsym(RTLD_NEXT, "iscsi_queue_pdu");
- if ((mp_num_sds == 0) || (mp_sds[0]->iscsi_url == NULL
- && mp_sds[0]->sgio_dev == NULL)) {
+ if ((mp_num_sds == 0) || (mp_sds[0]->iscsi_url == NULL
+ && mp_sds[0]->sgio_dev == NULL)) {
#ifdef HAVE_SG_IO
- fprintf(stderr, "You must specify either an iSCSI URL or a device file\n");
+ fprintf(stderr, "You must specify either an iSCSI URL or a device file\n");
#else
- fprintf(stderr, "You must specify an iSCSI URL\n");
+ fprintf(stderr, "You must specify an iSCSI URL\n");
#endif
- print_usage();
- if (testname_re)
- free(testname_re);
- return 10;
- }
+ print_usage();
+ if (testname_re)
+ free(testname_re);
+ return 10;
+ }
- /* sd remains an alias for the first device */
- sd = mp_sds[0];
+ /* sd remains an alias for the first device */
+ sd = mp_sds[0];
- for (i = 0; i < mp_num_sds; i++) {
- res = connect_scsi_device(mp_sds[i], initiatorname1);
- if (res < 0) {
- fprintf(stderr,
- "Failed to connect to SCSI device %d\n", i);
- goto err_sds_free;
- }
- }
+ for (i = 0; i < mp_num_sds; i++) {
+ res = connect_scsi_device(mp_sds[i], initiatorname1);
+ if (res < 0) {
+ fprintf(stderr,
+ "Failed to connect to SCSI device %d\n", i);
+ goto err_sds_free;
+ }
+ }
- if (mp_num_sds > 1) {
- /* check that all multipath sds identify as the same LU */
- res = mpath_check_matching_ids(mp_num_sds, mp_sds);
- if (res < 0) {
- fprintf(stderr, "multipath devices don't match\n");
- goto err_sds_free;
- }
- }
+ if (mp_num_sds > 1) {
+ /* check that all multipath sds identify as the same LU */
+ res = mpath_check_matching_ids(mp_num_sds, mp_sds);
+ if (res < 0) {
+ fprintf(stderr, "multipath devices don't match\n");
+ goto err_sds_free;
+ }
+ }
- /*
- * find the size of the LUN
- * All devices support readcapacity10 but only some support
- * readcapacity16
- */
- task = NULL;
- readcapacity10(sd, &task, 0, 0, EXPECT_STATUS_GOOD);
- if (task == NULL) {
- printf("Failed to send READCAPACITY10 command: %s\n", sd->error_str);
- goto err_sds_free;
- }
- if (task->status != SCSI_STATUS_GOOD) {
- printf("READCAPACITY10 command: failed with sense. %s\n", sd->error_str);
- scsi_free_scsi_task(task);
- goto err_sds_free;
- }
- rc10 = scsi_datain_unmarshall(task);
- if (rc10 == NULL) {
- printf("failed to unmarshall READCAPACITY10 data.\n");
- scsi_free_scsi_task(task);
- goto err_sds_free;
- }
- block_size = rc10->block_size;
- num_blocks = rc10->lba + 1;
- scsi_free_scsi_task(task);
+ /*
+ * find the size of the LUN
+ * All devices support readcapacity10 but only some support
+ * readcapacity16
+ */
+ task = NULL;
+ readcapacity10(sd, &task, 0, 0, EXPECT_STATUS_GOOD);
+ if (task == NULL) {
+ printf("Failed to send READCAPACITY10 command: %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ if (task->status != SCSI_STATUS_GOOD) {
+ printf("READCAPACITY10 command: failed with sense. %s\n", sd->error_str);
+ scsi_free_scsi_task(task);
+ goto err_sds_free;
+ }
+ rc10 = scsi_datain_unmarshall(task);
+ if (rc10 == NULL) {
+ printf("failed to unmarshall READCAPACITY10 data.\n");
+ scsi_free_scsi_task(task);
+ goto err_sds_free;
+ }
+ block_size = rc10->block_size;
+ num_blocks = rc10->lba + 1;
+ scsi_free_scsi_task(task);
- rc16_task = NULL;
- readcapacity16(sd, &rc16_task, 96, EXPECT_STATUS_GOOD);
- if (rc16_task == NULL) {
- printf("Failed to send READCAPACITY16 command: %s\n", sd->error_str);
- goto err_sds_free;
- }
- if (rc16_task->status == SCSI_STATUS_GOOD) {
- rc16 = scsi_datain_unmarshall(rc16_task);
- if (rc16 == NULL) {
- printf("failed to unmarshall READCAPACITY16 data. %s\n", sd->error_str);
- scsi_free_scsi_task(rc16_task);
- goto err_sds_free;
- }
- block_size = rc16->block_length;
- num_blocks = rc16->returned_lba + 1;
- lbppb = 1 << rc16->lbppbe;
- }
+ rc16_task = NULL;
+ readcapacity16(sd, &rc16_task, 96, EXPECT_STATUS_GOOD);
+ if (rc16_task == NULL) {
+ printf("Failed to send READCAPACITY16 command: %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ if (rc16_task->status == SCSI_STATUS_GOOD) {
+ rc16 = scsi_datain_unmarshall(rc16_task);
+ if (rc16 == NULL) {
+ printf("failed to unmarshall READCAPACITY16 data. %s\n", sd->error_str);
+ scsi_free_scsi_task(rc16_task);
+ goto err_sds_free;
+ }
+ block_size = rc16->block_length;
+ num_blocks = rc16->returned_lba + 1;
+ lbppb = 1 << rc16->lbppbe;
+ }
/* create a really big buffer we can use in the tests */
scratch = malloc(65536 * block_size);
- inq_task = NULL;
- inquiry(sd, &inq_task, 0, 0, 64, EXPECT_STATUS_GOOD);
- if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) {
- printf("Inquiry command failed : %s\n", sd->error_str);
- goto err_sds_free;
- }
- full_size = scsi_datain_getfullsize(inq_task);
- if (full_size > inq_task->datain.size) {
- scsi_free_scsi_task(inq_task);
+ inq_task = NULL;
+ inquiry(sd, &inq_task, 0, 0, 64, EXPECT_STATUS_GOOD);
+ if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) {
+ printf("Inquiry command failed : %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ full_size = scsi_datain_getfullsize(inq_task);
+ if (full_size > inq_task->datain.size) {
+ scsi_free_scsi_task(inq_task);
- /* we need more data for the full list */
- inq_task = NULL;
- inquiry(sd, &inq_task, 0, 0, full_size, EXPECT_STATUS_GOOD);
- if (inq_task == NULL) {
- printf("Inquiry command failed : %s\n", sd->error_str);
- goto err_sds_free;
- }
- }
- inq = scsi_datain_unmarshall(inq_task);
- if (inq == NULL) {
- printf("failed to unmarshall inquiry datain blob\n");
- scsi_free_scsi_task(inq_task);
- goto err_sds_free;
- }
+ /* we need more data for the full list */
+ inq_task = NULL;
+ inquiry(sd, &inq_task, 0, 0, full_size, EXPECT_STATUS_GOOD);
+ if (inq_task == NULL) {
+ printf("Inquiry command failed : %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ }
+ inq = scsi_datain_unmarshall(inq_task);
+ if (inq == NULL) {
+ printf("failed to unmarshall inquiry datain blob\n");
+ scsi_free_scsi_task(inq_task);
+ goto err_sds_free;
+ }
- sbc3_support = 0;
- for (i = 0; i < 8; i++) {
- if (inq->version_descriptor[i] == 0x04C0) {
- sbc3_support = 1;
- }
- }
+ sbc3_support = 0;
+ for (i = 0; i < 8; i++) {
+ if (inq->version_descriptor[i] == 0x04C0) {
+ sbc3_support = 1;
+ }
+ }
- /* try reading block limits vpd */
- inq_bl_task = NULL;
- inquiry(sd, &inq_bl_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 64, EXPECT_STATUS_GOOD);
- if (inq_bl_task && inq_bl_task->status != SCSI_STATUS_GOOD) {
- scsi_free_scsi_task(inq_bl_task);
- inq_bl_task = NULL;
- }
- if (inq_bl_task) {
- full_size = scsi_datain_getfullsize(inq_bl_task);
- if (full_size > inq_bl_task->datain.size) {
- scsi_free_scsi_task(inq_bl_task);
+ /* try reading block limits vpd */
+ inq_bl_task = NULL;
+ inquiry(sd, &inq_bl_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 64, EXPECT_STATUS_GOOD);
+ if (inq_bl_task && inq_bl_task->status != SCSI_STATUS_GOOD) {
+ scsi_free_scsi_task(inq_bl_task);
+ inq_bl_task = NULL;
+ }
+ if (inq_bl_task) {
+ full_size = scsi_datain_getfullsize(inq_bl_task);
+ if (full_size > inq_bl_task->datain.size) {
+ scsi_free_scsi_task(inq_bl_task);
- inq_bl_task = NULL;
- inquiry(sd, &inq_bl_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, full_size,
- EXPECT_STATUS_GOOD);
- if (inq_bl_task == NULL) {
- printf("Inquiry command failed : %s\n", sd->error_str);
- goto err_sds_free;
- }
- }
+ inq_bl_task = NULL;
+ inquiry(sd, &inq_bl_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, full_size,
+ EXPECT_STATUS_GOOD);
+ if (inq_bl_task == NULL) {
+ printf("Inquiry command failed : %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ }
- inq_bl = scsi_datain_unmarshall(inq_bl_task);
- if (inq_bl == NULL) {
- printf("failed to unmarshall inquiry datain blob\n");
- goto err_sds_free;
- }
- }
+ inq_bl = scsi_datain_unmarshall(inq_bl_task);
+ if (inq_bl == NULL) {
+ printf("failed to unmarshall inquiry datain blob\n");
+ goto err_sds_free;
+ }
+ }
- /* try reading block device characteristics vpd */
- inquiry(sd, &inq_bdc_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_DEVICE_CHARACTERISTICS, 255,
- EXPECT_STATUS_GOOD);
- if (inq_bdc_task == NULL || inq_bdc_task->status != SCSI_STATUS_GOOD) {
- printf("Failed to read Block Device Characteristics page\n");
- } else {
- inq_bdc = scsi_datain_unmarshall(inq_bdc_task);
- if (inq_bdc == NULL) {
- printf("failed to unmarshall inquiry datain blob\n");
- goto err_sds_free;
- }
- }
+ /* try reading block device characteristics vpd */
+ inquiry(sd, &inq_bdc_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_DEVICE_CHARACTERISTICS, 255,
+ EXPECT_STATUS_GOOD);
+ if (inq_bdc_task == NULL || inq_bdc_task->status != SCSI_STATUS_GOOD) {
+ printf("Failed to read Block Device Characteristics page\n");
+ } else {
+ inq_bdc = scsi_datain_unmarshall(inq_bdc_task);
+ if (inq_bdc == NULL) {
+ printf("failed to unmarshall inquiry datain blob\n");
+ goto err_sds_free;
+ }
+ }
- /* if thin provisioned we also need to read the VPD page for it */
- if (rc16 && rc16->lbpme != 0){
- inq_lbp_task = NULL;
- inquiry(sd, &inq_lbp_task, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64,
- EXPECT_STATUS_GOOD);
- if (inq_lbp_task == NULL || inq_lbp_task->status != SCSI_STATUS_GOOD) {
- printf("Inquiry command failed : %s\n", sd->error_str);
- goto err_sds_free;
- }
- full_size = scsi_datain_getfullsize(inq_lbp_task);
- if (full_size > inq_lbp_task->datain.size) {
- scsi_free_scsi_task(inq_lbp_task);
+ /* if thin provisioned we also need to read the VPD page for it */
+ if (rc16 && rc16->lbpme != 0){
+ inq_lbp_task = NULL;
+ inquiry(sd, &inq_lbp_task, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64,
+ EXPECT_STATUS_GOOD);
+ if (inq_lbp_task == NULL || inq_lbp_task->status != SCSI_STATUS_GOOD) {
+ printf("Inquiry command failed : %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ full_size = scsi_datain_getfullsize(inq_lbp_task);
+ if (full_size > inq_lbp_task->datain.size) {
+ scsi_free_scsi_task(inq_lbp_task);
- /* we need more data for the full list */
- inq_lbp_task = NULL;
- inquiry(sd, &inq_lbp_task, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
- full_size, EXPECT_STATUS_GOOD);
- if (inq_lbp_task == NULL) {
- printf("Inquiry command failed : %s\n", sd->error_str);
- goto err_sds_free;
- }
- }
+ /* we need more data for the full list */
+ inq_lbp_task = NULL;
+ inquiry(sd, &inq_lbp_task, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
+ full_size, EXPECT_STATUS_GOOD);
+ if (inq_lbp_task == NULL) {
+ printf("Inquiry command failed : %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ }
- inq_lbp = scsi_datain_unmarshall(inq_lbp_task);
- if (inq_lbp == NULL) {
- printf("failed to unmarshall inquiry datain blob\n");
- goto err_sds_free;
- }
- }
+ inq_lbp = scsi_datain_unmarshall(inq_lbp_task);
+ if (inq_lbp == NULL) {
+ printf("failed to unmarshall inquiry datain blob\n");
+ goto err_sds_free;
+ }
+ }
- rsop_task = NULL;
- report_supported_opcodes(sd, &rsop_task, 1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 65535,
- EXPECT_STATUS_GOOD);
- if (rsop_task == NULL) {
- printf("Failed to send REPORT_SUPPORTED_OPCODES command: %s\n", sd->error_str);
- goto err_sds_free;
- }
- if (rsop_task->status == SCSI_STATUS_GOOD) {
- rsop = scsi_datain_unmarshall(rsop_task);
- if (rsop == NULL) {
- printf("failed to unmarshall REPORT_SUPPORTED_OPCODES data.\n");
- scsi_free_scsi_task(rsop_task);
- rsop_task = NULL;
- }
- }
+ rsop_task = NULL;
+ report_supported_opcodes(sd, &rsop_task, 1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 65535,
+ EXPECT_STATUS_GOOD);
+ if (rsop_task == NULL) {
+ printf("Failed to send REPORT_SUPPORTED_OPCODES command: %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ if (rsop_task->status == SCSI_STATUS_GOOD) {
+ rsop = scsi_datain_unmarshall(rsop_task);
+ if (rsop == NULL) {
+ printf("failed to unmarshall REPORT_SUPPORTED_OPCODES data.\n");
+ scsi_free_scsi_task(rsop_task);
+ rsop_task = NULL;
+ }
+ }
- /* check if the device is write protected or not */
- task = NULL;
- modesense6(sd, &task, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
- EXPECT_STATUS_GOOD);
- if (task == NULL) {
- printf("Failed to send MODE_SENSE6 command: %s\n", sd->error_str);
- goto err_sds_free;
- }
- if (task->status == SCSI_STATUS_GOOD) {
- struct scsi_mode_sense *ms;
+ /* check if the device is write protected or not */
+ task = NULL;
+ modesense6(sd, &task, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
+ EXPECT_STATUS_GOOD);
+ if (task == NULL) {
+ printf("Failed to send MODE_SENSE6 command: %s\n", sd->error_str);
+ goto err_sds_free;
+ }
+ if (task->status == SCSI_STATUS_GOOD) {
+ struct scsi_mode_sense *ms;
- ms = scsi_datain_unmarshall(task);
- if (ms == NULL) {
- printf("failed to unmarshall mode sense datain blob\n");
- scsi_free_scsi_task(task);
- goto err_sds_free;
- }
- readonly = !!(ms->device_specific_parameter & 0x80);
- }
- scsi_free_scsi_task(task);
+ ms = scsi_datain_unmarshall(task);
+ if (ms == NULL) {
+ printf("failed to unmarshall mode sense datain blob\n");
+ scsi_free_scsi_task(task);
+ goto err_sds_free;
+ }
+ readonly = !!(ms->device_specific_parameter & 0x80);
+ }
+ scsi_free_scsi_task(task);
- if (clear_pr(sd) < 0) {
- printf("One or more persistent reservations keys have been registered\n");
- return -1;
- }
+ if (clear_pr(sd) < 0) {
+ printf("One or more persistent reservations keys have been registered\n");
+ return -1;
+ }
- if (maxsectors) {
- maximum_transfer_length = maxsectors;
- printf("Bus transfer size is limited to %d blocks. Clamping "
- "max transfers accordingly.\n", maxsectors);
- }
+ if (maxsectors) {
+ maximum_transfer_length = maxsectors;
+ printf("Bus transfer size is limited to %d blocks. Clamping "
+ "max transfers accordingly.\n", maxsectors);
+ }
- if (CU_initialize_registry() != 0) {
- fprintf(stderr, "error: unable to initialize test registry\n");
- goto err_sds_free;
- }
- if (CU_is_test_running()) {
- fprintf(stderr, "error: test suite(s) already running!?\n");
- exit(1);
- }
+ if (CU_initialize_registry() != 0) {
+ fprintf(stderr, "error: unable to initialize test registry\n");
+ goto err_sds_free;
+ }
+ if (CU_is_test_running()) {
+ fprintf(stderr, "error: test suite(s) already running!?\n");
+ exit(1);
+ }
- parse_and_add_tests(testname_re);
- if (testname_re)
- free(testname_re);
+ parse_and_add_tests(testname_re);
+ if (testname_re)
+ free(testname_re);
- CU_basic_set_mode(mode);
- CU_set_error_action(error_action);
- printf("\n");
+ CU_basic_set_mode(mode);
+ CU_set_error_action(error_action);
+ printf("\n");
- /*
- * this actually runs the tests ...
- */
+ /*
+ * this actually runs the tests ...
+ */
- if (xml_mode) {
- CU_list_tests_to_file();
- CU_automated_run_tests();
- } else {
- res = CU_basic_run_tests();
- printf("Tests completed with return value: %d\n", res);
- }
+ if (xml_mode) {
+ CU_list_tests_to_file();
+ CU_automated_run_tests();
+ } else {
+ res = CU_basic_run_tests();
+ printf("Tests completed with return value: %d\n", res);
+ }
- CU_cleanup_registry();
+ CU_cleanup_registry();
- if (inq_task != NULL) {
- scsi_free_scsi_task(inq_task);
- }
- if (inq_bl_task != NULL) {
- scsi_free_scsi_task(inq_bl_task);
- }
- if (inq_lbp_task != NULL) {
- scsi_free_scsi_task(inq_lbp_task);
- }
- if (inq_bdc_task != NULL) {
- scsi_free_scsi_task(inq_bdc_task);
- }
- if (rc16_task != NULL) {
- scsi_free_scsi_task(rc16_task);
- }
- if (rsop_task != NULL) {
- scsi_free_scsi_task(rsop_task);
- }
- for (i = 0; i < mp_num_sds; i++) {
- free_scsi_device(mp_sds[i]);
- }
+ if (inq_task != NULL) {
+ scsi_free_scsi_task(inq_task);
+ }
+ if (inq_bl_task != NULL) {
+ scsi_free_scsi_task(inq_bl_task);
+ }
+ if (inq_lbp_task != NULL) {
+ scsi_free_scsi_task(inq_lbp_task);
+ }
+ if (inq_bdc_task != NULL) {
+ scsi_free_scsi_task(inq_bdc_task);
+ }
+ if (rc16_task != NULL) {
+ scsi_free_scsi_task(rc16_task);
+ }
+ if (rsop_task != NULL) {
+ scsi_free_scsi_task(rsop_task);
+ }
+ for (i = 0; i < mp_num_sds; i++) {
+ free_scsi_device(mp_sds[i]);
+ }
free(scratch);
- return 0;
+ return 0;
err_sds_free:
- for (i = 0; i < mp_num_sds; i++) {
- free_scsi_device(mp_sds[i]);
- }
+ for (i = 0; i < mp_num_sds; i++) {
+ free_scsi_device(mp_sds[i]);
+ }
free(scratch);
- return -1;
+ return -1;
}
diff --git a/test-tool/iscsi-test-cu.h b/test-tool/iscsi-test-cu.h
index 881c1a7..38f900f 100644
--- a/test-tool/iscsi-test-cu.h
+++ b/test-tool/iscsi-test-cu.h
@@ -17,8 +17,8 @@
along with this program; if not, see .
*/
-#ifndef _ISCSI_TEST_CU_H_
-#define _ISCSI_TEST_CU_H_
+#ifndef _ISCSI_TEST_CU_H_
+#define _ISCSI_TEST_CU_H_
#include
#include
@@ -308,4 +308,4 @@ void test_multipathio_simple(void);
void test_multipathio_reset(void);
void test_multipathio_compareandwrite(void);
-#endif /* _ISCSI_TEST_CU_H_ */
+#endif /* _ISCSI_TEST_CU_H_ */
diff --git a/test-tool/test_compareandwrite_dpofua.c b/test-tool/test_compareandwrite_dpofua.c
index 5a73eaa..3c1e107 100644
--- a/test-tool/test_compareandwrite_dpofua.c
+++ b/test-tool/test_compareandwrite_dpofua.c
@@ -29,90 +29,90 @@
void
test_compareandwrite_dpofua(void)
{
- int ret, dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int ret, dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test COMPAREANDWRITE DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test COMPAREANDWRITE DPO/FUA flags");
- CHECK_FOR_SBC;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- logging(LOG_VERBOSE, "Read the first block");
- ret = read10(sd, NULL, 0, block_size,
- block_size, 0, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
- if (ret == 0)
- memcpy(scratch + block_size, scratch, block_size);
- else
- memset(scratch, 0xa6, 2 * block_size);
+ logging(LOG_VERBOSE, "Read the first block");
+ ret = read10(sd, NULL, 0, block_size,
+ block_size, 0, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
+ if (ret == 0)
+ memcpy(scratch + block_size, scratch, block_size);
+ else
+ memset(scratch, 0xa6, 2 * block_size);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1");
- if (dpofua) {
- COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
+ logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1");
+ if (dpofua) {
+ COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 0, 0,
EXPECT_STATUS_GOOD);
- } else {
- COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
+ } else {
+ COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test COMPAREANDWRITE with FUA==1");
- if (dpofua) {
- COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
+ logging(LOG_VERBOSE, "Test COMPAREANDWRITE with FUA==1");
+ if (dpofua) {
+ COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
block_size, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- } else {
- COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
+ } else {
+ COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
block_size, 0, 0, 1, 0,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1 FUA==1");
- if (dpofua) {
- COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
+ logging(LOG_VERBOSE, "Test COMPAREANDWRITE with DPO==1 FUA==1");
+ if (dpofua) {
+ COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 1, 0,
EXPECT_STATUS_GOOD);
- } else {
- COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
+ } else {
+ COMPAREANDWRITE(sd, 0, scratch, 2 * block_size,
block_size, 0, 1, 1, 0,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for COMPAREANDWRITE");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for COMPAREANDWRITE");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_COMPARE_AND_WRITE,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -133,5 +133,5 @@ test_compareandwrite_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_compareandwrite_miscompare.c b/test-tool/test_compareandwrite_miscompare.c
index deee4ca..d3dfec5 100644
--- a/test-tool/test_compareandwrite_miscompare.c
+++ b/test-tool/test_compareandwrite_miscompare.c
@@ -31,125 +31,125 @@
void
test_compareandwrite_miscompare(void)
{
- int i;
- unsigned j;
- int maxbl;
+ int i;
+ unsigned j;
+ int maxbl;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (inq_bl && inq_bl->max_cmp) {
- maxbl = inq_bl->max_cmp;
- } else {
- /* Assume we are not limited */
- maxbl = 256;
- }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
- "start of the LUN. One Byte miscompare in the final block.");
- for (i = 1; i < 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
- memset(scratch, 'A', 2 * i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, 0, i * block_size,
+ if (inq_bl && inq_bl->max_cmp) {
+ maxbl = inq_bl->max_cmp;
+ } else {
+ /* Assume we are not limited */
+ maxbl = 256;
+ }
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
+ "start of the LUN. One Byte miscompare in the final block.");
+ for (i = 1; i < 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
+ memset(scratch, 'A', 2 * i * block_size);
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
-
- logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
- scratch[i * block_size - 27] = 'C';
+
+ logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
+ scratch[i * block_size - 27] = 'C';
- if (i > maxbl) {
- logging(LOG_VERBOSE, "Number of blocks %d is greater than "
- "BlockLimits.MaximumCompareAndWriteLength(%d). "
- "Command should fail with INVALID_FIELD_IN_CDB",
- i, maxbl);
- COMPAREANDWRITE(sd, 0,
+ if (i > maxbl) {
+ logging(LOG_VERBOSE, "Number of blocks %d is greater than "
+ "BlockLimits.MaximumCompareAndWriteLength(%d). "
+ "Command should fail with INVALID_FIELD_IN_CDB",
+ i, maxbl);
+ COMPAREANDWRITE(sd, 0,
scratch, 2 * i * block_size,
block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
- continue;
- }
+ continue;
+ }
- memset(scratch + i * block_size, 'B', i * block_size);
+ memset(scratch + i * block_size, 'B', i * block_size);
- logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
- "at LBA:0 (if they all contain 'A')", i);
- COMPAREANDWRITE(sd, 0,
+ logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
+ "at LBA:0 (if they all contain 'A')", i);
+ COMPAREANDWRITE(sd, 0,
scratch, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_MISCOMPARE);
- logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
- "they are still unchanged as 'A'", i);
- READ16(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
+ "they are still unchanged as 'A'", i);
+ READ16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- for (j = 0; j < i * block_size; j++) {
- if (scratch[j] != 'A') {
- logging(LOG_VERBOSE, "[FAILED] Data changed "
- "eventhough there was a miscompare");
- CU_FAIL("Block was written to");
- return;
- }
- }
- }
+ for (j = 0; j < i * block_size; j++) {
+ if (scratch[j] != 'A') {
+ logging(LOG_VERBOSE, "[FAILED] Data changed "
+ "eventhough there was a miscompare");
+ CU_FAIL("Block was written to");
+ return;
+ }
+ }
+ }
- logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
- "end of the LUN");
- for (i = 1; i < 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
- i, num_blocks - i);
- memset(scratch, 'A', 2 * i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
+ "end of the LUN");
+ for (i = 1; i < 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
+ i, num_blocks - i);
+ memset(scratch, 'A', 2 * i * block_size);
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
- scratch[i * block_size - 27] = 'C';
+ logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
+ scratch[i * block_size - 27] = 'C';
- if (i > maxbl) {
- logging(LOG_VERBOSE, "Number of blocks %d is greater than "
- "BlockLimits.MaximumCompareAndWriteLength(%d). "
- "Command should fail with INVALID_FIELD_IN_CDB",
- i, maxbl);
- COMPAREANDWRITE(sd, 0,
+ if (i > maxbl) {
+ logging(LOG_VERBOSE, "Number of blocks %d is greater than "
+ "BlockLimits.MaximumCompareAndWriteLength(%d). "
+ "Command should fail with INVALID_FIELD_IN_CDB",
+ i, maxbl);
+ COMPAREANDWRITE(sd, 0,
scratch, 2 * i * block_size,
block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
- continue;
- }
- memset(scratch + i * block_size, 'B', i * block_size);
+ continue;
+ }
+ memset(scratch + i * block_size, 'B', i * block_size);
- logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
- "at LBA:%" PRIu64 " (if they all contain 'A')",
- i, num_blocks - i);
- COMPAREANDWRITE(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
+ "at LBA:%" PRIu64 " (if they all contain 'A')",
+ i, num_blocks - i);
+ COMPAREANDWRITE(sd, num_blocks - i,
scratch, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_MISCOMPARE);
- logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
- "they are still unchanged as 'A'",
- i, num_blocks - i);
- READ16(sd, NULL, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
+ "they are still unchanged as 'A'",
+ i, num_blocks - i);
+ READ16(sd, NULL, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- for (j = 0; j < i * block_size; j++) {
- if (scratch[j] != 'A') {
- logging(LOG_VERBOSE, "[FAILED] Data changed "
- "eventhough there was a miscompare");
- CU_FAIL("Block was written to");
- return;
- }
- }
- }
+ for (j = 0; j < i * block_size; j++) {
+ if (scratch[j] != 'A') {
+ logging(LOG_VERBOSE, "[FAILED] Data changed "
+ "eventhough there was a miscompare");
+ CU_FAIL("Block was written to");
+ return;
+ }
+ }
+ }
}
diff --git a/test-tool/test_compareandwrite_simple.c b/test-tool/test_compareandwrite_simple.c
index 97ab9e0..513aa18 100644
--- a/test-tool/test_compareandwrite_simple.c
+++ b/test-tool/test_compareandwrite_simple.c
@@ -31,121 +31,121 @@
void
test_compareandwrite_simple(void)
{
- int i;
- unsigned j;
- int maxbl;
+ int i;
+ unsigned j;
+ int maxbl;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (inq_bl && inq_bl->max_cmp) {
- maxbl = inq_bl->max_cmp;
- } else {
- /* Assume we are not limited */
- maxbl = 256;
- }
+ if (inq_bl && inq_bl->max_cmp) {
+ maxbl = inq_bl->max_cmp;
+ } else {
+ /* Assume we are not limited */
+ maxbl = 256;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
- "start of the LUN");
- for (i = 1; i < 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
- memset(scratch, 'A', 2 * i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
+ "start of the LUN");
+ for (i = 1; i < 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:0", i);
+ memset(scratch, 'A', 2 * i * block_size);
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (i > maxbl) {
- logging(LOG_VERBOSE, "Number of blocks %d is greater than "
- "BlockLimits.MaximumCompareAndWriteLength(%d). "
- "Command should fail with INVALID_FIELD_IN_CDB",
- i, maxbl);
- COMPAREANDWRITE(sd, 0,
+ if (i > maxbl) {
+ logging(LOG_VERBOSE, "Number of blocks %d is greater than "
+ "BlockLimits.MaximumCompareAndWriteLength(%d). "
+ "Command should fail with INVALID_FIELD_IN_CDB",
+ i, maxbl);
+ COMPAREANDWRITE(sd, 0,
scratch, 2 * i * block_size,
block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
- continue;
- }
+ continue;
+ }
- memset(scratch + i * block_size, 'B', i * block_size);
+ memset(scratch + i * block_size, 'B', i * block_size);
- logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
- "at LBA:0 (if they all contain 'A')", i);
- COMPAREANDWRITE(sd, 0,
+ logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
+ "at LBA:0 (if they all contain 'A')", i);
+ COMPAREANDWRITE(sd, 0,
scratch, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
- "they are all 'B'", i);
- READ16(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
+ "they are all 'B'", i);
+ READ16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- for (j = 0; j < i * block_size; j++) {
- if (scratch[j] != 'B') {
- logging(LOG_VERBOSE, "[FAILED] Data did not "
- "read back as 'B' (scratch[%d] = %#02x)",
- j, scratch[j]);
- CU_FAIL("Block was not written correctly");
- return;
- }
- }
- }
+ for (j = 0; j < i * block_size; j++) {
+ if (scratch[j] != 'B') {
+ logging(LOG_VERBOSE, "[FAILED] Data did not "
+ "read back as 'B' (scratch[%d] = %#02x)",
+ j, scratch[j]);
+ CU_FAIL("Block was not written correctly");
+ return;
+ }
+ }
+ }
- logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
- "end of the LUN");
- for (i = 1; i < 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
- i, num_blocks - i);
- memset(scratch, 'A', 2 * i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
+ "end of the LUN");
+ for (i = 1; i < 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 'A' at LBA:%" PRIu64,
+ i, num_blocks - i);
+ memset(scratch, 'A', 2 * i * block_size);
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (i > maxbl) {
- logging(LOG_VERBOSE, "Number of blocks %d is greater than "
- "BlockLimits.MaximumCompareAndWriteLength(%d). "
- "Command should fail with INVALID_FIELD_IN_CDB",
- i, maxbl);
- COMPAREANDWRITE(sd, 0,
+ if (i > maxbl) {
+ logging(LOG_VERBOSE, "Number of blocks %d is greater than "
+ "BlockLimits.MaximumCompareAndWriteLength(%d). "
+ "Command should fail with INVALID_FIELD_IN_CDB",
+ i, maxbl);
+ COMPAREANDWRITE(sd, 0,
scratch, 2 * i * block_size,
block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
- continue;
- }
- memset(scratch + i * block_size, 'B', i * block_size);
+ continue;
+ }
+ memset(scratch + i * block_size, 'B', i * block_size);
- logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
- "at LBA:%" PRIu64 " (if they all contain 'A')",
- i, num_blocks - i);
- COMPAREANDWRITE(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
+ "at LBA:%" PRIu64 " (if they all contain 'A')",
+ i, num_blocks - i);
+ COMPAREANDWRITE(sd, num_blocks - i,
scratch, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
- " and verify they are all 'B'",
- i, num_blocks - i);
- READ16(sd, NULL, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
+ " and verify they are all 'B'",
+ i, num_blocks - i);
+ READ16(sd, NULL, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- for (j = 0; j < i * block_size; j++) {
- if (scratch[j] != 'B') {
- logging(LOG_VERBOSE, "[FAILED] Data did not "
- "read back as 'B' (scratch[%d] = %#02x)",
- j, scratch[j]);
- CU_FAIL("Block was not written correctly");
- return;
- }
- }
- }
+ for (j = 0; j < i * block_size; j++) {
+ if (scratch[j] != 'B') {
+ logging(LOG_VERBOSE, "[FAILED] Data did not "
+ "read back as 'B' (scratch[%d] = %#02x)",
+ j, scratch[j]);
+ CU_FAIL("Block was not written correctly");
+ return;
+ }
+ }
+ }
}
diff --git a/test-tool/test_extendedcopy_descr_limits.c b/test-tool/test_extendedcopy_descr_limits.c
index f5240fb..44ac6ef 100644
--- a/test-tool/test_extendedcopy_descr_limits.c
+++ b/test-tool/test_extendedcopy_descr_limits.c
@@ -28,88 +28,88 @@
#include "iscsi-test-cu.h"
int init_xcopy_descr(unsigned char *buf, int offset, int num_tgt_desc,
- int num_seg_desc, int *tgt_desc_len, int *seg_desc_len)
+ int num_seg_desc, int *tgt_desc_len, int *seg_desc_len)
{
- int i;
+ int i;
- /* Initialize target descriptor list with num_tgt_desc
- * target descriptor */
- for (i = 0; i < num_tgt_desc; i++)
- offset += populate_tgt_desc(buf+offset, IDENT_DESCR_TGT_DESCR,
- LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
- *tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ /* Initialize target descriptor list with num_tgt_desc
+ * target descriptor */
+ for (i = 0; i < num_tgt_desc; i++)
+ offset += populate_tgt_desc(buf+offset, IDENT_DESCR_TGT_DESCR,
+ LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
+ *tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- /* Iniitialize segment descriptor list with num_seg_desc
- * segment descriptor */
- for (i = 0; i < num_seg_desc; i++)
- offset += populate_seg_desc_b2b(buf+offset, 0, 0, 0, 0,
- 2048, 0, num_blocks - 2048);
- *seg_desc_len = offset - XCOPY_DESC_OFFSET - *tgt_desc_len;
+ /* Iniitialize segment descriptor list with num_seg_desc
+ * segment descriptor */
+ for (i = 0; i < num_seg_desc; i++)
+ offset += populate_seg_desc_b2b(buf+offset, 0, 0, 0, 0,
+ 2048, 0, num_blocks - 2048);
+ *seg_desc_len = offset - XCOPY_DESC_OFFSET - *tgt_desc_len;
- return offset;
+ return offset;
}
void
test_extendedcopy_descr_limits(void)
{
- struct scsi_task *edl_task;
- struct iscsi_data data;
- unsigned char *xcopybuf;
- struct scsi_copy_results_op_params *opp = NULL;
- int tgt_desc_len = 0, seg_desc_len = 0;
- unsigned int alloc_len;
+ struct scsi_task *edl_task;
+ struct iscsi_data data;
+ unsigned char *xcopybuf;
+ struct scsi_copy_results_op_params *opp = NULL;
+ int tgt_desc_len = 0, seg_desc_len = 0;
+ unsigned int alloc_len;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test EXTENDED COPY descriptor limits");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test EXTENDED COPY descriptor limits");
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Issue RECEIVE COPY RESULTS (OPERATING PARAMS)");
- RECEIVE_COPY_RESULTS(&edl_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0,
+ logging(LOG_VERBOSE, "Issue RECEIVE COPY RESULTS (OPERATING PARAMS)");
+ RECEIVE_COPY_RESULTS(&edl_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0,
(void **)&opp, EXPECT_STATUS_GOOD);
- /* Allocate buffer to accommodate (MAX+1) target and
- * segment descriptors */
- alloc_len = XCOPY_DESC_OFFSET +
- (opp->max_target_desc_count+1) *
- get_desc_len(IDENT_DESCR_TGT_DESCR) +
- (opp->max_segment_desc_count+1) *
- get_desc_len(BLK_TO_BLK_SEG_DESCR);
- data.data = alloca(alloc_len);
- xcopybuf = data.data;
- memset(xcopybuf, 0, alloc_len);
+ /* Allocate buffer to accommodate (MAX+1) target and
+ * segment descriptors */
+ alloc_len = XCOPY_DESC_OFFSET +
+ (opp->max_target_desc_count+1) *
+ get_desc_len(IDENT_DESCR_TGT_DESCR) +
+ (opp->max_segment_desc_count+1) *
+ get_desc_len(BLK_TO_BLK_SEG_DESCR);
+ data.data = alloca(alloc_len);
+ xcopybuf = data.data;
+ memset(xcopybuf, 0, alloc_len);
- logging(LOG_VERBOSE,
- "Test sending more than supported target descriptors");
- data.size = init_xcopy_descr(xcopybuf, XCOPY_DESC_OFFSET,
- (opp->max_target_desc_count+1), 1,
- &tgt_desc_len, &seg_desc_len);
- populate_param_header(xcopybuf, 1, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_TOO_MANY_DESCR);
+ logging(LOG_VERBOSE,
+ "Test sending more than supported target descriptors");
+ data.size = init_xcopy_descr(xcopybuf, XCOPY_DESC_OFFSET,
+ (opp->max_target_desc_count+1), 1,
+ &tgt_desc_len, &seg_desc_len);
+ populate_param_header(xcopybuf, 1, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
+ EXTENDEDCOPY(sd, &data, EXPECT_TOO_MANY_DESCR);
- logging(LOG_VERBOSE,
- "Test sending more than supported segment descriptors");
- memset(xcopybuf, 0, alloc_len);
- data.size = init_xcopy_descr(xcopybuf, XCOPY_DESC_OFFSET, 1,
- (opp->max_segment_desc_count+1),
- &tgt_desc_len, &seg_desc_len);
- populate_param_header(xcopybuf, 2, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_TOO_MANY_DESCR);
+ logging(LOG_VERBOSE,
+ "Test sending more than supported segment descriptors");
+ memset(xcopybuf, 0, alloc_len);
+ data.size = init_xcopy_descr(xcopybuf, XCOPY_DESC_OFFSET, 1,
+ (opp->max_segment_desc_count+1),
+ &tgt_desc_len, &seg_desc_len);
+ populate_param_header(xcopybuf, 2, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
+ EXTENDEDCOPY(sd, &data, EXPECT_TOO_MANY_DESCR);
- logging(LOG_VERBOSE,
- "Test sending descriptors > Maximum Descriptor List Length");
- memset(xcopybuf, 0, alloc_len);
- if (opp->max_desc_list_length < alloc_len) {
- data.size = init_xcopy_descr(xcopybuf, XCOPY_DESC_OFFSET,
- (opp->max_target_desc_count+1),
- (opp->max_segment_desc_count+1),
- &tgt_desc_len, &seg_desc_len);
- populate_param_header(xcopybuf, 3, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_PARAM_LIST_LEN_ERR);
- }
+ logging(LOG_VERBOSE,
+ "Test sending descriptors > Maximum Descriptor List Length");
+ memset(xcopybuf, 0, alloc_len);
+ if (opp->max_desc_list_length < alloc_len) {
+ data.size = init_xcopy_descr(xcopybuf, XCOPY_DESC_OFFSET,
+ (opp->max_target_desc_count+1),
+ (opp->max_segment_desc_count+1),
+ &tgt_desc_len, &seg_desc_len);
+ populate_param_header(xcopybuf, 3, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
+ EXTENDEDCOPY(sd, &data, EXPECT_PARAM_LIST_LEN_ERR);
+ }
- scsi_free_scsi_task(edl_task);
+ scsi_free_scsi_task(edl_task);
}
diff --git a/test-tool/test_extendedcopy_descr_type.c b/test-tool/test_extendedcopy_descr_type.c
index 7a2914a..e1f3826 100644
--- a/test-tool/test_extendedcopy_descr_type.c
+++ b/test-tool/test_extendedcopy_descr_type.c
@@ -28,60 +28,60 @@
#include "iscsi-test-cu.h"
int init_xcopybuf(unsigned char *buf, int tgt_desc_type, int seg_desc_type,
- int *tgt_desc_len, int *seg_desc_len)
+ int *tgt_desc_len, int *seg_desc_len)
{
- int offset = XCOPY_DESC_OFFSET;
+ int offset = XCOPY_DESC_OFFSET;
- offset += populate_tgt_desc(buf+offset, tgt_desc_type, LU_ID_TYPE_LUN,
- 0, 0, 0, 0, sd);
- *tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- if (seg_desc_type == BLK_TO_BLK_SEG_DESCR)
- offset += populate_seg_desc_b2b(buf+offset, 0, 0, 0, 0, 2048, 0,
- num_blocks - 2048);
- else
- offset += populate_seg_desc_hdr(buf+offset, seg_desc_type,
- 0, 0, 0, 0);
- *seg_desc_len = offset - XCOPY_DESC_OFFSET - *tgt_desc_len;
+ offset += populate_tgt_desc(buf+offset, tgt_desc_type, LU_ID_TYPE_LUN,
+ 0, 0, 0, 0, sd);
+ *tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ if (seg_desc_type == BLK_TO_BLK_SEG_DESCR)
+ offset += populate_seg_desc_b2b(buf+offset, 0, 0, 0, 0, 2048, 0,
+ num_blocks - 2048);
+ else
+ offset += populate_seg_desc_hdr(buf+offset, seg_desc_type,
+ 0, 0, 0, 0);
+ *seg_desc_len = offset - XCOPY_DESC_OFFSET - *tgt_desc_len;
- return offset;
+ return offset;
}
void
test_extendedcopy_descr_type(void)
{
- int tgt_desc_len = 0, seg_desc_len = 0, alloc_len;
- struct iscsi_data data;
- unsigned char *xcopybuf;
+ int tgt_desc_len = 0, seg_desc_len = 0, alloc_len;
+ struct iscsi_data data;
+ unsigned char *xcopybuf;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE,
- "Test EXTENDED COPY unsupported descriptor types");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE,
+ "Test EXTENDED COPY unsupported descriptor types");
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- alloc_len = XCOPY_DESC_OFFSET +
- get_desc_len(IDENT_DESCR_TGT_DESCR) +
- get_desc_len(BLK_TO_BLK_SEG_DESCR);
- data.data = alloca(alloc_len);
- xcopybuf = data.data;
- memset(xcopybuf, 0, alloc_len);
+ alloc_len = XCOPY_DESC_OFFSET +
+ get_desc_len(IDENT_DESCR_TGT_DESCR) +
+ get_desc_len(BLK_TO_BLK_SEG_DESCR);
+ data.data = alloca(alloc_len);
+ xcopybuf = data.data;
+ memset(xcopybuf, 0, alloc_len);
- logging(LOG_VERBOSE,
- "Send Fibre Channel N_Port_Name target descriptor");
- data.size = init_xcopybuf(xcopybuf, 0xE0, BLK_TO_BLK_SEG_DESCR,
- &tgt_desc_len, &seg_desc_len);
- populate_param_header(xcopybuf, 1, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
+ logging(LOG_VERBOSE,
+ "Send Fibre Channel N_Port_Name target descriptor");
+ data.size = init_xcopybuf(xcopybuf, 0xE0, BLK_TO_BLK_SEG_DESCR,
+ &tgt_desc_len, &seg_desc_len);
+ populate_param_header(xcopybuf, 1, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_UNSUPP_DESCR_CODE);
+ EXTENDEDCOPY(sd, &data, EXPECT_UNSUPP_DESCR_CODE);
- logging(LOG_VERBOSE, "Send Stream-to-Stream Copy segment descriptor");
- memset(xcopybuf, 0, alloc_len);
- data.size = init_xcopybuf(xcopybuf, IDENT_DESCR_TGT_DESCR,
- STRM_TO_STRM_SEG_DESCR,
- &tgt_desc_len, &seg_desc_len);
- populate_param_header(xcopybuf, 1, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
+ logging(LOG_VERBOSE, "Send Stream-to-Stream Copy segment descriptor");
+ memset(xcopybuf, 0, alloc_len);
+ data.size = init_xcopybuf(xcopybuf, IDENT_DESCR_TGT_DESCR,
+ STRM_TO_STRM_SEG_DESCR,
+ &tgt_desc_len, &seg_desc_len);
+ populate_param_header(xcopybuf, 1, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_UNSUPP_DESCR_CODE);
+ EXTENDEDCOPY(sd, &data, EXPECT_UNSUPP_DESCR_CODE);
}
diff --git a/test-tool/test_extendedcopy_param.c b/test-tool/test_extendedcopy_param.c
index 3d12c3d..c6abb69 100644
--- a/test-tool/test_extendedcopy_param.c
+++ b/test-tool/test_extendedcopy_param.c
@@ -30,47 +30,47 @@
void
test_extendedcopy_param(void)
{
- int tgt_desc_len = 0, seg_desc_len = 0, offset = XCOPY_DESC_OFFSET;
- struct iscsi_data data;
- unsigned char *xcopybuf;
+ int tgt_desc_len = 0, seg_desc_len = 0, offset = XCOPY_DESC_OFFSET;
+ struct iscsi_data data;
+ unsigned char *xcopybuf;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test EXTENDED COPY parameter list length");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test EXTENDED COPY parameter list length");
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- data.size = XCOPY_DESC_OFFSET +
- get_desc_len(IDENT_DESCR_TGT_DESCR) +
- get_desc_len(BLK_TO_BLK_SEG_DESCR);
- data.data = alloca(data.size);
- xcopybuf = data.data;
- memset(xcopybuf, 0, data.size);
+ data.size = XCOPY_DESC_OFFSET +
+ get_desc_len(IDENT_DESCR_TGT_DESCR) +
+ get_desc_len(BLK_TO_BLK_SEG_DESCR);
+ data.data = alloca(data.size);
+ xcopybuf = data.data;
+ memset(xcopybuf, 0, data.size);
- offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
- LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
- tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
+ LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
+ tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
- 2048, 0, num_blocks - 2048);
- seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
+ offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
+ 2048, 0, num_blocks - 2048);
+ seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
- populate_param_header(xcopybuf, 1, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
+ populate_param_header(xcopybuf, 1, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
- logging(LOG_VERBOSE,
- "Test parameter list length truncating target descriptor");
- data.size = XCOPY_DESC_OFFSET +
- get_desc_len(IDENT_DESCR_TGT_DESCR) - 1;
- EXTENDEDCOPY(sd, &data, EXPECT_PARAM_LIST_LEN_ERR);
+ logging(LOG_VERBOSE,
+ "Test parameter list length truncating target descriptor");
+ data.size = XCOPY_DESC_OFFSET +
+ get_desc_len(IDENT_DESCR_TGT_DESCR) - 1;
+ EXTENDEDCOPY(sd, &data, EXPECT_PARAM_LIST_LEN_ERR);
- logging(LOG_VERBOSE,
- "Test parameter list length truncating segment descriptor");
- data.size = XCOPY_DESC_OFFSET +
- get_desc_len(IDENT_DESCR_TGT_DESCR) +
- get_desc_len(BLK_TO_BLK_SEG_DESCR) - 1;
- EXTENDEDCOPY(sd, &data, EXPECT_PARAM_LIST_LEN_ERR);
+ logging(LOG_VERBOSE,
+ "Test parameter list length truncating segment descriptor");
+ data.size = XCOPY_DESC_OFFSET +
+ get_desc_len(IDENT_DESCR_TGT_DESCR) +
+ get_desc_len(BLK_TO_BLK_SEG_DESCR) - 1;
+ EXTENDEDCOPY(sd, &data, EXPECT_PARAM_LIST_LEN_ERR);
- logging(LOG_VERBOSE, "Test parameter list length = 0");
- data.size = 0;
- EXTENDEDCOPY(sd, &data, EXPECT_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Test parameter list length = 0");
+ data.size = 0;
+ EXTENDEDCOPY(sd, &data, EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_extendedcopy_simple.c b/test-tool/test_extendedcopy_simple.c
index d341030..79c4862 100644
--- a/test-tool/test_extendedcopy_simple.c
+++ b/test-tool/test_extendedcopy_simple.c
@@ -30,55 +30,55 @@
void
test_extendedcopy_simple(void)
{
- int tgt_desc_len = 0, seg_desc_len = 0, offset = XCOPY_DESC_OFFSET;
- struct iscsi_data data;
- unsigned char *xcopybuf;
- unsigned char *buf1 = malloc(2048*block_size);
- unsigned char *buf2 = malloc(2048*block_size);
+ int tgt_desc_len = 0, seg_desc_len = 0, offset = XCOPY_DESC_OFFSET;
+ struct iscsi_data data;
+ unsigned char *xcopybuf;
+ unsigned char *buf1 = malloc(2048*block_size);
+ unsigned char *buf2 = malloc(2048*block_size);
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE,
- "Test EXTENDED COPY of 2048 blocks from start of LUN to end of LUN");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE,
+ "Test EXTENDED COPY of 2048 blocks from start of LUN to end of LUN");
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Write 2048 blocks of 'A' at LBA:0");
- memset(buf1, 'A', 2048*block_size);
- WRITE16(sd, 0, 2048*block_size, block_size, 0, 0, 0, 0, 0,
+ logging(LOG_VERBOSE, "Write 2048 blocks of 'A' at LBA:0");
+ memset(buf1, 'A', 2048*block_size);
+ WRITE16(sd, 0, 2048*block_size, block_size, 0, 0, 0, 0, 0,
buf1, EXPECT_STATUS_GOOD);
- data.size = XCOPY_DESC_OFFSET +
- get_desc_len(IDENT_DESCR_TGT_DESCR) +
- get_desc_len(BLK_TO_BLK_SEG_DESCR);
- data.data = alloca(data.size);
- xcopybuf = data.data;
- memset(xcopybuf, 0, data.size);
+ data.size = XCOPY_DESC_OFFSET +
+ get_desc_len(IDENT_DESCR_TGT_DESCR) +
+ get_desc_len(BLK_TO_BLK_SEG_DESCR);
+ data.data = alloca(data.size);
+ xcopybuf = data.data;
+ memset(xcopybuf, 0, data.size);
- /* Initialize target descriptor list with one target descriptor */
- offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
- LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
- tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ /* Initialize target descriptor list with one target descriptor */
+ offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
+ LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
+ tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- /* Iniitialize segment descriptor list with one segment descriptor */
- offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
- 2048, 0, num_blocks - 2048);
- seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
+ /* Iniitialize segment descriptor list with one segment descriptor */
+ offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
+ 2048, 0, num_blocks - 2048);
+ seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
- /* Initialize the parameter list header */
- populate_param_header(xcopybuf, 1, 0, LIST_ID_USAGE_DISCARD, 0,
- tgt_desc_len, seg_desc_len, 0);
+ /* Initialize the parameter list header */
+ populate_param_header(xcopybuf, 1, 0, LIST_ID_USAGE_DISCARD, 0,
+ tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_STATUS_GOOD);
+ EXTENDEDCOPY(sd, &data, EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read 2048 blocks from end of the LUN");
- READ16(sd, NULL, num_blocks - 2048, 2048*block_size,
+ logging(LOG_VERBOSE, "Read 2048 blocks from end of the LUN");
+ READ16(sd, NULL, num_blocks - 2048, 2048*block_size,
block_size, 0, 0, 0, 0, 0, buf2,
EXPECT_STATUS_GOOD);
- if (memcmp(buf1, buf2, 2048)) {
- CU_FAIL("Blocks were not copied correctly");
+ if (memcmp(buf1, buf2, 2048)) {
+ CU_FAIL("Blocks were not copied correctly");
}
- free(buf1);
- free(buf2);
+ free(buf1);
+ free(buf2);
}
diff --git a/test-tool/test_extendedcopy_validate_seg_descr.c b/test-tool/test_extendedcopy_validate_seg_descr.c
index 41a637c..a879536 100644
--- a/test-tool/test_extendedcopy_validate_seg_descr.c
+++ b/test-tool/test_extendedcopy_validate_seg_descr.c
@@ -30,48 +30,48 @@
void
test_extendedcopy_validate_seg_descr(void)
{
- int tgt_desc_len = 0, seg_desc_len = 0, offset = XCOPY_DESC_OFFSET;
- struct iscsi_data data;
- unsigned char *xcopybuf;
+ int tgt_desc_len = 0, seg_desc_len = 0, offset = XCOPY_DESC_OFFSET;
+ struct iscsi_data data;
+ unsigned char *xcopybuf;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test EXTENDED COPY segment descriptor fields");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test EXTENDED COPY segment descriptor fields");
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- data.size = XCOPY_DESC_OFFSET +
- get_desc_len(IDENT_DESCR_TGT_DESCR) +
- get_desc_len(BLK_TO_BLK_SEG_DESCR);
- data.data = alloca(data.size);
- xcopybuf = data.data;
- memset(xcopybuf, 0, data.size);
+ data.size = XCOPY_DESC_OFFSET +
+ get_desc_len(IDENT_DESCR_TGT_DESCR) +
+ get_desc_len(BLK_TO_BLK_SEG_DESCR);
+ data.data = alloca(data.size);
+ xcopybuf = data.data;
+ memset(xcopybuf, 0, data.size);
- logging(LOG_VERBOSE, "Send invalid target descriptor index");
- offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
- LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
- tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- /* Inaccessible DESTINATION TARGET DESCRIPTOR INDEX */
- offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 1,
- 2048, 0, num_blocks - 2048);
- seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
- populate_param_header(xcopybuf, 1, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
+ logging(LOG_VERBOSE, "Send invalid target descriptor index");
+ offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
+ LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
+ tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ /* Inaccessible DESTINATION TARGET DESCRIPTOR INDEX */
+ offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 1,
+ 2048, 0, num_blocks - 2048);
+ seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
+ populate_param_header(xcopybuf, 1, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_COPY_ABORTED);
+ EXTENDEDCOPY(sd, &data, EXPECT_COPY_ABORTED);
- logging(LOG_VERBOSE,
- "Number of copy blocks beyond destination block device capacity");
- memset(xcopybuf, 0, data.size);
- offset = XCOPY_DESC_OFFSET;
- offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
- LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
- tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- /* Beyond EOL */
- offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
- 2048, 0, num_blocks - 1);
- seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
- populate_param_header(xcopybuf, 1, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
+ logging(LOG_VERBOSE,
+ "Number of copy blocks beyond destination block device capacity");
+ memset(xcopybuf, 0, data.size);
+ offset = XCOPY_DESC_OFFSET;
+ offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
+ LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
+ tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ /* Beyond EOL */
+ offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
+ 2048, 0, num_blocks - 1);
+ seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
+ populate_param_header(xcopybuf, 1, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_COPY_ABORTED);
+ EXTENDEDCOPY(sd, &data, EXPECT_COPY_ABORTED);
}
diff --git a/test-tool/test_extendedcopy_validate_tgt_descr.c b/test-tool/test_extendedcopy_validate_tgt_descr.c
index 8975e16..173958a 100644
--- a/test-tool/test_extendedcopy_validate_tgt_descr.c
+++ b/test-tool/test_extendedcopy_validate_tgt_descr.c
@@ -30,47 +30,47 @@
void
test_extendedcopy_validate_tgt_descr(void)
{
- int tgt_desc_len = 0, seg_desc_len = 0, offset = XCOPY_DESC_OFFSET;
- struct iscsi_data data;
- unsigned char *xcopybuf;
+ int tgt_desc_len = 0, seg_desc_len = 0, offset = XCOPY_DESC_OFFSET;
+ struct iscsi_data data;
+ unsigned char *xcopybuf;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test EXTENDED COPY target descriptor fields");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test EXTENDED COPY target descriptor fields");
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- data.size = XCOPY_DESC_OFFSET +
- get_desc_len(IDENT_DESCR_TGT_DESCR) +
- get_desc_len(BLK_TO_BLK_SEG_DESCR);
- data.data = alloca(data.size);
- xcopybuf = data.data;
- memset(xcopybuf, 0, data.size);
+ data.size = XCOPY_DESC_OFFSET +
+ get_desc_len(IDENT_DESCR_TGT_DESCR) +
+ get_desc_len(BLK_TO_BLK_SEG_DESCR);
+ data.data = alloca(data.size);
+ xcopybuf = data.data;
+ memset(xcopybuf, 0, data.size);
- logging(LOG_VERBOSE, "Unsupported LU_ID TYPE");
- /* Unsupported LU ID TYPE */
- offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
- LU_ID_TYPE_RSVD, 0, 0, 0, 0, sd);
- tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
- 2048, 0, num_blocks - 2048);
- seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
- populate_param_header(xcopybuf, 1, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
+ logging(LOG_VERBOSE, "Unsupported LU_ID TYPE");
+ /* Unsupported LU ID TYPE */
+ offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
+ LU_ID_TYPE_RSVD, 0, 0, 0, 0, sd);
+ tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
+ 2048, 0, num_blocks - 2048);
+ seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
+ populate_param_header(xcopybuf, 1, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_INVALID_FIELD_IN_CDB);
+ EXTENDEDCOPY(sd, &data, EXPECT_INVALID_FIELD_IN_CDB);
- logging(LOG_VERBOSE, "Test NUL bit in target descriptor");
- /* NUL bit */
- memset(xcopybuf, 0, data.size);
- offset = XCOPY_DESC_OFFSET;
- offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
- LU_ID_TYPE_LUN, 1, 0, 0, 0, sd);
- tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
- 2048, 0, num_blocks - 2048);
- seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
- populate_param_header(xcopybuf, 1, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
+ logging(LOG_VERBOSE, "Test NUL bit in target descriptor");
+ /* NUL bit */
+ memset(xcopybuf, 0, data.size);
+ offset = XCOPY_DESC_OFFSET;
+ offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
+ LU_ID_TYPE_LUN, 1, 0, 0, 0, sd);
+ tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
+ 2048, 0, num_blocks - 2048);
+ seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
+ populate_param_header(xcopybuf, 1, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_COPY_ABORTED);
+ EXTENDEDCOPY(sd, &data, EXPECT_COPY_ABORTED);
}
diff --git a/test-tool/test_get_lba_status_beyond_eol.c b/test-tool/test_get_lba_status_beyond_eol.c
index 6f9e679..6cec526 100644
--- a/test-tool/test_get_lba_status_beyond_eol.c
+++ b/test-tool/test_get_lba_status_beyond_eol.c
@@ -29,17 +29,17 @@
void
test_get_lba_status_beyond_eol(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test GETLBASTATUS one block beyond the end of the LUN");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test GETLBASTATUS one block beyond the end of the LUN");
- GETLBASTATUS(sd, NULL, num_blocks + 1, 24,
+ GETLBASTATUS(sd, NULL, num_blocks + 1, 24,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test GETLBASTATUS at LBA 2^63");
- GETLBASTATUS(sd, NULL, 0x8000000000000000ULL, 24,
+ logging(LOG_VERBOSE, "Test GETLBASTATUS at LBA 2^63");
+ GETLBASTATUS(sd, NULL, 0x8000000000000000ULL, 24,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test GETLBASTATUS at LBA -1");
- GETLBASTATUS(sd, NULL, 0xffffffffffffffffULL, 24,
+ logging(LOG_VERBOSE, "Test GETLBASTATUS at LBA -1");
+ GETLBASTATUS(sd, NULL, 0xffffffffffffffffULL, 24,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_get_lba_status_simple.c b/test-tool/test_get_lba_status_simple.c
index 215b449..35ba314 100644
--- a/test-tool/test_get_lba_status_simple.c
+++ b/test-tool/test_get_lba_status_simple.c
@@ -29,18 +29,18 @@
void
test_get_lba_status_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test GETLBASTATUS of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- GETLBASTATUS(sd, NULL, i, 24,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test GETLBASTATUS of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ GETLBASTATUS(sd, NULL, i, 24,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test GETLBASTATUS of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- GETLBASTATUS(sd, NULL, num_blocks - i, 24,
+ logging(LOG_VERBOSE, "Test GETLBASTATUS of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ GETLBASTATUS(sd, NULL, num_blocks - i, 24,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_get_lba_status_unmap_single.c b/test-tool/test_get_lba_status_unmap_single.c
index 4ae9088..908ce31 100644
--- a/test-tool/test_get_lba_status_unmap_single.c
+++ b/test-tool/test_get_lba_status_unmap_single.c
@@ -29,120 +29,120 @@
void
test_get_lba_status_unmap_single(void)
{
- uint64_t i;
- struct unmap_list list[1];
- struct scsi_task *t = NULL;
- struct scsi_get_lba_status *lbas = NULL;
- struct scsi_lba_status_descriptor *lbasd = NULL;
+ uint64_t i;
+ struct unmap_list list[1];
+ struct scsi_task *t = NULL;
+ struct scsi_get_lba_status *lbas = NULL;
+ struct scsi_lba_status_descriptor *lbasd = NULL;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_LBPU;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_LBPU;
- memset(scratch, 'A', (256 + lbppb + 1) * block_size);
+ memset(scratch, 'A', (256 + lbppb + 1) * block_size);
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test GETLBASTATUS for a single unmapped block "
- "at offset 0-255");
- logging(LOG_VERBOSE, "We have %d logical blocks per physical block",
- lbppb);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test GETLBASTATUS for a single unmapped block "
+ "at offset 0-255");
+ logging(LOG_VERBOSE, "We have %d logical blocks per physical block",
+ lbppb);
- logging(LOG_VERBOSE, "Write the first %i blocks with a known "
- "pattern and thus map the blocks", 256 + lbppb);
- WRITE10(sd, 0, (256 + lbppb) * block_size,
+ logging(LOG_VERBOSE, "Write the first %i blocks with a known "
+ "pattern and thus map the blocks", 256 + lbppb);
+ WRITE10(sd, 0, (256 + lbppb) * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- for (i = 0; i + lbppb <= 256; i += lbppb) {
- logging(LOG_VERBOSE, "Unmap a single physical block at LBA:%"
- PRIu64 " (number of logical blocks: %d)", i, lbppb);
- list[0].lba = i;
- list[0].num = lbppb;
- UNMAP(sd, 0, list, 1,
+ for (i = 0; i + lbppb <= 256; i += lbppb) {
+ logging(LOG_VERBOSE, "Unmap a single physical block at LBA:%"
+ PRIu64 " (number of logical blocks: %d)", i, lbppb);
+ list[0].lba = i;
+ list[0].num = lbppb;
+ UNMAP(sd, 0, list, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
- PRIu64, i);
- GETLBASTATUS(sd, NULL, i, 24,
+ logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
+ PRIu64, i);
+ GETLBASTATUS(sd, NULL, i, 24,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
- PRIu64, i + lbppb);
- GETLBASTATUS(sd, &t, i + lbppb, 24,
+ logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
+ PRIu64, i + lbppb);
+ GETLBASTATUS(sd, &t, i + lbppb, 24,
EXPECT_STATUS_GOOD);
- if (t == NULL) {
- CU_FAIL("[FAILED] GETLBASTATUS task is NULL");
- return;
- }
- lbas = scsi_datain_unmarshall(t);
- if (lbas == NULL) {
- CU_FAIL("[FAILED] GETLBASTATUS command: failed "
- "to unmarshall data.");
- scsi_free_scsi_task(t);
- return;
- }
- lbasd = &lbas->descriptors[0];
- if (lbasd->lba != i + lbppb) {
- CU_FAIL("[FAILED] GETLBASTATUS command: "
- "lba offset in first descriptor does not "
- "match request.");
- scsi_free_scsi_task(t);
- return;
- }
- if (lbasd->provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
- CU_FAIL("[FAILED] LBA should be mapped but isn't");
- return;
- }
- scsi_free_scsi_task(t);
- }
+ if (t == NULL) {
+ CU_FAIL("[FAILED] GETLBASTATUS task is NULL");
+ return;
+ }
+ lbas = scsi_datain_unmarshall(t);
+ if (lbas == NULL) {
+ CU_FAIL("[FAILED] GETLBASTATUS command: failed "
+ "to unmarshall data.");
+ scsi_free_scsi_task(t);
+ return;
+ }
+ lbasd = &lbas->descriptors[0];
+ if (lbasd->lba != i + lbppb) {
+ CU_FAIL("[FAILED] GETLBASTATUS command: "
+ "lba offset in first descriptor does not "
+ "match request.");
+ scsi_free_scsi_task(t);
+ return;
+ }
+ if (lbasd->provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
+ CU_FAIL("[FAILED] LBA should be mapped but isn't");
+ return;
+ }
+ scsi_free_scsi_task(t);
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test GETLBASTATUS for a single range of 1-255 "
- "blocks at offset 0");
- for (i = lbppb; i + lbppb <= 256; i += lbppb) {
- logging(LOG_VERBOSE, "Write the first %i blocks with a known "
- "pattern and thus map the blocks", (256 + lbppb));
- WRITE10(sd, 0, (256 + lbppb) * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test GETLBASTATUS for a single range of 1-255 "
+ "blocks at offset 0");
+ for (i = lbppb; i + lbppb <= 256; i += lbppb) {
+ logging(LOG_VERBOSE, "Write the first %i blocks with a known "
+ "pattern and thus map the blocks", (256 + lbppb));
+ WRITE10(sd, 0, (256 + lbppb) * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %" PRIu64 " blocks at LBA 0", i);
- list[0].lba = 0;
- list[0].num = i;
- UNMAP(sd, 0, list, 1,
+ logging(LOG_VERBOSE, "Unmap %" PRIu64 " blocks at LBA 0", i);
+ list[0].lba = 0;
+ list[0].num = i;
+ UNMAP(sd, 0, list, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the status of the block at LBA:0");
+ logging(LOG_VERBOSE, "Read the status of the block at LBA:0");
- GETLBASTATUS(sd, NULL, 0, 24,
+ GETLBASTATUS(sd, NULL, 0, 24,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the status of the block at LBA:%" PRIu64, i + 1);
- GETLBASTATUS(sd, &t, i + 1, 24,
+ logging(LOG_VERBOSE, "Read the status of the block at LBA:%" PRIu64, i + 1);
+ GETLBASTATUS(sd, &t, i + 1, 24,
EXPECT_STATUS_GOOD);
- if (t == NULL) {
- CU_FAIL("[FAILED] GETLBASTATUS task is NULL");
- return;
- }
- lbas = scsi_datain_unmarshall(t);
- if (lbas == NULL) {
- CU_FAIL("[FAILED] GETLBASTATUS command: failed "
- "to unmarshall data.");
- scsi_free_scsi_task(t);
- return;
- }
- lbasd = &lbas->descriptors[0];
- if (lbasd->lba != i + lbppb) {
- CU_FAIL("[FAILED] GETLBASTATUS command: "
- "lba offset in first descriptor does not "
- "match request.");
- scsi_free_scsi_task(t);
- return;
- }
- if (lbasd->provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
- CU_FAIL("[FAILED] LBA should be mapped but isn't");
- return;
- }
- scsi_free_scsi_task(t);
- }
+ if (t == NULL) {
+ CU_FAIL("[FAILED] GETLBASTATUS task is NULL");
+ return;
+ }
+ lbas = scsi_datain_unmarshall(t);
+ if (lbas == NULL) {
+ CU_FAIL("[FAILED] GETLBASTATUS command: failed "
+ "to unmarshall data.");
+ scsi_free_scsi_task(t);
+ return;
+ }
+ lbasd = &lbas->descriptors[0];
+ if (lbasd->lba != i + lbppb) {
+ CU_FAIL("[FAILED] GETLBASTATUS command: "
+ "lba offset in first descriptor does not "
+ "match request.");
+ scsi_free_scsi_task(t);
+ return;
+ }
+ if (lbasd->provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
+ CU_FAIL("[FAILED] LBA should be mapped but isn't");
+ return;
+ }
+ scsi_free_scsi_task(t);
+ }
}
diff --git a/test-tool/test_inquiry_alloc_length.c b/test-tool/test_inquiry_alloc_length.c
index 1b54593..7512f2c 100644
--- a/test-tool/test_inquiry_alloc_length.c
+++ b/test-tool/test_inquiry_alloc_length.c
@@ -28,85 +28,85 @@
void
test_inquiry_alloc_length(void)
{
- int ret, i;
- struct scsi_inquiry_standard *std_inq;
- struct scsi_task *task2 = NULL;
+ int ret, i;
+ struct scsi_inquiry_standard *std_inq;
+ struct scsi_task *task2 = NULL;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of the INQUIRY allocation length");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of the INQUIRY allocation length");
- logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page with alloc length from 5-255");
- for (i = 5; i < 256 ; i++) {
- if (task != NULL) {
- scsi_free_scsi_task(task);
- task = NULL;
- }
- ret = inquiry(sd, &task, 0, 0, i,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
- }
- logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data when reading with alloc length 255");
- CU_ASSERT(task->datain.size >= 36);
+ logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page with alloc length from 5-255");
+ for (i = 5; i < 256 ; i++) {
+ if (task != NULL) {
+ scsi_free_scsi_task(task);
+ task = NULL;
+ }
+ ret = inquiry(sd, &task, 0, 0, i,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
+ logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data when reading with alloc length 255");
+ CU_ASSERT(task->datain.size >= 36);
- logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer");
- std_inq = scsi_datain_unmarshall(task);
- CU_ASSERT_NOT_EQUAL(std_inq, NULL);
- if (std_inq == NULL) {
- logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN "
- "buffer");
- return;
- }
+ logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer");
+ std_inq = scsi_datain_unmarshall(task);
+ CU_ASSERT_NOT_EQUAL(std_inq, NULL);
+ if (std_inq == NULL) {
+ logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN "
+ "buffer");
+ return;
+ }
- logging(LOG_VERBOSE, "Verify peripheral-qualifier is 0");
- CU_ASSERT_EQUAL(std_inq->qualifier, 0);
+ logging(LOG_VERBOSE, "Verify peripheral-qualifier is 0");
+ CU_ASSERT_EQUAL(std_inq->qualifier, 0);
- /* Final test. IF this claims SPC-3 or later then the target
- supports 16-bit allocation lengths. Try reading INQ data
- specifying 256 bytes as allocation length and make sure the
- target responds properly.
- */
- logging(LOG_VERBOSE, "If version is SPC-3 or later INQUIRY supports 16-bit allocation lengths");
- switch (std_inq->version) {
- case 0x5:
- case 0x6:
- break;
- default:
- logging(LOG_NORMAL, "[SKIPPED] This device does not claim "
- "SPC-3 or later");
- CU_PASS("[SKIPPED] Not SPC-3 or later");
- goto finished;
- }
+ /* Final test. IF this claims SPC-3 or later then the target
+ supports 16-bit allocation lengths. Try reading INQ data
+ specifying 256 bytes as allocation length and make sure the
+ target responds properly.
+ */
+ logging(LOG_VERBOSE, "If version is SPC-3 or later INQUIRY supports 16-bit allocation lengths");
+ switch (std_inq->version) {
+ case 0x5:
+ case 0x6:
+ break;
+ default:
+ logging(LOG_NORMAL, "[SKIPPED] This device does not claim "
+ "SPC-3 or later");
+ CU_PASS("[SKIPPED] Not SPC-3 or later");
+ goto finished;
+ }
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Version is SPC-3 or later. Read INQUIRY data using 16-bit allocation length");
- logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 511 (low order byte is 0xff)");
- ret = inquiry(sd, &task, 0, 0, 511,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Version is SPC-3 or later. Read INQUIRY data using 16-bit allocation length");
+ logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 511 (low order byte is 0xff)");
+ ret = inquiry(sd, &task, 0, 0, 511,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 512 (low order byte is 0x00)");
- ret = inquiry(sd, &task2, 0, 0, 512,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 512 (low order byte is 0x00)");
+ ret = inquiry(sd, &task2, 0, 0, 512,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "INQUIRY data should be the same when allocation length is 511 and 512 bytes");
- ret = task->datain.size != task2->datain.size;
- CU_ASSERT_EQUAL(ret, 0);
- ret = memcmp(task->datain.data, task2->datain.data, task->datain.size);
- CU_ASSERT_EQUAL(ret, 0);
-
+ logging(LOG_VERBOSE, "INQUIRY data should be the same when allocation length is 511 and 512 bytes");
+ ret = task->datain.size != task2->datain.size;
+ CU_ASSERT_EQUAL(ret, 0);
+ ret = memcmp(task->datain.data, task2->datain.data, task->datain.size);
+ CU_ASSERT_EQUAL(ret, 0);
+
finished:
- if (task != NULL) {
- scsi_free_scsi_task(task);
- task = NULL;
- }
- if (task2 != NULL) {
- scsi_free_scsi_task(task2);
- task2 = NULL;
- }
+ if (task != NULL) {
+ scsi_free_scsi_task(task);
+ task = NULL;
+ }
+ if (task2 != NULL) {
+ scsi_free_scsi_task(task2);
+ task2 = NULL;
+ }
}
diff --git a/test-tool/test_inquiry_block_limits.c b/test-tool/test_inquiry_block_limits.c
index fa7f58a..b134336 100644
--- a/test-tool/test_inquiry_block_limits.c
+++ b/test-tool/test_inquiry_block_limits.c
@@ -27,158 +27,158 @@
static void check_lbp(int *supports_lbp)
{
- *supports_lbp = 0;
+ *supports_lbp = 0;
- CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_THIN_PROVISIONING;
- *supports_lbp = 1;
+ *supports_lbp = 1;
}
void
test_inquiry_block_limits(void)
{
- int supports_lbp, ret;
- struct scsi_inquiry_block_limits *bl;
- struct scsi_task *bl_task = NULL;
- struct scsi_inquiry_logical_block_provisioning *lbp = NULL;
- struct scsi_task *lbp_task = NULL;
+ int supports_lbp, ret;
+ struct scsi_inquiry_block_limits *bl;
+ struct scsi_task *bl_task = NULL;
+ struct scsi_inquiry_logical_block_provisioning *lbp = NULL;
+ struct scsi_task *lbp_task = NULL;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of the INQUIRY Block Limits");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of the INQUIRY Block Limits");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Block device. Verify that we can read Block "
- "Limits VPD");
- ret = inquiry(sd, &bl_task,
- 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 255,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
- if (ret != 0) {
- logging(LOG_NORMAL, "[FAILURE] failed to send inquiry.");
- goto finished;
- }
+ logging(LOG_VERBOSE, "Block device. Verify that we can read Block "
+ "Limits VPD");
+ ret = inquiry(sd, &bl_task,
+ 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 255,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "[FAILURE] failed to send inquiry.");
+ goto finished;
+ }
- bl = scsi_datain_unmarshall(bl_task);
- if (bl == NULL) {
- logging(LOG_NORMAL, "[FAILURE] failed to unmarshall inquiry "
- "datain blob.");
- CU_FAIL("[FAILURE] failed to unmarshall inquiry "
- "datain blob.");
- goto finished;
- }
+ bl = scsi_datain_unmarshall(bl_task);
+ if (bl == NULL) {
+ logging(LOG_NORMAL, "[FAILURE] failed to unmarshall inquiry "
+ "datain blob.");
+ CU_FAIL("[FAILURE] failed to unmarshall inquiry "
+ "datain blob.");
+ goto finished;
+ }
- logging(LOG_VERBOSE, "Verify that the PageLength matches up with the "
- "size of the DATA-IN buffer.");
- CU_ASSERT_EQUAL(bl_task->datain.size, bl_task->datain.data[3] + 4);
- if (bl_task->datain.size != bl_task->datain.data[3] + 4) {
- logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned. "
- "Was %d but expected %d",
- bl_task->datain.data[3], bl_task->datain.size - 4);
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] PageLength matches DataIn "
- "buffer size");
- }
+ logging(LOG_VERBOSE, "Verify that the PageLength matches up with the "
+ "size of the DATA-IN buffer.");
+ CU_ASSERT_EQUAL(bl_task->datain.size, bl_task->datain.data[3] + 4);
+ if (bl_task->datain.size != bl_task->datain.data[3] + 4) {
+ logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned. "
+ "Was %d but expected %d",
+ bl_task->datain.data[3], bl_task->datain.size - 4);
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] PageLength matches DataIn "
+ "buffer size");
+ }
- logging(LOG_VERBOSE, "Verify that the PageLength matches SCSI-level.");
- /* if it is not SBC3 then we assume it must be SBC2 */
- if (sbc3_support) {
- logging(LOG_VERBOSE, "Device claims SBC-3. Verify that " "page size is >= 60");
- } else {
- logging(LOG_VERBOSE, "Device is not SBC-3. Verify that "
- "PageLength == 8 (but allow >= 60 too. Some SBC-2 "
- "devices support some SBC-3 features.");
- }
+ logging(LOG_VERBOSE, "Verify that the PageLength matches SCSI-level.");
+ /* if it is not SBC3 then we assume it must be SBC2 */
+ if (sbc3_support) {
+ logging(LOG_VERBOSE, "Device claims SBC-3. Verify that " "page size is >= 60");
+ } else {
+ logging(LOG_VERBOSE, "Device is not SBC-3. Verify that "
+ "PageLength == 8 (but allow >= 60 too. Some SBC-2 "
+ "devices support some SBC-3 features.");
+ }
- if (bl_task->datain.data[3] == 8) {
- if (sbc3_support) {
- logging(LOG_NORMAL, "[FAILURE] Invalid PageLength "
- "returned. SBC3 claimed but page length "
- "is 8.");
- CU_FAIL("[FAILED] Invalid pagelength returned. "
- "SBC3 claimed but page length is 8.");
- }
- } else if (bl_task->datain.size >= 60) {
- if (!sbc3_support) {
- logging(LOG_NORMAL, "[WARNING] SBC-3 pagelength "
- "(>=60) returned but SBC-3 support was not "
- "claimed in the standard inquiry page.");
- CU_FAIL("[WARNING] SBC-3 pagelength "
- "(>=60) returned but SBC-3 support was not "
- "claimed in the standard inquiry page.");
- }
- }
+ if (bl_task->datain.data[3] == 8) {
+ if (sbc3_support) {
+ logging(LOG_NORMAL, "[FAILURE] Invalid PageLength "
+ "returned. SBC3 claimed but page length "
+ "is 8.");
+ CU_FAIL("[FAILED] Invalid pagelength returned. "
+ "SBC3 claimed but page length is 8.");
+ }
+ } else if (bl_task->datain.size >= 60) {
+ if (!sbc3_support) {
+ logging(LOG_NORMAL, "[WARNING] SBC-3 pagelength "
+ "(>=60) returned but SBC-3 support was not "
+ "claimed in the standard inquiry page.");
+ CU_FAIL("[WARNING] SBC-3 pagelength "
+ "(>=60) returned but SBC-3 support was not "
+ "claimed in the standard inquiry page.");
+ }
+ }
- if (bl_task->datain.data[3] != 0x3c) {
- goto finished;
- }
+ if (bl_task->datain.data[3] != 0x3c) {
+ goto finished;
+ }
- check_lbp(&supports_lbp);
- if (!supports_lbp)
- goto finished;
+ check_lbp(&supports_lbp);
+ if (!supports_lbp)
+ goto finished;
- /*
- * MAXIMUM UNMAP LBA COUNT
- * MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT
- */
- logging(LOG_VERBOSE, "Try reading the logical block provisioning VPD");
- ret = inquiry(sd, &lbp_task,
- 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 255,
- EXPECT_STATUS_GOOD);
- if (ret == 0) {
- lbp = scsi_datain_unmarshall(lbp_task);
- if (lbp == NULL) {
- logging(LOG_NORMAL, "[FAILURE] failed to unmarshall "
- "inquiry datain blob.");
- }
- }
+ /*
+ * MAXIMUM UNMAP LBA COUNT
+ * MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT
+ */
+ logging(LOG_VERBOSE, "Try reading the logical block provisioning VPD");
+ ret = inquiry(sd, &lbp_task,
+ 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 255,
+ EXPECT_STATUS_GOOD);
+ if (ret == 0) {
+ lbp = scsi_datain_unmarshall(lbp_task);
+ if (lbp == NULL) {
+ logging(LOG_NORMAL, "[FAILURE] failed to unmarshall "
+ "inquiry datain blob.");
+ }
+ }
- if (lbp && lbp->lbpu) {
- /* We support UNMAP so MAXIMUM UNMAP LBA COUNT and
- * MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT.
- * They must be > 0.
- * It can be 0xffffffff which means no limit, but if there is
- * an explicit limit set, then we check that it looks sane.
- * Sane here means < 1M.
- */
- logging(LOG_VERBOSE, "Device claims UNMAP support via LBPU");
- logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP LBA COUNT is "
- "not 0");
- CU_ASSERT_NOT_EQUAL(bl->max_unmap, 0);
+ if (lbp && lbp->lbpu) {
+ /* We support UNMAP so MAXIMUM UNMAP LBA COUNT and
+ * MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT.
+ * They must be > 0.
+ * It can be 0xffffffff which means no limit, but if there is
+ * an explicit limit set, then we check that it looks sane.
+ * Sane here means < 1M.
+ */
+ logging(LOG_VERBOSE, "Device claims UNMAP support via LBPU");
+ logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP LBA COUNT is "
+ "not 0");
+ CU_ASSERT_NOT_EQUAL(bl->max_unmap, 0);
- logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP LBA COUNT is "
- "at least 2^LBPPBE");
- CU_ASSERT_EQUAL(bl->max_unmap >= (1U << rc16->lbppbe), 1);
+ logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP LBA COUNT is "
+ "at least 2^LBPPBE");
+ CU_ASSERT_EQUAL(bl->max_unmap >= (1U << rc16->lbppbe), 1);
- if (bl->max_unmap != 0xffffffff) {
- logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP LBA "
- "COUNT is not insanely big");
- CU_ASSERT_TRUE(bl->max_unmap <= 1024*1024);
- }
+ if (bl->max_unmap != 0xffffffff) {
+ logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP LBA "
+ "COUNT is not insanely big");
+ CU_ASSERT_TRUE(bl->max_unmap <= 1024*1024);
+ }
- logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP BLOCK "
- "DESCRIPTOR COUNT is not 0");
- CU_ASSERT_NOT_EQUAL(bl->max_unmap_bdc, 0);
- if (bl->max_unmap_bdc != 0xffffffff) {
- logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP "
- "BLOCK DESCRIPTOR COUNT is not insanely big");
- CU_ASSERT_TRUE(bl->max_unmap_bdc <= 1024*1024);
- }
- } else {
- logging(LOG_VERBOSE, "Device does not claim UNMAP support via "
- "LBPU");
- logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP LBA COUNT is "
- "0");
- CU_ASSERT_EQUAL(bl->max_unmap, 0);
+ logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP BLOCK "
+ "DESCRIPTOR COUNT is not 0");
+ CU_ASSERT_NOT_EQUAL(bl->max_unmap_bdc, 0);
+ if (bl->max_unmap_bdc != 0xffffffff) {
+ logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP "
+ "BLOCK DESCRIPTOR COUNT is not insanely big");
+ CU_ASSERT_TRUE(bl->max_unmap_bdc <= 1024*1024);
+ }
+ } else {
+ logging(LOG_VERBOSE, "Device does not claim UNMAP support via "
+ "LBPU");
+ logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP LBA COUNT is "
+ "0");
+ CU_ASSERT_EQUAL(bl->max_unmap, 0);
- logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP BLOCK "
- "DESCRIPTOR COUNT is 0");
- CU_ASSERT_EQUAL(bl->max_unmap_bdc, 0);
- }
+ logging(LOG_VERBOSE, "Verify that MAXIMUM UNMAP BLOCK "
+ "DESCRIPTOR COUNT is 0");
+ CU_ASSERT_EQUAL(bl->max_unmap_bdc, 0);
+ }
finished:
- scsi_free_scsi_task(bl_task);
- scsi_free_scsi_task(lbp_task);
+ scsi_free_scsi_task(bl_task);
+ scsi_free_scsi_task(lbp_task);
}
diff --git a/test-tool/test_inquiry_evpd.c b/test-tool/test_inquiry_evpd.c
index 9c0a6a7..fb01a80 100644
--- a/test-tool/test_inquiry_evpd.c
+++ b/test-tool/test_inquiry_evpd.c
@@ -28,13 +28,13 @@
void
test_inquiry_evpd(void)
{
- int ret;
+ int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of the INQUIRY EVPD bit");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of the INQUIRY EVPD bit");
- logging(LOG_VERBOSE, "Verify that INQUIRY with EVPD==0 and PC!=0 is an error");
- ret = inquiry(sd, NULL, 0, 1, 256,
- EXPECT_INVALID_FIELD_IN_CDB);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Verify that INQUIRY with EVPD==0 and PC!=0 is an error");
+ ret = inquiry(sd, NULL, 0, 1, 256,
+ EXPECT_INVALID_FIELD_IN_CDB);
+ CU_ASSERT_EQUAL(ret, 0);
}
diff --git a/test-tool/test_inquiry_mandatory_vpd_sbc.c b/test-tool/test_inquiry_mandatory_vpd_sbc.c
index 8fb6ce5..8110034 100644
--- a/test-tool/test_inquiry_mandatory_vpd_sbc.c
+++ b/test-tool/test_inquiry_mandatory_vpd_sbc.c
@@ -28,23 +28,23 @@
void
test_inquiry_mandatory_vpd_sbc(void)
{
- int ret;
+ int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test INQUIRY support for mandatory SBC VPD");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test INQUIRY support for mandatory SBC VPD");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "SUPPORTED_VPD_PAGES is mandatory for SBC devices. Verify we can read it.");
- ret = inquiry(sd, NULL,
- 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "SUPPORTED_VPD_PAGES is mandatory for SBC devices. Verify we can read it.");
+ ret = inquiry(sd, NULL,
+ 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "DEVICE_IDENTIFICATION is mandatory for SBC devices. Verify we can read it.");
- ret = inquiry(sd, NULL,
- 1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION, 255,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "DEVICE_IDENTIFICATION is mandatory for SBC devices. Verify we can read it.");
+ ret = inquiry(sd, NULL,
+ 1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION, 255,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
}
diff --git a/test-tool/test_inquiry_standard.c b/test-tool/test_inquiry_standard.c
index 7f084d2..d89df2b 100644
--- a/test-tool/test_inquiry_standard.c
+++ b/test-tool/test_inquiry_standard.c
@@ -28,150 +28,150 @@
void
test_inquiry_standard(void)
{
- int ret, i;
- struct scsi_inquiry_standard *std_inq;
+ int ret, i;
+ struct scsi_inquiry_standard *std_inq;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of the standard INQUIRY page");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of the standard INQUIRY page");
- logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page");
- /* 260 bytes is the maximum possible size of the standard vpd */
- ret = inquiry(sd, &task, 0, 0, 260,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page");
+ /* 260 bytes is the maximum possible size of the standard vpd */
+ ret = inquiry(sd, &task, 0, 0, 260,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data");
- CU_ASSERT(task->datain.size >= 36);
+ logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data");
+ CU_ASSERT(task->datain.size >= 36);
- logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer");
- std_inq = scsi_datain_unmarshall(task);
- CU_ASSERT_NOT_EQUAL(std_inq, NULL);
- if (std_inq == NULL) {
- logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN "
- "buffer");
- return;
- }
+ logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer");
+ std_inq = scsi_datain_unmarshall(task);
+ CU_ASSERT_NOT_EQUAL(std_inq, NULL);
+ if (std_inq == NULL) {
+ logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN "
+ "buffer");
+ return;
+ }
- logging(LOG_VERBOSE, "Verify peripheral-qualifier is 0");
- CU_ASSERT_EQUAL(std_inq->qualifier, 0);
+ logging(LOG_VERBOSE, "Verify peripheral-qualifier is 0");
+ CU_ASSERT_EQUAL(std_inq->qualifier, 0);
- logging(LOG_VERBOSE, "Verify version field is either 0x4, 0x5 or 0x6");
- switch (std_inq->version) {
- case 0x0:
- logging(LOG_NORMAL, "[WARNING] Standard INQUIRY data claims "
- "conformance to no standard. Version==0. "
- "Bad sport.");
+ logging(LOG_VERBOSE, "Verify version field is either 0x4, 0x5 or 0x6");
+ switch (std_inq->version) {
+ case 0x0:
+ logging(LOG_NORMAL, "[WARNING] Standard INQUIRY data claims "
+ "conformance to no standard. Version==0. "
+ "Bad sport.");
- break;
- case 0x4:
- case 0x5:
- case 0x6:
- break;
- default:
- logging(LOG_NORMAL, "[FAILED] Invalid version in standard "
- "INQUIRY data. Version %d found but only versions "
- "0x4,0x4,0x6 are valid.", std_inq->version);
- CU_FAIL("Invalid version in INQUIRY data");
- }
+ break;
+ case 0x4:
+ case 0x5:
+ case 0x6:
+ break;
+ default:
+ logging(LOG_NORMAL, "[FAILED] Invalid version in standard "
+ "INQUIRY data. Version %d found but only versions "
+ "0x4,0x4,0x6 are valid.", std_inq->version);
+ CU_FAIL("Invalid version in INQUIRY data");
+ }
- logging(LOG_VERBOSE, "Verify response-data-format is 2 "
- "(SPC-2 or later)");
- if (std_inq->response_data_format != 2) {
- logging(LOG_NORMAL, "[FAILED] Response data format is "
- "invalid. Must be 2 but device returned %d",
- std_inq->response_data_format);
- }
- CU_ASSERT_EQUAL(std_inq->response_data_format, 2);
+ logging(LOG_VERBOSE, "Verify response-data-format is 2 "
+ "(SPC-2 or later)");
+ if (std_inq->response_data_format != 2) {
+ logging(LOG_NORMAL, "[FAILED] Response data format is "
+ "invalid. Must be 2 but device returned %d",
+ std_inq->response_data_format);
+ }
+ CU_ASSERT_EQUAL(std_inq->response_data_format, 2);
- logging(LOG_VERBOSE, "Verify additional-length is correct");
- if (std_inq->additional_length > task->datain.size - 5) {
- logging(LOG_NORMAL, "[FAILED] Bad additional length "
- "returned. Should be %d but device returned %d.",
- task->datain.size - 5,
- std_inq->additional_length);
- logging(LOG_NORMAL, "[FAILED] Additional length points "
- "beyond end of data");
- CU_FAIL("Additional length points beyond end of data");
- }
- if (std_inq->additional_length < task->datain.size - 5) {
- logging(LOG_NORMAL, "[WARNING] Bad additional length "
- "returned. Should be %d but device returned %d. ",
- task->datain.size - 5,
- std_inq->additional_length);
- logging(LOG_VERBOSE, "Verify that all padding data is 0");
- for (i = std_inq->additional_length + 6; i < task->datain.size; i++) {
- if (!task->datain.data[i])
- continue;
- logging(LOG_NORMAL, "[FAILED] Padding data is not zero."
- " Are we leaking data?");
- CU_FAIL("Padding data is not zero. Leaking data?");
- }
- }
+ logging(LOG_VERBOSE, "Verify additional-length is correct");
+ if (std_inq->additional_length > task->datain.size - 5) {
+ logging(LOG_NORMAL, "[FAILED] Bad additional length "
+ "returned. Should be %d but device returned %d.",
+ task->datain.size - 5,
+ std_inq->additional_length);
+ logging(LOG_NORMAL, "[FAILED] Additional length points "
+ "beyond end of data");
+ CU_FAIL("Additional length points beyond end of data");
+ }
+ if (std_inq->additional_length < task->datain.size - 5) {
+ logging(LOG_NORMAL, "[WARNING] Bad additional length "
+ "returned. Should be %d but device returned %d. ",
+ task->datain.size - 5,
+ std_inq->additional_length);
+ logging(LOG_VERBOSE, "Verify that all padding data is 0");
+ for (i = std_inq->additional_length + 6; i < task->datain.size; i++) {
+ if (!task->datain.data[i])
+ continue;
+ logging(LOG_NORMAL, "[FAILED] Padding data is not zero."
+ " Are we leaking data?");
+ CU_FAIL("Padding data is not zero. Leaking data?");
+ }
+ }
- logging(LOG_VERBOSE, "Verify VENDOR_IDENTIFICATION is in ASCII");
- for (i = 8; i < 16; i++) {
- /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
- if (task->datain.data[i] == 0) {
- continue;
- }
- if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) {
- continue;
- }
+ logging(LOG_VERBOSE, "Verify VENDOR_IDENTIFICATION is in ASCII");
+ for (i = 8; i < 16; i++) {
+ /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
+ if (task->datain.data[i] == 0) {
+ continue;
+ }
+ if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) {
+ continue;
+ }
- logging(LOG_NORMAL, "[FAILED] VENDOR_IDENTIFICATION contains "
- "non-ASCII characters");
- CU_FAIL("Invalid characters in VENDOR_IDENTIFICATION");
- break;
- }
+ logging(LOG_NORMAL, "[FAILED] VENDOR_IDENTIFICATION contains "
+ "non-ASCII characters");
+ CU_FAIL("Invalid characters in VENDOR_IDENTIFICATION");
+ break;
+ }
- logging(LOG_VERBOSE, "Verify PRODUCT_IDENTIFICATION is in ASCII");
- for (i = 16; i < 32; i++) {
- /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
- if (task->datain.data[i] == 0) {
- continue;
- }
- if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) {
- continue;
- }
+ logging(LOG_VERBOSE, "Verify PRODUCT_IDENTIFICATION is in ASCII");
+ for (i = 16; i < 32; i++) {
+ /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
+ if (task->datain.data[i] == 0) {
+ continue;
+ }
+ if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) {
+ continue;
+ }
- logging(LOG_NORMAL, "[FAILED] PRODUCT_IDENTIFICATION contains "
- "non-ASCII characters");
- CU_FAIL("Invalid characters in PRODUCT_IDENTIFICATION");
- break;
- }
+ logging(LOG_NORMAL, "[FAILED] PRODUCT_IDENTIFICATION contains "
+ "non-ASCII characters");
+ CU_FAIL("Invalid characters in PRODUCT_IDENTIFICATION");
+ break;
+ }
- logging(LOG_VERBOSE, "Verify PRODUCT_REVISION_LEVEL is in ASCII");
- for (i = 32; i < 36; i++) {
- /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
- if (task->datain.data[i] == 0) {
- continue;
- }
- if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) {
- continue;
- }
+ logging(LOG_VERBOSE, "Verify PRODUCT_REVISION_LEVEL is in ASCII");
+ for (i = 32; i < 36; i++) {
+ /* SPC-4 4.4.1 only characters 0x00 and 0x20-0x7E allowed */
+ if (task->datain.data[i] == 0) {
+ continue;
+ }
+ if (task->datain.data[i] >= 0x20 && task->datain.data[i] <= 0x7e) {
+ continue;
+ }
- logging(LOG_NORMAL, "[FAILED] PRODUCT_REVISON_LEVEL contains "
- "non-ASCII characters");
- CU_FAIL("Invalid characters in PRODUCT_REVISON_LEVEL");
- break;
- }
+ logging(LOG_NORMAL, "[FAILED] PRODUCT_REVISON_LEVEL contains "
+ "non-ASCII characters");
+ CU_FAIL("Invalid characters in PRODUCT_REVISON_LEVEL");
+ break;
+ }
- logging(LOG_VERBOSE, "Verify AERC is clear in SPC-3 and later");
- if (task->datain.data[3] & 0x80 && std_inq->version >= 5) {
- logging(LOG_NORMAL, "[FAILED] AERC is set but this device "
- "reports SPC-3 or later.");
- CU_FAIL("AERC is set but SPC-3+ is claimed");
- }
+ logging(LOG_VERBOSE, "Verify AERC is clear in SPC-3 and later");
+ if (task->datain.data[3] & 0x80 && std_inq->version >= 5) {
+ logging(LOG_NORMAL, "[FAILED] AERC is set but this device "
+ "reports SPC-3 or later.");
+ CU_FAIL("AERC is set but SPC-3+ is claimed");
+ }
- logging(LOG_VERBOSE, "Verify TRMTSK is clear in SPC-2 and later");
- if (task->datain.data[3] & 0x40 && std_inq->version >= 4) {
- logging(LOG_NORMAL, "[FAILED] TRMTSK is set but this device "
- "reports SPC-2 or later.");
- CU_FAIL("TRMTSK is set but SPC-2+ is claimed");
- }
+ logging(LOG_VERBOSE, "Verify TRMTSK is clear in SPC-2 and later");
+ if (task->datain.data[3] & 0x40 && std_inq->version >= 4) {
+ logging(LOG_NORMAL, "[FAILED] TRMTSK is set but this device "
+ "reports SPC-2 or later.");
+ CU_FAIL("TRMTSK is set but SPC-2+ is claimed");
+ }
- if (task != NULL) {
- scsi_free_scsi_task(task);
- task = NULL;
- }
+ if (task != NULL) {
+ scsi_free_scsi_task(task);
+ task = NULL;
+ }
}
diff --git a/test-tool/test_inquiry_supported_vpd.c b/test-tool/test_inquiry_supported_vpd.c
index 79d1c3f..1624ccf 100644
--- a/test-tool/test_inquiry_supported_vpd.c
+++ b/test-tool/test_inquiry_supported_vpd.c
@@ -28,42 +28,42 @@
void
test_inquiry_supported_vpd(void)
{
- int ret, i;
- struct scsi_inquiry_supported_pages *sup_inq;
+ int ret, i;
+ struct scsi_inquiry_supported_pages *sup_inq;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test INQUIRY supported VPD pages");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test INQUIRY supported VPD pages");
- logging(LOG_VERBOSE, "Verify we can read the SUPPORTED VPD page");
- ret = inquiry(sd, &task,
- 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Verify we can read the SUPPORTED VPD page");
+ ret = inquiry(sd, &task,
+ 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Verify we got at least 4 bytes of data");
- CU_ASSERT(task->datain.size >= 4);
+ logging(LOG_VERBOSE, "Verify we got at least 4 bytes of data");
+ CU_ASSERT(task->datain.size >= 4);
- logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer");
- sup_inq = scsi_datain_unmarshall(task);
- CU_ASSERT_NOT_EQUAL(sup_inq, NULL);
- if (sup_inq == NULL) {
- logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN "
- "buffer");
- return;
- }
+ logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer");
+ sup_inq = scsi_datain_unmarshall(task);
+ CU_ASSERT_NOT_EQUAL(sup_inq, NULL);
+ if (sup_inq == NULL) {
+ logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN "
+ "buffer");
+ return;
+ }
- logging(LOG_VERBOSE, "Verify we read all the supported pages");
- for (i = 0; i < sup_inq->num_pages; i++) {
- logging(LOG_VERBOSE, "Verify we can read page 0x%02x",
- sup_inq->pages[i]);
+ logging(LOG_VERBOSE, "Verify we read all the supported pages");
+ for (i = 0; i < sup_inq->num_pages; i++) {
+ logging(LOG_VERBOSE, "Verify we can read page 0x%02x",
+ sup_inq->pages[i]);
- ret = inquiry(sd, NULL, 1, sup_inq->pages[i], 255,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ ret = inquiry(sd, NULL, 1, sup_inq->pages[i], 255,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- if (task != NULL) {
- scsi_free_scsi_task(task);
- task = NULL;
- }
+ if (task != NULL) {
+ scsi_free_scsi_task(task);
+ task = NULL;
+ }
}
diff --git a/test-tool/test_inquiry_version_descriptors.c b/test-tool/test_inquiry_version_descriptors.c
index 402b216..f819fa2 100644
--- a/test-tool/test_inquiry_version_descriptors.c
+++ b/test-tool/test_inquiry_version_descriptors.c
@@ -28,80 +28,80 @@
void
test_inquiry_version_descriptors(void)
{
- int i, claimed_ok;
+ int i, claimed_ok;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of the INQUIRY version descriptors");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of the INQUIRY version descriptors");
- switch (inq->device_type) {
- case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS:
- logging(LOG_VERBOSE, "Device is a block device");
+ switch (inq->device_type) {
+ case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS:
+ logging(LOG_VERBOSE, "Device is a block device");
- logging(LOG_VERBOSE, "Verify it claim some version of SPC");
- claimed_ok = 0;
- for (i = 0; i < 8; i++) {
- switch(inq->version_descriptor[i]) {
- case SCSI_VERSION_DESCRIPTOR_SPC:
- case SCSI_VERSION_DESCRIPTOR_SPC_ANSI_INCITS_301_1997:
- case SCSI_VERSION_DESCRIPTOR_SPC_T10_0995_D_R11A:
- case SCSI_VERSION_DESCRIPTOR_SPC_2:
- case SCSI_VERSION_DESCRIPTOR_SPC_2_ISO_IEC_14776_452:
- case SCSI_VERSION_DESCRIPTOR_SPC_2_ANSI_INCITS_351_2001:
- case SCSI_VERSION_DESCRIPTOR_SPC_2_T10_1236_D_R20:
- case SCSI_VERSION_DESCRIPTOR_SPC_2_T10_1236_D_R12:
- case SCSI_VERSION_DESCRIPTOR_SPC_2_T10_1236_D_R18:
- case SCSI_VERSION_DESCRIPTOR_SPC_2_T10_1236_D_R19:
- case SCSI_VERSION_DESCRIPTOR_SPC_3:
- case SCSI_VERSION_DESCRIPTOR_SPC_3_ISO_IEC_14776_453:
- case SCSI_VERSION_DESCRIPTOR_SPC_3_ANSI_INCITS_408_2005:
- case SCSI_VERSION_DESCRIPTOR_SPC_3_T10_1416_D_R7:
- case SCSI_VERSION_DESCRIPTOR_SPC_3_T10_1416_D_R21:
- case SCSI_VERSION_DESCRIPTOR_SPC_3_T10_1416_D_R22:
- case SCSI_VERSION_DESCRIPTOR_SPC_3_T10_1416_D_R23:
- case SCSI_VERSION_DESCRIPTOR_SPC_4:
- case SCSI_VERSION_DESCRIPTOR_SPC_4_T10_1731_D_R16:
- case SCSI_VERSION_DESCRIPTOR_SPC_4_T10_1731_D_R18:
- case SCSI_VERSION_DESCRIPTOR_SPC_4_T10_1731_D_R23:
- claimed_ok = 1;
- break;
- }
- }
- if (claimed_ok == 0) {
- logging(LOG_NORMAL, "[WARNING] Block device "
- "did not claim any version of SPC");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Block device "
- "claimed a version of SPC");
- }
+ logging(LOG_VERBOSE, "Verify it claim some version of SPC");
+ claimed_ok = 0;
+ for (i = 0; i < 8; i++) {
+ switch(inq->version_descriptor[i]) {
+ case SCSI_VERSION_DESCRIPTOR_SPC:
+ case SCSI_VERSION_DESCRIPTOR_SPC_ANSI_INCITS_301_1997:
+ case SCSI_VERSION_DESCRIPTOR_SPC_T10_0995_D_R11A:
+ case SCSI_VERSION_DESCRIPTOR_SPC_2:
+ case SCSI_VERSION_DESCRIPTOR_SPC_2_ISO_IEC_14776_452:
+ case SCSI_VERSION_DESCRIPTOR_SPC_2_ANSI_INCITS_351_2001:
+ case SCSI_VERSION_DESCRIPTOR_SPC_2_T10_1236_D_R20:
+ case SCSI_VERSION_DESCRIPTOR_SPC_2_T10_1236_D_R12:
+ case SCSI_VERSION_DESCRIPTOR_SPC_2_T10_1236_D_R18:
+ case SCSI_VERSION_DESCRIPTOR_SPC_2_T10_1236_D_R19:
+ case SCSI_VERSION_DESCRIPTOR_SPC_3:
+ case SCSI_VERSION_DESCRIPTOR_SPC_3_ISO_IEC_14776_453:
+ case SCSI_VERSION_DESCRIPTOR_SPC_3_ANSI_INCITS_408_2005:
+ case SCSI_VERSION_DESCRIPTOR_SPC_3_T10_1416_D_R7:
+ case SCSI_VERSION_DESCRIPTOR_SPC_3_T10_1416_D_R21:
+ case SCSI_VERSION_DESCRIPTOR_SPC_3_T10_1416_D_R22:
+ case SCSI_VERSION_DESCRIPTOR_SPC_3_T10_1416_D_R23:
+ case SCSI_VERSION_DESCRIPTOR_SPC_4:
+ case SCSI_VERSION_DESCRIPTOR_SPC_4_T10_1731_D_R16:
+ case SCSI_VERSION_DESCRIPTOR_SPC_4_T10_1731_D_R18:
+ case SCSI_VERSION_DESCRIPTOR_SPC_4_T10_1731_D_R23:
+ claimed_ok = 1;
+ break;
+ }
+ }
+ if (claimed_ok == 0) {
+ logging(LOG_NORMAL, "[WARNING] Block device "
+ "did not claim any version of SPC");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Block device "
+ "claimed a version of SPC");
+ }
- logging(LOG_VERBOSE, "Verify it claim some version of SBC");
- claimed_ok = 0;
- for (i = 0; i < 8; i++) {
- switch(inq->version_descriptor[i]) {
- case SCSI_VERSION_DESCRIPTOR_SBC:
- case SCSI_VERSION_DESCRIPTOR_SBC_ANSI_INCITS_306_1998:
- case SCSI_VERSION_DESCRIPTOR_SBC_T10_0996_D_R08C:
- case SCSI_VERSION_DESCRIPTOR_SBC_2:
- case SCSI_VERSION_DESCRIPTOR_SBC_2_ISO_IEC_14776_322:
- case SCSI_VERSION_DESCRIPTOR_SBC_2_ANSI_INCITS_405_2005:
- case SCSI_VERSION_DESCRIPTOR_SBC_2_T10_1417_D_R16:
- case SCSI_VERSION_DESCRIPTOR_SBC_2_T10_1417_D_R5A:
- case SCSI_VERSION_DESCRIPTOR_SBC_2_T10_1417_D_R15:
- case SCSI_VERSION_DESCRIPTOR_SBC_3:
- claimed_ok = 1;
- break;
- }
- }
- if (claimed_ok == 0) {
- logging(LOG_NORMAL, "[WARNING] Block device "
- "did not claim any version of SBC");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Block device "
- "claimed a version of SBC");
- }
- break;
- default:
- logging(LOG_VERBOSE, "No version descriptor tests for device"
- " type %d yet.", inq->device_type);
- }
+ logging(LOG_VERBOSE, "Verify it claim some version of SBC");
+ claimed_ok = 0;
+ for (i = 0; i < 8; i++) {
+ switch(inq->version_descriptor[i]) {
+ case SCSI_VERSION_DESCRIPTOR_SBC:
+ case SCSI_VERSION_DESCRIPTOR_SBC_ANSI_INCITS_306_1998:
+ case SCSI_VERSION_DESCRIPTOR_SBC_T10_0996_D_R08C:
+ case SCSI_VERSION_DESCRIPTOR_SBC_2:
+ case SCSI_VERSION_DESCRIPTOR_SBC_2_ISO_IEC_14776_322:
+ case SCSI_VERSION_DESCRIPTOR_SBC_2_ANSI_INCITS_405_2005:
+ case SCSI_VERSION_DESCRIPTOR_SBC_2_T10_1417_D_R16:
+ case SCSI_VERSION_DESCRIPTOR_SBC_2_T10_1417_D_R5A:
+ case SCSI_VERSION_DESCRIPTOR_SBC_2_T10_1417_D_R15:
+ case SCSI_VERSION_DESCRIPTOR_SBC_3:
+ claimed_ok = 1;
+ break;
+ }
+ }
+ if (claimed_ok == 0) {
+ logging(LOG_NORMAL, "[WARNING] Block device "
+ "did not claim any version of SBC");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Block device "
+ "claimed a version of SBC");
+ }
+ break;
+ default:
+ logging(LOG_VERBOSE, "No version descriptor tests for device"
+ " type %d yet.", inq->device_type);
+ }
}
diff --git a/test-tool/test_iscsi_cmdsn_toohigh.c b/test-tool/test_iscsi_cmdsn_toohigh.c
index 8c5f72e..8a2c4c1 100644
--- a/test-tool/test_iscsi_cmdsn_toohigh.c
+++ b/test-tool/test_iscsi_cmdsn_toohigh.c
@@ -29,62 +29,62 @@ static int change_cmdsn;
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
{
- switch (change_cmdsn) {
- case 1:
- /* change the cmdsn so it becomes too big */
- scsi_set_uint32(&pdu->outdata.data[24], iscsi->maxcmdsn + 1);
- /* fudge the cmdsn value back to where it should be if this
- * pdu is ignored.
- */
- iscsi->cmdsn = iscsi->expcmdsn;
- break;
- }
+ switch (change_cmdsn) {
+ case 1:
+ /* change the cmdsn so it becomes too big */
+ scsi_set_uint32(&pdu->outdata.data[24], iscsi->maxcmdsn + 1);
+ /* fudge the cmdsn value back to where it should be if this
+ * pdu is ignored.
+ */
+ iscsi->cmdsn = iscsi->expcmdsn;
+ break;
+ }
- change_cmdsn = 0;
- return 0;
+ change_cmdsn = 0;
+ return 0;
}
void test_iscsi_cmdsn_toohigh(void)
{
- int ret;
+ int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN");
- logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN");
+ logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN > MAXCMDSN must be silently ignored by the target");
- logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == MAXCMDSN+1. Should be ignored by the target.");
+ logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN > MAXCMDSN must be silently ignored by the target");
+ logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == MAXCMDSN+1. Should be ignored by the target.");
- sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
- sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- change_cmdsn = 1;
- /* we don't want autoreconnect since some targets will incorrectly
- * drop the connection on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- iscsi_set_timeout(sd->iscsi_ctx, 3);
+ sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
+ sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ change_cmdsn = 1;
+ /* we don't want autoreconnect since some targets will incorrectly
+ * drop the connection on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ iscsi_set_timeout(sd->iscsi_ctx, 3);
- ret = testunitready(sd,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, -1);
- if (ret == -1) {
- logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply");
- } else {
- logging(LOG_VERBOSE, "[FAILURE] We got a response from the target but SMDSN was outside of the window.");
- }
+ ret = testunitready(sd,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, -1);
+ if (ret == -1) {
+ logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply");
+ } else {
+ logging(LOG_VERBOSE, "[FAILURE] We got a response from the target but SMDSN was outside of the window.");
+ }
-
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again");
- TESTUNITREADY(sd,
+
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_iscsi_cmdsn_toolow.c b/test-tool/test_iscsi_cmdsn_toolow.c
index e5eef78..60d19a5 100644
--- a/test-tool/test_iscsi_cmdsn_toolow.c
+++ b/test-tool/test_iscsi_cmdsn_toolow.c
@@ -29,63 +29,63 @@ static int change_cmdsn;
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
{
- switch (change_cmdsn) {
- case 1:
- /* change the cmdsn so it becomes too big */
- scsi_set_uint32(&pdu->outdata.data[24], iscsi->expcmdsn - 1);
- /* fudge the cmdsn value back to where it should be if this
- * pdu is ignored.
- */
- iscsi->cmdsn = iscsi->expcmdsn;
- break;
- }
+ switch (change_cmdsn) {
+ case 1:
+ /* change the cmdsn so it becomes too big */
+ scsi_set_uint32(&pdu->outdata.data[24], iscsi->expcmdsn - 1);
+ /* fudge the cmdsn value back to where it should be if this
+ * pdu is ignored.
+ */
+ iscsi->cmdsn = iscsi->expcmdsn;
+ break;
+ }
- change_cmdsn = 0;
- return 0;
+ change_cmdsn = 0;
+ return 0;
}
void test_iscsi_cmdsn_toolow(void)
{
- int ret;
+ int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN");
- logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN");
+ logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN < EXPCMDSN must be silently ignored by the target");
- logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN-1. Should be ignored by the target.");
+ logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN < EXPCMDSN must be silently ignored by the target");
+ logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN-1. Should be ignored by the target.");
- sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
- sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- change_cmdsn = 1;
- /* we don't want autoreconnect since some targets will incorrectly
- * drop the connection on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- iscsi_set_timeout(sd->iscsi_ctx, 3);
+ sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
+ sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ change_cmdsn = 1;
+ /* we don't want autoreconnect since some targets will incorrectly
+ * drop the connection on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ iscsi_set_timeout(sd->iscsi_ctx, 3);
- ret = testunitready(sd,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, -1);
- if (ret == -1) {
- logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply");
- } else {
- logging(LOG_VERBOSE, "[FAILURE] We got a response from the target but SMDSN was outside of the window.");
- }
+ ret = testunitready(sd,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, -1);
+ if (ret == -1) {
+ logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply");
+ } else {
+ logging(LOG_VERBOSE, "[FAILURE] We got a response from the target but SMDSN was outside of the window.");
+ }
-
+
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again");
- TESTUNITREADY(sd,
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_iscsi_datasn_invalid.c b/test-tool/test_iscsi_datasn_invalid.c
index db04777..8ad1e19 100644
--- a/test-tool/test_iscsi_datasn_invalid.c
+++ b/test-tool/test_iscsi_datasn_invalid.c
@@ -29,142 +29,142 @@ static int change_datasn;
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu _U_)
{
- uint32_t datasn;
+ uint32_t datasn;
- if (pdu->outdata.data[0] != ISCSI_PDU_DATA_OUT) {
- return 0;
- }
- switch (change_datasn) {
- case 1:
- /* change DataSN to 0 */
- scsi_set_uint32(&pdu->outdata.data[36], 0);
- break;
- case 2:
- /* change DataSN to 27 */
- scsi_set_uint32(&pdu->outdata.data[36], 27);
- break;
- case 3:
- /* change DataSN to -1 */
- scsi_set_uint32(&pdu->outdata.data[36], -1);
- break;
- case 4:
- /* change DataSN from (0,1) to (1,0) */
- datasn = scsi_get_uint32(&pdu->outdata.data[36]);
- scsi_set_uint32(&pdu->outdata.data[36], 1 - datasn);
- break;
- }
- return 0;
+ if (pdu->outdata.data[0] != ISCSI_PDU_DATA_OUT) {
+ return 0;
+ }
+ switch (change_datasn) {
+ case 1:
+ /* change DataSN to 0 */
+ scsi_set_uint32(&pdu->outdata.data[36], 0);
+ break;
+ case 2:
+ /* change DataSN to 27 */
+ scsi_set_uint32(&pdu->outdata.data[36], 27);
+ break;
+ case 3:
+ /* change DataSN to -1 */
+ scsi_set_uint32(&pdu->outdata.data[36], -1);
+ break;
+ case 4:
+ /* change DataSN from (0,1) to (1,0) */
+ datasn = scsi_get_uint32(&pdu->outdata.data[36]);
+ scsi_set_uint32(&pdu->outdata.data[36], 1 - datasn);
+ break;
+ }
+ return 0;
}
void test_iscsi_datasn_invalid(void)
{
- int ret;
+ int ret;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test sending invalid iSCSI DataSN");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test sending invalid iSCSI DataSN");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Send two Data-Out PDU's with DataSN==0. Should fail.");
- change_datasn = 1;
+ logging(LOG_VERBOSE, "Send two Data-Out PDU's with DataSN==0. Should fail.");
+ change_datasn = 1;
- sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
- sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- iscsi_set_timeout(sd->iscsi_ctx, 3);
+ sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
+ sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ iscsi_set_timeout(sd->iscsi_ctx, 3);
- memset(scratch, 0xa6, 2 * block_size);
+ memset(scratch, 0xa6, 2 * block_size);
- ret = write10(sd, 100, 2 * block_size,
- block_size, 0, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
- CU_PASS("WRITE10 is not implemented.");
- local_iscsi_queue_pdu = NULL;
- return;
- }
- CU_ASSERT_NOT_EQUAL(ret, 0);
+ ret = write10(sd, 100, 2 * block_size,
+ block_size, 0, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
+ CU_PASS("WRITE10 is not implemented.");
+ local_iscsi_queue_pdu = NULL;
+ return;
+ }
+ CU_ASSERT_NOT_EQUAL(ret, 0);
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Send Data-Out PDU with DataSN==27. Should fail");
- change_datasn = 2;
+ logging(LOG_VERBOSE, "Send Data-Out PDU with DataSN==27. Should fail");
+ change_datasn = 2;
- sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
- sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- iscsi_set_timeout(sd->iscsi_ctx, 3);
+ sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
+ sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ iscsi_set_timeout(sd->iscsi_ctx, 3);
- ret = write10(sd, 100, block_size,
- block_size, 0, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
- CU_PASS("WRITE10 is not implemented.");
- local_iscsi_queue_pdu = NULL;
- return;
- }
- CU_ASSERT_NOT_EQUAL(ret, 0);
+ ret = write10(sd, 100, block_size,
+ block_size, 0, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
+ CU_PASS("WRITE10 is not implemented.");
+ local_iscsi_queue_pdu = NULL;
+ return;
+ }
+ CU_ASSERT_NOT_EQUAL(ret, 0);
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Send Data-Out PDU with DataSN==-1. Should fail");
- change_datasn = 3;
+ logging(LOG_VERBOSE, "Send Data-Out PDU with DataSN==-1. Should fail");
+ change_datasn = 3;
- sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
- sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- iscsi_set_timeout(sd->iscsi_ctx, 3);
+ sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
+ sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ iscsi_set_timeout(sd->iscsi_ctx, 3);
- ret = write10(sd, 100, block_size,
- block_size, 0, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
- CU_PASS("WRITE10 is not implemented.");
- local_iscsi_queue_pdu = NULL;
- return;
- }
- CU_ASSERT_NOT_EQUAL(ret, 0);
+ ret = write10(sd, 100, block_size,
+ block_size, 0, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
+ CU_PASS("WRITE10 is not implemented.");
+ local_iscsi_queue_pdu = NULL;
+ return;
+ }
+ CU_ASSERT_NOT_EQUAL(ret, 0);
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Send Data-Out PDU's in reverse order (DataSN == 1,0). Should fail");
- change_datasn = 4;
+ logging(LOG_VERBOSE, "Send Data-Out PDU's in reverse order (DataSN == 1,0). Should fail");
+ change_datasn = 4;
- sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
- sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- iscsi_set_timeout(sd->iscsi_ctx, 3);
+ sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
+ sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ iscsi_set_timeout(sd->iscsi_ctx, 3);
- ret = write10(sd, 100, 2 * block_size,
- block_size, 0, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
- CU_PASS("WRITE10 is not implemented.");
- local_iscsi_queue_pdu = NULL;
- return;
- }
- CU_ASSERT_NOT_EQUAL(ret, 0);
+ ret = write10(sd, 100, 2 * block_size,
+ block_size, 0, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
+ CU_PASS("WRITE10 is not implemented.");
+ local_iscsi_queue_pdu = NULL;
+ return;
+ }
+ CU_ASSERT_NOT_EQUAL(ret, 0);
- local_iscsi_queue_pdu = NULL;
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ local_iscsi_queue_pdu = NULL;
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
}
diff --git a/test-tool/test_mandatory_sbc.c b/test-tool/test_mandatory_sbc.c
index 3f5bd28..ed6a12c 100644
--- a/test-tool/test_mandatory_sbc.c
+++ b/test-tool/test_mandatory_sbc.c
@@ -28,48 +28,48 @@
void
test_mandatory_sbc(void)
{
- int ret;
- //unsigned char buf[4096];
- //struct unmap_list list[1];
+ int ret;
+ //unsigned char buf[4096];
+ //struct unmap_list list[1];
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test support for all mandatory opcodes on SBC devices");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test support for all mandatory opcodes on SBC devices");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Test INQUIRY.");
- ret = inquiry(sd, NULL, 0, 0, 255,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Test INQUIRY.");
+ ret = inquiry(sd, NULL, 0, 0, 255,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Test READCAPACITY10.");
- ret = readcapacity10(sd, NULL, 0, 0,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Test READCAPACITY10.");
+ ret = readcapacity10(sd, NULL, 0, 0,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- if (sbc3_support) {
- logging(LOG_VERBOSE, "Test READCAPACITY16. The device claims SBC-3 support.");
- ret = readcapacity16(sd, NULL, 15,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ if (sbc3_support) {
+ logging(LOG_VERBOSE, "Test READCAPACITY16. The device claims SBC-3 support.");
+ ret = readcapacity16(sd, NULL, 15,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- logging(LOG_VERBOSE, "Test READ10.");
- ret = read10(sd, NULL, 0, block_size, block_size,
- 0, 0, 0, 0, 0, NULL,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Test READ10.");
+ ret = read10(sd, NULL, 0, block_size, block_size,
+ 0, 0, 0, 0, 0, NULL,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- if (sbc3_support) {
- logging(LOG_VERBOSE, "Test READ16. the device claims SBC-3 support.");
- ret = read16(sd, NULL, 0, block_size, block_size,
- 0, 0, 0, 0, 0, NULL,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ if (sbc3_support) {
+ logging(LOG_VERBOSE, "Test READ16. the device claims SBC-3 support.");
+ ret = read16(sd, NULL, 0, block_size, block_size,
+ 0, 0, 0, 0, 0, NULL,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- logging(LOG_VERBOSE, "Test TESTUNITREADY.");
- ret = testunitready(sd,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Test TESTUNITREADY.");
+ ret = testunitready(sd,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
}
diff --git a/test-tool/test_modesense6_all_pages.c b/test-tool/test_modesense6_all_pages.c
index bef4c43..1065ad4 100644
--- a/test-tool/test_modesense6_all_pages.c
+++ b/test-tool/test_modesense6_all_pages.c
@@ -28,39 +28,39 @@
void
test_modesense6_all_pages(void)
{
- struct scsi_mode_sense *ms;
- struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *ms_task = NULL;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of MODESENSE6 AllPages");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of MODESENSE6 AllPages");
- logging(LOG_VERBOSE, "Send MODESENSE6 command to fetch AllPages");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Send MODESENSE6 command to fetch AllPages");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
+ logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
- logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
- ms = scsi_datain_unmarshall(ms_task);
- if (ms == NULL) {
- logging(LOG_VERBOSE, "[FAILED] failed to unmarshall mode sense "
- "datain buffer");
- CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
- scsi_free_scsi_task(ms_task);
- return;
- }
- logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
+ logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
+ ms = scsi_datain_unmarshall(ms_task);
+ if (ms == NULL) {
+ logging(LOG_VERBOSE, "[FAILED] failed to unmarshall mode sense "
+ "datain buffer");
+ CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
+ scsi_free_scsi_task(ms_task);
+ return;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
- logging(LOG_VERBOSE, "Verify that mode data length is >= 3");
- if (ms->mode_data_length >= 3) {
- logging(LOG_VERBOSE, "[SUCCESS] Mode data length is >= 3");
- } else {
- logging(LOG_VERBOSE, "[FAILED] Mode data length is < 3");
- }
- CU_ASSERT_TRUE(ms->mode_data_length >= 3);
+ logging(LOG_VERBOSE, "Verify that mode data length is >= 3");
+ if (ms->mode_data_length >= 3) {
+ logging(LOG_VERBOSE, "[SUCCESS] Mode data length is >= 3");
+ } else {
+ logging(LOG_VERBOSE, "[FAILED] Mode data length is < 3");
+ }
+ CU_ASSERT_TRUE(ms->mode_data_length >= 3);
- scsi_free_scsi_task(ms_task);
+ scsi_free_scsi_task(ms_task);
}
diff --git a/test-tool/test_modesense6_control.c b/test-tool/test_modesense6_control.c
index 7160e0d..02d6efa 100644
--- a/test-tool/test_modesense6_control.c
+++ b/test-tool/test_modesense6_control.c
@@ -28,213 +28,213 @@
void
test_modesense6_control(void)
{
- struct scsi_mode_sense *ms;
- struct scsi_mode_page *ap_page;
- struct scsi_mode_page *ct_page;
- struct scsi_task *ap_task = NULL;
- struct scsi_task *ct_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_mode_page *ap_page;
+ struct scsi_mode_page *ct_page;
+ struct scsi_task *ap_task = NULL;
+ struct scsi_task *ct_task = NULL;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of MODESENSE6 CONTROL page");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of MODESENSE6 CONTROL page");
- logging(LOG_VERBOSE, "Fetch the CONTROL page via AllPages");
- logging(LOG_VERBOSE, "Send MODESENSE6 command to fetch AllPages");
- MODESENSE6(sd, &ap_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Fetch the CONTROL page via AllPages");
+ logging(LOG_VERBOSE, "Send MODESENSE6 command to fetch AllPages");
+ MODESENSE6(sd, &ap_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
+ logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
- logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
- ms = scsi_datain_unmarshall(ap_task);
- if (ms == NULL) {
- logging(LOG_NORMAL, "[FAILED] failed to unmarshall mode sense "
- "datain buffer");
- CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
+ logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
+ ms = scsi_datain_unmarshall(ap_task);
+ if (ms == NULL) {
+ logging(LOG_NORMAL, "[FAILED] failed to unmarshall mode sense "
+ "datain buffer");
+ CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
- logging(LOG_VERBOSE, "Verify that mode data length is >= 3");
- if (ms->mode_data_length >= 3) {
- logging(LOG_VERBOSE, "[SUCCESS] Mode data length is >= 3");
- } else {
- logging(LOG_NORMAL, "[FAILED] Mode data length is < 3");
- }
- CU_ASSERT_TRUE(ms->mode_data_length >= 3);
+ logging(LOG_VERBOSE, "Verify that mode data length is >= 3");
+ if (ms->mode_data_length >= 3) {
+ logging(LOG_VERBOSE, "[SUCCESS] Mode data length is >= 3");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] Mode data length is < 3");
+ }
+ CU_ASSERT_TRUE(ms->mode_data_length >= 3);
- for (ap_page = ms->pages; ap_page; ap_page = ap_page->next) {
- if (ap_page->page_code == SCSI_MODEPAGE_CONTROL &&
- ap_page->spf == 0) {
- break;
- }
- }
- if(ap_page == NULL) {
- logging(LOG_NORMAL, "[WARNING] CONTROL page was not returned "
- "from AllPages. All devices SHOULD implement this "
- "page.");
- }
+ for (ap_page = ms->pages; ap_page; ap_page = ap_page->next) {
+ if (ap_page->page_code == SCSI_MODEPAGE_CONTROL &&
+ ap_page->spf == 0) {
+ break;
+ }
+ }
+ if(ap_page == NULL) {
+ logging(LOG_NORMAL, "[WARNING] CONTROL page was not returned "
+ "from AllPages. All devices SHOULD implement this "
+ "page.");
+ }
- logging(LOG_VERBOSE, "Fetch the CONTROL page directly");
- logging(LOG_VERBOSE, "Send MODESENSE6 command to fetch CONTROL");
- MODESENSE6(sd, &ct_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Fetch the CONTROL page directly");
+ logging(LOG_VERBOSE, "Send MODESENSE6 command to fetch CONTROL");
+ MODESENSE6(sd, &ct_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_CONTROL, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
+ logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
- logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
- ms = scsi_datain_unmarshall(ct_task);
- if (ms == NULL) {
- logging(LOG_NORMAL, "[FAILED] failed to unmarshall mode sense "
- "datain buffer");
- CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
+ logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
+ ms = scsi_datain_unmarshall(ct_task);
+ if (ms == NULL) {
+ logging(LOG_NORMAL, "[FAILED] failed to unmarshall mode sense "
+ "datain buffer");
+ CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
- logging(LOG_VERBOSE, "Verify that mode data length is >= 3");
- if (ms->mode_data_length >= 3) {
- logging(LOG_VERBOSE, "[SUCCESS] Mode data length is >= 3");
- } else {
- logging(LOG_NORMAL, "[FAILED] Mode data length is < 3");
- }
- CU_ASSERT_TRUE(ms->mode_data_length >= 3);
+ logging(LOG_VERBOSE, "Verify that mode data length is >= 3");
+ if (ms->mode_data_length >= 3) {
+ logging(LOG_VERBOSE, "[SUCCESS] Mode data length is >= 3");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] Mode data length is < 3");
+ }
+ CU_ASSERT_TRUE(ms->mode_data_length >= 3);
- for (ct_page = ms->pages; ct_page; ct_page = ct_page->next) {
- if (ct_page->page_code == SCSI_MODEPAGE_CONTROL) {
- break;
- }
- }
- if(ct_page == NULL) {
- logging(LOG_NORMAL, "[WARNING] CONTROL page was not returned."
- "All devices SHOULD implement this page.");
- }
+ for (ct_page = ms->pages; ct_page; ct_page = ct_page->next) {
+ if (ct_page->page_code == SCSI_MODEPAGE_CONTROL) {
+ break;
+ }
+ }
+ if(ct_page == NULL) {
+ logging(LOG_NORMAL, "[WARNING] CONTROL page was not returned."
+ "All devices SHOULD implement this page.");
+ }
- if (ap_page == NULL && ct_page != NULL) {
- logging(LOG_NORMAL, "[FAILED] CONTROL page was not returned "
- "from AllPages.");
- CU_FAIL("[FAILED] CONTROL page is missing from AllPages");
- goto finished;
- }
+ if (ap_page == NULL && ct_page != NULL) {
+ logging(LOG_NORMAL, "[FAILED] CONTROL page was not returned "
+ "from AllPages.");
+ CU_FAIL("[FAILED] CONTROL page is missing from AllPages");
+ goto finished;
+ }
- if (ap_page != NULL && ct_page == NULL) {
- logging(LOG_NORMAL, "[FAILED] CONTROL page is only available "
- "from AllPages but not directly.");
- CU_FAIL("[FAILED] CONTROL page is missing");
- goto finished;
- }
+ if (ap_page != NULL && ct_page == NULL) {
+ logging(LOG_NORMAL, "[FAILED] CONTROL page is only available "
+ "from AllPages but not directly.");
+ CU_FAIL("[FAILED] CONTROL page is missing");
+ goto finished;
+ }
- if (ct_page == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] CONTROL page is not "
- "implemented.");
- CU_PASS("CONTROL page is not implemented.");
- goto finished;
- }
+ if (ct_page == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] CONTROL page is not "
+ "implemented.");
+ CU_PASS("CONTROL page is not implemented.");
+ goto finished;
+ }
- logging(LOG_VERBOSE, "Verify that the two pages are identical.");
+ logging(LOG_VERBOSE, "Verify that the two pages are identical.");
- logging(LOG_VERBOSE, "Check TST field");
- CU_ASSERT_EQUAL(ct_page->control.tst, ap_page->control.tst);
- logging(LOG_VERBOSE, "Check TMF_ONLY field");
- CU_ASSERT_EQUAL(ct_page->control.tmf_only, ap_page->control.tmf_only);
- logging(LOG_VERBOSE, "Check dpicz field");
- CU_ASSERT_EQUAL(ct_page->control.dpicz, ap_page->control.dpicz);
- logging(LOG_VERBOSE, "Check d_sense field");
- CU_ASSERT_EQUAL(ct_page->control.d_sense, ap_page->control.d_sense);
- logging(LOG_VERBOSE, "Check gltsd field");
- CU_ASSERT_EQUAL(ct_page->control.gltsd, ap_page->control.gltsd);
- logging(LOG_VERBOSE, "Check rlec field");
- CU_ASSERT_EQUAL(ct_page->control.rlec, ap_page->control.rlec);
- logging(LOG_VERBOSE, "Check queue_algorithm_modifier field");
- CU_ASSERT_EQUAL(ct_page->control.queue_algorithm_modifier,
- ap_page->control.queue_algorithm_modifier);
- logging(LOG_VERBOSE, "Check nuar field");
- CU_ASSERT_EQUAL(ct_page->control.nuar, ap_page->control.nuar);
- logging(LOG_VERBOSE, "Check qerr field");
- CU_ASSERT_EQUAL(ct_page->control.qerr, ap_page->control.qerr);
- logging(LOG_VERBOSE, "Check vs field");
- CU_ASSERT_EQUAL(ct_page->control.vs, ap_page->control.vs);
- logging(LOG_VERBOSE, "Check rac field");
- CU_ASSERT_EQUAL(ct_page->control.rac, ap_page->control.rac);
- logging(LOG_VERBOSE, "Check ua_intlck_ctrl field");
- CU_ASSERT_EQUAL(ct_page->control.ua_intlck_ctrl,
- ap_page->control.ua_intlck_ctrl);
- logging(LOG_VERBOSE, "Check swp field");
- CU_ASSERT_EQUAL(ct_page->control.swp, ap_page->control.swp);
- logging(LOG_VERBOSE, "Check ato field");
- CU_ASSERT_EQUAL(ct_page->control.ato, ap_page->control.ato);
- logging(LOG_VERBOSE, "Check tas field");
- CU_ASSERT_EQUAL(ct_page->control.tas, ap_page->control.tas);
- logging(LOG_VERBOSE, "Check atmpe field");
- CU_ASSERT_EQUAL(ct_page->control.atmpe, ap_page->control.atmpe);
- logging(LOG_VERBOSE, "Check rwwp field");
- CU_ASSERT_EQUAL(ct_page->control.rwwp, ap_page->control.rwwp);
- logging(LOG_VERBOSE, "Check autoload_mode field");
- CU_ASSERT_EQUAL(ct_page->control.autoload_mode,
- ap_page->control.autoload_mode);
- logging(LOG_VERBOSE, "Check busy_timeout_period field");
- CU_ASSERT_EQUAL(ct_page->control.busy_timeout_period,
- ap_page->control.busy_timeout_period);
- logging(LOG_VERBOSE, "Check extended_selftest_completion_time field");
- CU_ASSERT_EQUAL(ct_page->control.extended_selftest_completion_time,
- ap_page->control.extended_selftest_completion_time);
+ logging(LOG_VERBOSE, "Check TST field");
+ CU_ASSERT_EQUAL(ct_page->control.tst, ap_page->control.tst);
+ logging(LOG_VERBOSE, "Check TMF_ONLY field");
+ CU_ASSERT_EQUAL(ct_page->control.tmf_only, ap_page->control.tmf_only);
+ logging(LOG_VERBOSE, "Check dpicz field");
+ CU_ASSERT_EQUAL(ct_page->control.dpicz, ap_page->control.dpicz);
+ logging(LOG_VERBOSE, "Check d_sense field");
+ CU_ASSERT_EQUAL(ct_page->control.d_sense, ap_page->control.d_sense);
+ logging(LOG_VERBOSE, "Check gltsd field");
+ CU_ASSERT_EQUAL(ct_page->control.gltsd, ap_page->control.gltsd);
+ logging(LOG_VERBOSE, "Check rlec field");
+ CU_ASSERT_EQUAL(ct_page->control.rlec, ap_page->control.rlec);
+ logging(LOG_VERBOSE, "Check queue_algorithm_modifier field");
+ CU_ASSERT_EQUAL(ct_page->control.queue_algorithm_modifier,
+ ap_page->control.queue_algorithm_modifier);
+ logging(LOG_VERBOSE, "Check nuar field");
+ CU_ASSERT_EQUAL(ct_page->control.nuar, ap_page->control.nuar);
+ logging(LOG_VERBOSE, "Check qerr field");
+ CU_ASSERT_EQUAL(ct_page->control.qerr, ap_page->control.qerr);
+ logging(LOG_VERBOSE, "Check vs field");
+ CU_ASSERT_EQUAL(ct_page->control.vs, ap_page->control.vs);
+ logging(LOG_VERBOSE, "Check rac field");
+ CU_ASSERT_EQUAL(ct_page->control.rac, ap_page->control.rac);
+ logging(LOG_VERBOSE, "Check ua_intlck_ctrl field");
+ CU_ASSERT_EQUAL(ct_page->control.ua_intlck_ctrl,
+ ap_page->control.ua_intlck_ctrl);
+ logging(LOG_VERBOSE, "Check swp field");
+ CU_ASSERT_EQUAL(ct_page->control.swp, ap_page->control.swp);
+ logging(LOG_VERBOSE, "Check ato field");
+ CU_ASSERT_EQUAL(ct_page->control.ato, ap_page->control.ato);
+ logging(LOG_VERBOSE, "Check tas field");
+ CU_ASSERT_EQUAL(ct_page->control.tas, ap_page->control.tas);
+ logging(LOG_VERBOSE, "Check atmpe field");
+ CU_ASSERT_EQUAL(ct_page->control.atmpe, ap_page->control.atmpe);
+ logging(LOG_VERBOSE, "Check rwwp field");
+ CU_ASSERT_EQUAL(ct_page->control.rwwp, ap_page->control.rwwp);
+ logging(LOG_VERBOSE, "Check autoload_mode field");
+ CU_ASSERT_EQUAL(ct_page->control.autoload_mode,
+ ap_page->control.autoload_mode);
+ logging(LOG_VERBOSE, "Check busy_timeout_period field");
+ CU_ASSERT_EQUAL(ct_page->control.busy_timeout_period,
+ ap_page->control.busy_timeout_period);
+ logging(LOG_VERBOSE, "Check extended_selftest_completion_time field");
+ CU_ASSERT_EQUAL(ct_page->control.extended_selftest_completion_time,
+ ap_page->control.extended_selftest_completion_time);
- logging(LOG_VERBOSE, "Verify that the values are sane.");
- logging(LOG_VERBOSE, "Check that TST is 0 or 1.");
- if (ct_page->control.tst > 1) {
- logging(LOG_NORMAL, "[FAILED] TST value is invalid. Must be "
- "0, 1 but was %d", ct_page->control.tst);
- CU_FAIL("[FAILED] TST is invalid.");
- }
- logging(LOG_VERBOSE, "Check that QUEUE_ALGORITHM_MODIFIER is "
- "0, 1 or >7");
- if (ct_page->control.queue_algorithm_modifier > 1 &&
- ct_page->control.queue_algorithm_modifier < 8) {
- logging(LOG_NORMAL, "[FAILED] QUEUE_ALGORITHM_MODIFIER value "
- "is invalid. Must be 0, 1 or >7 but was %d",
- ct_page->control.queue_algorithm_modifier);
- CU_FAIL("[FAILED] QUEUE_ALGORITHM_MODIFIER is invalid.");
- }
+ logging(LOG_VERBOSE, "Verify that the values are sane.");
+ logging(LOG_VERBOSE, "Check that TST is 0 or 1.");
+ if (ct_page->control.tst > 1) {
+ logging(LOG_NORMAL, "[FAILED] TST value is invalid. Must be "
+ "0, 1 but was %d", ct_page->control.tst);
+ CU_FAIL("[FAILED] TST is invalid.");
+ }
+ logging(LOG_VERBOSE, "Check that QUEUE_ALGORITHM_MODIFIER is "
+ "0, 1 or >7");
+ if (ct_page->control.queue_algorithm_modifier > 1 &&
+ ct_page->control.queue_algorithm_modifier < 8) {
+ logging(LOG_NORMAL, "[FAILED] QUEUE_ALGORITHM_MODIFIER value "
+ "is invalid. Must be 0, 1 or >7 but was %d",
+ ct_page->control.queue_algorithm_modifier);
+ CU_FAIL("[FAILED] QUEUE_ALGORITHM_MODIFIER is invalid.");
+ }
- logging(LOG_VERBOSE, "Check that QERR is not 2");
- if (ct_page->control.qerr == 2) {
- logging(LOG_NORMAL, "[FAILED] QERR value "
- "is invalid. Can not be 2");
- CU_FAIL("[FAILED] QERR is invalid.");
- }
+ logging(LOG_VERBOSE, "Check that QERR is not 2");
+ if (ct_page->control.qerr == 2) {
+ logging(LOG_NORMAL, "[FAILED] QERR value "
+ "is invalid. Can not be 2");
+ CU_FAIL("[FAILED] QERR is invalid.");
+ }
- logging(LOG_VERBOSE, "Check that UA_INTLCK_CTRL is not 1");
- if (ct_page->control.ua_intlck_ctrl == 1) {
- logging(LOG_NORMAL, "[FAILED] UA_INTLCK_CTRL value "
- "is invalid. Can not be 1");
- CU_FAIL("[FAILED] UA_INTLCK_CTRL is invalid.");
- }
+ logging(LOG_VERBOSE, "Check that UA_INTLCK_CTRL is not 1");
+ if (ct_page->control.ua_intlck_ctrl == 1) {
+ logging(LOG_NORMAL, "[FAILED] UA_INTLCK_CTRL value "
+ "is invalid. Can not be 1");
+ CU_FAIL("[FAILED] UA_INTLCK_CTRL is invalid.");
+ }
- logging(LOG_VERBOSE, "Check that AUTOLOAD is 0, 1 or 2");
- if (ct_page->control.autoload_mode > 2) {
- logging(LOG_NORMAL, "[FAILED] AUTOLOAD value "
- "is invalid. Must be 0, 1 or 2 but was %d",
- ct_page->control.autoload_mode);
- CU_FAIL("[FAILED] AUTOLOAD is invalid.");
- }
+ logging(LOG_VERBOSE, "Check that AUTOLOAD is 0, 1 or 2");
+ if (ct_page->control.autoload_mode > 2) {
+ logging(LOG_NORMAL, "[FAILED] AUTOLOAD value "
+ "is invalid. Must be 0, 1 or 2 but was %d",
+ ct_page->control.autoload_mode);
+ CU_FAIL("[FAILED] AUTOLOAD is invalid.");
+ }
- logging(LOG_VERBOSE, "Check that BUSY_TIMEOUT_PERIOD is specified");
- if (ct_page->control.busy_timeout_period == 0) {
- logging(LOG_NORMAL, "[WARNING] BUSY_TIMEOUT_PERIOD is "
- "undefined.");
- }
+ logging(LOG_VERBOSE, "Check that BUSY_TIMEOUT_PERIOD is specified");
+ if (ct_page->control.busy_timeout_period == 0) {
+ logging(LOG_NORMAL, "[WARNING] BUSY_TIMEOUT_PERIOD is "
+ "undefined.");
+ }
finished:
- if (ap_task != NULL) {
- scsi_free_scsi_task(ap_task);
- }
- if (ct_task != NULL) {
- scsi_free_scsi_task(ct_task);
- }
+ if (ap_task != NULL) {
+ scsi_free_scsi_task(ap_task);
+ }
+ if (ct_task != NULL) {
+ scsi_free_scsi_task(ct_task);
+ }
}
diff --git a/test-tool/test_modesense6_control_d_sense.c b/test-tool/test_modesense6_control_d_sense.c
index cdcd7b4..3905cb3 100644
--- a/test-tool/test_modesense6_control_d_sense.c
+++ b/test-tool/test_modesense6_control_d_sense.c
@@ -29,86 +29,86 @@
void
test_modesense6_control_d_sense(void)
{
- struct scsi_task *ms_task = NULL;
- struct scsi_task *r16_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_mode_page *page;
- int ret;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_task *r16_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_mode_page *page;
+ int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of MODESENSE6 CONTROL D_SENSE flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of MODESENSE6 CONTROL D_SENSE flag");
- logging(LOG_VERBOSE, "Read the CONTROL page from the device");
- ret = modesense6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
- SCSI_MODEPAGE_CONTROL, 0, 255,
- EXPECT_STATUS_GOOD);
- if (ret != 0) {
- logging(LOG_NORMAL,"[WARNING] Could not read "
- "BlockDeviceCharacteristics.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
+ logging(LOG_VERBOSE, "Read the CONTROL page from the device");
+ ret = modesense6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ SCSI_MODEPAGE_CONTROL, 0, 255,
+ EXPECT_STATUS_GOOD);
+ if (ret != 0) {
+ logging(LOG_NORMAL,"[WARNING] Could not read "
+ "BlockDeviceCharacteristics.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
- logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
- ms = scsi_datain_unmarshall(ms_task);
- if (ms == NULL) {
- logging(LOG_NORMAL, "[FAILED] failed to unmarshall mode sense "
- "datain buffer");
- CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
- for (page = ms->pages; page; page = page->next) {
- if (page->page_code == SCSI_MODEPAGE_CONTROL) {
- break;
- }
- }
- if(page == NULL) {
- logging(LOG_NORMAL, "[WARNING] CONTROL page was not returned."
- "All devices SHOULD implement this page.");
- CU_PASS("[SKIPPED] CONTROL page not reported");
- goto finished;
- }
- logging(LOG_VERBOSE, "Send a READ16 that will fail so we can check "
- "the type of sense data returned");
- READ16(sd, &r16_task, 0xffffffffffffffffLL, block_size, block_size, 0,
+ logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
+ ms = scsi_datain_unmarshall(ms_task);
+ if (ms == NULL) {
+ logging(LOG_NORMAL, "[FAILED] failed to unmarshall mode sense "
+ "datain buffer");
+ CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
+ for (page = ms->pages; page; page = page->next) {
+ if (page->page_code == SCSI_MODEPAGE_CONTROL) {
+ break;
+ }
+ }
+ if(page == NULL) {
+ logging(LOG_NORMAL, "[WARNING] CONTROL page was not returned."
+ "All devices SHOULD implement this page.");
+ CU_PASS("[SKIPPED] CONTROL page not reported");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "Send a READ16 that will fail so we can check "
+ "the type of sense data returned");
+ READ16(sd, &r16_task, 0xffffffffffffffffLL, block_size, block_size, 0,
0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- if (page->control.d_sense) {
- logging(LOG_VERBOSE, "D_SENSE is set, verify that sense format "
- "is descriptor format");
- } else {
- logging(LOG_VERBOSE, "D_SENSE is clear, verify that sense format "
- "is fixed format");
- }
- switch (r16_task->sense.error_type) {
- case SCSI_SENSE_DESCRIPTOR_CURRENT:
- case SCSI_SENSE_DESCRIPTOR_DEFERRED_ERRORS:
- if (!page->control.d_sense) {
- logging(LOG_NORMAL, "[FAILED] D_SENSE is set but "
- "returned sense is not descriptor format");
- CU_FAIL("[FAILED] Wrong type of sense format returned");
- goto finished;
- }
- break;
- case SCSI_SENSE_FIXED_CURRENT:
- case SCSI_SENSE_FIXED_DEFERRED_ERRORS:
- if (page->control.d_sense) {
- logging(LOG_NORMAL, "[FAILED] D_SENSE is cleat but "
- "returned sense is not fixed format");
- CU_FAIL("[FAILED] Wrong type of sense format returned");
- goto finished;
- }
- break;
- }
+ if (page->control.d_sense) {
+ logging(LOG_VERBOSE, "D_SENSE is set, verify that sense format "
+ "is descriptor format");
+ } else {
+ logging(LOG_VERBOSE, "D_SENSE is clear, verify that sense format "
+ "is fixed format");
+ }
+ switch (r16_task->sense.error_type) {
+ case SCSI_SENSE_DESCRIPTOR_CURRENT:
+ case SCSI_SENSE_DESCRIPTOR_DEFERRED_ERRORS:
+ if (!page->control.d_sense) {
+ logging(LOG_NORMAL, "[FAILED] D_SENSE is set but "
+ "returned sense is not descriptor format");
+ CU_FAIL("[FAILED] Wrong type of sense format returned");
+ goto finished;
+ }
+ break;
+ case SCSI_SENSE_FIXED_CURRENT:
+ case SCSI_SENSE_FIXED_DEFERRED_ERRORS:
+ if (page->control.d_sense) {
+ logging(LOG_NORMAL, "[FAILED] D_SENSE is cleat but "
+ "returned sense is not fixed format");
+ CU_FAIL("[FAILED] Wrong type of sense format returned");
+ goto finished;
+ }
+ break;
+ }
finished:
- if (ms_task != NULL) {
- scsi_free_scsi_task(ms_task);
- }
- if (r16_task != NULL) {
- scsi_free_scsi_task(r16_task);
- }
+ if (ms_task != NULL) {
+ scsi_free_scsi_task(ms_task);
+ }
+ if (r16_task != NULL) {
+ scsi_free_scsi_task(r16_task);
+ }
}
diff --git a/test-tool/test_modesense6_control_swp.c b/test-tool/test_modesense6_control_swp.c
index bc196f6..343ab7c 100644
--- a/test-tool/test_modesense6_control_swp.c
+++ b/test-tool/test_modesense6_control_swp.c
@@ -29,74 +29,74 @@
void
test_modesense6_control_swp(void)
{
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_mode_page *page;
- int ret;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_mode_page *page;
+ int ret;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of MODESENSE6 CONTROL SWP flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of MODESENSE6 CONTROL SWP flag");
- logging(LOG_VERBOSE, "Set SWP to enable write protect");
- ret = set_swp(sd);
- if (ret == -2) {
- CU_PASS("[SKIPPED] Target does not support changing SWP");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
- if (ret) {
- goto finished;
- }
+ logging(LOG_VERBOSE, "Set SWP to enable write protect");
+ ret = set_swp(sd);
+ if (ret == -2) {
+ CU_PASS("[SKIPPED] Target does not support changing SWP");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
+ if (ret) {
+ goto finished;
+ }
- logging(LOG_VERBOSE, "Read the CONTROL page back from the device");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the CONTROL page back from the device");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_CONTROL, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
+ logging(LOG_VERBOSE, "[SUCCESS] CONTROL page fetched.");
- logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
- ms = scsi_datain_unmarshall(ms_task);
- if (ms == NULL) {
- logging(LOG_NORMAL, "[FAILED] failed to unmarshall mode sense "
- "datain buffer");
- CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
- for (page = ms->pages; page; page = page->next) {
- if (page->page_code == SCSI_MODEPAGE_CONTROL) {
- break;
- }
- }
- if(page == NULL) {
- logging(LOG_NORMAL, "[WARNING] CONTROL page was not returned."
- "All devices SHOULD implement this page.");
- }
+ logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
+ ms = scsi_datain_unmarshall(ms_task);
+ if (ms == NULL) {
+ logging(LOG_NORMAL, "[FAILED] failed to unmarshall mode sense "
+ "datain buffer");
+ CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
+ for (page = ms->pages; page; page = page->next) {
+ if (page->page_code == SCSI_MODEPAGE_CONTROL) {
+ break;
+ }
+ }
+ if(page == NULL) {
+ logging(LOG_NORMAL, "[WARNING] CONTROL page was not returned."
+ "All devices SHOULD implement this page.");
+ }
- logging(LOG_VERBOSE, "Verify that the SWP bit is set");
- if (page->control.swp == 0) {
- logging(LOG_NORMAL, "[FAILED] SWP bit is not set");
- CU_FAIL("[FAILED] SWP is not set");
- goto finished;
- }
- logging(LOG_VERBOSE, "[SUCCESS] SWP was set successfully");
+ logging(LOG_VERBOSE, "Verify that the SWP bit is set");
+ if (page->control.swp == 0) {
+ logging(LOG_NORMAL, "[FAILED] SWP bit is not set");
+ CU_FAIL("[FAILED] SWP is not set");
+ goto finished;
+ }
+ logging(LOG_VERBOSE, "[SUCCESS] SWP was set successfully");
- logging(LOG_VERBOSE, "Read a block from the now Read-Only device");
- READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Read a block from the now Read-Only device");
+ READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Try to write a block to the Read-Only device");
- WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Try to write a block to the Read-Only device");
+ WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
finished:
- if (ms_task != NULL) {
- scsi_free_scsi_task(ms_task);
- }
- logging(LOG_VERBOSE, "Clear SWP to disable write protect");
- clear_swp(sd);
+ if (ms_task != NULL) {
+ scsi_free_scsi_task(ms_task);
+ }
+ logging(LOG_VERBOSE, "Clear SWP to disable write protect");
+ clear_swp(sd);
}
diff --git a/test-tool/test_modesense6_residuals.c b/test-tool/test_modesense6_residuals.c
index 5fe69cb..4c9f88f 100644
--- a/test-tool/test_modesense6_residuals.c
+++ b/test-tool/test_modesense6_residuals.c
@@ -28,78 +28,78 @@
void
test_modesense6_residuals(void)
{
- struct scsi_task *ms_task = NULL;
+ struct scsi_task *ms_task = NULL;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test of MODESENSE6 Residuals");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test of MODESENSE6 Residuals");
- logging(LOG_VERBOSE, "MODESENSE6 command should not result in any "
- "residuals");
+ logging(LOG_VERBOSE, "MODESENSE6 command should not result in any "
+ "residuals");
-
- logging(LOG_VERBOSE, "Try a MODESENSE6 command with 4 bytes of "
- "transfer length and verify that we don't get residuals.");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+
+ logging(LOG_VERBOSE, "Try a MODESENSE6 command with 4 bytes of "
+ "transfer length and verify that we don't get residuals.");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 4,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
+ logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
- logging(LOG_VERBOSE, "Verify that we got at most 4 bytes of DATA-IN");
- if (ms_task->datain.size > 4) {
- logging(LOG_NORMAL, "[FAILED] got more than 4 bytes of "
- "DATA-IN.");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] <= 4 bytes of DATA-IN "
- "received.");
- }
- CU_ASSERT_TRUE(ms_task->datain.size <= 4);
+ logging(LOG_VERBOSE, "Verify that we got at most 4 bytes of DATA-IN");
+ if (ms_task->datain.size > 4) {
+ logging(LOG_NORMAL, "[FAILED] got more than 4 bytes of "
+ "DATA-IN.");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] <= 4 bytes of DATA-IN "
+ "received.");
+ }
+ CU_ASSERT_TRUE(ms_task->datain.size <= 4);
- logging(LOG_VERBOSE, "Verify residual overflow flag not set");
- if (ms_task->residual_status == SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target set residual "
- "overflow flag");
- }
- CU_ASSERT_NOT_EQUAL(ms_task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag not set");
+ if (ms_task->residual_status == SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_NOT_EQUAL(ms_task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Try a MODESENSE6 command with 255 bytes of "
- "transfer length and verify that we get residuals if the target returns less than the requested amount of data.");
- scsi_free_scsi_task(ms_task);
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Try a MODESENSE6 command with 255 bytes of "
+ "transfer length and verify that we get residuals if the target returns less than the requested amount of data.");
+ scsi_free_scsi_task(ms_task);
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
+ logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
- if (ms_task->datain.size == 255) {
- logging(LOG_VERBOSE, "We got all 255 bytes of data back "
- "from the target. Verify that underflow is not set.");
+ if (ms_task->datain.size == 255) {
+ logging(LOG_VERBOSE, "We got all 255 bytes of data back "
+ "from the target. Verify that underflow is not set.");
- if (ms_task->residual_status == SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target set residual "
- "underflow flag");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Residual underflow "
- "is not set");
- }
- CU_ASSERT_NOT_EQUAL(ms_task->residual_status,
- SCSI_RESIDUAL_UNDERFLOW);
- } else {
- logging(LOG_VERBOSE, "We got less than the requested 255 bytes "
- "from the target. Verify that underflow is set.");
+ if (ms_task->residual_status == SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target set residual "
+ "underflow flag");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Residual underflow "
+ "is not set");
+ }
+ CU_ASSERT_NOT_EQUAL(ms_task->residual_status,
+ SCSI_RESIDUAL_UNDERFLOW);
+ } else {
+ logging(LOG_VERBOSE, "We got less than the requested 255 bytes "
+ "from the target. Verify that underflow is set.");
- if (ms_task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set "
- "residual underflow flag");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Residual underflow "
- "is set");
- }
- CU_ASSERT_EQUAL(ms_task->residual_status,
- SCSI_RESIDUAL_UNDERFLOW);
- }
+ if (ms_task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set "
+ "residual underflow flag");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Residual underflow "
+ "is set");
+ }
+ CU_ASSERT_EQUAL(ms_task->residual_status,
+ SCSI_RESIDUAL_UNDERFLOW);
+ }
- scsi_free_scsi_task(ms_task);
+ scsi_free_scsi_task(ms_task);
}
diff --git a/test-tool/test_multipathio_compareandwrite.c b/test-tool/test_multipathio_compareandwrite.c
index b58ad6d..7378acc 100644
--- a/test-tool/test_multipathio_compareandwrite.c
+++ b/test-tool/test_multipathio_compareandwrite.c
@@ -32,65 +32,65 @@
void
test_multipathio_compareandwrite(void)
{
- int io_bl = 1; /* 1 block CAW IOs */
- int path;
- int i, ret;
- int maxbl;
+ int io_bl = 1; /* 1 block CAW IOs */
+ int path;
+ int i, ret;
+ int maxbl;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
- MPATH_SKIP_IF_UNAVAILABLE(mp_sds, mp_num_sds);
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ MPATH_SKIP_IF_UNAVAILABLE(mp_sds, mp_num_sds);
- if (inq_bl) {
- maxbl = inq_bl->max_cmp;
- } else {
- /* Assume we are not limited */
- maxbl = 256;
- }
- if (maxbl < io_bl) {
- CU_PASS("[SKIPPED] MAXIMUM_COMPARE_AND_WRITE_LENGTH too small");
- return;
- }
+ if (inq_bl) {
+ maxbl = inq_bl->max_cmp;
+ } else {
+ /* Assume we are not limited */
+ maxbl = 256;
+ }
+ if (maxbl < io_bl) {
+ CU_PASS("[SKIPPED] MAXIMUM_COMPARE_AND_WRITE_LENGTH too small");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Initialising data prior to COMPARE_AND_WRITE");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Initialising data prior to COMPARE_AND_WRITE");
- memset(scratch, 0, io_bl * block_size);
- ret = writesame10(mp_sds[0], 0,
- block_size, 256, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ memset(scratch, 0, io_bl * block_size);
+ ret = writesame10(mp_sds[0], 0,
+ block_size, 256, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Test multipath COMPARE_AND_WRITE");
- for (i = 0; i < 256; i++) {
+ logging(LOG_VERBOSE, "Test multipath COMPARE_AND_WRITE");
+ for (i = 0; i < 256; i++) {
- for (path = 0; path < mp_num_sds; path++) {
- logging(LOG_VERBOSE,
- "Test COMPARE_AND_WRITE(%d->%d) using path %d",
- path, path + 1, path);
+ for (path = 0; path < mp_num_sds; path++) {
+ logging(LOG_VERBOSE,
+ "Test COMPARE_AND_WRITE(%d->%d) using path %d",
+ path, path + 1, path);
- /* compare data is first half */
- memset(scratch, path, io_bl * block_size);
- /* write data is the second half, wrap around */
- memset(scratch + io_bl * block_size, path + 1,
- io_bl * block_size);
- COMPAREANDWRITE(mp_sds[path], i,
+ /* compare data is first half */
+ memset(scratch, path, io_bl * block_size);
+ /* write data is the second half, wrap around */
+ memset(scratch + io_bl * block_size, path + 1,
+ io_bl * block_size);
+ COMPAREANDWRITE(mp_sds[path], i,
scratch, 2 * io_bl * block_size,
block_size, 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE,
- "Test bad COMPARE_AND_WRITE(%d->%d)",
- path, path + 1);
+ logging(LOG_VERBOSE,
+ "Test bad COMPARE_AND_WRITE(%d->%d)",
+ path, path + 1);
- COMPAREANDWRITE(mp_sds[path], i,
+ COMPAREANDWRITE(mp_sds[path], i,
scratch, 2 * io_bl * block_size,
block_size, 0, 0, 0, 0,
EXPECT_MISCOMPARE);
- }
- }
+ }
+ }
}
diff --git a/test-tool/test_multipathio_reset.c b/test-tool/test_multipathio_reset.c
index 5241093..63191dc 100644
--- a/test-tool/test_multipathio_reset.c
+++ b/test-tool/test_multipathio_reset.c
@@ -31,43 +31,43 @@
void
test_multipathio_reset(void)
{
- int reset_path;
+ int reset_path;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
- MPATH_SKIP_IF_UNAVAILABLE(mp_sds, mp_num_sds);
- MPATH_SKIP_UNLESS_ISCSI(mp_sds, mp_num_sds);
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ MPATH_SKIP_IF_UNAVAILABLE(mp_sds, mp_num_sds);
+ MPATH_SKIP_UNLESS_ISCSI(mp_sds, mp_num_sds);
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
- for (reset_path = 0; reset_path < mp_num_sds; reset_path++) {
- int num_uas;
- int ret;
- int tur_path;
- struct scsi_device *reset_sd = mp_sds[reset_path];
+ for (reset_path = 0; reset_path < mp_num_sds; reset_path++) {
+ int num_uas;
+ int ret;
+ int tur_path;
+ struct scsi_device *reset_sd = mp_sds[reset_path];
- logging(LOG_VERBOSE, "Awaiting good TUR");
- ret = test_iscsi_tur_until_good(reset_sd, &num_uas);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Awaiting good TUR");
+ ret = test_iscsi_tur_until_good(reset_sd, &num_uas);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE,
- "Test multipath LUN Reset using path %d", reset_path);
+ logging(LOG_VERBOSE,
+ "Test multipath LUN Reset using path %d", reset_path);
- ret = iscsi_task_mgmt_lun_reset_sync(reset_sd->iscsi_ctx,
- reset_sd->iscsi_lun);
- if (ret != 0) {
- logging(LOG_NORMAL, "LUN reset failed. %s",
- iscsi_get_error(reset_sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(ret, 0);
+ ret = iscsi_task_mgmt_lun_reset_sync(reset_sd->iscsi_ctx,
+ reset_sd->iscsi_lun);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "LUN reset failed. %s",
+ iscsi_get_error(reset_sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- /* check for and clear LU reset UA on all paths */
- for (tur_path = 0; tur_path < mp_num_sds; tur_path++) {
- logging(LOG_VERBOSE, "check for LU reset unit "
- "attention via TUR on path %d", tur_path);
- ret = test_iscsi_tur_until_good(mp_sds[tur_path], &num_uas);
- CU_ASSERT_EQUAL(ret, 0);
- CU_ASSERT_NOT_EQUAL(num_uas, 0);
- }
- }
+ /* check for and clear LU reset UA on all paths */
+ for (tur_path = 0; tur_path < mp_num_sds; tur_path++) {
+ logging(LOG_VERBOSE, "check for LU reset unit "
+ "attention via TUR on path %d", tur_path);
+ ret = test_iscsi_tur_until_good(mp_sds[tur_path], &num_uas);
+ CU_ASSERT_EQUAL(ret, 0);
+ CU_ASSERT_NOT_EQUAL(num_uas, 0);
+ }
+ }
}
diff --git a/test-tool/test_multipathio_simple.c b/test-tool/test_multipathio_simple.c
index ab3f797..ff1dcab 100644
--- a/test-tool/test_multipathio_simple.c
+++ b/test-tool/test_multipathio_simple.c
@@ -31,44 +31,44 @@
void
test_multipathio_simple(void)
{
- int write_path;
- unsigned char *write_buf = alloca(256 * block_size);
- unsigned char *read_buf = alloca(256 * block_size);
+ int write_path;
+ unsigned char *write_buf = alloca(256 * block_size);
+ unsigned char *read_buf = alloca(256 * block_size);
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
- MPATH_SKIP_IF_UNAVAILABLE(mp_sds, mp_num_sds);
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ MPATH_SKIP_IF_UNAVAILABLE(mp_sds, mp_num_sds);
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- memset(write_buf, 0xa6, 256 * block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ memset(write_buf, 0xa6, 256 * block_size);
- for (write_path = 0; write_path < mp_num_sds; write_path++) {
- int i;
- int read_path;
+ for (write_path = 0; write_path < mp_num_sds; write_path++) {
+ int i;
+ int read_path;
- /* read back written data using a different path */
- read_path = (write_path + 1) % mp_num_sds;
+ /* read back written data using a different path */
+ read_path = (write_path + 1) % mp_num_sds;
- logging(LOG_VERBOSE,
- "Test multipath WRITE10/READ10 of 1-256 blocks using "
- "path %d", write_path);
+ logging(LOG_VERBOSE,
+ "Test multipath WRITE10/READ10 of 1-256 blocks using "
+ "path %d", write_path);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length
- && maximum_transfer_length < i) {
- break;
- }
- WRITE10(mp_sds[write_path], 0, i * block_size,
- block_size, 0, 0, 0, 0, 0, write_buf,
- EXPECT_STATUS_GOOD);
- READ10(mp_sds[read_path], NULL, 0, i * block_size,
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length
+ && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE10(mp_sds[write_path], 0, i * block_size,
+ block_size, 0, 0, 0, 0, 0, write_buf,
+ EXPECT_STATUS_GOOD);
+ READ10(mp_sds[read_path], NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, read_buf,
EXPECT_STATUS_GOOD);
- /* compare written and read data */
- CU_ASSERT_EQUAL(0,
- memcmp(write_buf, read_buf, i * block_size));
- }
+ /* compare written and read data */
+ CU_ASSERT_EQUAL(0,
+ memcmp(write_buf, read_buf, i * block_size));
+ }
- }
+ }
}
diff --git a/test-tool/test_nomedia_sbc.c b/test-tool/test_nomedia_sbc.c
index 559ec14..f3eaa34 100644
--- a/test-tool/test_nomedia_sbc.c
+++ b/test-tool/test_nomedia_sbc.c
@@ -28,64 +28,64 @@
static void
test_synchronizecache10(void)
{
- logging(LOG_VERBOSE, "Test SYNCHRONIZECACHE10 when medium is ejected.");
- SYNCHRONIZECACHE10(sd, 0, 1, 1, 1,
+ logging(LOG_VERBOSE, "Test SYNCHRONIZECACHE10 when medium is ejected.");
+ SYNCHRONIZECACHE10(sd, 0, 1, 1, 1,
EXPECT_NO_MEDIUM);
}
static void
test_synchronizecache16(void)
{
- logging(LOG_VERBOSE, "Test SYNCHRONIZECACHE16 when medium is ejected.");
- SYNCHRONIZECACHE16(sd, 0, 1, 1, 1,
+ logging(LOG_VERBOSE, "Test SYNCHRONIZECACHE16 when medium is ejected.");
+ SYNCHRONIZECACHE16(sd, 0, 1, 1, 1,
EXPECT_NO_MEDIUM);
}
static void
test_read10(void)
{
- logging(LOG_VERBOSE, "Test READ10 when medium is ejected.");
- READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ10 when medium is ejected.");
+ READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_NO_MEDIUM);
}
static void
test_read12(void)
{
- logging(LOG_VERBOSE, "Test READ12 when medium is ejected.");
- READ12(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ12 when medium is ejected.");
+ READ12(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_NO_MEDIUM);
}
static void
test_read16(void)
{
- logging(LOG_VERBOSE, "Test READ16 when medium is ejected.");
- READ16(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ16 when medium is ejected.");
+ READ16(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_NO_MEDIUM);
}
static void
test_write10(void)
{
- logging(LOG_VERBOSE, "Test WRITE10 when medium is ejected.");
- WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 when medium is ejected.");
+ WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_write12(void)
{
- logging(LOG_VERBOSE, "Test WRITE12 when medium is ejected.");
- WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 when medium is ejected.");
+ WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_write16(void)
{
- logging(LOG_VERBOSE, "Test WRITE16 when medium is ejected.");
- WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 when medium is ejected.");
+ WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
@@ -93,7 +93,7 @@ static void
test_writeverify10(void)
{
logging(LOG_VERBOSE, "Test WRITEVERIFY10 when medium is ejected.");
- WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
+ WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
@@ -101,7 +101,7 @@ static void
test_writeverify12(void)
{
logging(LOG_VERBOSE, "Test WRITEVERIFY12 when medium is ejected.");
- WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
+ WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
@@ -109,68 +109,68 @@ static void
test_writeverify16(void)
{
logging(LOG_VERBOSE, "Test WRITEVERIFY16 when medium is ejected.");
- WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
+ WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_verify10(void)
{
- logging(LOG_VERBOSE, "Test VERIFY10 when medium is ejected.");
- VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY10 when medium is ejected.");
+ VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_verify12(void)
{
- logging(LOG_VERBOSE, "Test VERIFY12 when medium is ejected.");
- VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY12 when medium is ejected.");
+ VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_verify16(void)
{
- logging(LOG_VERBOSE, "Test VERIFY16 when medium is ejected.");
- VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY16 when medium is ejected.");
+ VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_getlbastatus(void)
{
- logging(LOG_VERBOSE, "Test GET_LBA_STATUS when medium is ejected.");
- GETLBASTATUS(sd, NULL, 0, 24,
+ logging(LOG_VERBOSE, "Test GET_LBA_STATUS when medium is ejected.");
+ GETLBASTATUS(sd, NULL, 0, 24,
EXPECT_NO_MEDIUM);
}
static void
test_prefetch10(void)
{
- logging(LOG_VERBOSE, "Test PREFETCH10 when medium is ejected.");
- PREFETCH10(sd, 0, 1, 1, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 when medium is ejected.");
+ PREFETCH10(sd, 0, 1, 1, 0,
EXPECT_NO_MEDIUM);
}
static void
test_prefetch16(void)
{
- logging(LOG_VERBOSE, "Test PREFETCH16 when medium is ejected.");
- PREFETCH16(sd, 0, 1, 1, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 when medium is ejected.");
+ PREFETCH16(sd, 0, 1, 1, 0,
EXPECT_NO_MEDIUM);
}
static void
test_orwrite(void)
{
- logging(LOG_VERBOSE, "Test ORWRITE when medium is ejected.");
- ORWRITE(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test ORWRITE when medium is ejected.");
+ ORWRITE(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_compareandwrite(void)
{
- logging(LOG_VERBOSE, "Test COMPAREANDWRITE when medium is ejected.");
+ logging(LOG_VERBOSE, "Test COMPAREANDWRITE when medium is ejected.");
COMPAREANDWRITE(sd, 0, scratch, 2 * block_size, block_size, 0, 0, 0, 0,
EXPECT_NO_MEDIUM);
}
@@ -178,36 +178,36 @@ test_compareandwrite(void)
static void
test_writesame10(void)
{
- logging(LOG_VERBOSE, "Test WRITESAME10 when medium is ejected.");
- WRITESAME10(sd, 0, block_size, 1, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME10 when medium is ejected.");
+ WRITESAME10(sd, 0, block_size, 1, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_writesame16(void)
{
- logging(LOG_VERBOSE, "Test WRITESAME16 when medium is ejected.");
- WRITESAME16(sd, 0, block_size, 1, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME16 when medium is ejected.");
+ WRITESAME16(sd, 0, block_size, 1, 0, 0, 0, 0, scratch,
EXPECT_NO_MEDIUM);
}
static void
test_unmap(void)
{
- struct unmap_list list[1];
+ struct unmap_list list[1];
logging(LOG_VERBOSE, "Test UNMAP when medium is ejected.");
- list[0].lba = 0;
- list[0].num = lbppb;
- UNMAP(sd, 0, list, 1,
- EXPECT_NO_MEDIUM);
+ list[0].lba = 0;
+ list[0].num = lbppb;
+ UNMAP(sd, 0, list, 1,
+ EXPECT_NO_MEDIUM);
}
static void
test_readcapacity10(void)
{
logging(LOG_VERBOSE, "Test READCAPACITY10 when medium is ejected.");
- READCAPACITY10(sd, NULL, 0, 0,
+ READCAPACITY10(sd, NULL, 0, 0,
EXPECT_NO_MEDIUM);
}
@@ -215,30 +215,30 @@ static void
test_readcapacity16(void)
{
logging(LOG_VERBOSE, "Test READCAPACITY16 when medium is ejected.");
- READCAPACITY16(sd, NULL, 15,
+ READCAPACITY16(sd, NULL, 15,
EXPECT_NO_MEDIUM);
}
void
test_nomedia_sbc(void)
{
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that Medium commands fail when medium is ejected on SBC devices");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that Medium commands fail when medium is ejected on SBC devices");
- if (!inq->rmb) {
- logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. "
- "Skipping test.");
- return;
- }
+ if (!inq->rmb) {
+ logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. "
+ "Skipping test.");
+ return;
+ }
- logging(LOG_VERBOSE, "Eject the medium.");
- STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Eject the medium.");
+ STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY when medium is ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY when medium is ejected.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
test_synchronizecache10();
@@ -255,10 +255,10 @@ test_nomedia_sbc(void)
test_prefetch10();
test_prefetch16();
- if (!data_loss) {
- logging(LOG_VERBOSE, "[SKIPPING] Dataloss flag not set. Skipping test for WRITE commands");
- goto finished;
- }
+ if (!data_loss) {
+ logging(LOG_VERBOSE, "[SKIPPING] Dataloss flag not set. Skipping test for WRITE commands");
+ goto finished;
+ }
test_compareandwrite();
test_orwrite();
@@ -273,7 +273,7 @@ test_nomedia_sbc(void)
test_writeverify16();
finished:
- logging(LOG_VERBOSE, "Load the medium again.");
- STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Load the medium again.");
+ STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_orwrite_0blocks.c b/test-tool/test_orwrite_0blocks.c
index cc53387..c482253 100644
--- a/test-tool/test_orwrite_0blocks.c
+++ b/test-tool/test_orwrite_0blocks.c
@@ -27,23 +27,23 @@
void
test_orwrite_0blocks(void)
{
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==0");
- ORWRITE(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==0");
+ ORWRITE(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test ORWRITE 0-blocks one block past end-of-LUN");
- ORWRITE(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test ORWRITE 0-blocks one block past end-of-LUN");
+ ORWRITE(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==2^63");
- ORWRITE(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==2^63");
+ ORWRITE(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==-1");
- ORWRITE(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==-1");
+ ORWRITE(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_orwrite_beyond_eol.c b/test-tool/test_orwrite_beyond_eol.c
index 92d0168..ece8bed 100644
--- a/test-tool/test_orwrite_beyond_eol.c
+++ b/test-tool/test_orwrite_beyond_eol.c
@@ -29,53 +29,53 @@
void
test_orwrite_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- ORWRITE(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ ORWRITE(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks at LBA==2^63");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- ORWRITE(sd, 0x8000000000000000ULL, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks at LBA==2^63");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ ORWRITE(sd, 0x8000000000000000ULL, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- ORWRITE(sd, -1, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Test ORWRITE 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ ORWRITE(sd, -1, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test ORWRITE 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- ORWRITE(sd, num_blocks - 1, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Test ORWRITE 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ ORWRITE(sd, num_blocks - 1, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_orwrite_dpofua.c b/test-tool/test_orwrite_dpofua.c
index 4a9137a..6065ea4 100644
--- a/test-tool/test_orwrite_dpofua.c
+++ b/test-tool/test_orwrite_dpofua.c
@@ -29,75 +29,75 @@
void
test_orwrite_dpofua(void)
{
- int dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test ORWRITE DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test ORWRITE DPO/FUA flags");
- CHECK_FOR_SBC;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test ORWRITE with DPO==1");
- memset(scratch, 0xa6, block_size);
- if (dpofua) {
- ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test ORWRITE with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ if (dpofua) {
+ ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ } else {
+ ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test ORWRITE with FUA==1");
- if (dpofua) {
- ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test ORWRITE with FUA==1");
+ if (dpofua) {
+ ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ } else {
+ ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1");
- if (dpofua) {
- ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1");
+ if (dpofua) {
+ ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
+ } else {
+ ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for ORWRITE");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for ORWRITE");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_ORWRITE,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -118,5 +118,5 @@ test_orwrite_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_orwrite_simple.c b/test-tool/test_orwrite_simple.c
index d29bea4..b33f794 100644
--- a/test-tool/test_orwrite_simple.c
+++ b/test-tool/test_orwrite_simple.c
@@ -30,30 +30,30 @@
void
test_orwrite_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- ORWRITE(sd, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- ORWRITE(sd, num_blocks - i, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ ORWRITE(sd, num_blocks - i, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_orwrite_verify.c b/test-tool/test_orwrite_verify.c
index 5ca824f..ac7f462 100644
--- a/test-tool/test_orwrite_verify.c
+++ b/test-tool/test_orwrite_verify.c
@@ -31,101 +31,101 @@
void
test_orwrite_verify(void)
{
- int i, ret;
- unsigned char *buf = &scratch[0];
- unsigned char *readbuf = &scratch[256 * block_size];
+ int i, ret;
+ unsigned char *buf = &scratch[0];
+ unsigned char *readbuf = &scratch[256 * block_size];
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
- logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
- memset(buf, 0, block_size * i);
- ret = write10(sd, 0, i * block_size,
- block_size, 0, 0, 0, 0, 0, buf,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
+ memset(buf, 0, block_size * i);
+ ret = write10(sd, 0, i * block_size,
+ block_size, 0, 0, 0, 0, 0, buf,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
- memset(buf, 0xa5, block_size * i);
- ORWRITE(sd, 0, i * block_size,
+ logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
+ memset(buf, 0xa5, block_size * i);
+ ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read %d blocks back", i);
- READ10(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, "Read %d blocks back", i);
+ READ10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the blocks are all 0xa5");
- ret = memcmp(buf, readbuf, block_size * i);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Verify that the blocks are all 0xa5");
+ ret = memcmp(buf, readbuf, block_size * i);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i);
- memset(buf, 0x5a, block_size * i);
- ORWRITE(sd, 0, i * block_size,
+ logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i);
+ memset(buf, 0x5a, block_size * i);
+ ORWRITE(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read %d blocks back", i);
- READ10(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, "Read %d blocks back", i);
+ READ10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the blocks are all 0xff");
- memset(buf, 0xff, block_size * i);
- ret = memcmp(buf, readbuf, block_size * i);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ logging(LOG_VERBOSE, "Verify that the blocks are all 0xff");
+ memset(buf, 0xff, block_size * i);
+ ret = memcmp(buf, readbuf, block_size * i);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
+ logging(LOG_VERBOSE, "Test ORWRITE of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
- logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
- memset(buf, 0, block_size * i);
- WRITE16(sd, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
+ memset(buf, 0, block_size * i);
+ WRITE16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
- memset(buf, 0xa5, block_size * i);
- ORWRITE(sd, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
+ memset(buf, 0xa5, block_size * i);
+ ORWRITE(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read %d blocks back", i);
- READ16(sd, NULL, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "Read %d blocks back", i);
+ READ16(sd, NULL, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the blocks are all 0xa5");
- ret = memcmp(buf, readbuf, block_size * i);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Verify that the blocks are all 0xa5");
+ ret = memcmp(buf, readbuf, block_size * i);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i);
- memset(buf, 0x5a, block_size * i);
- ORWRITE(sd, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i);
+ memset(buf, 0x5a, block_size * i);
+ ORWRITE(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read %d blocks back", i);
- READ16(sd, NULL, num_blocks - i, i * block_size,
+ logging(LOG_VERBOSE, "Read %d blocks back", i);
+ READ16(sd, NULL, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the blocks are all 0xff");
- memset(buf, 0xff, block_size * i);
- ret = memcmp(buf, readbuf, block_size * i);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ logging(LOG_VERBOSE, "Verify that the blocks are all 0xff");
+ memset(buf, 0xff, block_size * i);
+ ret = memcmp(buf, readbuf, block_size * i);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
}
diff --git a/test-tool/test_orwrite_wrprotect.c b/test-tool/test_orwrite_wrprotect.c
index 9183036..bcf9e9d 100644
--- a/test-tool/test_orwrite_wrprotect.c
+++ b/test-tool/test_orwrite_wrprotect.c
@@ -30,27 +30,27 @@
void
test_orwrite_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test ORWRITE with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test ORWRITE with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0xa6, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- ORWRITE(sd, 0, block_size,
+ memset(scratch, 0xa6, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ ORWRITE(sd, 0, block_size,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_prefetch10_0blocks.c b/test-tool/test_prefetch10_0blocks.c
index df36414..da1505a 100644
--- a/test-tool/test_prefetch10_0blocks.c
+++ b/test-tool/test_prefetch10_0blocks.c
@@ -27,26 +27,26 @@
void
test_prefetch10_0blocks(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==0");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==0");
- PREFETCH10(sd, 0, 0, 0, 0,
+ PREFETCH10(sd, 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
- if (num_blocks > 0x80000000) {
- CU_PASS("[SKIPPED] LUN is too big");
- return;
- }
+ if (num_blocks > 0x80000000) {
+ CU_PASS("[SKIPPED] LUN is too big");
+ return;
+ }
- logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks one block past end-of-LUN");
- PREFETCH10(sd, num_blocks + 1, 0, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks one block past end-of-LUN");
+ PREFETCH10(sd, num_blocks + 1, 0, 0, 0,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==2^31");
- PREFETCH10(sd, 0x80000000, 0, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==2^31");
+ PREFETCH10(sd, 0x80000000, 0, 0, 0,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==-1");
- PREFETCH10(sd, -1, 0, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==-1");
+ PREFETCH10(sd, -1, 0, 0, 0,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_prefetch10_beyond_eol.c b/test-tool/test_prefetch10_beyond_eol.c
index 36f7cce..0cda4a5 100644
--- a/test-tool/test_prefetch10_beyond_eol.c
+++ b/test-tool/test_prefetch10_beyond_eol.c
@@ -28,35 +28,35 @@
void
test_prefetch10_beyond_eol(void)
{
- int i;
+ int i;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with PREFETCH10. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with PREFETCH10. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks one block beyond the end");
- for (i = 1; i <= 256; i++) {
- PREFETCH10(sd, num_blocks + 1 - i, i, 0, 0,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks one block beyond the end");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH10(sd, num_blocks + 1 - i, i, 0, 0,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- PREFETCH10(sd, 0x80000000, i, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH10(sd, 0x80000000, i, 0, 0,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- PREFETCH10(sd, -1, i, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH10(sd, -1, i, 0, 0,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test PREFETCH10 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- PREFETCH10(sd, num_blocks - 1, i, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ PREFETCH10(sd, num_blocks - 1, i, 0, 0,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_prefetch10_flags.c b/test-tool/test_prefetch10_flags.c
index 9b02488..21fc328 100644
--- a/test-tool/test_prefetch10_flags.c
+++ b/test-tool/test_prefetch10_flags.c
@@ -29,18 +29,18 @@
void
test_prefetch10_flags(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREFETCH10 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREFETCH10 flags");
- logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED==1");
- PREFETCH10(sd, 0, 1, 1, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED==1");
+ PREFETCH10(sd, 0, 1, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test PREFETCH10 with GROUP==3");
- PREFETCH10(sd, 0, 1, 0, 3,
+ logging(LOG_VERBOSE, "Test PREFETCH10 with GROUP==3");
+ PREFETCH10(sd, 0, 1, 0, 3,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED=1 and GROUP==3");
- PREFETCH10(sd, 0, 1, 1, 3,
+ logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED=1 and GROUP==3");
+ PREFETCH10(sd, 0, 1, 1, 3,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_prefetch10_simple.c b/test-tool/test_prefetch10_simple.c
index 68a7ed9..bcd72e8 100644
--- a/test-tool/test_prefetch10_simple.c
+++ b/test-tool/test_prefetch10_simple.c
@@ -29,19 +29,19 @@
void
test_prefetch10_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- PREFETCH10(sd, 0, i, 0, 0,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH10(sd, 0, i, 0, 0,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- PREFETCH10(sd, num_blocks - i, i, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH10(sd, num_blocks - i, i, 0, 0,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_prefetch16_0blocks.c b/test-tool/test_prefetch16_0blocks.c
index 9d670b5..c7fdb3b 100644
--- a/test-tool/test_prefetch16_0blocks.c
+++ b/test-tool/test_prefetch16_0blocks.c
@@ -27,21 +27,21 @@
void
test_prefetch16_0blocks(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==0");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==0");
- PREFETCH16(sd, 0, 0, 0, 0,
+ PREFETCH16(sd, 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks one block past end-of-LUN");
- PREFETCH16(sd, num_blocks + 1, 0, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks one block past end-of-LUN");
+ PREFETCH16(sd, num_blocks + 1, 0, 0, 0,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==2^63");
- PREFETCH16(sd, 0x8000000000000000ULL, 0, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==2^63");
+ PREFETCH16(sd, 0x8000000000000000ULL, 0, 0, 0,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==-1");
- PREFETCH16(sd, -1, 0, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==-1");
+ PREFETCH16(sd, -1, 0, 0, 0,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_prefetch16_beyond_eol.c b/test-tool/test_prefetch16_beyond_eol.c
index 2dc9634..b93bcdb 100644
--- a/test-tool/test_prefetch16_beyond_eol.c
+++ b/test-tool/test_prefetch16_beyond_eol.c
@@ -28,30 +28,30 @@
void
test_prefetch16_beyond_eol(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks one block beyond the end");
- for (i = 1; i <= 256; i++) {
- PREFETCH16(sd, num_blocks + 1 - i, i, 0, 0,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks one block beyond the end");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH16(sd, num_blocks + 1 - i, i, 0, 0,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==2^63");
- for (i = 1; i <= 256; i++) {
- PREFETCH16(sd, 0x8000000000000000ULL, i, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==2^63");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH16(sd, 0x8000000000000000ULL, i, 0, 0,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- PREFETCH16(sd, -1, i, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH16(sd, -1, i, 0, 0,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test PREFETCH16 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- PREFETCH16(sd, num_blocks - 1, i, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ PREFETCH16(sd, num_blocks - 1, i, 0, 0,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_prefetch16_flags.c b/test-tool/test_prefetch16_flags.c
index 5e98cb8..d07d7bd 100644
--- a/test-tool/test_prefetch16_flags.c
+++ b/test-tool/test_prefetch16_flags.c
@@ -29,18 +29,18 @@
void
test_prefetch16_flags(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREFETCH16 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREFETCH16 flags");
- logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED==1");
- PREFETCH16(sd, 0, 1, 1, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED==1");
+ PREFETCH16(sd, 0, 1, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test PREFETCH16 with GROUP==3");
- PREFETCH16(sd, 0, 1, 0, 3,
+ logging(LOG_VERBOSE, "Test PREFETCH16 with GROUP==3");
+ PREFETCH16(sd, 0, 1, 0, 3,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED=1 and GROUP==3");
- PREFETCH16(sd, 0, 1, 1, 3,
+ logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED=1 and GROUP==3");
+ PREFETCH16(sd, 0, 1, 1, 3,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_prefetch16_simple.c b/test-tool/test_prefetch16_simple.c
index 1d2afdf..5c0b8eb 100644
--- a/test-tool/test_prefetch16_simple.c
+++ b/test-tool/test_prefetch16_simple.c
@@ -29,19 +29,19 @@
void
test_prefetch16_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- PREFETCH16(sd, 0, i, 0, 0,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH16(sd, 0, i, 0, 0,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- PREFETCH16(sd, num_blocks - i, i, 0, 0,
+ logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ PREFETCH16(sd, num_blocks - i, i, 0, 0,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_preventallow_2_itnexuses.c b/test-tool/test_preventallow_2_itnexuses.c
index c4e6a41..620a888 100644
--- a/test-tool/test_preventallow_2_itnexuses.c
+++ b/test-tool/test_preventallow_2_itnexuses.c
@@ -29,52 +29,52 @@
void
test_preventallow_2_itnexuses(void)
{
- int ret;
- struct scsi_device *sd2;
+ int ret;
+ struct scsi_device *sd2;
- CHECK_FOR_SBC;
- CHECK_FOR_REMOVABLE;
+ CHECK_FOR_SBC;
+ CHECK_FOR_REMOVABLE;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that PREVENT MEDIUM REMOVAL are seen on other nexuses as well");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that PREVENT MEDIUM REMOVAL are seen on other nexuses as well");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PREVENTALLOW test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PREVENTALLOW test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Set the PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Set the PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Verify we can still access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can still access the media.");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
- 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, "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");
- STARTSTOPUNIT(sd2, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium on the second connection");
+ STARTSTOPUNIT(sd2, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Logout the second connection from target");
- mpath_sd2_put(sd2);
+ logging(LOG_VERBOSE, "Logout the second connection from target");
+ mpath_sd2_put(sd2);
- logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
- logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
+ logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_preventallow_cold_reset.c b/test-tool/test_preventallow_cold_reset.c
index 2543ceb..9932ac7 100644
--- a/test-tool/test_preventallow_cold_reset.c
+++ b/test-tool/test_preventallow_cold_reset.c
@@ -30,56 +30,56 @@ test_preventallow_cold_reset(void)
{
int ret;
- CHECK_FOR_SBC;
- CHECK_FOR_REMOVABLE;
+ CHECK_FOR_SBC;
+ CHECK_FOR_REMOVABLE;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PREVENTALLOW test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PREVENTALLOW test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Set the PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Set the PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Verify we can still access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can still access the media.");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
-
- logging(LOG_VERBOSE, "Perform cold reset on target");
- ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
- CU_ASSERT_EQUAL(ret, 0);
+
+ logging(LOG_VERBOSE, "Perform cold reset on target");
+ ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Wait until all unit attentions clear");
- while (testunitready(sd, EXPECT_STATUS_GOOD) != 0)
- ;
+ logging(LOG_VERBOSE, "Wait until all unit attentions clear");
+ while (testunitready(sd, EXPECT_STATUS_GOOD) != 0)
+ ;
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we can not access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can not access the media.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
- logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
+ logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_preventallow_eject.c b/test-tool/test_preventallow_eject.c
index a2bc997..93336af 100644
--- a/test-tool/test_preventallow_eject.c
+++ b/test-tool/test_preventallow_eject.c
@@ -28,45 +28,45 @@
void
test_preventallow_eject(void)
{
- CHECK_FOR_SBC;
- CHECK_FOR_REMOVABLE;
+ CHECK_FOR_SBC;
+ CHECK_FOR_REMOVABLE;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that we can not eject medium when PREVENT is active");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that we can not eject medium when PREVENT is active");
- logging(LOG_VERBOSE, "Set the PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Set the PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Verify we can still access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can still access the media.");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we can not access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can not access the media.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
- logging(LOG_VERBOSE, "Set the PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Set the PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Try to load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Try to load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
- logging(LOG_VERBOSE, "Load the medium again");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Load the medium again");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_preventallow_itnexus_loss.c b/test-tool/test_preventallow_itnexus_loss.c
index 2e99cae..67bc4e8 100644
--- a/test-tool/test_preventallow_itnexus_loss.c
+++ b/test-tool/test_preventallow_itnexus_loss.c
@@ -28,58 +28,58 @@
void
test_preventallow_itnexus_loss(void)
{
- CHECK_FOR_SBC;
- CHECK_FOR_REMOVABLE;
+ CHECK_FOR_SBC;
+ CHECK_FOR_REMOVABLE;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that IT-Nexus loss clears PREVENT MEDIUM REMOVAL");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that IT-Nexus loss clears PREVENT MEDIUM REMOVAL");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PREVENTALLOW test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PREVENTALLOW test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Set the PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Set the PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Verify we can still access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can still access the media.");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
-
- logging(LOG_VERBOSE, "Disconnect from the target.");
- iscsi_destroy_context(sd->iscsi_ctx);
+
+ logging(LOG_VERBOSE, "Disconnect from the target.");
+ iscsi_destroy_context(sd->iscsi_ctx);
- logging(LOG_VERBOSE, "Reconnect to target");
- sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
- if (sd->iscsi_ctx == NULL) {
- logging(LOG_VERBOSE, "Failed to login to target");
- return;
- }
+ logging(LOG_VERBOSE, "Reconnect to target");
+ sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
+ if (sd->iscsi_ctx == NULL) {
+ logging(LOG_VERBOSE, "Failed to login to target");
+ return;
+ }
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we can not access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can not access the media.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
- logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
+ logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_preventallow_logout.c b/test-tool/test_preventallow_logout.c
index ed24955..b4054ba 100644
--- a/test-tool/test_preventallow_logout.c
+++ b/test-tool/test_preventallow_logout.c
@@ -28,59 +28,59 @@
void
test_preventallow_logout(void)
{
- CHECK_FOR_SBC;
- CHECK_FOR_REMOVABLE;
+ CHECK_FOR_SBC;
+ CHECK_FOR_REMOVABLE;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that Logout loss clears PREVENT MEDIUM REMOVAL");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that Logout loss clears PREVENT MEDIUM REMOVAL");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PREVENTALLOW test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PREVENTALLOW test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Set the PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Set the PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Verify we can still access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can still access the media.");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Logout from target");
- iscsi_logout_sync(sd->iscsi_ctx);
- iscsi_destroy_context(sd->iscsi_ctx);
+ logging(LOG_VERBOSE, "Logout from target");
+ iscsi_logout_sync(sd->iscsi_ctx);
+ iscsi_destroy_context(sd->iscsi_ctx);
- logging(LOG_VERBOSE, "Relogin to target");
- sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
- if (sd->iscsi_ctx == NULL) {
- logging(LOG_VERBOSE, "Failed to login to target");
- return;
- }
+ logging(LOG_VERBOSE, "Relogin to target");
+ sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
+ if (sd->iscsi_ctx == NULL) {
+ logging(LOG_VERBOSE, "Failed to login to target");
+ return;
+ }
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we can not access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can not access the media.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
- logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
+ logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_preventallow_lun_reset.c b/test-tool/test_preventallow_lun_reset.c
index c37f7ae..bc05fc0 100644
--- a/test-tool/test_preventallow_lun_reset.c
+++ b/test-tool/test_preventallow_lun_reset.c
@@ -28,58 +28,58 @@
void
test_preventallow_lun_reset(void)
{
- int ret;
+ int ret;
- CHECK_FOR_SBC;
- CHECK_FOR_REMOVABLE;
+ CHECK_FOR_SBC;
+ CHECK_FOR_REMOVABLE;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PREVENTALLOW test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PREVENTALLOW test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Set the PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Set the PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Verify we can still access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can still access the media.");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
-
- logging(LOG_VERBOSE, "Perform LUN reset on target");
- ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
- CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Wait until all unit attentions clear");
- while (testunitready(sd, EXPECT_STATUS_GOOD) != 0)
- ;
+
+ logging(LOG_VERBOSE, "Perform LUN reset on target");
+ ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
+ CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Wait until all unit attentions clear");
+ while (testunitready(sd, EXPECT_STATUS_GOOD) != 0)
+ ;
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we can not access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can not access the media.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
- logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
+ logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_preventallow_simple.c b/test-tool/test_preventallow_simple.c
index a66fd61..27c0779 100644
--- a/test-tool/test_preventallow_simple.c
+++ b/test-tool/test_preventallow_simple.c
@@ -28,15 +28,15 @@
void
test_preventallow_simple(void)
{
- CHECK_FOR_SBC;
- CHECK_FOR_REMOVABLE;
+ CHECK_FOR_SBC;
+ CHECK_FOR_REMOVABLE;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test PREVENTALLOW basics");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test PREVENTALLOW basics");
- logging(LOG_VERBOSE, "Test we can set PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Test we can set PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
}
diff --git a/test-tool/test_preventallow_warm_reset.c b/test-tool/test_preventallow_warm_reset.c
index da5781a..c3e713d 100644
--- a/test-tool/test_preventallow_warm_reset.c
+++ b/test-tool/test_preventallow_warm_reset.c
@@ -28,58 +28,58 @@
void
test_preventallow_warm_reset(void)
{
- int ret;
+ int ret;
- CHECK_FOR_SBC;
- CHECK_FOR_REMOVABLE;
+ CHECK_FOR_SBC;
+ CHECK_FOR_REMOVABLE;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PREVENTALLOW test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PREVENTALLOW test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Set the PREVENT flag");
- PREVENTALLOW(sd, 1);
+ logging(LOG_VERBOSE, "Set the PREVENT flag");
+ PREVENTALLOW(sd, 1);
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
- logging(LOG_VERBOSE, "Verify we can still access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can still access the media.");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
-
- logging(LOG_VERBOSE, "Perform warm reset on target");
- ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
- CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Wait until all unit attentions clear");
- while (testunitready(sd, EXPECT_STATUS_GOOD) != 0)
- ;
+
+ logging(LOG_VERBOSE, "Perform warm reset on target");
+ ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
+ CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Wait until all unit attentions clear");
+ while (testunitready(sd, EXPECT_STATUS_GOOD) != 0)
+ ;
- logging(LOG_VERBOSE, "Try to eject the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Try to eject the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we can not access the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can not access the media.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
- logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
- PREVENTALLOW(sd, 0);
+ logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
+ logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
+ PREVENTALLOW(sd, 0);
- logging(LOG_VERBOSE, "Load the medium");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Load the medium");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_prin_read_keys_simple.c b/test-tool/test_prin_read_keys_simple.c
index 5489742..127925c 100644
--- a/test-tool/test_prin_read_keys_simple.c
+++ b/test-tool/test_prin_read_keys_simple.c
@@ -30,34 +30,34 @@
void
test_prin_read_keys_simple(void)
{
- int ret = 0;
- int al;
+ int ret = 0;
+ int al;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test Persistent Reserve IN READ_KEYS works.");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve IN READ_KEYS works.");
- ret = prin_read_keys(sd, &task, NULL);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE IN is not implemented.");
- CU_PASS("PERSISTENT RESERVE IN is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ ret = prin_read_keys(sd, &task, NULL);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE IN is not implemented.");
+ CU_PASS("PERSISTENT RESERVE IN is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Test DATA-IN is at least 8 bytes.");
- if (task->datain.size < 8) {
- logging(LOG_NORMAL,
- "[FAILED] DATA-IN returned less than 8 bytes");
- return;
- }
+ logging(LOG_VERBOSE, "Test DATA-IN is at least 8 bytes.");
+ if (task->datain.size < 8) {
+ logging(LOG_NORMAL,
+ "[FAILED] DATA-IN returned less than 8 bytes");
+ return;
+ }
- logging(LOG_VERBOSE, "Test ADDITIONAL_LENGTH matches DATA_IN size.");
- al = scsi_get_uint32(&task->datain.data[4]);
- if (al != task->datain.size - 8) {
- logging(LOG_NORMAL,
- "[FAILED] ADDITIONAL_LENGTH was %d bytes but %d was expected.",
- al, task->datain.size - 8);
- return;
- }
+ logging(LOG_VERBOSE, "Test ADDITIONAL_LENGTH matches DATA_IN size.");
+ al = scsi_get_uint32(&task->datain.data[4]);
+ if (al != task->datain.size - 8) {
+ logging(LOG_NORMAL,
+ "[FAILED] ADDITIONAL_LENGTH was %d bytes but %d was expected.",
+ al, task->datain.size - 8);
+ return;
+ }
}
diff --git a/test-tool/test_prin_report_caps.c b/test-tool/test_prin_report_caps.c
index aaa251d..167730a 100644
--- a/test-tool/test_prin_report_caps.c
+++ b/test-tool/test_prin_report_caps.c
@@ -27,89 +27,89 @@
#include "iscsi-test-cu.h"
static struct test_prin_report_caps_types {
- enum scsi_persistent_reservation_type_mask mask;
- enum scsi_persistent_out_type op;
+ enum scsi_persistent_reservation_type_mask mask;
+ enum scsi_persistent_out_type op;
} report_caps_types_array[] = {
- { SCSI_PR_TYPE_MASK_WR_EX_AR,
- SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS },
- { SCSI_PR_TYPE_MASK_EX_AC_RO,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY },
- { SCSI_PR_TYPE_MASK_WR_EX_RO,
- SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY },
- { SCSI_PR_TYPE_MASK_EX_AC,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS },
- { SCSI_PR_TYPE_MASK_WR_EX,
- SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE },
- { SCSI_PR_TYPE_MASK_EX_AC_AR,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS },
- { 0, 0 }
+ { SCSI_PR_TYPE_MASK_WR_EX_AR,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS },
+ { SCSI_PR_TYPE_MASK_EX_AC_RO,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY },
+ { SCSI_PR_TYPE_MASK_WR_EX_RO,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY },
+ { SCSI_PR_TYPE_MASK_EX_AC,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS },
+ { SCSI_PR_TYPE_MASK_WR_EX,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE },
+ { SCSI_PR_TYPE_MASK_EX_AC_AR,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS },
+ { 0, 0 }
};
void
test_prin_report_caps_simple(void)
{
- int ret = 0;
- const unsigned long long key = rand_key();
- struct scsi_task *tsk;
- struct scsi_persistent_reserve_in_report_capabilities *rcaps;
- struct test_prin_report_caps_types *type;
+ int ret = 0;
+ const unsigned long long key = rand_key();
+ struct scsi_task *tsk;
+ struct scsi_persistent_reserve_in_report_capabilities *rcaps;
+ struct test_prin_report_caps_types *type;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE,
- "Test Persistent Reserve In REPORT CAPABILITIES works.");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE,
+ "Test Persistent Reserve In REPORT CAPABILITIES works.");
- /* register our reservation key with the target */
- ret = prout_register_and_ignore(sd, key);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
- CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(sd, key);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
+ CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- ret = prin_report_caps(sd, &tsk, &rcaps);
- CU_ASSERT_EQUAL(ret, 0);
+ ret = prin_report_caps(sd, &tsk, &rcaps);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE,
- "Checking PERSISTENT RESERVE IN REPORT CAPABILITIES fields.");
- CU_ASSERT_EQUAL(rcaps->length, 8);
- CU_ASSERT_TRUE(rcaps->allow_commands <= 5);
- CU_ASSERT_EQUAL(rcaps->persistent_reservation_type_mask
- & ~SCSI_PR_TYPE_MASK_ALL, 0);
+ logging(LOG_VERBOSE,
+ "Checking PERSISTENT RESERVE IN REPORT CAPABILITIES fields.");
+ CU_ASSERT_EQUAL(rcaps->length, 8);
+ CU_ASSERT_TRUE(rcaps->allow_commands <= 5);
+ CU_ASSERT_EQUAL(rcaps->persistent_reservation_type_mask
+ & ~SCSI_PR_TYPE_MASK_ALL, 0);
- for (type = &report_caps_types_array[0]; type->mask != 0; type++) {
- if (!(rcaps->persistent_reservation_type_mask & type->mask)) {
- logging(LOG_NORMAL,
- "PERSISTENT RESERVE op 0x%x not supported",
- type->op);
- continue;
- }
+ for (type = &report_caps_types_array[0]; type->mask != 0; type++) {
+ if (!(rcaps->persistent_reservation_type_mask & type->mask)) {
+ logging(LOG_NORMAL,
+ "PERSISTENT RESERVE op 0x%x not supported",
+ type->op);
+ continue;
+ }
- logging(LOG_VERBOSE,
- "PERSISTENT RESERVE OUT op 0x%x supported, testing",
- type->op);
+ logging(LOG_VERBOSE,
+ "PERSISTENT RESERVE OUT op 0x%x supported, testing",
+ type->op);
- /* reserve the target */
- ret = prout_reserve(sd, key, type->op);
- CU_ASSERT_EQUAL(ret, 0);
+ /* reserve the target */
+ ret = prout_reserve(sd, key, type->op);
+ CU_ASSERT_EQUAL(ret, 0);
- /* verify target reservation */
- ret = prin_verify_reserved_as(sd,
- pr_type_is_all_registrants(type->op) ? 0 : key,
- type->op);
- CU_ASSERT_EQUAL(0, ret);
+ /* verify target reservation */
+ ret = prin_verify_reserved_as(sd,
+ pr_type_is_all_registrants(type->op) ? 0 : key,
+ type->op);
+ CU_ASSERT_EQUAL(0, ret);
- /* release the target */
- ret = prout_release(sd, key, type->op);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ /* release the target */
+ ret = prout_release(sd, key, type->op);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- scsi_free_scsi_task(tsk);
- rcaps = NULL; /* freed with tsk */
+ scsi_free_scsi_task(tsk);
+ rcaps = NULL; /* freed with tsk */
- /* drop registration */
- ret = prout_register_key(sd, 0, key);
- CU_ASSERT_EQUAL(ret, 0);
+ /* drop registration */
+ ret = prout_register_key(sd, 0, key);
+ CU_ASSERT_EQUAL(ret, 0);
}
diff --git a/test-tool/test_prin_serviceaction_range.c b/test-tool/test_prin_serviceaction_range.c
index 7b720a1..4551c0a 100644
--- a/test-tool/test_prin_serviceaction_range.c
+++ b/test-tool/test_prin_serviceaction_range.c
@@ -30,31 +30,31 @@
void
test_prin_serviceaction_range(void)
{
- int ret = 0;
- int i;
+ int ret = 0;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test Persistent Reserve IN Serviceaction range.");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve IN Serviceaction range.");
- /* verify PRIN/READ_KEYS works -- XXX redundant -- remove this? */
- ret = prin_read_keys(sd, &task, NULL);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE IN is not implemented.");
- CU_PASS("PERSISTENT RESERVE IN is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ /* verify PRIN/READ_KEYS works -- XXX redundant -- remove this? */
+ ret = prin_read_keys(sd, &task, NULL);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE IN is not implemented.");
+ CU_PASS("PERSISTENT RESERVE IN is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- /* verify that PRIN/SA={0,1,2,3} works ... */
- for (i = 0; i < 4; i++) {
- ret = prin_task(sd, i, 1);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ /* verify that PRIN/SA={0,1,2,3} works ... */
+ for (i = 0; i < 4; i++) {
+ ret = prin_task(sd, i, 1);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- /* verify that PRIN/SA={4..0x20} fails ... */
- for (i = 4; i < 0x20; i++) {
- ret = prin_task(sd, i, 0);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ /* verify that PRIN/SA={4..0x20} fails ... */
+ for (i = 4; i < 0x20; i++) {
+ ret = prin_task(sd, i, 0);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
}
diff --git a/test-tool/test_prout_clear_simple.c b/test-tool/test_prout_clear_simple.c
index 8492220..a78f6d2 100644
--- a/test-tool/test_prout_clear_simple.c
+++ b/test-tool/test_prout_clear_simple.c
@@ -29,60 +29,60 @@
void
test_prout_clear_simple(void)
{
- int ret = 0;
- uint32_t old_gen;
- const unsigned long long key = rand_key();
- struct scsi_task *tsk;
- struct scsi_persistent_reserve_in_read_keys *rk;
+ int ret = 0;
+ uint32_t old_gen;
+ const unsigned long long key = rand_key();
+ struct scsi_task *tsk;
+ struct scsi_persistent_reserve_in_read_keys *rk;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test Persistent Reserve OUT CLEAR works.");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve OUT CLEAR works.");
- /* register our reservation key with the target */
- ret = prout_register_and_ignore(sd, key);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
- CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(sd, key);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTENT RESERVE OUT is not implemented.");
+ CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- ret = prin_read_keys(sd, &tsk, &rk);
- CU_ASSERT_EQUAL(ret, 0);
+ ret = prin_read_keys(sd, &tsk, &rk);
+ CU_ASSERT_EQUAL(ret, 0);
- CU_ASSERT_NOT_EQUAL(rk->num_keys, 0);
- /* retain PR generation number to check for increments */
- old_gen = rk->prgeneration;
+ CU_ASSERT_NOT_EQUAL(rk->num_keys, 0);
+ /* retain PR generation number to check for increments */
+ old_gen = rk->prgeneration;
- scsi_free_scsi_task(tsk);
- rk = NULL; /* freed with tsk */
+ scsi_free_scsi_task(tsk);
+ rk = NULL; /* freed with tsk */
- /* reserve the target */
- ret = prout_reserve(sd, key,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS);
- CU_ASSERT_EQUAL(ret, 0);
+ /* reserve the target */
+ ret = prout_reserve(sd, key,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS);
+ CU_ASSERT_EQUAL(ret, 0);
- /* verify target reservation */
- ret = prin_verify_reserved_as(sd, key,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS);
- CU_ASSERT_EQUAL(ret, 0);
+ /* verify target reservation */
+ ret = prin_verify_reserved_as(sd, key,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS);
+ CU_ASSERT_EQUAL(ret, 0);
- /* clear reservation and registration */
- ret = prout_clear(sd, key);
- CU_ASSERT_EQUAL(ret, 0);
+ /* clear reservation and registration */
+ ret = prout_clear(sd, key);
+ CU_ASSERT_EQUAL(ret, 0);
- ret = prin_verify_not_reserved(sd);
- CU_ASSERT_EQUAL(ret, 0);
+ ret = prin_verify_not_reserved(sd);
+ CU_ASSERT_EQUAL(ret, 0);
- ret = prin_read_keys(sd, &tsk, &rk);
- CU_ASSERT_EQUAL(ret, 0);
+ ret = prin_read_keys(sd, &tsk, &rk);
+ CU_ASSERT_EQUAL(ret, 0);
- CU_ASSERT_EQUAL(rk->num_keys, 0);
- /* generation incremented once for CLEAR (not for RESERVE) */
- CU_ASSERT_EQUAL(rk->prgeneration, old_gen + 1);
+ CU_ASSERT_EQUAL(rk->num_keys, 0);
+ /* generation incremented once for CLEAR (not for RESERVE) */
+ CU_ASSERT_EQUAL(rk->prgeneration, old_gen + 1);
- scsi_free_scsi_task(tsk);
- rk = NULL; /* freed with tsk */
+ scsi_free_scsi_task(tsk);
+ rk = NULL; /* freed with tsk */
}
diff --git a/test-tool/test_prout_preempt.c b/test-tool/test_prout_preempt.c
index a101b1c..201acca 100644
--- a/test-tool/test_prout_preempt.c
+++ b/test-tool/test_prout_preempt.c
@@ -30,86 +30,86 @@
void
test_prout_preempt_rm_reg(void)
{
- int ret = 0;
- const unsigned long long k1 = rand_key();
- const unsigned long long k2 = rand_key();
- struct scsi_device *sd2;
- struct scsi_task *tsk;
- uint32_t old_gen;
- int num_uas;
- struct scsi_persistent_reserve_in_read_keys *rk;
+ int ret = 0;
+ const unsigned long long k1 = rand_key();
+ const unsigned long long k2 = rand_key();
+ struct scsi_device *sd2;
+ struct scsi_task *tsk;
+ uint32_t old_gen;
+ int num_uas;
+ struct scsi_persistent_reserve_in_read_keys *rk;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test Persistent Reserve IN PREEMPT works.");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve IN PREEMPT works.");
- ret = prout_register_and_ignore(sd, k1);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
- CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ ret = prout_register_and_ignore(sd, k1);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
+ CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- /* clear all PR state */
- ret = prout_clear(sd, k1);
- CU_ASSERT_EQUAL(ret, 0);
+ /* clear all PR state */
+ ret = prout_clear(sd, k1);
+ CU_ASSERT_EQUAL(ret, 0);
- /* need to reregister cleared key */
- ret = prout_register_and_ignore(sd, k1);
- CU_ASSERT_EQUAL(ret, 0);
+ /* need to reregister cleared key */
+ ret = prout_register_and_ignore(sd, k1);
+ CU_ASSERT_EQUAL(ret, 0);
- ret = mpath_sd2_get_or_clone(sd, &sd2);
- CU_ASSERT_EQUAL(ret, 0);
+ ret = mpath_sd2_get_or_clone(sd, &sd2);
+ CU_ASSERT_EQUAL(ret, 0);
- if (ret < 0)
- return;
+ if (ret < 0)
+ return;
- /* register secondary key */
- ret = prout_register_and_ignore(sd2, k2);
- CU_ASSERT_EQUAL(ret, 0);
+ /* register secondary key */
+ ret = prout_register_and_ignore(sd2, k2);
+ CU_ASSERT_EQUAL(ret, 0);
- /* confirm that k1 and k2 are registered */
- ret = prin_read_keys(sd, &tsk, &rk);
- CU_ASSERT_EQUAL_FATAL(ret, 0);
+ /* confirm that k1 and k2 are registered */
+ ret = prin_read_keys(sd, &tsk, &rk);
+ CU_ASSERT_EQUAL_FATAL(ret, 0);
- CU_ASSERT_EQUAL(rk->num_keys, 2);
- /* retain PR generation number to check for increments */
- old_gen = rk->prgeneration;
+ CU_ASSERT_EQUAL(rk->num_keys, 2);
+ /* retain PR generation number to check for increments */
+ old_gen = rk->prgeneration;
- scsi_free_scsi_task(tsk);
- rk = NULL; /* freed with tsk */
+ scsi_free_scsi_task(tsk);
+ rk = NULL; /* freed with tsk */
- /* use second connection to clear k1 registration */
- ret = prout_preempt(sd2, k1, k2,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS);
- CU_ASSERT_EQUAL(ret, 0);
+ /* use second connection to clear k1 registration */
+ ret = prout_preempt(sd2, k1, k2,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS);
+ CU_ASSERT_EQUAL(ret, 0);
- /* clear any UAs generated by preempt */
- ret = test_iscsi_tur_until_good(sd, &num_uas);
- CU_ASSERT_EQUAL(ret, 0);
- ret = test_iscsi_tur_until_good(sd2, &num_uas);
- CU_ASSERT_EQUAL(ret, 0);
+ /* clear any UAs generated by preempt */
+ ret = test_iscsi_tur_until_good(sd, &num_uas);
+ CU_ASSERT_EQUAL(ret, 0);
+ ret = test_iscsi_tur_until_good(sd2, &num_uas);
+ CU_ASSERT_EQUAL(ret, 0);
- ret = prin_read_keys(sd, &tsk, &rk);
- CU_ASSERT_EQUAL_FATAL(ret, 0);
+ ret = prin_read_keys(sd, &tsk, &rk);
+ CU_ASSERT_EQUAL_FATAL(ret, 0);
- CU_ASSERT_EQUAL(rk->num_keys, 1);
- /* ensure preempt bumped generation number */
- CU_ASSERT_EQUAL(rk->prgeneration, old_gen + 1);
- /* ensure k2 is retained */
- CU_ASSERT_EQUAL(rk->keys[0], k2);
+ CU_ASSERT_EQUAL(rk->num_keys, 1);
+ /* ensure preempt bumped generation number */
+ CU_ASSERT_EQUAL(rk->prgeneration, old_gen + 1);
+ /* ensure k2 is retained */
+ CU_ASSERT_EQUAL(rk->keys[0], k2);
- /* unregister k2 */
- ret = prout_register_key(sd2, 0, k2);
- CU_ASSERT_EQUAL(ret, 0);
+ /* unregister k2 */
+ ret = prout_register_key(sd2, 0, k2);
+ CU_ASSERT_EQUAL(ret, 0);
}
diff --git a/test-tool/test_prout_register_simple.c b/test-tool/test_prout_register_simple.c
index ccbd05f..c705875 100644
--- a/test-tool/test_prout_register_simple.c
+++ b/test-tool/test_prout_register_simple.c
@@ -30,35 +30,35 @@
void
test_prout_register_simple(void)
{
- const unsigned long long key = rand_key();
- int ret = 0;
+ const unsigned long long key = rand_key();
+ int ret = 0;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test Persistent Reserve IN REGISTER works.");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve IN REGISTER works.");
- /* register our reservation key with the target */
- ret = prout_register_and_ignore(sd, key);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
- CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(sd, key);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
+ CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- /* verify we can read the registration */
- ret = prin_verify_key_presence(sd, key, 1);
- CU_ASSERT_EQUAL(ret, 0);
+ /* verify we can read the registration */
+ ret = prin_verify_key_presence(sd, key, 1);
+ CU_ASSERT_EQUAL(ret, 0);
- /* try to reregister, which should fail */
- ret = prout_reregister_key_fails(sd, key+1);
- CU_ASSERT_EQUAL(ret, 0);
+ /* try to reregister, which should fail */
+ ret = prout_reregister_key_fails(sd, key+1);
+ CU_ASSERT_EQUAL(ret, 0);
- /* release from the target */
- ret = prout_register_key(sd, 0, key);
- CU_ASSERT_EQUAL(ret, 0);
+ /* release from the target */
+ ret = prout_register_key(sd, 0, key);
+ CU_ASSERT_EQUAL(ret, 0);
- /* Verify the registration is gone */
- ret = prin_verify_key_presence(sd, key, 0);
- CU_ASSERT_EQUAL(ret, 0);
+ /* Verify the registration is gone */
+ ret = prin_verify_key_presence(sd, key, 0);
+ CU_ASSERT_EQUAL(ret, 0);
}
diff --git a/test-tool/test_prout_reserve_access.c b/test-tool/test_prout_reserve_access.c
index 1d84872..4f17848 100644
--- a/test-tool/test_prout_reserve_access.c
+++ b/test-tool/test_prout_reserve_access.c
@@ -33,232 +33,232 @@ verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd
int unreg_i2_can_read,
int unreg_i2_can_write)
{
- int ret;
- const unsigned long long key = rand_key();
- const unsigned long long key2 = rand_key();
+ int ret;
+ const unsigned long long key = rand_key();
+ const unsigned long long key2 = rand_key();
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE,
- "Verify access for reservation type: %s",
- scsi_pr_type_str(pr_type));
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE,
+ "Verify access for reservation type: %s",
+ scsi_pr_type_str(pr_type));
- /* send TURs to clear possible check conditions */
- (void) testunitready_clear_ua(sd1);
- (void) testunitready_clear_ua(sd2);
+ /* send TURs to clear possible check conditions */
+ (void) testunitready_clear_ua(sd1);
+ (void) testunitready_clear_ua(sd2);
- /* register our reservation key with the target */
- ret = prout_register_and_ignore(sd1, key);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
- CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(0, ret);
- ret = prout_register_and_ignore(sd2, key2);
- CU_ASSERT_EQUAL(0, ret);
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(sd1, key);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
+ CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(0, ret);
+ ret = prout_register_and_ignore(sd2, key2);
+ CU_ASSERT_EQUAL(0, ret);
- /* reserve the target through initiator 1 */
- ret = prout_reserve(sd1, key, pr_type);
- CU_ASSERT_EQUAL(0, ret);
+ /* reserve the target through initiator 1 */
+ ret = prout_reserve(sd1, key, pr_type);
+ CU_ASSERT_EQUAL(0, ret);
- /* verify target reservation */
- ret = prin_verify_reserved_as(sd1,
- pr_type_is_all_registrants(pr_type) ? 0 : key,
- pr_type);
- CU_ASSERT_EQUAL(0, ret);
+ /* verify target reservation */
+ ret = prin_verify_reserved_as(sd1,
+ pr_type_is_all_registrants(pr_type) ? 0 : key,
+ pr_type);
+ CU_ASSERT_EQUAL(0, ret);
- CU_ASSERT_PTR_NOT_NULL_FATAL(scratch);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(scratch);
- /* make sure init1 can read */
- ret = verify_read_works(sd1, scratch);
- CU_ASSERT_EQUAL(0, ret);
+ /* make sure init1 can read */
+ ret = verify_read_works(sd1, scratch);
+ CU_ASSERT_EQUAL(0, ret);
- /* make sure init1 can write */
- ret = verify_write_works(sd1, scratch);
- CU_ASSERT_EQUAL(0, ret);
+ /* make sure init1 can write */
+ ret = verify_write_works(sd1, scratch);
+ CU_ASSERT_EQUAL(0, ret);
- /* verify registered init2 read access */
- if (reg_i2_can_read)
- ret = verify_read_works(sd2, scratch);
- else
- ret = verify_read_fails(sd2, scratch);
- CU_ASSERT_EQUAL(0, ret);
+ /* verify registered init2 read access */
+ if (reg_i2_can_read)
+ ret = verify_read_works(sd2, scratch);
+ else
+ ret = verify_read_fails(sd2, scratch);
+ CU_ASSERT_EQUAL(0, ret);
- /* verify registered init2 write access */
- if (reg_i2_can_write)
- ret = verify_write_works(sd2, scratch);
- else
- ret = verify_write_fails(sd2, scratch);
- CU_ASSERT_EQUAL(0, ret);
+ /* verify registered init2 write access */
+ if (reg_i2_can_write)
+ ret = verify_write_works(sd2, scratch);
+ else
+ ret = verify_write_fails(sd2, scratch);
+ CU_ASSERT_EQUAL(0, ret);
- /* unregister init2 */
- ret = prout_register_key(sd2, 0, key2);
- CU_ASSERT_EQUAL(0, ret);
+ /* unregister init2 */
+ ret = prout_register_key(sd2, 0, key2);
+ CU_ASSERT_EQUAL(0, ret);
- /* verify unregistered init2 read access */
- if (unreg_i2_can_read)
- ret = verify_read_works(sd2, scratch);
- else
- ret = verify_read_fails(sd2, scratch);
- CU_ASSERT_EQUAL(0, ret);
+ /* verify unregistered init2 read access */
+ if (unreg_i2_can_read)
+ ret = verify_read_works(sd2, scratch);
+ else
+ ret = verify_read_fails(sd2, scratch);
+ CU_ASSERT_EQUAL(0, ret);
- /* verify unregistered init2 write access */
- if (unreg_i2_can_write)
- ret = verify_write_works(sd2, scratch);
- else
- ret = verify_write_fails(sd2, scratch);
- CU_ASSERT_EQUAL(0, ret);
+ /* verify unregistered init2 write access */
+ if (unreg_i2_can_write)
+ ret = verify_write_works(sd2, scratch);
+ else
+ ret = verify_write_fails(sd2, scratch);
+ CU_ASSERT_EQUAL(0, ret);
- /* release our reservation */
- ret = prout_release(sd1, key, pr_type);
- CU_ASSERT_EQUAL(0, ret);
+ /* release our reservation */
+ ret = prout_release(sd1, key, pr_type);
+ CU_ASSERT_EQUAL(0, ret);
- /* remove our key from the target */
- ret = prout_register_key(sd1, 0, key);
- CU_ASSERT_EQUAL(0, ret);
+ /* remove our key from the target */
+ ret = prout_register_key(sd1, 0, key);
+ CU_ASSERT_EQUAL(0, ret);
}
void
test_prout_reserve_access_ea(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
- mpath_sd2_put(sd2);
+ 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);
+ mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_we(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
- mpath_sd2_put(sd2);
+ 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);
+ mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_earo(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
- mpath_sd2_put(sd2);
+ 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);
+ mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_wero(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
- mpath_sd2_put(sd2);
+ 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);
+ mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_eaar(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
- mpath_sd2_put(sd2);
+ 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);
+ mpath_sd2_put(sd2);
}
void
test_prout_reserve_access_wear(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
- mpath_sd2_put(sd2);
+ 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);
+ mpath_sd2_put(sd2);
}
diff --git a/test-tool/test_prout_reserve_ownership.c b/test-tool/test_prout_reserve_ownership.c
index b75e903..b14478c 100644
--- a/test-tool/test_prout_reserve_ownership.c
+++ b/test-tool/test_prout_reserve_ownership.c
@@ -30,204 +30,204 @@ verify_persistent_reserve_ownership(struct scsi_device *sd1, struct scsi_device
const enum scsi_persistent_out_type pr_type,
int resvn_is_shared)
{
- int ret;
- const unsigned long long key1 = rand_key();
- const unsigned long long key2 = rand_key();
+ int ret;
+ const unsigned long long key1 = rand_key();
+ const unsigned long long key2 = rand_key();
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE,
- "Verify ownership for reservation type: %s",
- scsi_pr_type_str(pr_type));
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE,
+ "Verify ownership for reservation type: %s",
+ scsi_pr_type_str(pr_type));
- /* send TURs to clear possible check conditions */
- (void) testunitready_clear_ua(sd1);
- (void) testunitready_clear_ua(sd2);
+ /* send TURs to clear possible check conditions */
+ (void) testunitready_clear_ua(sd1);
+ (void) testunitready_clear_ua(sd2);
- /* register our reservation key with the target */
- ret = prout_register_and_ignore(sd1, key1);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
- CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(0, ret);
- ret = prout_register_and_ignore(sd2, key2);
- CU_ASSERT_EQUAL(0, ret);
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(sd1, key1);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
+ CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(0, ret);
+ ret = prout_register_and_ignore(sd2, key2);
+ CU_ASSERT_EQUAL(0, ret);
- /* reserve the target through initiator 1 */
- ret = prout_reserve(sd1, key1, pr_type);
- CU_ASSERT_EQUAL(0, ret);
+ /* reserve the target through initiator 1 */
+ ret = prout_reserve(sd1, key1, pr_type);
+ CU_ASSERT_EQUAL(0, ret);
- /* verify target reservation */
- ret = prin_verify_reserved_as(sd1,
- pr_type_is_all_registrants(pr_type) ? 0 : key1,
- pr_type);
- CU_ASSERT_EQUAL(0, ret);
+ /* verify target reservation */
+ ret = prin_verify_reserved_as(sd1,
+ pr_type_is_all_registrants(pr_type) ? 0 : key1,
+ pr_type);
+ CU_ASSERT_EQUAL(0, ret);
- /* unregister init1 */
- ret = prout_register_key(sd1, 0, key1);
- CU_ASSERT_EQUAL(0, ret);
+ /* unregister init1 */
+ ret = prout_register_key(sd1, 0, key1);
+ CU_ASSERT_EQUAL(0, ret);
- /* verify if reservation is still present */
- if (resvn_is_shared) {
- /* verify target reservation */
- ret = prin_verify_reserved_as(sd1,
- pr_type_is_all_registrants(pr_type) ? 0 : key1,
- pr_type);
- CU_ASSERT_EQUAL(0, ret);
+ /* verify if reservation is still present */
+ if (resvn_is_shared) {
+ /* verify target reservation */
+ ret = prin_verify_reserved_as(sd1,
+ pr_type_is_all_registrants(pr_type) ? 0 : key1,
+ pr_type);
+ CU_ASSERT_EQUAL(0, ret);
- /* release our reservation */
- ret = prout_release(sd2, key2, pr_type);
- CU_ASSERT_EQUAL(0, ret);
- } else {
- /* verify target is not reserved now */
- ret = prin_verify_not_reserved(sd1);
- CU_ASSERT_EQUAL(0, ret);
+ /* release our reservation */
+ ret = prout_release(sd2, key2, pr_type);
+ CU_ASSERT_EQUAL(0, ret);
+ } else {
+ /* verify target is not reserved now */
+ ret = prin_verify_not_reserved(sd1);
+ CU_ASSERT_EQUAL(0, ret);
- /* send TUR to clear possible check condition */
- (void) testunitready_clear_ua(sd2);
- }
+ /* send TUR to clear possible check condition */
+ (void) testunitready_clear_ua(sd2);
+ }
- /* remove our remaining key from the target */
- ret = prout_register_key(sd2, 0, key2);
- CU_ASSERT_EQUAL(0, ret);
+ /* remove our remaining key from the target */
+ ret = prout_register_key(sd2, 0, key2);
+ CU_ASSERT_EQUAL(0, ret);
}
void
test_prout_reserve_ownership_ea(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
+ 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);
}
void
test_prout_reserve_ownership_we(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
+ 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);
}
void
test_prout_reserve_ownership_earo(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
+ 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);
}
void
test_prout_reserve_ownership_wero(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
+ 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);
}
void
test_prout_reserve_ownership_eaar(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
+ 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);
}
void
test_prout_reserve_ownership_wear(void)
{
- struct scsi_device *sd2;
- int ret;
+ struct scsi_device *sd2;
+ int ret;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
- "only supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
+ "only supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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);
+ 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_prout_reserve_simple.c b/test-tool/test_prout_reserve_simple.c
index 8427697..14d4793 100644
--- a/test-tool/test_prout_reserve_simple.c
+++ b/test-tool/test_prout_reserve_simple.c
@@ -31,57 +31,57 @@
* list of persistent reservation types to test, in order
*/
static enum scsi_persistent_out_type pr_types_to_test[] = {
- SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
- SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
- SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
- SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
- 0
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
+ 0
};
void
test_prout_reserve_simple(void)
{
- int ret = 0;
- int i;
- const unsigned long long key = rand_key();
+ int ret = 0;
+ int i;
+ const unsigned long long key = rand_key();
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test Persistent Reserve IN RESERVE works.");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve IN RESERVE works.");
- /* register our reservation key with the target */
- ret = prout_register_and_ignore(sd, key);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
- CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(sd, key);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
+ CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- /* test each reservatoin type */
- for (i = 0; pr_types_to_test[i] != 0; i++) {
- enum scsi_persistent_out_type pr_type = pr_types_to_test[i];
+ /* test each reservatoin type */
+ for (i = 0; pr_types_to_test[i] != 0; i++) {
+ enum scsi_persistent_out_type pr_type = pr_types_to_test[i];
- /* reserve the target */
- ret = prout_reserve(sd, key, pr_type);
- CU_ASSERT_EQUAL(ret, 0);
+ /* reserve the target */
+ ret = prout_reserve(sd, key, pr_type);
+ CU_ASSERT_EQUAL(ret, 0);
- /* verify target reservation */
- ret = prin_verify_reserved_as(sd,
- pr_type_is_all_registrants(pr_type) ? 0 : key,
- pr_type);
- CU_ASSERT_EQUAL(ret, 0);
+ /* verify target reservation */
+ ret = prin_verify_reserved_as(sd,
+ pr_type_is_all_registrants(pr_type) ? 0 : key,
+ pr_type);
+ CU_ASSERT_EQUAL(ret, 0);
- /* release our reservation */
- ret = prout_release(sd, key, pr_type);
- CU_ASSERT_EQUAL(ret, 0);
- }
+ /* release our reservation */
+ ret = prout_release(sd, key, pr_type);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- /* remove our key from the target */
- ret = prout_register_key(sd, 0, key);
- CU_ASSERT_EQUAL(ret, 0);
+ /* remove our key from the target */
+ ret = prout_register_key(sd, 0, key);
+ CU_ASSERT_EQUAL(ret, 0);
}
diff --git a/test-tool/test_read10_0blocks.c b/test-tool/test_read10_0blocks.c
index 02f3390..808bc51 100644
--- a/test-tool/test_read10_0blocks.c
+++ b/test-tool/test_read10_0blocks.c
@@ -27,26 +27,26 @@
void
test_read10_0blocks(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==0");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==0");
- READ10(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ READ10(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- if (num_blocks > 0x80000000) {
- CU_PASS("[SKIPPED] LUN is too big");
- return;
- }
+ if (num_blocks > 0x80000000) {
+ CU_PASS("[SKIPPED] LUN is too big");
+ return;
+ }
- logging(LOG_VERBOSE, "Test READ10 0-blocks one block past end-of-LUN");
- READ10(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ10 0-blocks one block past end-of-LUN");
+ READ10(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==2^31");
- READ10(sd, NULL, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==2^31");
+ READ10(sd, NULL, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==-1");
- READ10(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==-1");
+ READ10(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_read10_beyond_eol.c b/test-tool/test_read10_beyond_eol.c
index 9fc5542..7fee33a 100644
--- a/test-tool/test_read10_beyond_eol.c
+++ b/test-tool/test_read10_beyond_eol.c
@@ -28,51 +28,51 @@
void
test_read10_beyond_eol(void)
{
- int i;
+ int i;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with READ10. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with READ10. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ10 1-256 blocks one block beyond the end");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ10 1-256 blocks one block beyond the end");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ10 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, 0x80000000,
+ logging(LOG_VERBOSE, "Test READ10 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ10 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test READ10 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ10 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test READ10 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_read10_dpofua.c b/test-tool/test_read10_dpofua.c
index f2dbe9e..e9edcec 100644
--- a/test-tool/test_read10_dpofua.c
+++ b/test-tool/test_read10_dpofua.c
@@ -29,80 +29,80 @@
void
test_read10_dpofua(void)
{
- int dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ10 DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ10 DPO/FUA flags");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test READ10 with DPO==1");
- if (dpofua) {
- READ10(sd, NULL, 0,
+ logging(LOG_VERBOSE, "Test READ10 with DPO==1");
+ if (dpofua) {
+ READ10(sd, NULL, 0,
block_size, block_size, 0, 1, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ10(sd, NULL, 0,
+ } else {
+ READ10(sd, NULL, 0,
block_size, block_size, 0, 1, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ10 with FUA==1");
- if (dpofua) {
- READ10(sd, NULL, 0,
+ logging(LOG_VERBOSE, "Test READ10 with FUA==1");
+ if (dpofua) {
+ READ10(sd, NULL, 0,
block_size, block_size, 0, 0, 1, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ10(sd, NULL, 0,
+ } else {
+ READ10(sd, NULL, 0,
block_size, block_size, 0, 0, 1, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ10 with DPO==1 FUA==1");
- if (dpofua) {
- READ10(sd, NULL, 0,
+ logging(LOG_VERBOSE, "Test READ10 with DPO==1 FUA==1");
+ if (dpofua) {
+ READ10(sd, NULL, 0,
block_size, block_size, 0, 1, 1, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ10(sd, NULL, 0,
+ } else {
+ READ10(sd, NULL, 0,
block_size, block_size, 0, 1, 1, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for READ10");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for READ10");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_READ10,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -123,5 +123,5 @@ test_read10_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_read10_invalid.c b/test-tool/test_read10_invalid.c
index 7d9eb4d..e5eb709 100644
--- a/test-tool/test_read10_invalid.c
+++ b/test-tool/test_read10_invalid.c
@@ -32,236 +32,236 @@
void
test_read10_invalid(void)
{
- struct iscsi_data data;
- struct scsi_task *task_ret;
+ struct iscsi_data data;
+ struct scsi_task *task_ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test invalid READ10 commands");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test invalid READ10 commands");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This READ10 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This READ10 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* Try a read10 of 1 block but xferlength == 0 */
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ /* Try a read10 of 1 block but xferlength == 0 */
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 10000;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got a whole block back from the target");
- CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
+ logging(LOG_VERBOSE, "Verify we got a whole block back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 200;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got 200 bytes back from the target");
- CU_ASSERT_EQUAL(task->datain.size, 200);
+ logging(LOG_VERBOSE, "Verify we got 200 bytes back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, 200);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try reading two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 2;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 2;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = block_size;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
- CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
+ logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try READ10 for one block but flag it as a write on the iSCSI layer.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try READ10 for one block but flag it as a write on the iSCSI layer.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- memset(scratch, 0xa6, block_size);
- data.size = block_size;
- data.data = (unsigned char *)scratch;
+ memset(scratch, 0xa6, block_size);
+ data.size = block_size;
+ data.data = (unsigned char *)scratch;
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- iscsi_set_timeout(sd->iscsi_ctx, 3);
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ iscsi_set_timeout(sd->iscsi_ctx, 3);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ scsi_free_scsi_task(task);
+ task = NULL;
}
diff --git a/test-tool/test_read10_rdprotect.c b/test-tool/test_read10_rdprotect.c
index 2e70fa8..3a6aa25 100644
--- a/test-tool/test_read10_rdprotect.c
+++ b/test-tool/test_read10_rdprotect.c
@@ -29,25 +29,25 @@
void
test_read10_rdprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for RDPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ10 with non-zero RDPROTECT");
+ /*
+ * Try out different non-zero values for RDPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ10 with non-zero RDPROTECT");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- READ10(sd, NULL, 0, block_size, block_size,
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ READ10(sd, NULL, 0, block_size, block_size,
i, 0, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_read10_residuals.c b/test-tool/test_read10_residuals.c
index f425506..944cc20 100644
--- a/test-tool/test_read10_residuals.c
+++ b/test-tool/test_read10_residuals.c
@@ -35,206 +35,206 @@
void
test_read10_residuals(void)
{
- struct scsi_task *task_ret;
+ struct scsi_task *task_ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ10 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ10 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This READ10 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This READ10 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* Try a read10 of 1 block but xferlength == 0 */
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ /* Try a read10 of 1 block but xferlength == 0 */
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 10000;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
- if (task->datain.size != (int)block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target returned %u bytes "
- "of data but should have returned %zu bytes.",
- task->datain.size,block_size);
- }
- CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
+ logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
+ if (task->datain.size != (int)block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned %u bytes "
+ "of data but should have returned %zu bytes.",
+ task->datain.size,block_size);
+ }
+ CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 200;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got 200 bytes back from the target");
- CU_ASSERT_EQUAL(task->datain.size, 200);
+ logging(LOG_VERBOSE, "Verify we got 200 bytes back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, 200);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try reading two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ10;
- task->cdb[8] = 2;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ10;
+ task->cdb[8] = 2;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = block_size;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
- CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
+ logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
}
diff --git a/test-tool/test_read10_simple.c b/test-tool/test_read10_simple.c
index a5c4ef1..6fd2480 100644
--- a/test-tool/test_read10_simple.c
+++ b/test-tool/test_read10_simple.c
@@ -29,26 +29,26 @@
void
test_read10_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ10 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ10 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test READ10 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Test READ10 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_read12_0blocks.c b/test-tool/test_read12_0blocks.c
index e2e2983..4bcddb8 100644
--- a/test-tool/test_read12_0blocks.c
+++ b/test-tool/test_read12_0blocks.c
@@ -27,25 +27,25 @@
void
test_read12_0blocks(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==0");
- READ12(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==0");
+ READ12(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- if (num_blocks > 0x80000000) {
- CU_PASS("[SKIPPED] LUN is too big");
- return;
- }
+ if (num_blocks > 0x80000000) {
+ CU_PASS("[SKIPPED] LUN is too big");
+ return;
+ }
- logging(LOG_VERBOSE, "Test READ12 0-blocks one block past end-of-LUN");
- READ12(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ12 0-blocks one block past end-of-LUN");
+ READ12(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==2^31");
- READ12(sd, NULL, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==2^31");
+ READ12(sd, NULL, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==-1");
- READ12(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==-1");
+ READ12(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_read12_beyond_eol.c b/test-tool/test_read12_beyond_eol.c
index 5ac469c..bdfc53f 100644
--- a/test-tool/test_read12_beyond_eol.c
+++ b/test-tool/test_read12_beyond_eol.c
@@ -28,51 +28,51 @@
void
test_read12_beyond_eol(void)
{
- int i;
+ int i;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with READ12. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with READ12. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ12 1-256 blocks one block beyond the end");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ12 1-256 blocks one block beyond the end");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ12 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, 0x80000000,
+ logging(LOG_VERBOSE, "Test READ12 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ12 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test READ12 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ12 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test READ12 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_read12_dpofua.c b/test-tool/test_read12_dpofua.c
index 8b88a00..01d0639 100644
--- a/test-tool/test_read12_dpofua.c
+++ b/test-tool/test_read12_dpofua.c
@@ -29,79 +29,79 @@
void
test_read12_dpofua(void)
{
- int dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ12 DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ12 DPO/FUA flags");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test READ12 with DPO==1");
- if (dpofua) {
- READ12(sd, NULL, 0,
+ logging(LOG_VERBOSE, "Test READ12 with DPO==1");
+ if (dpofua) {
+ READ12(sd, NULL, 0,
block_size, block_size, 0, 1, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ12(sd, NULL, 0,
+ } else {
+ READ12(sd, NULL, 0,
block_size, block_size, 0, 1, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ12 with FUA==1");
- if (dpofua) {
- READ12(sd, NULL, 0,
+ logging(LOG_VERBOSE, "Test READ12 with FUA==1");
+ if (dpofua) {
+ READ12(sd, NULL, 0,
block_size, block_size, 0, 0, 1, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ12(sd, NULL, 0,
+ } else {
+ READ12(sd, NULL, 0,
block_size, block_size, 0, 0, 1, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ12 with DPO==1 FUA==1");
- if (dpofua) {
- READ12(sd, NULL, 0,
+ logging(LOG_VERBOSE, "Test READ12 with DPO==1 FUA==1");
+ if (dpofua) {
+ READ12(sd, NULL, 0,
block_size, block_size, 0, 1, 1, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ12(sd, NULL, 0,
+ } else {
+ READ12(sd, NULL, 0,
block_size, block_size, 0, 1, 1, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for READ12");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for READ12");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_READ12,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -122,5 +122,5 @@ test_read12_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_read12_rdprotect.c b/test-tool/test_read12_rdprotect.c
index 7650872..dd21aeb 100644
--- a/test-tool/test_read12_rdprotect.c
+++ b/test-tool/test_read12_rdprotect.c
@@ -29,25 +29,25 @@
void
test_read12_rdprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for RDPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ12 with non-zero RDPROTECT");
+ /*
+ * Try out different non-zero values for RDPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ12 with non-zero RDPROTECT");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- READ12(sd, NULL, 0, block_size, block_size,
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ READ12(sd, NULL, 0, block_size, block_size,
i, 0, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_read12_residuals.c b/test-tool/test_read12_residuals.c
index b95be1d..c2dd0d3 100644
--- a/test-tool/test_read12_residuals.c
+++ b/test-tool/test_read12_residuals.c
@@ -31,212 +31,212 @@
void
test_read12_residuals(void)
{
- struct scsi_task *task_ret;
+ struct scsi_task *task_ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ12 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ12 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This READ12 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This READ12 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
- && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented on this target.");
- CU_PASS("READ12 is not implemented.");
- return;
- }
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
+ && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
+ logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented on this target.");
+ CU_PASS("READ12 is not implemented.");
+ return;
+ }
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 10000;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
- if (task->datain.size != (int)block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target returned %u bytes "
- "of data but should have returned %zu bytes.",
- task->datain.size,block_size);
- }
- CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
+ logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
+ if (task->datain.size != (int)block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned %u bytes "
+ "of data but should have returned %zu bytes.",
+ task->datain.size,block_size);
+ }
+ CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 200;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got 200 bytes back from the target");
- CU_ASSERT_EQUAL(task->datain.size, 200);
+ logging(LOG_VERBOSE, "Verify we got 200 bytes back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, 200);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try reading two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ12;
- task->cdb[9] = 2;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ12;
+ task->cdb[9] = 2;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = block_size;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
- CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
+ logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
}
diff --git a/test-tool/test_read12_simple.c b/test-tool/test_read12_simple.c
index 233f365..160f82f 100644
--- a/test-tool/test_read12_simple.c
+++ b/test-tool/test_read12_simple.c
@@ -29,27 +29,27 @@
void
test_read12_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ12 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ12 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test READ12 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Test READ12 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_read16_0blocks.c b/test-tool/test_read16_0blocks.c
index a58321f..20540e2 100644
--- a/test-tool/test_read16_0blocks.c
+++ b/test-tool/test_read16_0blocks.c
@@ -27,23 +27,23 @@
void
test_read16_0blocks(void)
{
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==0");
- READ16(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==0");
+ READ16(sd, NULL, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test READ16 0-blocks one block past end-of-LUN");
- READ16(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ16 0-blocks one block past end-of-LUN");
+ READ16(sd, NULL, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==2^63");
- READ16(sd, NULL, 0x8000000000000000ULL, 0,
+ logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==2^63");
+ READ16(sd, NULL, 0x8000000000000000ULL, 0,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==-1");
- READ16(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==-1");
+ READ16(sd, NULL, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_read16_beyond_eol.c b/test-tool/test_read16_beyond_eol.c
index 16a2fd6..0a2f4d2 100644
--- a/test-tool/test_read16_beyond_eol.c
+++ b/test-tool/test_read16_beyond_eol.c
@@ -27,82 +27,82 @@
static int ilog2(size_t i)
{
- int j = -1;
+ int j = -1;
- while (i) {
- i >>= 1;
- j++;
- }
- return j;
+ while (i) {
+ i >>= 1;
+ j++;
+ }
+ return j;
}
void
test_read16_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ16 1-256 blocks one block beyond the end");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ16 1-256 blocks one block beyond the end");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^63");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, 0x8000000000000000ULL,
+ logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^63");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^%d",
- 64 - ilog2(block_size));
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, 1ULL << (64 - ilog2(block_size)),
+ logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^%d",
+ 64 - ilog2(block_size));
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, 1ULL << (64 - ilog2(block_size)),
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^%d",
- 63 - ilog2(block_size));
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, 1ULL << (63 - ilog2(block_size)),
+ logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^%d",
+ 63 - ilog2(block_size));
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, 1ULL << (63 - ilog2(block_size)),
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ16 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test READ16 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_read16_dpofua.c b/test-tool/test_read16_dpofua.c
index 91968f6..a1b124f 100644
--- a/test-tool/test_read16_dpofua.c
+++ b/test-tool/test_read16_dpofua.c
@@ -29,73 +29,73 @@
void
test_read16_dpofua(void)
{
- int dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ16 DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ16 DPO/FUA flags");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test READ16 with DPO==1");
- if (dpofua) {
- READ16(sd, NULL, 0, block_size, block_size, 0, 1, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ16 with DPO==1");
+ if (dpofua) {
+ READ16(sd, NULL, 0, block_size, block_size, 0, 1, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ16(sd, NULL, 0, block_size, block_size, 0, 1, 0, 0, 0, NULL,
+ } else {
+ READ16(sd, NULL, 0, block_size, block_size, 0, 1, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ16 with FUA==1");
- if (dpofua) {
- READ16(sd, NULL, 0, block_size, block_size, 0, 0, 1, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ16 with FUA==1");
+ if (dpofua) {
+ READ16(sd, NULL, 0, block_size, block_size, 0, 0, 1, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ16(sd, NULL, 0, block_size, block_size, 0, 0, 1, 0, 0, NULL,
+ } else {
+ READ16(sd, NULL, 0, block_size, block_size, 0, 0, 1, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ16 with DPO==1 FUA==1");
- if (dpofua) {
- READ16(sd, NULL, 0, block_size, block_size, 0, 1, 1, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test READ16 with DPO==1 FUA==1");
+ if (dpofua) {
+ READ16(sd, NULL, 0, block_size, block_size, 0, 1, 1, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- } else {
- READ16(sd, NULL, 0, block_size, block_size, 0, 1, 1, 0, 0, NULL,
+ } else {
+ READ16(sd, NULL, 0, block_size, block_size, 0, 1, 1, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for READ16");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for READ16");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_READ16,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -116,5 +116,5 @@ test_read16_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_read16_rdprotect.c b/test-tool/test_read16_rdprotect.c
index f6f06e9..30c3507 100644
--- a/test-tool/test_read16_rdprotect.c
+++ b/test-tool/test_read16_rdprotect.c
@@ -29,24 +29,24 @@
void
test_read16_rdprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for RDPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ16 with non-zero RDPROTECT");
+ /*
+ * Try out different non-zero values for RDPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ16 with non-zero RDPROTECT");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- READ16(sd, NULL, 0, block_size, block_size,
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ READ16(sd, NULL, 0, block_size, block_size,
i, 0, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ }
+ return;
+ }
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_read16_residuals.c b/test-tool/test_read16_residuals.c
index b7c3f1d..81dc3c3 100644
--- a/test-tool/test_read16_residuals.c
+++ b/test-tool/test_read16_residuals.c
@@ -31,212 +31,212 @@
void
test_read16_residuals(void)
{
- struct scsi_task *task_ret;
+ struct scsi_task *task_ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ16 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ16 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This READ16 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This READ16 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
- && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
- CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
- return;
- }
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
+ && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
+ logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
+ CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
+ return;
+ }
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 10000;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
- if (task->datain.size != (int)block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target returned %u bytes "
- "of data but should have returned %zu bytes.",
- task->datain.size,block_size);
- }
- CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
+ logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
+ if (task->datain.size != (int)block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned %u bytes "
+ "of data but should have returned %zu bytes.",
+ task->datain.size,block_size);
+ }
+ CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = 200;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got 200 bytes back from the target");
- CU_ASSERT_EQUAL(task->datain.size, 200);
+ logging(LOG_VERBOSE, "Verify we got 200 bytes back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, 200);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try reading two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try reading two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_READ16;
- task->cdb[13] = 2;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_READ;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_READ16;
+ task->cdb[13] = 2;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_READ;
+ task->expxferlen = block_size;
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
- CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
+ logging(LOG_VERBOSE, "Verify we got one whole block back from the target");
+ CU_ASSERT_EQUAL(task->datain.size, (int)block_size);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
}
diff --git a/test-tool/test_read16_simple.c b/test-tool/test_read16_simple.c
index 7a57aaa..30a882d 100644
--- a/test-tool/test_read16_simple.c
+++ b/test-tool/test_read16_simple.c
@@ -29,29 +29,29 @@
void
test_read16_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ16 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ16 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test READ16 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Test READ16 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_read6_beyond_eol.c b/test-tool/test_read6_beyond_eol.c
index 6747057..f5dd498 100644
--- a/test-tool/test_read6_beyond_eol.c
+++ b/test-tool/test_read6_beyond_eol.c
@@ -28,36 +28,36 @@
void
test_read6_beyond_eol(void)
{
- int i;
+ int i;
- if (num_blocks > 0x1fffff) {
- CU_PASS("LUN is too big for read-beyond-eol tests with READ6. Skipping test.\n");
- return;
- }
+ if (num_blocks > 0x1fffff) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with READ6. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end");
- for (i = 1; i <= 255 && i + 0U <= num_blocks + 1; i++) {
- READ6(sd, NULL, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end");
+ for (i = 1; i <= 255 && i + 0U <= num_blocks + 1; i++) {
+ READ6(sd, NULL, num_blocks + 1 - i,
i * block_size, block_size, NULL,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff");
- for (i = 1; i <= 255; i++) {
- READ6(sd, NULL, 0x1fffff, i * block_size, block_size, NULL,
+ logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff");
+ for (i = 1; i <= 255; i++) {
+ READ6(sd, NULL, 0x1fffff, i * block_size, block_size, NULL,
EXPECT_LBA_OOB);
- }
+ }
- if (num_blocks == 0) {
- CU_PASS("LUN is too small for read-beyond-eol tests with READ6. Skipping test.\n");
- return;
- }
+ if (num_blocks == 0) {
+ CU_PASS("LUN is too small for read-beyond-eol tests with READ6. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end");
- for (i = 2; i <= 255; i++) {
- READ6(sd, NULL, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end");
+ for (i = 2; i <= 255; i++) {
+ READ6(sd, NULL, num_blocks - 1,
i * block_size, block_size, NULL,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_read6_simple.c b/test-tool/test_read6_simple.c
index 9cb09da..78f9ec8 100644
--- a/test-tool/test_read6_simple.c
+++ b/test-tool/test_read6_simple.c
@@ -29,54 +29,54 @@
void
test_read6_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN");
- for (i = 1; i <= 255; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ6(sd, NULL, 0, i * block_size, block_size, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN");
+ for (i = 1; i <= 255; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ6(sd, NULL, 0, i * block_size, block_size, NULL,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the end of the LUN");
- if (num_blocks > 0x200000) {
- CU_PASS("LUN is too big for read-at-eol tests with READ6. Skipping test.\n");
- } else {
- for (i = 1; i <= 255 && i + 0U <= num_blocks; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ6(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the end of the LUN");
+ if (num_blocks > 0x200000) {
+ CU_PASS("LUN is too big for read-at-eol tests with READ6. Skipping test.\n");
+ } else {
+ for (i = 1; i <= 255 && i + 0U <= num_blocks; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ6(sd, NULL, num_blocks - i,
i * block_size, block_size, NULL,
EXPECT_STATUS_GOOD);
- }
- }
+ }
+ }
- /* 256 is converted to 0 when the CDB is marshalled by the helper */
- if (maximum_transfer_length >= 256) {
- logging(LOG_VERBOSE, "Transfer length == 0 means we want to "
- "transfer 256 blocks");
- READ6(sd, &task, 0,
+ /* 256 is converted to 0 when the CDB is marshalled by the helper */
+ if (maximum_transfer_length >= 256) {
+ logging(LOG_VERBOSE, "Transfer length == 0 means we want to "
+ "transfer 256 blocks");
+ READ6(sd, &task, 0,
256 * block_size, block_size, NULL,
EXPECT_STATUS_GOOD);
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_NORMAL, "[FAILED] READ6 command: "
- "failed with sense. %s", sd->error_str );
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL, "[FAILED] READ6 command: "
+ "failed with sense. %s", sd->error_str );
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that we did get 256 blocks of "
- "data back");
- if (task->datain.size == (int)(256 * block_size)) {
- logging(LOG_VERBOSE, "[SUCCESS] Target returned 256 "
- "blocks of data");
- } else {
- logging(LOG_NORMAL, "[FAILED] Target did not return "
- "256 blocks of data");
- }
- CU_ASSERT_EQUAL(task->datain.size, (int)(256 * block_size));
- }
+ logging(LOG_VERBOSE, "Verify that we did get 256 blocks of "
+ "data back");
+ if (task->datain.size == (int)(256 * block_size)) {
+ logging(LOG_VERBOSE, "[SUCCESS] Target returned 256 "
+ "blocks of data");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] Target did not return "
+ "256 blocks of data");
+ }
+ CU_ASSERT_EQUAL(task->datain.size, (int)(256 * block_size));
+ }
}
diff --git a/test-tool/test_readcapacity10_simple.c b/test-tool/test_readcapacity10_simple.c
index e56c9d9..a0865a0 100644
--- a/test-tool/test_readcapacity10_simple.c
+++ b/test-tool/test_readcapacity10_simple.c
@@ -29,9 +29,9 @@
void
test_readcapacity10_simple(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test basic READCAPACITY10");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test basic READCAPACITY10");
- READCAPACITY10(sd, NULL, 0, 0,
+ READCAPACITY10(sd, NULL, 0, 0,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_readcapacity16_alloclen.c b/test-tool/test_readcapacity16_alloclen.c
index 9b210bc..7eae153 100644
--- a/test-tool/test_readcapacity16_alloclen.c
+++ b/test-tool/test_readcapacity16_alloclen.c
@@ -29,13 +29,13 @@
void
test_readcapacity16_alloclen(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that READCAPACITY16 with alloc_len 0-15 is not an error");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that READCAPACITY16 with alloc_len 0-15 is not an error");
- for (i = 0; i < 16; i++) {
- READCAPACITY16(sd, NULL, i,
+ for (i = 0; i < 16; i++) {
+ READCAPACITY16(sd, NULL, i,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_readcapacity16_protection.c b/test-tool/test_readcapacity16_protection.c
index c39eade..9bb0922 100644
--- a/test-tool/test_readcapacity16_protection.c
+++ b/test-tool/test_readcapacity16_protection.c
@@ -29,95 +29,95 @@
void
test_readcapacity16_protection(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READCAPACITY16 Protection Information");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READCAPACITY16 Protection Information");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- if (rc16 == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target.");
- CU_PASS("READCAPACITY16 is not implemented.");
- return;
- }
+ if (rc16 == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target.");
+ CU_PASS("READCAPACITY16 is not implemented.");
+ return;
+ }
- if (!inq->protect) {
- logging(LOG_VERBOSE, "This device does not support PI. "
- "Verify that all relevant fields in READCAPACITY16 "
- "are 0");
+ if (!inq->protect) {
+ logging(LOG_VERBOSE, "This device does not support PI. "
+ "Verify that all relevant fields in READCAPACITY16 "
+ "are 0");
- logging(LOG_VERBOSE, "Verify that PROT_EN is 0");
- if (rc16->prot_en) {
- logging(LOG_VERBOSE, "[FAILED] PROT_EN is set but "
- "the device does not claim support for "
- "protection information in the standard "
- "inquiry VPD.");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] PROT_EN is 0");
- }
- CU_ASSERT_EQUAL(rc16->prot_en, 0);
+ logging(LOG_VERBOSE, "Verify that PROT_EN is 0");
+ if (rc16->prot_en) {
+ logging(LOG_VERBOSE, "[FAILED] PROT_EN is set but "
+ "the device does not claim support for "
+ "protection information in the standard "
+ "inquiry VPD.");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] PROT_EN is 0");
+ }
+ CU_ASSERT_EQUAL(rc16->prot_en, 0);
- logging(LOG_VERBOSE, "Verify that P_TYPE is 0");
- if (rc16->p_type) {
- logging(LOG_VERBOSE, "[FAILED] P_TYPE is non-zero but "
- "the device does not claim support for "
- "protection information in the standard "
- "inquiry VPD.");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] P_TYPE is 0");
- }
- CU_ASSERT_EQUAL(rc16->p_type, 0);
+ logging(LOG_VERBOSE, "Verify that P_TYPE is 0");
+ if (rc16->p_type) {
+ logging(LOG_VERBOSE, "[FAILED] P_TYPE is non-zero but "
+ "the device does not claim support for "
+ "protection information in the standard "
+ "inquiry VPD.");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] P_TYPE is 0");
+ }
+ CU_ASSERT_EQUAL(rc16->p_type, 0);
- logging(LOG_VERBOSE, "Verify that P_I_EXP is 0");
- if (rc16->p_i_exp) {
- logging(LOG_VERBOSE, "[FAILED] P_I_EXP is non-zero but "
- "the device does not claim support for "
- "protection information in the standard "
- "inquiry VPD.");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] P_I_EXP is 0");
- }
- CU_ASSERT_EQUAL(rc16->p_i_exp, 0);
+ logging(LOG_VERBOSE, "Verify that P_I_EXP is 0");
+ if (rc16->p_i_exp) {
+ logging(LOG_VERBOSE, "[FAILED] P_I_EXP is non-zero but "
+ "the device does not claim support for "
+ "protection information in the standard "
+ "inquiry VPD.");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] P_I_EXP is 0");
+ }
+ CU_ASSERT_EQUAL(rc16->p_i_exp, 0);
- return;
- }
+ return;
+ }
- logging(LOG_VERBOSE, "This device supports PI. "
- "Verify that all relevant fields are sane");
- if (!rc16->prot_en) {
- logging(LOG_VERBOSE, "Protection is not enabled. Verify "
- "that all relevant fields are zero");
+ logging(LOG_VERBOSE, "This device supports PI. "
+ "Verify that all relevant fields are sane");
+ if (!rc16->prot_en) {
+ logging(LOG_VERBOSE, "Protection is not enabled. Verify "
+ "that all relevant fields are zero");
- logging(LOG_VERBOSE, "Verify that P_TYPE is 0");
- if (rc16->p_type) {
- logging(LOG_VERBOSE, "[FAILED] P_TYPE is non-zero but "
- "protection information is not enabled.");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] P_TYPE is 0");
- }
- CU_ASSERT_EQUAL(rc16->p_type, 0);
+ logging(LOG_VERBOSE, "Verify that P_TYPE is 0");
+ if (rc16->p_type) {
+ logging(LOG_VERBOSE, "[FAILED] P_TYPE is non-zero but "
+ "protection information is not enabled.");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] P_TYPE is 0");
+ }
+ CU_ASSERT_EQUAL(rc16->p_type, 0);
- logging(LOG_VERBOSE, "Verify that P_I_EXP is 0");
- if (rc16->p_i_exp) {
- logging(LOG_VERBOSE, "[FAILED] P_I_EXP is non-zero but "
- "protection information is not enabled");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] P_I_EXP is 0");
- }
- CU_ASSERT_EQUAL(rc16->p_i_exp, 0);
+ logging(LOG_VERBOSE, "Verify that P_I_EXP is 0");
+ if (rc16->p_i_exp) {
+ logging(LOG_VERBOSE, "[FAILED] P_I_EXP is non-zero but "
+ "protection information is not enabled");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] P_I_EXP is 0");
+ }
+ CU_ASSERT_EQUAL(rc16->p_i_exp, 0);
- return;
- }
+ return;
+ }
- logging(LOG_VERBOSE, "Protection is enabled. Verify "
- "that all relevant fields are sane");
- switch (rc16->p_type) {
- case 0:
- case 1:
- case 2:
- break;
- default:
- logging(LOG_VERBOSE, "[FAILED] P_TYPE is invalid. Must be "
- "0,1,2 but was %d", rc16->p_type);
- CU_FAIL("P_TYPE is invalid");
- }
+ logging(LOG_VERBOSE, "Protection is enabled. Verify "
+ "that all relevant fields are sane");
+ switch (rc16->p_type) {
+ case 0:
+ case 1:
+ case 2:
+ break;
+ default:
+ logging(LOG_VERBOSE, "[FAILED] P_TYPE is invalid. Must be "
+ "0,1,2 but was %d", rc16->p_type);
+ CU_FAIL("P_TYPE is invalid");
+ }
}
diff --git a/test-tool/test_readcapacity16_simple.c b/test-tool/test_readcapacity16_simple.c
index 81a79af..e1d2865 100644
--- a/test-tool/test_readcapacity16_simple.c
+++ b/test-tool/test_readcapacity16_simple.c
@@ -29,9 +29,9 @@
void
test_readcapacity16_simple(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that READCAPACITY16 works");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that READCAPACITY16 works");
- READCAPACITY16(sd, NULL, 16,
+ READCAPACITY16(sd, NULL, 16,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_readcapacity16_support.c b/test-tool/test_readcapacity16_support.c
index 8b7bf39..698c7d5 100644
--- a/test-tool/test_readcapacity16_support.c
+++ b/test-tool/test_readcapacity16_support.c
@@ -31,19 +31,19 @@ test_readcapacity16_support(void)
{
int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that READCAPACITY16 is supported on SBC3");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that READCAPACITY16 is supported on SBC3");
- ret = readcapacity16(sd, NULL, 15,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- if (sbc3_support) {
- logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support.");
- CU_FAIL("READCAPACITY16 failed but the device claims SBC-3 support.");
- } else {
- logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim SBC-3 support.");
- }
- } else {
- CU_ASSERT_EQUAL(ret, 0);
- }
+ ret = readcapacity16(sd, NULL, 15,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ if (sbc3_support) {
+ logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support.");
+ CU_FAIL("READCAPACITY16 failed but the device claims SBC-3 support.");
+ } else {
+ logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim SBC-3 support.");
+ }
+ } else {
+ CU_ASSERT_EQUAL(ret, 0);
+ }
}
diff --git a/test-tool/test_readonly_sbc.c b/test-tool/test_readonly_sbc.c
index 4db10f0..e1a976b 100644
--- a/test-tool/test_readonly_sbc.c
+++ b/test-tool/test_readonly_sbc.c
@@ -28,38 +28,38 @@
static void
test_write10(void)
{
- logging(LOG_VERBOSE, "Test WRITE10 fails with WRITE_PROTECTED");
- memset(scratch, 0xa6, block_size);
- WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 fails with WRITE_PROTECTED");
+ memset(scratch, 0xa6, block_size);
+ WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
}
static void
test_write12(void)
{
- logging(LOG_VERBOSE, "Test WRITE12 fails with WRITE_PROTECTED");
- memset(scratch, 0xa6, block_size);
- WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 fails with WRITE_PROTECTED");
+ memset(scratch, 0xa6, block_size);
+ WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
}
static void
test_write16(void)
{
- logging(LOG_VERBOSE, "Test WRITE16 fails with WRITE_PROTECTED");
- memset(scratch, 0xa6, block_size);
- WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 fails with WRITE_PROTECTED");
+ memset(scratch, 0xa6, block_size);
+ WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
}
static void
test_writesame10(void)
{
- logging(LOG_VERBOSE, "Test WRITE_SAME10 fails with WRITE_PROTECTED");
+ logging(LOG_VERBOSE, "Test WRITE_SAME10 fails with WRITE_PROTECTED");
WRITESAME10(sd, 0, block_size, 1, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
- logging(LOG_VERBOSE, "Test WRITE_SAME10 UNMAP fails with "
+ logging(LOG_VERBOSE, "Test WRITE_SAME10 UNMAP fails with "
"WRITE_PROTECTED");
WRITESAME10(sd, 0, block_size, 1, 0, 1, 0, 0, NULL,
EXPECT_WRITE_PROTECTED);
@@ -68,11 +68,11 @@ test_writesame10(void)
static void
test_writesame16(void)
{
- logging(LOG_VERBOSE, "Test WRITE_SAME16 fails with WRITE_PROTECTED");
+ logging(LOG_VERBOSE, "Test WRITE_SAME16 fails with WRITE_PROTECTED");
WRITESAME16(sd, 0, block_size, 1, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
- logging(LOG_VERBOSE, "Test WRITE_SAME16 UNMAP fails with "
+ logging(LOG_VERBOSE, "Test WRITE_SAME16 UNMAP fails with "
"WRITE_PROTECTED");
WRITESAME16(sd, 0, block_size, 1, 0, 1, 0, 0, NULL,
EXPECT_WRITE_PROTECTED);
@@ -81,39 +81,39 @@ test_writesame16(void)
static void
test_writeverify10(void)
{
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 fails with WRITE_PROTECTED");
- WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 fails with WRITE_PROTECTED");
+ WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
}
static void
test_writeverify12(void)
{
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 fails with WRITE_PROTECTED");
- WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 fails with WRITE_PROTECTED");
+ WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
}
static void
test_writeverify16(void)
{
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 fails with WRITE_PROTECTED");
- WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 fails with WRITE_PROTECTED");
+ WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
}
static void
test_orwrite(void)
{
- logging(LOG_VERBOSE, "Test ORWRITE fails with WRITE_PROTECTED");
- ORWRITE(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test ORWRITE fails with WRITE_PROTECTED");
+ ORWRITE(sd, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_WRITE_PROTECTED);
}
static void
test_compareandwrite(void)
{
- logging(LOG_VERBOSE, "Test COMPAREANDWRITE fails with WRITE_PROTECTED");
+ logging(LOG_VERBOSE, "Test COMPAREANDWRITE fails with WRITE_PROTECTED");
COMPAREANDWRITE(sd, 0, scratch, 2 * block_size, block_size, 0, 0, 0, 0,
EXPECT_WRITE_PROTECTED);
}
@@ -121,32 +121,32 @@ test_compareandwrite(void)
static void
test_unmap(void)
{
- struct unmap_list list[1];
+ struct unmap_list list[1];
- logging(LOG_VERBOSE, "Test UNMAP of one physical block fails with "
+ logging(LOG_VERBOSE, "Test UNMAP of one physical block fails with "
"WRITE_PROTECTED");
- list[0].lba = 0;
- list[0].num = lbppb;
- UNMAP(sd, 0, list, 1,
+ list[0].lba = 0;
+ list[0].num = lbppb;
+ UNMAP(sd, 0, list, 1,
EXPECT_WRITE_PROTECTED);
- logging(LOG_VERBOSE, "Test UNMAP of one logical block fails with "
+ logging(LOG_VERBOSE, "Test UNMAP of one logical block fails with "
"WRITE_PROTECTED");
- list[0].lba = 0;
- list[0].num = 1;
- UNMAP(sd, 0, list, 1,
+ list[0].lba = 0;
+ list[0].num = 1;
+ UNMAP(sd, 0, list, 1,
EXPECT_WRITE_PROTECTED);
}
void
test_readonly_sbc(void)
{
- CHECK_FOR_DATALOSS;
- CHECK_FOR_READONLY;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_READONLY;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that Medium write commands fail for READ-ONLY SBC devices");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that Medium write commands fail for READ-ONLY SBC devices");
test_compareandwrite();
test_orwrite();
diff --git a/test-tool/test_receive_copy_results_copy_status.c b/test-tool/test_receive_copy_results_copy_status.c
index 8125a80..307f08f 100644
--- a/test-tool/test_receive_copy_results_copy_status.c
+++ b/test-tool/test_receive_copy_results_copy_status.c
@@ -30,52 +30,52 @@
void
test_receive_copy_results_copy_status(void)
{
- struct scsi_task *cs_task;
- struct scsi_copy_results_copy_status *csp;
- int tgt_desc_len = 0, seg_desc_len = 0;
- int offset = XCOPY_DESC_OFFSET, list_id = 1;
- struct iscsi_data data;
- unsigned char *xcopybuf;
+ struct scsi_task *cs_task;
+ struct scsi_copy_results_copy_status *csp;
+ int tgt_desc_len = 0, seg_desc_len = 0;
+ int offset = XCOPY_DESC_OFFSET, list_id = 1;
+ struct iscsi_data data;
+ unsigned char *xcopybuf;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, COPY STATUS");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, COPY STATUS");
- logging(LOG_VERBOSE, "No copy in progress");
- RECEIVE_COPY_RESULTS(&cs_task, sd, SCSI_COPY_RESULTS_COPY_STATUS,
+ logging(LOG_VERBOSE, "No copy in progress");
+ RECEIVE_COPY_RESULTS(&cs_task, sd, SCSI_COPY_RESULTS_COPY_STATUS,
list_id, NULL, EXPECT_INVALID_FIELD_IN_CDB);
- scsi_free_scsi_task(cs_task);
- cs_task = NULL;
+ scsi_free_scsi_task(cs_task);
+ cs_task = NULL;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Issue Extended Copy");
- data.size = XCOPY_DESC_OFFSET +
- get_desc_len(IDENT_DESCR_TGT_DESCR) +
- get_desc_len(BLK_TO_BLK_SEG_DESCR);
- data.data = alloca(data.size);
- xcopybuf = data.data;
- memset(xcopybuf, 0, data.size);
+ logging(LOG_VERBOSE, "Issue Extended Copy");
+ data.size = XCOPY_DESC_OFFSET +
+ get_desc_len(IDENT_DESCR_TGT_DESCR) +
+ get_desc_len(BLK_TO_BLK_SEG_DESCR);
+ data.data = alloca(data.size);
+ xcopybuf = data.data;
+ memset(xcopybuf, 0, data.size);
- /* Initialize target descriptor list with one target descriptor */
- offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
- LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
- tgt_desc_len = offset - XCOPY_DESC_OFFSET;
+ /* Initialize target descriptor list with one target descriptor */
+ offset += populate_tgt_desc(xcopybuf+offset, IDENT_DESCR_TGT_DESCR,
+ LU_ID_TYPE_LUN, 0, 0, 0, 0, sd);
+ tgt_desc_len = offset - XCOPY_DESC_OFFSET;
- /* Initialize segment descriptor list with one segment descriptor */
- offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
- 2048, 0, num_blocks - 2048);
- seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
+ /* Initialize segment descriptor list with one segment descriptor */
+ offset += populate_seg_desc_b2b(xcopybuf+offset, 0, 0, 0, 0,
+ 2048, 0, num_blocks - 2048);
+ seg_desc_len = offset - XCOPY_DESC_OFFSET - tgt_desc_len;
- /* Initialize the parameter list header */
- populate_param_header(xcopybuf, list_id, 0, 0, 0,
- tgt_desc_len, seg_desc_len, 0);
+ /* Initialize the parameter list header */
+ populate_param_header(xcopybuf, list_id, 0, 0, 0,
+ tgt_desc_len, seg_desc_len, 0);
- EXTENDEDCOPY(sd, &data, EXPECT_STATUS_GOOD);
+ EXTENDEDCOPY(sd, &data, EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE,
- "Copy Status for the above Extended Copy command");
- RECEIVE_COPY_RESULTS(&cs_task, sd, SCSI_COPY_RESULTS_COPY_STATUS,
+ logging(LOG_VERBOSE,
+ "Copy Status for the above Extended Copy command");
+ RECEIVE_COPY_RESULTS(&cs_task, sd, SCSI_COPY_RESULTS_COPY_STATUS,
list_id, (void **)&csp, EXPECT_STATUS_GOOD);
- scsi_free_scsi_task(cs_task);
+ scsi_free_scsi_task(cs_task);
}
diff --git a/test-tool/test_receive_copy_results_op_params.c b/test-tool/test_receive_copy_results_op_params.c
index 05a8b83..2ee0b99 100644
--- a/test-tool/test_receive_copy_results_op_params.c
+++ b/test-tool/test_receive_copy_results_op_params.c
@@ -30,19 +30,19 @@
void
test_receive_copy_results_op_params(void)
{
- struct scsi_task *op_task = NULL;
- struct scsi_copy_results_op_params *opp;
+ struct scsi_task *op_task = NULL;
+ struct scsi_copy_results_op_params *opp;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, OPERATING PARAMS");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test RECEIVE COPY RESULTS, OPERATING PARAMS");
- RECEIVE_COPY_RESULTS(&op_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0,
+ RECEIVE_COPY_RESULTS(&op_task, sd, SCSI_COPY_RESULTS_OP_PARAMS, 0,
(void **)&opp, EXPECT_STATUS_GOOD);
- logging(LOG_NORMAL,
- "max_target_desc=%d, max_seg_desc=%d",
- opp->max_target_desc_count,
- opp->max_segment_desc_count);
+ logging(LOG_NORMAL,
+ "max_target_desc=%d, max_seg_desc=%d",
+ opp->max_target_desc_count,
+ opp->max_segment_desc_count);
- scsi_free_scsi_task(op_task);
+ scsi_free_scsi_task(op_task);
}
diff --git a/test-tool/test_report_supported_opcodes_one_command.c b/test-tool/test_report_supported_opcodes_one_command.c
index 889e01b..bb991bc 100644
--- a/test-tool/test_report_supported_opcodes_one_command.c
+++ b/test-tool/test_report_supported_opcodes_one_command.c
@@ -29,82 +29,82 @@
void
test_report_supported_opcodes_one_command(void)
{
- int i;
- struct scsi_task *rso_task;
- struct scsi_task *one_task;
- struct scsi_report_supported_op_codes *rsoc;
- struct scsi_report_supported_op_codes_one_command *rsoc_one;
+ int i;
+ struct scsi_task *rso_task;
+ struct scsi_task *one_task;
+ struct scsi_report_supported_op_codes *rsoc;
+ struct scsi_report_supported_op_codes_one_command *rsoc_one;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES reading one-command");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES reading one-command");
- logging(LOG_VERBOSE, "Fetch list of all supported opcodes");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Fetch list of all supported opcodes");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPS_ALL,
0, 0, 65535,
EXPECT_STATUS_GOOD);
-
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- logging(LOG_VERBOSE, "Verify read one-command works for all supported "
- "opcodes");
- for (i = 0; i < rsoc->num_descriptors; i++) {
- logging(LOG_VERBOSE, "Check opcode:0x%02x ServiceAction:0x%02x",
- rsoc->descriptors[i].opcode,
- rsoc->descriptors[i].sa);
- if (rsoc->descriptors[i].servactv) {
- logging(LOG_VERBOSE, "This opcode has service actions. "
- "Reporting Options 001b should fail");
- REPORT_SUPPORTED_OPCODES(sd, NULL, 0,
+ logging(LOG_VERBOSE, "Verify read one-command works for all supported "
+ "opcodes");
+ for (i = 0; i < rsoc->num_descriptors; i++) {
+ logging(LOG_VERBOSE, "Check opcode:0x%02x ServiceAction:0x%02x",
+ rsoc->descriptors[i].opcode,
+ rsoc->descriptors[i].sa);
+ if (rsoc->descriptors[i].servactv) {
+ logging(LOG_VERBOSE, "This opcode has service actions. "
+ "Reporting Options 001b should fail");
+ REPORT_SUPPORTED_OPCODES(sd, NULL, 0,
SCSI_REPORT_SUPPORTING_OPCODE,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535,
EXPECT_INVALID_FIELD_IN_CDB);
- } else {
- logging(LOG_VERBOSE, "This opcode does not have "
- "service actions. Reporting Options 001b "
- "should work");
- REPORT_SUPPORTED_OPCODES(sd, NULL, 0,
+ } else {
+ logging(LOG_VERBOSE, "This opcode does not have "
+ "service actions. Reporting Options 001b "
+ "should work");
+ REPORT_SUPPORTED_OPCODES(sd, NULL, 0,
SCSI_REPORT_SUPPORTING_OPCODE,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535,
EXPECT_STATUS_GOOD);
- }
+ }
- if (rsoc->descriptors[i].servactv) {
- logging(LOG_VERBOSE, "This opcode has service actions. "
- "Reporting Options 002b should work");
- REPORT_SUPPORTED_OPCODES(sd, NULL, 0,
+ if (rsoc->descriptors[i].servactv) {
+ logging(LOG_VERBOSE, "This opcode has service actions. "
+ "Reporting Options 002b should work");
+ REPORT_SUPPORTED_OPCODES(sd, NULL, 0,
SCSI_REPORT_SUPPORTING_SERVICEACTION,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535,
EXPECT_STATUS_GOOD);
- } else {
- logging(LOG_VERBOSE, "This opcode does not have "
- "service actions. Reporting Options 002b "
- "should fail");
- REPORT_SUPPORTED_OPCODES(sd, NULL, 0,
+ } else {
+ logging(LOG_VERBOSE, "This opcode does not have "
+ "service actions. Reporting Options 002b "
+ "should fail");
+ REPORT_SUPPORTED_OPCODES(sd, NULL, 0,
SCSI_REPORT_SUPPORTING_SERVICEACTION,
rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa,
65535,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- }
+ }
+ }
- logging(LOG_VERBOSE, "Verify read one-command CDB looks sane");
- for (i = 0; i < rsoc->num_descriptors; i++) {
- logging(LOG_VERBOSE, "Check CDB for opcode:0x%02x "
- "ServiceAction:0x%02x",
- rsoc->descriptors[i].opcode,
- rsoc->descriptors[i].sa);
- REPORT_SUPPORTED_OPCODES(sd, &one_task, 0,
+ logging(LOG_VERBOSE, "Verify read one-command CDB looks sane");
+ for (i = 0; i < rsoc->num_descriptors; i++) {
+ logging(LOG_VERBOSE, "Check CDB for opcode:0x%02x "
+ "ServiceAction:0x%02x",
+ rsoc->descriptors[i].opcode,
+ rsoc->descriptors[i].sa);
+ REPORT_SUPPORTED_OPCODES(sd, &one_task, 0,
rsoc->descriptors[i].servactv ?
SCSI_REPORT_SUPPORTING_SERVICEACTION :
SCSI_REPORT_SUPPORTING_OPCODE,
@@ -113,29 +113,29 @@ test_report_supported_opcodes_one_command(void)
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc_one = scsi_datain_unmarshall(one_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc_one);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc_one = scsi_datain_unmarshall(one_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc_one);
- logging(LOG_VERBOSE, "Verify CDB length is not 0");
- CU_ASSERT_NOT_EQUAL(rsoc_one->cdb_length, 0);
- if (rsoc_one->cdb_length == 0) {
- logging(LOG_NORMAL, "[FAILED] CDB length is 0");
- }
-
- logging(LOG_VERBOSE, "Verify CDB[0] Usage Data == ");
- CU_ASSERT_EQUAL(rsoc_one->cdb_usage_data[0],
- rsoc->descriptors[i].opcode);
- if (rsoc_one->cdb_usage_data[0] != rsoc->descriptors[i].opcode) {
- logging(LOG_NORMAL, "[FAILED] CDB[0] Usage Data was "
- "0x%02x, expected 0x%02x for opcode 0x%02x",
- rsoc_one->cdb_usage_data[0],
- rsoc->descriptors[i].opcode,
- rsoc->descriptors[i].opcode);
- }
+ logging(LOG_VERBOSE, "Verify CDB length is not 0");
+ CU_ASSERT_NOT_EQUAL(rsoc_one->cdb_length, 0);
+ if (rsoc_one->cdb_length == 0) {
+ logging(LOG_NORMAL, "[FAILED] CDB length is 0");
+ }
+
+ logging(LOG_VERBOSE, "Verify CDB[0] Usage Data == ");
+ CU_ASSERT_EQUAL(rsoc_one->cdb_usage_data[0],
+ rsoc->descriptors[i].opcode);
+ if (rsoc_one->cdb_usage_data[0] != rsoc->descriptors[i].opcode) {
+ logging(LOG_NORMAL, "[FAILED] CDB[0] Usage Data was "
+ "0x%02x, expected 0x%02x for opcode 0x%02x",
+ rsoc_one->cdb_usage_data[0],
+ rsoc->descriptors[i].opcode,
+ rsoc->descriptors[i].opcode);
+ }
- scsi_free_scsi_task(one_task);
- }
+ scsi_free_scsi_task(one_task);
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_report_supported_opcodes_rctd.c b/test-tool/test_report_supported_opcodes_rctd.c
index 5c3acc7..4129f2d 100644
--- a/test-tool/test_report_supported_opcodes_rctd.c
+++ b/test-tool/test_report_supported_opcodes_rctd.c
@@ -29,70 +29,70 @@
void
test_report_supported_opcodes_rctd(void)
{
- int i;
- struct scsi_task *rso_task;
- struct scsi_report_supported_op_codes *rsoc;
+ int i;
+ struct scsi_task *rso_task;
+ struct scsi_report_supported_op_codes *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES RCTD flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES RCTD flag");
- logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes "
- "without timeout descriptors. RCTD==0");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes "
+ "without timeout descriptors. RCTD==0");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535,
EXPECT_STATUS_GOOD);
-
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- logging(LOG_VERBOSE, "Verify that all returned command descriptors "
- "lack timeout description");
- for (i = 0; i < rsoc->num_descriptors; i++) {
- if (rsoc->descriptors[i].ctdp) {
- logging(LOG_NORMAL, "[FAILED] Command descriptor with "
- "CTDP set received when RCTD==0");
- CU_FAIL("[FAILED] Command descriptor with "
- "CTDP set");
- }
- }
- scsi_free_scsi_task(rso_task);
+ logging(LOG_VERBOSE, "Verify that all returned command descriptors "
+ "lack timeout description");
+ for (i = 0; i < rsoc->num_descriptors; i++) {
+ if (rsoc->descriptors[i].ctdp) {
+ logging(LOG_NORMAL, "[FAILED] Command descriptor with "
+ "CTDP set received when RCTD==0");
+ CU_FAIL("[FAILED] Command descriptor with "
+ "CTDP set");
+ }
+ }
+ scsi_free_scsi_task(rso_task);
- logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes "
- "with timeout descriptors. RCTD==1");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes "
+ "with timeout descriptors. RCTD==1");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535,
EXPECT_STATUS_GOOD);
-
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_NOT_EQUAL(rsoc, NULL);
+
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_NOT_EQUAL(rsoc, NULL);
- logging(LOG_VERBOSE, "Verify that all returned command descriptors "
- "have a timeout description");
- for (i = 0; i < rsoc->num_descriptors; i++) {
- if (!rsoc->descriptors[i].ctdp) {
- logging(LOG_NORMAL, "[FAILED] Command descriptor "
- "with CTDP clear when RCTD==1");
- CU_FAIL("[FAILED] Command descriptor without "
- "CTDP set");
- }
- }
+ logging(LOG_VERBOSE, "Verify that all returned command descriptors "
+ "have a timeout description");
+ for (i = 0; i < rsoc->num_descriptors; i++) {
+ if (!rsoc->descriptors[i].ctdp) {
+ logging(LOG_NORMAL, "[FAILED] Command descriptor "
+ "with CTDP clear when RCTD==1");
+ CU_FAIL("[FAILED] Command descriptor without "
+ "CTDP set");
+ }
+ }
- logging(LOG_VERBOSE, "Verify that all timeout descriptors have the "
- "correct length");
- for (i = 0; i < rsoc->num_descriptors; i++) {
- if (rsoc->descriptors[i].ctdp &&
- rsoc->descriptors[i].to.descriptor_length != 0x0a) {
- logging(LOG_NORMAL, "[FAILED] Command descriptor "
- "with invalid TimeoutDescriptor length");
- CU_FAIL("[FAILED] Command descriptor with "
- "invalid TimeoutDescriptor length");
- }
- }
+ logging(LOG_VERBOSE, "Verify that all timeout descriptors have the "
+ "correct length");
+ for (i = 0; i < rsoc->num_descriptors; i++) {
+ if (rsoc->descriptors[i].ctdp &&
+ rsoc->descriptors[i].to.descriptor_length != 0x0a) {
+ logging(LOG_NORMAL, "[FAILED] Command descriptor "
+ "with invalid TimeoutDescriptor length");
+ CU_FAIL("[FAILED] Command descriptor with "
+ "invalid TimeoutDescriptor length");
+ }
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_report_supported_opcodes_servactv.c b/test-tool/test_report_supported_opcodes_servactv.c
index 8109e12..240cb4f 100644
--- a/test-tool/test_report_supported_opcodes_servactv.c
+++ b/test-tool/test_report_supported_opcodes_servactv.c
@@ -29,32 +29,32 @@
void
test_report_supported_opcodes_servactv(void)
{
- int i;
- struct scsi_task *rso_task;
- struct scsi_report_supported_op_codes *rsoc;
+ int i;
+ struct scsi_task *rso_task;
+ struct scsi_report_supported_op_codes *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES SERVACTV flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES SERVACTV flag");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- logging(LOG_VERBOSE, "Verify that when SERVACTV is clear then "
- "ServiceAction must be zero.");
- for (i = 0; i < rsoc->num_descriptors; i++) {
- if (!rsoc->descriptors[i].servactv && rsoc->descriptors[i].sa) {
- logging(LOG_NORMAL, "[FAILED] ServiceAction is "
- "non-zero but SERVACTV is clear");
- CU_FAIL("[FAILED] ServiceAction is "
- "non-zero but SERVACTV is clear");
- }
- }
+ logging(LOG_VERBOSE, "Verify that when SERVACTV is clear then "
+ "ServiceAction must be zero.");
+ for (i = 0; i < rsoc->num_descriptors; i++) {
+ if (!rsoc->descriptors[i].servactv && rsoc->descriptors[i].sa) {
+ logging(LOG_NORMAL, "[FAILED] ServiceAction is "
+ "non-zero but SERVACTV is clear");
+ CU_FAIL("[FAILED] ServiceAction is "
+ "non-zero but SERVACTV is clear");
+ }
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_report_supported_opcodes_simple.c b/test-tool/test_report_supported_opcodes_simple.c
index 5fbe906..df84c96 100644
--- a/test-tool/test_report_supported_opcodes_simple.c
+++ b/test-tool/test_report_supported_opcodes_simple.c
@@ -29,10 +29,10 @@
void
test_report_supported_opcodes_simple(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test basic READ_SUPPORTED_OPCODES");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test basic READ_SUPPORTED_OPCODES");
- REPORT_SUPPORTED_OPCODES(sd, NULL,
+ REPORT_SUPPORTED_OPCODES(sd, NULL,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
1024,
EXPECT_STATUS_GOOD);
diff --git a/test-tool/test_reserve6_2initiators.c b/test-tool/test_reserve6_2initiators.c
index 0d642a9..d27a955 100644
--- a/test-tool/test_reserve6_2initiators.c
+++ b/test-tool/test_reserve6_2initiators.c
@@ -29,61 +29,61 @@
void
test_reserve6_2initiators(void)
{
- int ret;
- struct scsi_device *sd2;
+ int ret;
+ struct scsi_device *sd2;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test RESERVE6/RELEASE6 across two initiators");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test RESERVE6/RELEASE6 across two initiators");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This RESERVE6 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This RESERVE6 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
- RESERVE6(sd);
+ logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
+ RESERVE6(sd);
- logging(LOG_NORMAL, "Verify that the first initiator can re-RESERVE6 the same reservation");
- RESERVE6(sd);
+ logging(LOG_NORMAL, "Verify that the first initiator can re-RESERVE6 the same reservation");
+ RESERVE6(sd);
- ret = mpath_sd2_get_or_clone(sd, &sd2);
- CU_ASSERT_EQUAL(ret, 0);
- if (ret < 0)
- return;
+ 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);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
+ ret = reserve6_conflict(sd2);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_NORMAL, "Try to RELEASE from the second initiator. Should be a nop");
- RELEASE6(sd2);
+ logging(LOG_NORMAL, "Try to RELEASE from the second initiator. Should be a nop");
+ RELEASE6(sd2);
- logging(LOG_NORMAL, "Test we can still send MODE SENSE from the first initiator");
- MODESENSE6(sd, NULL, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_NORMAL, "Test we can still send MODE SENSE from the first initiator");
+ MODESENSE6(sd, NULL, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
- EXPECT_STATUS_GOOD);
+ EXPECT_STATUS_GOOD);
- logging(LOG_NORMAL, "MODE SENSE should fail from the second initiator");
- MODESENSE6(sd2, NULL, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_NORMAL, "MODE SENSE should fail from the second initiator");
+ MODESENSE6(sd2, NULL, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_RESERVATION_CONFLICT);
- logging(LOG_NORMAL, "RESERVE6 from the second initiator should still fail");
- ret = reserve6_conflict(sd2);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_NORMAL, "RESERVE6 from the second initiator should still fail");
+ ret = reserve6_conflict(sd2);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_NORMAL, "RELEASE6 from the first initiator");
- RELEASE6(sd);
+ logging(LOG_NORMAL, "RELEASE6 from the first initiator");
+ RELEASE6(sd);
- logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
- RESERVE6(sd2);
+ logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
+ RESERVE6(sd2);
- logging(LOG_NORMAL, "RELEASE6 from the second initiator");
- RELEASE6(sd2);
+ logging(LOG_NORMAL, "RELEASE6 from the second initiator");
+ RELEASE6(sd2);
- mpath_sd2_put(sd2);
+ mpath_sd2_put(sd2);
}
diff --git a/test-tool/test_reserve6_itnexus_loss.c b/test-tool/test_reserve6_itnexus_loss.c
index ac18055..17239fe 100644
--- a/test-tool/test_reserve6_itnexus_loss.c
+++ b/test-tool/test_reserve6_itnexus_loss.c
@@ -29,52 +29,52 @@
void
test_reserve6_itnexus_loss(void)
{
- int ret;
- struct scsi_device *sd2;
+ int ret;
+ struct scsi_device *sd2;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that RESERVE6 is released on it-nexus loss");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that RESERVE6 is released on it-nexus loss");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This RESERVE6 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This RESERVE6 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
- RESERVE6(sd);
+ logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
+ RESERVE6(sd);
- 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, "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);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
+ ret = reserve6_conflict(sd2);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Disconnect from the target.");
- iscsi_destroy_context(sd->iscsi_ctx);
+ logging(LOG_VERBOSE, "Disconnect from the target.");
+ iscsi_destroy_context(sd->iscsi_ctx);
- logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
- sleep(3);
+ logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
+ sleep(3);
- logging(LOG_VERBOSE, "Reconnect to target");
- sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
- if (sd->iscsi_ctx == NULL) {
- logging(LOG_VERBOSE, "Failed to login to target");
- goto finished;
- }
+ logging(LOG_VERBOSE, "Reconnect to target");
+ sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
+ if (sd->iscsi_ctx == NULL) {
+ logging(LOG_VERBOSE, "Failed to login to target");
+ goto finished;
+ }
- logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
- RESERVE6(sd2);
+ logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
+ RESERVE6(sd2);
- logging(LOG_NORMAL, "RELEASE6 from the second initiator");
- RELEASE6(sd2);
+ logging(LOG_NORMAL, "RELEASE6 from the second initiator");
+ RELEASE6(sd2);
finished:
- mpath_sd2_put(sd2);
+ mpath_sd2_put(sd2);
}
diff --git a/test-tool/test_reserve6_logout.c b/test-tool/test_reserve6_logout.c
index c662fa2..96f65c0 100644
--- a/test-tool/test_reserve6_logout.c
+++ b/test-tool/test_reserve6_logout.c
@@ -29,49 +29,49 @@
void
test_reserve6_logout(void)
{
- int ret;
- struct scsi_device *sd2;
+ int ret;
+ struct scsi_device *sd2;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that RESERVE6 is released on logout");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that RESERVE6 is released on logout");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This RESERVE6 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This RESERVE6 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
- RESERVE6(sd);
+ logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
+ RESERVE6(sd);
- 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, "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);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
+ ret = reserve6_conflict(sd2);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Logout from target");
- iscsi_logout_sync(sd->iscsi_ctx);
- iscsi_destroy_context(sd->iscsi_ctx);
+ logging(LOG_VERBOSE, "Logout from target");
+ iscsi_logout_sync(sd->iscsi_ctx);
+ iscsi_destroy_context(sd->iscsi_ctx);
- logging(LOG_VERBOSE, "Relogin to target");
- sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
- if (sd->iscsi_ctx == NULL) {
- logging(LOG_VERBOSE, "Failed to login to target");
- return;
- }
+ logging(LOG_VERBOSE, "Relogin to target");
+ sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
+ if (sd->iscsi_ctx == NULL) {
+ logging(LOG_VERBOSE, "Failed to login to target");
+ return;
+ }
- logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
- RESERVE6(sd2);
+ logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
+ RESERVE6(sd2);
- logging(LOG_NORMAL, "RELEASE6 from the second initiator");
- RELEASE6(sd2);
+ logging(LOG_NORMAL, "RELEASE6 from the second initiator");
+ RELEASE6(sd2);
- mpath_sd2_put(sd2);
+ mpath_sd2_put(sd2);
}
diff --git a/test-tool/test_reserve6_lun_reset.c b/test-tool/test_reserve6_lun_reset.c
index 7b4ed37..3d6b6ea 100644
--- a/test-tool/test_reserve6_lun_reset.c
+++ b/test-tool/test_reserve6_lun_reset.c
@@ -29,50 +29,50 @@
void
test_reserve6_lun_reset(void)
{
- int ret;
- struct scsi_device sd2;
+ int ret;
+ struct scsi_device sd2;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that RESERVE6 is released on lun reset");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that RESERVE6 is released on lun reset");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This RESERVE6 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This RESERVE6 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
- RESERVE6(sd);
+ logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
+ RESERVE6(sd);
- logging(LOG_VERBOSE, "Send a LUN Reset");
- ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
- if (ret != 0) {
- logging(LOG_NORMAL, "LUN reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Send a LUN Reset");
+ ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "LUN reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
- sleep(3);
+ logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
+ sleep(3);
- logging(LOG_VERBOSE, "Create a second connection to the target");
- memset(&sd2, 0, sizeof(sd2));
- sd2.iscsi_url = sd->iscsi_url;
- sd2.iscsi_lun = sd->iscsi_lun;
- sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun);
- if (sd2.iscsi_ctx == NULL) {
- logging(LOG_VERBOSE, "Failed to login to target");
- return;
- }
+ logging(LOG_VERBOSE, "Create a second connection to the target");
+ memset(&sd2, 0, sizeof(sd2));
+ sd2.iscsi_url = sd->iscsi_url;
+ sd2.iscsi_lun = sd->iscsi_lun;
+ sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun);
+ if (sd2.iscsi_ctx == NULL) {
+ logging(LOG_VERBOSE, "Failed to login to target");
+ return;
+ }
- logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
- RESERVE6(&sd2);
+ logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
+ RESERVE6(&sd2);
- logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
- RELEASE6(&sd2);
+ logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
+ RELEASE6(&sd2);
- iscsi_logout_sync(sd2.iscsi_ctx);
- iscsi_destroy_context(sd2.iscsi_ctx);
+ 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 27f7d19..e63df9b 100644
--- a/test-tool/test_reserve6_simple.c
+++ b/test-tool/test_reserve6_simple.c
@@ -29,10 +29,10 @@
void
test_reserve6_simple(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test basic RESERVE6/RELEASE6 commands if supported");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test basic RESERVE6/RELEASE6 commands if supported");
- RESERVE6(sd);
+ RESERVE6(sd);
- RELEASE6(sd);
+ RELEASE6(sd);
}
diff --git a/test-tool/test_reserve6_target_cold_reset.c b/test-tool/test_reserve6_target_cold_reset.c
index d4b9901..8c4a7e5 100644
--- a/test-tool/test_reserve6_target_cold_reset.c
+++ b/test-tool/test_reserve6_target_cold_reset.c
@@ -30,43 +30,43 @@ void
test_reserve6_target_cold_reset(void)
{
int ret;
- struct scsi_device *sd2;
+ struct scsi_device *sd2;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that RESERVE6 is released on target cold reset");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that RESERVE6 is released on target cold reset");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This RESERVE6 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This RESERVE6 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
- RESERVE6(sd);
+ logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
+ RESERVE6(sd);
- logging(LOG_VERBOSE, "Send a Cold Reset to the target");
- ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
- if (ret != 0) {
- logging(LOG_NORMAL, "Cold reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Send a Cold Reset to the target");
+ ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "Cold reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
- sleep(3);
+ logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
+ sleep(3);
- 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, "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");
- RESERVE6(sd2);
+ logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
+ RESERVE6(sd2);
- logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
- RELEASE6(sd2);
+ logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
+ RELEASE6(sd2);
- mpath_sd2_put(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 6a8b9e2..719d5d4 100644
--- a/test-tool/test_reserve6_target_warm_reset.c
+++ b/test-tool/test_reserve6_target_warm_reset.c
@@ -29,45 +29,45 @@
void
test_reserve6_target_warm_reset(void)
{
- int ret;
- struct scsi_device *sd2;
+ int ret;
+ struct scsi_device *sd2;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that RESERVE6 is released on target warm reset");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that RESERVE6 is released on target warm reset");
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This RESERVE6 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This RESERVE6 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
- RESERVE6(sd);
+ logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
+ RESERVE6(sd);
- logging(LOG_VERBOSE, "Send a Warm Reset to the target");
- ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
- if (ret != 0) {
- logging(LOG_NORMAL, "Warm reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Send a Warm Reset to the target");
+ ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "Warm reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
- sleep(3);
+ logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
+ sleep(3);
- 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, "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");
- RESERVE6(sd2);
+ logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
+ RESERVE6(sd2);
- logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
- RELEASE6(sd2);
+ logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
+ RELEASE6(sd2);
- mpath_sd2_put(sd2);
+ mpath_sd2_put(sd2);
}
diff --git a/test-tool/test_sanitize_block_erase.c b/test-tool/test_sanitize_block_erase.c
index 0b1d289..6017ae0 100644
--- a/test-tool/test_sanitize_block_erase.c
+++ b/test-tool/test_sanitize_block_erase.c
@@ -31,312 +31,312 @@
static void
check_wabereq(void)
{
- struct scsi_task *task_ret = NULL;
+ struct scsi_task *task_ret = NULL;
- logging(LOG_VERBOSE, "Read one block from LBA 0");
- READ10(sd, &task_ret, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ logging(LOG_VERBOSE, "Read one block from LBA 0");
+ READ10(sd, &task_ret, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
if (task_ret == NULL) {
return;
}
- CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED);
+ CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED);
- switch (inq_bdc->wabereq) {
- case 0:
- logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE "
- "opcode is supported but WABEREQ is 0");
- CU_FAIL("[FAILED] SANITIZE BLOCK ERASE "
- "opcode is supported but WABEREQ is 0");
- break;
- case 1:
- logging(LOG_VERBOSE, "WABEREQ==1. Reads from the "
- "device should be successful.");
- if (task_ret->status == SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[SUCCESS] Read was "
- "successful after SANITIZE");
- break;
- }
- logging(LOG_NORMAL, "[FAILED] Read after "
- "SANITIZE failed but WABEREQ is 1");
- CU_FAIL("[FAILED] Read after SANITIZE failed "
- "but WABEREQ is 1");
- break;
- case 2:
- logging(LOG_VERBOSE, "WABEREQ==2. Reads from the "
- "device should fail.");
- if (task_ret->status == SCSI_STATUS_CHECK_CONDITION
- && task_ret->sense.key == SCSI_SENSE_MEDIUM_ERROR
- && task_ret->sense.ascq != SCSI_SENSE_ASCQ_WRITE_AFTER_SANITIZE_REQUIRED) {
- logging(LOG_VERBOSE, "[SUCCESS] Read failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "!WRITE_AFTER_SANITIZE_REQUIRED");
- break;
- }
- logging(LOG_VERBOSE, "[FAILED] Read should have failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "!WRITE_AFTER_SANITIZE_REQUIRED");
- CU_FAIL("[FAILED] Read should have failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "!WRITE_AFTER_SANITIZE_REQUIRED");
- break;
- case 3:
- logging(LOG_VERBOSE, "WABEREQ==3. Reads from the "
- "device should fail.");
- if (task_ret->status == SCSI_STATUS_CHECK_CONDITION
- && task_ret->sense.key == SCSI_SENSE_MEDIUM_ERROR
- && task_ret->sense.ascq == SCSI_SENSE_ASCQ_WRITE_AFTER_SANITIZE_REQUIRED) {
- logging(LOG_VERBOSE, "[SUCCESS] Read failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "WRITE_AFTER_SANITIZE_REQUIRED");
- break;
- }
- logging(LOG_VERBOSE, "[FAILED] Read should have failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "WRITE_AFTER_SANITIZE_REQUIRED");
- CU_FAIL("[FAILED] Read should have failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "WRITE_AFTER_SANITIZE_REQUIRED");
- break;
- }
+ switch (inq_bdc->wabereq) {
+ case 0:
+ logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE "
+ "opcode is supported but WABEREQ is 0");
+ CU_FAIL("[FAILED] SANITIZE BLOCK ERASE "
+ "opcode is supported but WABEREQ is 0");
+ break;
+ case 1:
+ logging(LOG_VERBOSE, "WABEREQ==1. Reads from the "
+ "device should be successful.");
+ if (task_ret->status == SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[SUCCESS] Read was "
+ "successful after SANITIZE");
+ break;
+ }
+ logging(LOG_NORMAL, "[FAILED] Read after "
+ "SANITIZE failed but WABEREQ is 1");
+ CU_FAIL("[FAILED] Read after SANITIZE failed "
+ "but WABEREQ is 1");
+ break;
+ case 2:
+ logging(LOG_VERBOSE, "WABEREQ==2. Reads from the "
+ "device should fail.");
+ if (task_ret->status == SCSI_STATUS_CHECK_CONDITION
+ && task_ret->sense.key == SCSI_SENSE_MEDIUM_ERROR
+ && task_ret->sense.ascq != SCSI_SENSE_ASCQ_WRITE_AFTER_SANITIZE_REQUIRED) {
+ logging(LOG_VERBOSE, "[SUCCESS] Read failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "!WRITE_AFTER_SANITIZE_REQUIRED");
+ break;
+ }
+ logging(LOG_VERBOSE, "[FAILED] Read should have failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "!WRITE_AFTER_SANITIZE_REQUIRED");
+ CU_FAIL("[FAILED] Read should have failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "!WRITE_AFTER_SANITIZE_REQUIRED");
+ break;
+ case 3:
+ logging(LOG_VERBOSE, "WABEREQ==3. Reads from the "
+ "device should fail.");
+ if (task_ret->status == SCSI_STATUS_CHECK_CONDITION
+ && task_ret->sense.key == SCSI_SENSE_MEDIUM_ERROR
+ && task_ret->sense.ascq == SCSI_SENSE_ASCQ_WRITE_AFTER_SANITIZE_REQUIRED) {
+ logging(LOG_VERBOSE, "[SUCCESS] Read failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "WRITE_AFTER_SANITIZE_REQUIRED");
+ break;
+ }
+ logging(LOG_VERBOSE, "[FAILED] Read should have failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "WRITE_AFTER_SANITIZE_REQUIRED");
+ CU_FAIL("[FAILED] Read should have failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "WRITE_AFTER_SANITIZE_REQUIRED");
+ break;
+ }
- scsi_free_scsi_task(task_ret);
+ scsi_free_scsi_task(task_ret);
}
static void
check_unmap(void)
{
- int i;
- struct scsi_task *task_ret = NULL;
- struct scsi_get_lba_status *lbas;
- uint64_t lba;
+ int i;
+ struct scsi_task *task_ret = NULL;
+ struct scsi_get_lba_status *lbas;
+ uint64_t lba;
- logging(LOG_VERBOSE, "Read LBA mapping from the target");
- GETLBASTATUS(sd, &task_ret, 0, 256,
+ logging(LOG_VERBOSE, "Read LBA mapping from the target");
+ GETLBASTATUS(sd, &task_ret, 0, 256,
EXPECT_STATUS_GOOD);
- if (task_ret == NULL) {
- logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping "
- "from the target.");
- CU_FAIL("[FAILED] Failed to read LBA mapping "
- "from the target.");
- return;
- }
- if (task_ret->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping "
- "from the target. Sense: %s",
- sd->error_str);
- CU_FAIL("[FAILED] Failed to read LBA mapping "
- "from the target.");
- scsi_free_scsi_task(task_ret);
- return;
- }
+ if (task_ret == NULL) {
+ logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping "
+ "from the target.");
+ CU_FAIL("[FAILED] Failed to read LBA mapping "
+ "from the target.");
+ return;
+ }
+ if (task_ret->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping "
+ "from the target. Sense: %s",
+ sd->error_str);
+ CU_FAIL("[FAILED] Failed to read LBA mapping "
+ "from the target.");
+ scsi_free_scsi_task(task_ret);
+ return;
+ }
- logging(LOG_VERBOSE, "Unmarshall LBA mapping datain buffer");
- lbas = scsi_datain_unmarshall(task_ret);
- if (lbas == NULL) {
- logging(LOG_VERBOSE, "[FAILED] Failed to unmarshall LBA "
- "mapping");
- CU_FAIL("[FAILED] Failed to read unmarshall LBA mapping");
- scsi_free_scsi_task(task_ret);
- return;
- }
+ logging(LOG_VERBOSE, "Unmarshall LBA mapping datain buffer");
+ lbas = scsi_datain_unmarshall(task_ret);
+ if (lbas == NULL) {
+ logging(LOG_VERBOSE, "[FAILED] Failed to unmarshall LBA "
+ "mapping");
+ CU_FAIL("[FAILED] Failed to read unmarshall LBA mapping");
+ scsi_free_scsi_task(task_ret);
+ return;
+ }
- logging(LOG_VERBOSE, "Verify we got at least one status descriptor "
- "from the target");
- if (lbas->num_descriptors < 1) {
- logging(LOG_VERBOSE, "[FAILED] Wrong number of LBA status "
- "descriptors. Expected >=1 but got %d descriptors",
- lbas->num_descriptors);
- CU_FAIL("[FAILED] Wrong number of LBA status descriptors.");
- scsi_free_scsi_task(task_ret);
- return;
- }
+ logging(LOG_VERBOSE, "Verify we got at least one status descriptor "
+ "from the target");
+ if (lbas->num_descriptors < 1) {
+ logging(LOG_VERBOSE, "[FAILED] Wrong number of LBA status "
+ "descriptors. Expected >=1 but got %d descriptors",
+ lbas->num_descriptors);
+ CU_FAIL("[FAILED] Wrong number of LBA status descriptors.");
+ scsi_free_scsi_task(task_ret);
+ return;
+ }
- logging(LOG_VERBOSE, "Verify that all descriptors are either "
- "DEALLOCATED or ANCHORED.");
- for (i = 0; i < (int)lbas->num_descriptors; i++) {
- logging(LOG_VERBOSE, "Check descriptor %d LBA:%" PRIu64 "-%"
- PRIu64 " that it is not MAPPED",
- i,
- lbas->descriptors[i].lba,
- lbas->descriptors[i].lba + lbas->descriptors[i].num_blocks);
- if (lbas->descriptors[i].provisioning == SCSI_PROVISIONING_TYPE_MAPPED) {
- logging(LOG_VERBOSE, "[FAILED] Descriptor %d is MAPPED."
- "All descriptors shoudl be either DEALLOCATED "
- "or ANCHORED after SANITIZE", i);
- CU_FAIL("[FAILED] LBA status descriptor is MAPPED.");
- }
- }
+ logging(LOG_VERBOSE, "Verify that all descriptors are either "
+ "DEALLOCATED or ANCHORED.");
+ for (i = 0; i < (int)lbas->num_descriptors; i++) {
+ logging(LOG_VERBOSE, "Check descriptor %d LBA:%" PRIu64 "-%"
+ PRIu64 " that it is not MAPPED",
+ i,
+ lbas->descriptors[i].lba,
+ lbas->descriptors[i].lba + lbas->descriptors[i].num_blocks);
+ if (lbas->descriptors[i].provisioning == SCSI_PROVISIONING_TYPE_MAPPED) {
+ logging(LOG_VERBOSE, "[FAILED] Descriptor %d is MAPPED."
+ "All descriptors shoudl be either DEALLOCATED "
+ "or ANCHORED after SANITIZE", i);
+ CU_FAIL("[FAILED] LBA status descriptor is MAPPED.");
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the descriptors cover the whole LUN");
- lba = 0;
- for (i = 0; i < (int)lbas->num_descriptors; i++) {
- logging(LOG_VERBOSE, "Check descriptor %d LBA:%" PRIu64 "-%"
- PRIu64 " that it is in order",
- i,
- lbas->descriptors[i].lba,
- lbas->descriptors[i].lba + lbas->descriptors[i].num_blocks);
- if (lba != lbas->descriptors[i].lba) {
- logging(LOG_VERBOSE, "[FAILED] LBA status descriptors "
- "are not in order.");
- CU_FAIL("[FAILED] LBA status descriptors not in order");
- }
- lba += lbas->descriptors[i].num_blocks;
- }
- if (lba != num_blocks) {
- logging(LOG_VERBOSE, "[FAILED] The LUN is not fully"
- "DEALLOCATED/ANCHORED");
- CU_FAIL("[FAILED] The LUN is not fully"
- "DEALLOCATED/ANCHORED");
- }
+ logging(LOG_VERBOSE, "Verify that the descriptors cover the whole LUN");
+ lba = 0;
+ for (i = 0; i < (int)lbas->num_descriptors; i++) {
+ logging(LOG_VERBOSE, "Check descriptor %d LBA:%" PRIu64 "-%"
+ PRIu64 " that it is in order",
+ i,
+ lbas->descriptors[i].lba,
+ lbas->descriptors[i].lba + lbas->descriptors[i].num_blocks);
+ if (lba != lbas->descriptors[i].lba) {
+ logging(LOG_VERBOSE, "[FAILED] LBA status descriptors "
+ "are not in order.");
+ CU_FAIL("[FAILED] LBA status descriptors not in order");
+ }
+ lba += lbas->descriptors[i].num_blocks;
+ }
+ if (lba != num_blocks) {
+ logging(LOG_VERBOSE, "[FAILED] The LUN is not fully"
+ "DEALLOCATED/ANCHORED");
+ CU_FAIL("[FAILED] The LUN is not fully"
+ "DEALLOCATED/ANCHORED");
+ }
- scsi_free_scsi_task(task_ret);
+ scsi_free_scsi_task(task_ret);
}
static void
check_lun_is_wiped(unsigned char *buf, uint64_t lba)
{
- unsigned char *rbuf = alloca(256 * block_size);
+ unsigned char *rbuf = alloca(256 * block_size);
- READ16(sd, NULL, lba, 256 * block_size, block_size, 0, 0, 0, 0, 0, rbuf,
+ READ16(sd, NULL, lba, 256 * block_size, block_size, 0, 0, 0, 0, 0, rbuf,
EXPECT_STATUS_GOOD);
- if (rc16 == NULL) {
- return;
- }
+ if (rc16 == NULL) {
+ return;
+ }
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ==1 All blocks "
- "should read back as 0");
- if (all_zeroes(rbuf, 256 * block_size) == 0) {
- logging(LOG_NORMAL, "[FAILED] Blocks did not "
- "read back as zero");
- CU_FAIL("[FAILED] Blocks did not read back "
- "as zero");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
- "back as zero");
- }
- } else {
- logging(LOG_VERBOSE, "LBPRZ==0 Blocks should not read back as "
- "all 'a' any more");
- if (!memcmp(buf, rbuf, 256 * block_size)) {
- logging(LOG_NORMAL, "[FAILED] Blocks were not wiped");
- CU_FAIL("[FAILED] Blocks were not wiped");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Blocks were wiped");
- }
- }
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ==1 All blocks "
+ "should read back as 0");
+ if (all_zeroes(rbuf, 256 * block_size) == 0) {
+ logging(LOG_NORMAL, "[FAILED] Blocks did not "
+ "read back as zero");
+ CU_FAIL("[FAILED] Blocks did not read back "
+ "as zero");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
+ "back as zero");
+ }
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ==0 Blocks should not read back as "
+ "all 'a' any more");
+ if (!memcmp(buf, rbuf, 256 * block_size)) {
+ logging(LOG_NORMAL, "[FAILED] Blocks were not wiped");
+ CU_FAIL("[FAILED] Blocks were not wiped");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Blocks were wiped");
+ }
+ }
}
void
test_sanitize_block_erase(void)
{
- struct iscsi_data data;
- struct scsi_command_descriptor *cd;
- unsigned char *buf = alloca(256 * block_size);
+ struct iscsi_data data;
+ struct scsi_command_descriptor *cd;
+ unsigned char *buf = alloca(256 * block_size);
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE BLOCK ERASE");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE BLOCK ERASE");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Check that SANITIZE BLOCK_ERASE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_BLOCK_ERASE);
- if (cd == NULL) {
- logging(LOG_VERBOSE, "Opcode is not supported. Verify that "
- "WABEREQ is zero.");
- if (inq_bdc && inq_bdc->wabereq) {
- logging(LOG_NORMAL, "[FAILED] WABEREQ is not 0 but "
- "SANITIZE BLOCK ERASE opcode is not supported");
- CU_FAIL("[FAILED] WABEREQ is not 0 but BLOCK ERASE "
- "is not supported.");
- }
+ logging(LOG_VERBOSE, "Check that SANITIZE BLOCK_ERASE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_BLOCK_ERASE);
+ if (cd == NULL) {
+ logging(LOG_VERBOSE, "Opcode is not supported. Verify that "
+ "WABEREQ is zero.");
+ if (inq_bdc && inq_bdc->wabereq) {
+ logging(LOG_NORMAL, "[FAILED] WABEREQ is not 0 but "
+ "SANITIZE BLOCK ERASE opcode is not supported");
+ CU_FAIL("[FAILED] WABEREQ is not 0 but BLOCK ERASE "
+ "is not supported.");
+ }
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- CU_PASS("SANITIZE is not implemented.");
- return;
- }
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ CU_PASS("SANITIZE is not implemented.");
+ return;
+ }
- logging(LOG_VERBOSE, "Verify that we have BlockDeviceCharacteristics "
- "VPD page.");
- if (inq_bdc == NULL) {
- logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE opcode is "
- "supported but BlockDeviceCharacteristics VPD page is "
- "missing");
- CU_FAIL("[FAILED] BlockDeviceCharacteristics VPD "
- "page is missing");
- }
+ logging(LOG_VERBOSE, "Verify that we have BlockDeviceCharacteristics "
+ "VPD page.");
+ if (inq_bdc == NULL) {
+ logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE opcode is "
+ "supported but BlockDeviceCharacteristics VPD page is "
+ "missing");
+ CU_FAIL("[FAILED] BlockDeviceCharacteristics VPD "
+ "page is missing");
+ }
- logging(LOG_VERBOSE, "Verify that we have READCAPACITY16");
- if (!rc16) {
- logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE opcode is "
- "supported but READCAPACITY16 is missing.");
- CU_FAIL("[FAILED] READCAPACITY16 is missing");
- }
+ logging(LOG_VERBOSE, "Verify that we have READCAPACITY16");
+ if (!rc16) {
+ logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE opcode is "
+ "supported but READCAPACITY16 is missing.");
+ CU_FAIL("[FAILED] READCAPACITY16 is missing");
+ }
- logging(LOG_VERBOSE, "Verify that logical block provisioning (LBPME) "
- "is available.");
- if (!rc16 || !(rc16->lbpme)) {
- logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE opcode is "
- "supported but LBPME==0.");
- CU_FAIL("[FAILED] SANITIZE BLOCK ERASE opcode is "
- "supported but LBPME==0.");
- }
+ logging(LOG_VERBOSE, "Verify that logical block provisioning (LBPME) "
+ "is available.");
+ if (!rc16 || !(rc16->lbpme)) {
+ logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE opcode is "
+ "supported but LBPME==0.");
+ CU_FAIL("[FAILED] SANITIZE BLOCK ERASE opcode is "
+ "supported but LBPME==0.");
+ }
- logging(LOG_VERBOSE, "Check MediumRotationRate whether this is a HDD "
- "or a SSD device.");
- if (inq_bdc && inq_bdc->medium_rotation_rate != 0) {
- logging(LOG_NORMAL, "This is a HDD device");
- logging(LOG_NORMAL, "[WARNING] SANITIZE BLOCK ERASE opcode is "
- "supported but MediumRotationRate is not 0 "
- "indicating that this is a HDD. Only SSDs should "
- "implement BLOCK ERASE");
- } else {
- logging(LOG_NORMAL, "This is a HDD device");
- }
+ logging(LOG_VERBOSE, "Check MediumRotationRate whether this is a HDD "
+ "or a SSD device.");
+ if (inq_bdc && inq_bdc->medium_rotation_rate != 0) {
+ logging(LOG_NORMAL, "This is a HDD device");
+ logging(LOG_NORMAL, "[WARNING] SANITIZE BLOCK ERASE opcode is "
+ "supported but MediumRotationRate is not 0 "
+ "indicating that this is a HDD. Only SSDs should "
+ "implement BLOCK ERASE");
+ } else {
+ logging(LOG_NORMAL, "This is a HDD device");
+ }
- logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
- memset(scratch, 'a', 256 * block_size);
- WRITE16(sd, 0, 256 * block_size,
+ logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
+ memset(scratch, 'a', 256 * block_size);
+ WRITE16(sd, 0, 256 * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs");
- WRITE16(sd, num_blocks - 256, 256 * block_size,
+ logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs");
+ WRITE16(sd, num_blocks - 256, 256 * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test we can perform basic BLOCK ERASE SANITIZE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
+ logging(LOG_VERBOSE, "Test we can perform basic BLOCK ERASE SANITIZE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
- check_lun_is_wiped(buf, 0);
- logging(LOG_VERBOSE, "Check that the last 256 LBAs are wiped.");
- check_lun_is_wiped(buf, num_blocks - 256);
+ logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
+ check_lun_is_wiped(buf, 0);
+ logging(LOG_VERBOSE, "Check that the last 256 LBAs are wiped.");
+ check_lun_is_wiped(buf, num_blocks - 256);
- data.size = 8;
- data.data = alloca(data.size);
- memset(data.data, 0, data.size);
+ data.size = 8;
+ data.data = alloca(data.size);
+ memset(data.data, 0, data.size);
- logging(LOG_VERBOSE, "BLOCK_ERASE parameter list length must be 0");
- logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
- "BLOCK ERASE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 8, &data,
+ logging(LOG_VERBOSE, "BLOCK_ERASE parameter list length must be 0");
+ logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
+ "BLOCK ERASE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 8, &data,
EXPECT_INVALID_FIELD_IN_CDB);
- if (inq_bdc) {
- logging(LOG_VERBOSE, "Check WABEREQ setting and that READ "
- "after SANITIZE works correctly.");
- check_wabereq();
- }
+ if (inq_bdc) {
+ logging(LOG_VERBOSE, "Check WABEREQ setting and that READ "
+ "after SANITIZE works correctly.");
+ check_wabereq();
+ }
- logging(LOG_VERBOSE, "Verify that all blocks are unmapped after "
- "SANITIZE BLOCK_ERASE");
- check_unmap();
+ logging(LOG_VERBOSE, "Verify that all blocks are unmapped after "
+ "SANITIZE BLOCK_ERASE");
+ check_unmap();
}
diff --git a/test-tool/test_sanitize_block_erase_reserved.c b/test-tool/test_sanitize_block_erase_reserved.c
index f329dac..f710dbb 100644
--- a/test-tool/test_sanitize_block_erase_reserved.c
+++ b/test-tool/test_sanitize_block_erase_reserved.c
@@ -29,50 +29,50 @@ static int change_num;
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu)
{
- switch (change_num) {
- case 1:
- /* Set reserved bit 0x40 in byte 1 of the CDB */
- pdu->outdata.data[33] |= 0x40;
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- /* Set reserved byte in the CDB */
- pdu->outdata.data[32 + change_num] = change_num;
- break;
- }
+ switch (change_num) {
+ case 1:
+ /* Set reserved bit 0x40 in byte 1 of the CDB */
+ pdu->outdata.data[33] |= 0x40;
+ break;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ /* Set reserved byte in the CDB */
+ pdu->outdata.data[32 + change_num] = change_num;
+ break;
+ }
- change_num = 0;
- return 0;
+ change_num = 0;
+ return 0;
}
void test_sanitize_block_erase_reserved(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE Reserved bits/bytes");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE Reserved bits/bytes");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
- "bit in byte 1 set to 1");
- change_num = 1;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
+ logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
+ "bit in byte 1 set to 1");
+ change_num = 1;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- for (i = 2; i < 7; i++) {
- logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
- "byte %d set to non-zero", i);
- change_num = i;
+ for (i = 2; i < 7; i++) {
+ logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
+ "byte %d set to non-zero", i);
+ change_num = i;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
}
diff --git a/test-tool/test_sanitize_crypto_erase.c b/test-tool/test_sanitize_crypto_erase.c
index 1c96e48..18a0a35 100644
--- a/test-tool/test_sanitize_crypto_erase.c
+++ b/test-tool/test_sanitize_crypto_erase.c
@@ -31,170 +31,170 @@
static void
check_wacereq(void)
{
- struct scsi_task *task_ret = NULL;
+ struct scsi_task *task_ret = NULL;
- logging(LOG_VERBOSE, "Read one block from LBA 0");
- READ10(sd, &task_ret, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ logging(LOG_VERBOSE, "Read one block from LBA 0");
+ READ10(sd, &task_ret, 0, block_size, block_size, 0, 0, 0, 0, 0, NULL,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
if (task_ret == NULL) {
return;
}
- CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED);
+ CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED);
- switch (inq_bdc->wabereq) {
- case 0:
- logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE "
- "opcode is supported but WACEREQ is 0");
- CU_FAIL("[FAILED] SANITIZE BLOCK ERASE "
- "opcode is supported but WACEREQ is 0");
- break;
- case 1:
- logging(LOG_VERBOSE, "WACEREQ==1. Reads from the "
- "device should be successful.");
- if (task_ret->status == SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[SUCCESS] Read was "
- "successful after SANITIZE");
- break;
- }
- logging(LOG_NORMAL, "[FAILED] Read after "
- "SANITIZE failed but WACEREQ is 1");
- CU_FAIL("[FAILED] Read after SANITIZE failed "
- "but WACEREQ is 1");
- break;
- case 2:
- logging(LOG_VERBOSE, "WACEREQ==2. Reads from the "
- "device should fail.");
- if (task_ret->status == SCSI_STATUS_CHECK_CONDITION
- && task_ret->sense.key == SCSI_SENSE_MEDIUM_ERROR
- && task_ret->sense.ascq != SCSI_SENSE_ASCQ_WRITE_AFTER_SANITIZE_REQUIRED) {
- logging(LOG_VERBOSE, "[SUCCESS] Read failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "!WRITE_AFTER_SANITIZE_REQUIRED");
- break;
- }
- logging(LOG_VERBOSE, "[FAILED] Read should have failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "!WRITE_AFTER_SANITIZE_REQUIRED");
- CU_FAIL("[FAILED] Read should have failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "!WRITE_AFTER_SANITIZE_REQUIRED");
- break;
- case 3:
- logging(LOG_VERBOSE, "WACEREQ==3. Reads from the "
- "device should fail.");
- if (task_ret->status == SCSI_STATUS_CHECK_CONDITION
- && task_ret->sense.key == SCSI_SENSE_MEDIUM_ERROR
- && task_ret->sense.ascq == SCSI_SENSE_ASCQ_WRITE_AFTER_SANITIZE_REQUIRED) {
- logging(LOG_VERBOSE, "[SUCCESS] Read failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "WRITE_AFTER_SANITIZE_REQUIRED");
- break;
- }
- logging(LOG_VERBOSE, "[FAILED] Read should have failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "WRITE_AFTER_SANITIZE_REQUIRED");
- CU_FAIL("[FAILED] Read should have failed "
- "with CHECK_CONDITION/MEDIUM_ERROR/"
- "WRITE_AFTER_SANITIZE_REQUIRED");
- break;
- }
+ switch (inq_bdc->wabereq) {
+ case 0:
+ logging(LOG_NORMAL, "[FAILED] SANITIZE BLOCK ERASE "
+ "opcode is supported but WACEREQ is 0");
+ CU_FAIL("[FAILED] SANITIZE BLOCK ERASE "
+ "opcode is supported but WACEREQ is 0");
+ break;
+ case 1:
+ logging(LOG_VERBOSE, "WACEREQ==1. Reads from the "
+ "device should be successful.");
+ if (task_ret->status == SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[SUCCESS] Read was "
+ "successful after SANITIZE");
+ break;
+ }
+ logging(LOG_NORMAL, "[FAILED] Read after "
+ "SANITIZE failed but WACEREQ is 1");
+ CU_FAIL("[FAILED] Read after SANITIZE failed "
+ "but WACEREQ is 1");
+ break;
+ case 2:
+ logging(LOG_VERBOSE, "WACEREQ==2. Reads from the "
+ "device should fail.");
+ if (task_ret->status == SCSI_STATUS_CHECK_CONDITION
+ && task_ret->sense.key == SCSI_SENSE_MEDIUM_ERROR
+ && task_ret->sense.ascq != SCSI_SENSE_ASCQ_WRITE_AFTER_SANITIZE_REQUIRED) {
+ logging(LOG_VERBOSE, "[SUCCESS] Read failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "!WRITE_AFTER_SANITIZE_REQUIRED");
+ break;
+ }
+ logging(LOG_VERBOSE, "[FAILED] Read should have failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "!WRITE_AFTER_SANITIZE_REQUIRED");
+ CU_FAIL("[FAILED] Read should have failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "!WRITE_AFTER_SANITIZE_REQUIRED");
+ break;
+ case 3:
+ logging(LOG_VERBOSE, "WACEREQ==3. Reads from the "
+ "device should fail.");
+ if (task_ret->status == SCSI_STATUS_CHECK_CONDITION
+ && task_ret->sense.key == SCSI_SENSE_MEDIUM_ERROR
+ && task_ret->sense.ascq == SCSI_SENSE_ASCQ_WRITE_AFTER_SANITIZE_REQUIRED) {
+ logging(LOG_VERBOSE, "[SUCCESS] Read failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "WRITE_AFTER_SANITIZE_REQUIRED");
+ break;
+ }
+ logging(LOG_VERBOSE, "[FAILED] Read should have failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "WRITE_AFTER_SANITIZE_REQUIRED");
+ CU_FAIL("[FAILED] Read should have failed "
+ "with CHECK_CONDITION/MEDIUM_ERROR/"
+ "WRITE_AFTER_SANITIZE_REQUIRED");
+ break;
+ }
- scsi_free_scsi_task(task_ret);
+ scsi_free_scsi_task(task_ret);
}
static void
check_lun_is_wiped(unsigned char *buf, uint64_t lba)
{
- unsigned char *rbuf = alloca(256 * block_size);
+ unsigned char *rbuf = alloca(256 * block_size);
- READ16(sd, NULL, lba, 256 * block_size, block_size, 0, 0, 0, 0, 0, rbuf,
+ READ16(sd, NULL, lba, 256 * block_size, block_size, 0, 0, 0, 0, 0, rbuf,
EXPECT_STATUS_GOOD);
- if (!memcmp(buf, rbuf, 256 * block_size)) {
- logging(LOG_NORMAL, "[FAILED] Blocks were not wiped");
- CU_FAIL("[FAILED] Blocks were not wiped");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Blocks were wiped");
- }
+ if (!memcmp(buf, rbuf, 256 * block_size)) {
+ logging(LOG_NORMAL, "[FAILED] Blocks were not wiped");
+ CU_FAIL("[FAILED] Blocks were not wiped");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Blocks were wiped");
+ }
}
void
test_sanitize_crypto_erase(void)
{
- struct iscsi_data data;
- struct scsi_command_descriptor *cd;
- unsigned char *buf = alloca(256 * block_size);
+ struct iscsi_data data;
+ struct scsi_command_descriptor *cd;
+ unsigned char *buf = alloca(256 * block_size);
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE CRYPTO ERASE");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE CRYPTO ERASE");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Check that SANITIZE CRYPTO_ERASE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_CRYPTO_ERASE);
- if (cd == NULL) {
- logging(LOG_VERBOSE, "Opcode is not supported. Verify that "
- "WACEREQ is zero.");
- if (inq_bdc && inq_bdc->wacereq) {
- logging(LOG_NORMAL, "[FAILED] WACEREQ is not 0 but "
- "SANITIZE CRYPTO ERASE opcode is not "
- "supported");
- CU_FAIL("[FAILED] WACEREQ is not 0 but CRYPTO ERASE "
- "is not supported.");
- }
+ logging(LOG_VERBOSE, "Check that SANITIZE CRYPTO_ERASE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_CRYPTO_ERASE);
+ if (cd == NULL) {
+ logging(LOG_VERBOSE, "Opcode is not supported. Verify that "
+ "WACEREQ is zero.");
+ if (inq_bdc && inq_bdc->wacereq) {
+ logging(LOG_NORMAL, "[FAILED] WACEREQ is not 0 but "
+ "SANITIZE CRYPTO ERASE opcode is not "
+ "supported");
+ CU_FAIL("[FAILED] WACEREQ is not 0 but CRYPTO ERASE "
+ "is not supported.");
+ }
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- CU_PASS("SANITIZE is not implemented.");
- return;
- }
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ CU_PASS("SANITIZE is not implemented.");
+ return;
+ }
- logging(LOG_VERBOSE, "Verify that we have BlockDeviceCharacteristics "
- "VPD page.");
- if (inq_bdc == NULL) {
- logging(LOG_NORMAL, "[FAILED] SANITIZE CRYPTO ERASE opcode is "
- "supported but BlockDeviceCharacteristics VPD page is "
- "missing");
- CU_FAIL("[FAILED] BlockDeviceCharacteristics VPD "
- "page is missing");
- }
+ logging(LOG_VERBOSE, "Verify that we have BlockDeviceCharacteristics "
+ "VPD page.");
+ if (inq_bdc == NULL) {
+ logging(LOG_NORMAL, "[FAILED] SANITIZE CRYPTO ERASE opcode is "
+ "supported but BlockDeviceCharacteristics VPD page is "
+ "missing");
+ CU_FAIL("[FAILED] BlockDeviceCharacteristics VPD "
+ "page is missing");
+ }
- logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
- memset(scratch, 'a', 256 * block_size);
- WRITE16(sd, 0, 256 * block_size,
+ logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
+ memset(scratch, 'a', 256 * block_size);
+ WRITE16(sd, 0, 256 * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs");
- WRITE16(sd, num_blocks - 256, 256 * block_size,
+ logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs");
+ WRITE16(sd, num_blocks - 256, 256 * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
+ logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
- check_lun_is_wiped(buf, 0);
- logging(LOG_VERBOSE, "Check that the last 256 LBAs are wiped.");
- check_lun_is_wiped(buf, num_blocks - 256);
+ logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
+ check_lun_is_wiped(buf, 0);
+ logging(LOG_VERBOSE, "Check that the last 256 LBAs are wiped.");
+ check_lun_is_wiped(buf, num_blocks - 256);
- data.size = 8;
- data.data = alloca(data.size);
- memset(data.data, 0, data.size);
+ data.size = 8;
+ data.data = alloca(data.size);
+ memset(data.data, 0, data.size);
- logging(LOG_VERBOSE, "CRYPTO_ERASE parameter list length must be 0");
- logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
- "CRYPTO ERASE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 8, &data,
+ logging(LOG_VERBOSE, "CRYPTO_ERASE parameter list length must be 0");
+ logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
+ "CRYPTO ERASE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 8, &data,
EXPECT_INVALID_FIELD_IN_CDB);
- if (inq_bdc) {
- logging(LOG_VERBOSE, "Check WACEREQ setting and that READ "
- "after SANITIZE works correctly.");
- check_wacereq();
- }
+ if (inq_bdc) {
+ logging(LOG_VERBOSE, "Check WACEREQ setting and that READ "
+ "after SANITIZE works correctly.");
+ check_wacereq();
+ }
}
diff --git a/test-tool/test_sanitize_crypto_erase_reserved.c b/test-tool/test_sanitize_crypto_erase_reserved.c
index 3d2df55..a8ec6dc 100644
--- a/test-tool/test_sanitize_crypto_erase_reserved.c
+++ b/test-tool/test_sanitize_crypto_erase_reserved.c
@@ -29,50 +29,50 @@ static int change_num;
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu)
{
- switch (change_num) {
- case 1:
- /* Set reserved bit 0x40 in byte 1 of the CDB */
- pdu->outdata.data[33] |= 0x40;
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- /* Set reserved byte in the CDB */
- pdu->outdata.data[32 + change_num] = change_num;
- break;
- }
+ switch (change_num) {
+ case 1:
+ /* Set reserved bit 0x40 in byte 1 of the CDB */
+ pdu->outdata.data[33] |= 0x40;
+ break;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ /* Set reserved byte in the CDB */
+ pdu->outdata.data[32 + change_num] = change_num;
+ break;
+ }
- change_num = 0;
- return 0;
+ change_num = 0;
+ return 0;
}
void test_sanitize_crypto_erase_reserved(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE Reserved bits/bytes");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE Reserved bits/bytes");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
- "bit in byte 1 set to 1");
- change_num = 1;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
+ logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
+ "bit in byte 1 set to 1");
+ change_num = 1;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- for (i = 2; i < 7; i++) {
- logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
- "byte %d set to non-zero", i);
- change_num = i;
+ for (i = 2; i < 7; i++) {
+ logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
+ "byte %d set to non-zero", i);
+ change_num = i;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
}
diff --git a/test-tool/test_sanitize_exit_failure_mode.c b/test-tool/test_sanitize_exit_failure_mode.c
index a695bb3..f7f74f1 100644
--- a/test-tool/test_sanitize_exit_failure_mode.c
+++ b/test-tool/test_sanitize_exit_failure_mode.c
@@ -30,35 +30,35 @@
void
test_sanitize_exit_failure_mode(void)
{
- struct iscsi_data data;
- struct scsi_command_descriptor *cd;
+ struct iscsi_data data;
+ struct scsi_command_descriptor *cd;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE EXIT FAILURE MODE");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE EXIT FAILURE MODE");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Check that SANITIZE EXIT FAILURE MODE is "
- "supported in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_EXIT_FAILURE_MODE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE EXIT FAILURE MODE is "
- "not implemented according to "
- "REPORT_SUPPORTED_OPCODES.");
- CU_PASS("SANITIZE is not implemented.");
- return;
- }
+ logging(LOG_VERBOSE, "Check that SANITIZE EXIT FAILURE MODE is "
+ "supported in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_EXIT_FAILURE_MODE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE EXIT FAILURE MODE is "
+ "not implemented according to "
+ "REPORT_SUPPORTED_OPCODES.");
+ CU_PASS("SANITIZE is not implemented.");
+ return;
+ }
- data.size = 8;
- data.data = alloca(data.size);
- memset(data.data, 0, data.size);
+ data.size = 8;
+ data.data = alloca(data.size);
+ memset(data.data, 0, data.size);
- logging(LOG_VERBOSE, "EXIT_FAILURE_MODE parameter list length must "
- "be 0");
- logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
- "EXIT_FAILURE_MODE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_EXIT_FAILURE_MODE, 8, &data,
+ logging(LOG_VERBOSE, "EXIT_FAILURE_MODE parameter list length must "
+ "be 0");
+ logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
+ "EXIT_FAILURE_MODE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_EXIT_FAILURE_MODE, 8, &data,
EXPECT_INVALID_FIELD_IN_CDB);
}
diff --git a/test-tool/test_sanitize_invalid_serviceaction.c b/test-tool/test_sanitize_invalid_serviceaction.c
index 1b3577d..e002c9e 100644
--- a/test-tool/test_sanitize_invalid_serviceaction.c
+++ b/test-tool/test_sanitize_invalid_serviceaction.c
@@ -30,28 +30,28 @@
void
test_sanitize_invalid_serviceaction(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE for invalid serviceactions");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE for invalid serviceactions");
- CHECK_FOR_SANITIZE;
+ CHECK_FOR_SANITIZE;
- logging(LOG_VERBOSE, "Test all invalid service actions and make sure "
- "they fail with an error");
- for (i = 0; i <= 0x1f; i++) {
- switch (i) {
- case 1:
- case 2:
- case 3:
- case 0x1f:
- continue;
- }
+ logging(LOG_VERBOSE, "Test all invalid service actions and make sure "
+ "they fail with an error");
+ for (i = 0; i <= 0x1f; i++) {
+ switch (i) {
+ case 1:
+ case 2:
+ case 3:
+ case 0x1f:
+ continue;
+ }
- logging(LOG_VERBOSE, "Verify that ServiceAction:0x%02d is "
- "an error.", i);
+ logging(LOG_VERBOSE, "Verify that ServiceAction:0x%02d is "
+ "an error.", i);
- SANITIZE(sd, 0, 0, i, 0, NULL,
+ SANITIZE(sd, 0, 0, i, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
}
diff --git a/test-tool/test_sanitize_overwrite.c b/test-tool/test_sanitize_overwrite.c
index aa9cf52..7dd4534 100644
--- a/test-tool/test_sanitize_overwrite.c
+++ b/test-tool/test_sanitize_overwrite.c
@@ -30,166 +30,166 @@
static void
check_lun_is_wiped(uint64_t lba, unsigned char c)
{
- unsigned char *rbuf = alloca(256 * block_size);
- unsigned char *zbuf = alloca(256 * block_size);
+ unsigned char *rbuf = alloca(256 * block_size);
+ unsigned char *zbuf = alloca(256 * block_size);
- READ16(sd, NULL, lba, 256 * block_size,
+ READ16(sd, NULL, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, rbuf,
EXPECT_STATUS_GOOD);
- memset(zbuf, c, 256 * block_size);
+ memset(zbuf, c, 256 * block_size);
- if (memcmp(zbuf, rbuf, 256 * block_size)) {
- logging(LOG_NORMAL, "[FAILED] Blocks did not read back as %#x",
- c);
- CU_FAIL("[FAILED] Blocks did not read back as expected");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Blocks read back as %#x", c);
- }
+ if (memcmp(zbuf, rbuf, 256 * block_size)) {
+ logging(LOG_NORMAL, "[FAILED] Blocks did not read back as %#x",
+ c);
+ CU_FAIL("[FAILED] Blocks did not read back as expected");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Blocks read back as %#x", c);
+ }
}
void
test_sanitize_overwrite(void)
{
- int i;
- struct iscsi_data data;
- struct scsi_command_descriptor *cd;
+ int i;
+ struct iscsi_data data;
+ struct scsi_command_descriptor *cd;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Check that SANITIZE OVERWRITE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_OVERWRITE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- CU_PASS("SANITIZE is not implemented.");
- return;
- }
+ logging(LOG_VERBOSE, "Check that SANITIZE OVERWRITE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_OVERWRITE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ CU_PASS("SANITIZE is not implemented.");
+ return;
+ }
- logging(LOG_VERBOSE, "Verify that we have BlockDeviceCharacteristics "
- "VPD page.");
- if (inq_bdc == NULL) {
- logging(LOG_NORMAL, "[FAILED] SANITIZE OVERWRITE opcode is "
- "supported but BlockDeviceCharacteristics VPD page is "
- "missing");
- CU_FAIL("[FAILED] BlockDeviceCharacteristics VPD "
- "page is missing");
- }
+ logging(LOG_VERBOSE, "Verify that we have BlockDeviceCharacteristics "
+ "VPD page.");
+ if (inq_bdc == NULL) {
+ logging(LOG_NORMAL, "[FAILED] SANITIZE OVERWRITE opcode is "
+ "supported but BlockDeviceCharacteristics VPD page is "
+ "missing");
+ CU_FAIL("[FAILED] BlockDeviceCharacteristics VPD "
+ "page is missing");
+ }
- logging(LOG_VERBOSE, "Check MediumRotationRate whether this is a HDD "
- "or a SSD device.");
- if (inq_bdc && inq_bdc->medium_rotation_rate == 0) {
- logging(LOG_NORMAL, "This is a HDD device");
- logging(LOG_NORMAL, "[WARNING] SANITIZE OVERWRITE opcode is "
- "supported but MediumRotationRate is 0 "
- "indicating that this is an SSD. Only HDDs should "
- "implement OVERWRITE");
- } else {
- logging(LOG_NORMAL, "This is a SSD device");
- }
+ logging(LOG_VERBOSE, "Check MediumRotationRate whether this is a HDD "
+ "or a SSD device.");
+ if (inq_bdc && inq_bdc->medium_rotation_rate == 0) {
+ logging(LOG_NORMAL, "This is a HDD device");
+ logging(LOG_NORMAL, "[WARNING] SANITIZE OVERWRITE opcode is "
+ "supported but MediumRotationRate is 0 "
+ "indicating that this is an SSD. Only HDDs should "
+ "implement OVERWRITE");
+ } else {
+ logging(LOG_NORMAL, "This is a SSD device");
+ }
- logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
- memset(scratch, 'a', 256 * block_size);
- WRITE16(sd, 0, 256 * block_size,
+ logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
+ memset(scratch, 'a', 256 * block_size);
+ WRITE16(sd, 0, 256 * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs");
- WRITE16(sd, num_blocks - 256, 256 * block_size,
+ logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs");
+ WRITE16(sd, num_blocks - 256, 256 * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with initialization pattern of one full block");
- data.size = block_size + 4;
- data.data = alloca(data.size);
- memset(&data.data[4], 0xaa, block_size);
+ logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with initialization pattern of one full block");
+ data.size = block_size + 4;
+ data.data = alloca(data.size);
+ memset(&data.data[4], 0xaa, block_size);
- data.data[0] = 0x01;
- data.data[1] = 0x00;
- data.data[2] = block_size >> 8;
- data.data[3] = block_size & 0xff;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ data.data[0] = 0x01;
+ data.data[1] = 0x00;
+ data.data[2] = block_size >> 8;
+ data.data[3] = block_size & 0xff;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
- check_lun_is_wiped(0, 0xaa);
- logging(LOG_VERBOSE, "Check that the last 256 LBAs are wiped.");
- check_lun_is_wiped(num_blocks - 256, 0xaa);
+ logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
+ check_lun_is_wiped(0, 0xaa);
+ logging(LOG_VERBOSE, "Check that the last 256 LBAs are wiped.");
+ check_lun_is_wiped(num_blocks - 256, 0xaa);
- logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with initialization pattern of one half block");
- data.size = block_size / 2 + 4;
+ logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with initialization pattern of one half block");
+ data.size = block_size / 2 + 4;
- data.data[2] = (block_size / 2) >> 8;
- data.data[3] = (block_size / 2 ) & 0xff;
+ data.data[2] = (block_size / 2) >> 8;
+ data.data[3] = (block_size / 2 ) & 0xff;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with initialization pattern of 4 bytes");
- data.size = 4 + 4;
+ logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with initialization pattern of 4 bytes");
+ data.size = 4 + 4;
- data.data[2] = 0;
- data.data[3] = 4;
+ data.data[2] = 0;
+ data.data[3] = 4;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "OVERWRITE parameter list length must "
- "be > 4 and < blocksize+5");
- for (i = 0; i < 5; i++) {
- logging(LOG_VERBOSE, "Test OVERWRITE with ParamLen:%d is an "
- "error.", i);
+ logging(LOG_VERBOSE, "OVERWRITE parameter list length must "
+ "be > 4 and < blocksize+5");
+ for (i = 0; i < 5; i++) {
+ logging(LOG_VERBOSE, "Test OVERWRITE with ParamLen:%d is an "
+ "error.", i);
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, i, &data,
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, i, &data,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test OVERWRITE with ParamLen:%zd (blocksize+5) "
- "is an error.", block_size + 5);
+ logging(LOG_VERBOSE, "Test OVERWRITE with ParamLen:%zd (blocksize+5) "
+ "is an error.", block_size + 5);
- data.size = block_size + 8;
- data.data = alloca(block_size + 8); /* so we can send IP > blocksize */
- memset(data.data, 0, data.size);
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, block_size + 5, &data,
+ data.size = block_size + 8;
+ data.data = alloca(block_size + 8); /* so we can send IP > blocksize */
+ memset(data.data, 0, data.size);
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, block_size + 5, &data,
EXPECT_INVALID_FIELD_IN_CDB);
- logging(LOG_VERBOSE, "Test OVERWRITE COUNT == 0 is an error");
- data.size = block_size + 4;
+ logging(LOG_VERBOSE, "Test OVERWRITE COUNT == 0 is an error");
+ data.size = block_size + 4;
- data.data[0] = 0x00;
- data.data[1] = 0x00;
- data.data[2] = block_size >> 8;
- data.data[3] = block_size & 0xff;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ data.data[0] = 0x00;
+ data.data[1] = 0x00;
+ data.data[2] = block_size >> 8;
+ data.data[3] = block_size & 0xff;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_INVALID_FIELD_IN_CDB);
- logging(LOG_VERBOSE, "Test INITIALIZATION PATTERN LENGTH == 0 is an "
- "error");
- data.size = block_size + 4;
+ logging(LOG_VERBOSE, "Test INITIALIZATION PATTERN LENGTH == 0 is an "
+ "error");
+ data.size = block_size + 4;
- data.data[0] = 0x00;
- data.data[1] = 0x00;
- data.data[2] = 0x00;
- data.data[3] = 0x00;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ data.data[0] = 0x00;
+ data.data[1] = 0x00;
+ data.data[2] = 0x00;
+ data.data[3] = 0x00;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_INVALID_FIELD_IN_CDB);
- logging(LOG_VERBOSE, "Test INITIALIZATION PATTERN LENGTH == %zd > %zd "
- "(blocksize) is an error", block_size + 4, block_size);
+ logging(LOG_VERBOSE, "Test INITIALIZATION PATTERN LENGTH == %zd > %zd "
+ "(blocksize) is an error", block_size + 4, block_size);
- data.size = block_size + 4;
+ data.size = block_size + 4;
- data.data[0] = 0x00;
- data.data[1] = 0x00;
- data.data[2] = (block_size + 4) >> 8;
- data.data[3] = (block_size + 4) & 0xff;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ data.data[0] = 0x00;
+ data.data[1] = 0x00;
+ data.data[2] = (block_size + 4) >> 8;
+ data.data[3] = (block_size + 4) & 0xff;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_INVALID_FIELD_IN_CDB);
}
diff --git a/test-tool/test_sanitize_overwrite_reserved.c b/test-tool/test_sanitize_overwrite_reserved.c
index 58a3b1b..a6b190f 100644
--- a/test-tool/test_sanitize_overwrite_reserved.c
+++ b/test-tool/test_sanitize_overwrite_reserved.c
@@ -30,59 +30,59 @@ static int change_num;
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu)
{
- switch (change_num) {
- case 1:
- /* Set reserved bit 0x40 in byte 1 of the CDB */
- pdu->outdata.data[33] |= 0x40;
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- /* Set reserved byte in the CDB */
- pdu->outdata.data[32 + change_num] = change_num;
- break;
- }
+ switch (change_num) {
+ case 1:
+ /* Set reserved bit 0x40 in byte 1 of the CDB */
+ pdu->outdata.data[33] |= 0x40;
+ break;
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ /* Set reserved byte in the CDB */
+ pdu->outdata.data[32 + change_num] = change_num;
+ break;
+ }
- change_num = 0;
- return 0;
+ change_num = 0;
+ return 0;
}
void test_sanitize_overwrite_reserved(void)
{
- int i;
- struct iscsi_data data;
+ int i;
+ struct iscsi_data data;
- data.size = block_size + 4;
- data.data = alloca(data.size);
- memset(&data.data[4], 0xaa, block_size);
+ data.size = block_size + 4;
+ data.data = alloca(data.size);
+ memset(&data.data[4], 0xaa, block_size);
- data.data[0] = 0x01;
- data.data[1] = 0x00;
- data.data[2] = block_size >> 8;
- data.data[3] = block_size & 0xff;
+ data.data[0] = 0x01;
+ data.data[1] = 0x00;
+ data.data[2] = block_size >> 8;
+ data.data[3] = block_size & 0xff;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE Reserved bits/bytes");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE Reserved bits/bytes");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- local_iscsi_queue_pdu = my_iscsi_queue_pdu;
+ local_iscsi_queue_pdu = my_iscsi_queue_pdu;
- logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
- "bit in byte 1 set to 1");
- change_num = 1;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
+ "bit in byte 1 set to 1");
+ change_num = 1;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_INVALID_FIELD_IN_CDB);
- for (i = 2; i < 7; i++) {
- logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
- "byte %d set to non-zero", i);
- change_num = i;
+ for (i = 2; i < 7; i++) {
+ logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
+ "byte %d set to non-zero", i);
+ change_num = i;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
}
diff --git a/test-tool/test_sanitize_readonly.c b/test-tool/test_sanitize_readonly.c
index 21183b8..390c69d 100644
--- a/test-tool/test_sanitize_readonly.c
+++ b/test-tool/test_sanitize_readonly.c
@@ -31,103 +31,103 @@
void
test_sanitize_readonly(void)
{
- int ret;
- struct iscsi_data data;
- struct scsi_command_descriptor *cd;
- struct scsi_device *sd2;
+ int ret;
+ struct iscsi_data data;
+ struct scsi_command_descriptor *cd;
+ struct scsi_device *sd2;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE with READONLY devices");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE with READONLY devices");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This SANITIZE test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This SANITIZE test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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, "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);
- CU_ASSERT_EQUAL(ret, 0);
- if (ret != 0) {
- return;
- }
+ logging(LOG_VERBOSE, "Set Software Write Protect on the second connection");
+ ret = set_swp(sd2);
+ CU_ASSERT_EQUAL(ret, 0);
+ if (ret != 0) {
+ return;
+ }
- logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on "
- "first connection");
- while (testunitready_clear_ua(sd)) {
- sleep(1);
- }
+ logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on "
+ "first connection");
+ while (testunitready_clear_ua(sd)) {
+ sleep(1);
+ }
- logging(LOG_VERBOSE, "Check if SANITIZE OVERWRITE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_OVERWRITE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- } else {
- logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with "
- "initialization pattern of one full block");
- data.size = block_size + 4;
- data.data = alloca(data.size);
- memset(&data.data[4], 0xaa, block_size);
+ logging(LOG_VERBOSE, "Check if SANITIZE OVERWRITE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_OVERWRITE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ } else {
+ logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with "
+ "initialization pattern of one full block");
+ data.size = block_size + 4;
+ data.data = alloca(data.size);
+ memset(&data.data[4], 0xaa, block_size);
- data.data[0] = 0x01;
- data.data[1] = 0x00;
- data.data[2] = block_size >> 8;
- data.data[3] = block_size & 0xff;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ data.data[0] = 0x01;
+ data.data[1] = 0x00;
+ data.data[2] = block_size >> 8;
+ data.data[3] = block_size & 0xff;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_WRITE_PROTECTED);
- }
+ }
- logging(LOG_VERBOSE, "Check if SANITIZE BLOCK_ERASE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_BLOCK_ERASE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- } else {
- logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
+ logging(LOG_VERBOSE, "Check if SANITIZE BLOCK_ERASE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_BLOCK_ERASE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ } else {
+ logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
EXPECT_WRITE_PROTECTED);
- }
+ }
- logging(LOG_VERBOSE, "Check if SANITIZE CRYPTO_ERASE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_CRYPTO_ERASE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- } else {
- logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
+ logging(LOG_VERBOSE, "Check if SANITIZE CRYPTO_ERASE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_CRYPTO_ERASE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ } else {
+ logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
EXPECT_WRITE_PROTECTED);
- }
+ }
- logging(LOG_VERBOSE, "Clear Software Write Protect on the second connection");
- ret = clear_swp(sd2);
- CU_ASSERT_EQUAL(ret, 0);
+ 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");
- while (testunitready_clear_ua(sd)) {
- sleep(1);
- }
+ logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on "
+ "first connection");
+ while (testunitready_clear_ua(sd)) {
+ sleep(1);
+ }
- mpath_sd2_put(sd2);
+ mpath_sd2_put(sd2);
}
diff --git a/test-tool/test_sanitize_reservations.c b/test-tool/test_sanitize_reservations.c
index 711653e..13345e9 100644
--- a/test-tool/test_sanitize_reservations.c
+++ b/test-tool/test_sanitize_reservations.c
@@ -32,82 +32,82 @@ void
test_sanitize_reservations(void)
{
int ret;
- struct iscsi_data data;
- struct scsi_command_descriptor *cd;
- struct scsi_device *sd2;
+ struct iscsi_data data;
+ struct scsi_command_descriptor *cd;
+ struct scsi_device *sd2;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE with RESERVATIONS");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE with RESERVATIONS");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This SANITIZE test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This SANITIZE test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- 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, "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");
- RESERVE6(sd2);
+ logging(LOG_VERBOSE, "Take out a RESERVE6 from the second "
+ "initiator");
+ RESERVE6(sd2);
- logging(LOG_VERBOSE, "Check if SANITIZE OVERWRITE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_OVERWRITE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- } else {
- logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with "
- "initialization pattern of one full block");
- data.size = block_size + 4;
- data.data = alloca(data.size);
- memset(&data.data[4], 0xaa, block_size);
+ logging(LOG_VERBOSE, "Check if SANITIZE OVERWRITE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_OVERWRITE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ } else {
+ logging(LOG_VERBOSE, "Test SANITIZE OVERWRITE with "
+ "initialization pattern of one full block");
+ data.size = block_size + 4;
+ data.data = alloca(data.size);
+ memset(&data.data[4], 0xaa, block_size);
- data.data[0] = 0x01;
- data.data[1] = 0x00;
- data.data[2] = block_size >> 8;
- data.data[3] = block_size & 0xff;
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
+ data.data[0] = 0x01;
+ data.data[1] = 0x00;
+ data.data[2] = block_size >> 8;
+ data.data[3] = block_size & 0xff;
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
EXPECT_RESERVATION_CONFLICT);
- }
+ }
- logging(LOG_VERBOSE, "Check if SANITIZE BLOCK_ERASE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_BLOCK_ERASE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- } else {
- logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
+ logging(LOG_VERBOSE, "Check if SANITIZE BLOCK_ERASE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_BLOCK_ERASE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ } else {
+ logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
EXPECT_RESERVATION_CONFLICT);
- }
+ }
- logging(LOG_VERBOSE, "Check if SANITIZE CRYPTO_ERASE is supported "
- "in REPORT_SUPPORTED_OPCODES");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_CRYPTO_ERASE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- } else {
- logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE");
- SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
+ logging(LOG_VERBOSE, "Check if SANITIZE CRYPTO_ERASE is supported "
+ "in REPORT_SUPPORTED_OPCODES");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_CRYPTO_ERASE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ } else {
+ logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE");
+ SANITIZE(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
EXPECT_RESERVATION_CONFLICT);
- }
+ }
- mpath_sd2_put(sd2);
+ mpath_sd2_put(sd2);
}
diff --git a/test-tool/test_sanitize_reset.c b/test-tool/test_sanitize_reset.c
index 0f79bcc..c6199f3 100644
--- a/test-tool/test_sanitize_reset.c
+++ b/test-tool/test_sanitize_reset.c
@@ -35,139 +35,139 @@ static void sanitize_cb(struct iscsi_context *iscsi _U_, int status _U_,
void
test_sanitize_reset(void)
{
- int ret;
- struct scsi_command_descriptor *cd;
- struct scsi_task *sanitize_task;
- struct scsi_task *rl_task;
- struct iscsi_data data;
+ int ret;
+ struct scsi_command_descriptor *cd;
+ struct scsi_task *sanitize_task;
+ struct scsi_task *rl_task;
+ struct iscsi_data data;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test SANITIZE with Task/Lun/Target/Session reset");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test SANITIZE with Task/Lun/Target/Session reset");
- CHECK_FOR_SANITIZE;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SANITIZE;
+ CHECK_FOR_DATALOSS;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This SANITIZE test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This SANITIZE test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- logging(LOG_VERBOSE, "Check that SANITIZE OVERWRITE will continue "
- "even after Task/Lun/Target/* reset.");
- cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
- SCSI_SANITIZE_OVERWRITE);
- if (cd == NULL) {
- logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
- "implemented according to REPORT_SUPPORTED_OPCODES.");
- CU_PASS("SANITIZE is not implemented.");
- return;
- }
+ logging(LOG_VERBOSE, "Check that SANITIZE OVERWRITE will continue "
+ "even after Task/Lun/Target/* reset.");
+ cd = get_command_descriptor(SCSI_OPCODE_SANITIZE,
+ SCSI_SANITIZE_OVERWRITE);
+ if (cd == NULL) {
+ logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
+ "implemented according to REPORT_SUPPORTED_OPCODES.");
+ CU_PASS("SANITIZE is not implemented.");
+ return;
+ }
- logging(LOG_VERBOSE, "Send an asyncronous SANITIZE to the target.");
- data.size = block_size + 4;
- data.data = alloca(data.size);
- memset(&data.data[4], 0, block_size);
+ logging(LOG_VERBOSE, "Send an asyncronous SANITIZE to the target.");
+ data.size = block_size + 4;
+ data.data = alloca(data.size);
+ memset(&data.data[4], 0, block_size);
- data.data[0] = 0x01;
- data.data[1] = 0x00;
- data.data[2] = block_size >> 8;
- data.data[3] = block_size & 0xff;
- sanitize_task = iscsi_sanitize_task(sd->iscsi_ctx, sd->iscsi_lun,
- 0, 0, SCSI_SANITIZE_OVERWRITE,
- data.size, &data,
- sanitize_cb, NULL);
- CU_ASSERT_NOT_EQUAL(sanitize_task, NULL);
- /* just send something so that we know the sanitize command is sent
- * to the target
- */
- rl_task = iscsi_reportluns_sync(sd->iscsi_ctx, 0, 64);
- if (rl_task) {
- scsi_free_scsi_task(rl_task);
- }
+ data.data[0] = 0x01;
+ data.data[1] = 0x00;
+ data.data[2] = block_size >> 8;
+ data.data[3] = block_size & 0xff;
+ sanitize_task = iscsi_sanitize_task(sd->iscsi_ctx, sd->iscsi_lun,
+ 0, 0, SCSI_SANITIZE_OVERWRITE,
+ data.size, &data,
+ sanitize_cb, NULL);
+ CU_ASSERT_NOT_EQUAL(sanitize_task, NULL);
+ /* just send something so that we know the sanitize command is sent
+ * to the target
+ */
+ rl_task = iscsi_reportluns_sync(sd->iscsi_ctx, 0, 64);
+ if (rl_task) {
+ scsi_free_scsi_task(rl_task);
+ }
- logging(LOG_VERBOSE, "Sleep for three seconds incase the target is "
- "slow to start the SANITIZE");
- sleep(3);
+ logging(LOG_VERBOSE, "Sleep for three seconds incase the target is "
+ "slow to start the SANITIZE");
+ sleep(3);
- logging(LOG_VERBOSE, "Verify that the SANITIZE has started and that "
- "TESTUNITREADY fails with SANITIZE_IN_PROGRESS");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify that the SANITIZE has started and that "
+ "TESTUNITREADY fails with SANITIZE_IN_PROGRESS");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Verify that STARTSTOPUNIT fails with "
- "SANITIZE_IN_PROGRESS");
- STARTSTOPUNIT(sd, 1, 0, 1, 0, 1, 0,
+ logging(LOG_VERBOSE, "Verify that STARTSTOPUNIT fails with "
+ "SANITIZE_IN_PROGRESS");
+ STARTSTOPUNIT(sd, 1, 0, 1, 0, 1, 0,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Verify that READ16 fails with "
- "SANITIZE_IN_PROGRESS");
- READ16(sd, NULL, 0, block_size,
+ logging(LOG_VERBOSE, "Verify that READ16 fails with "
+ "SANITIZE_IN_PROGRESS");
+ READ16(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Verify that INQUIRY is still allowed while "
- "SANITIZE is in progress");
- ret = inquiry(sd, NULL, 0, 0, 255,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
+ logging(LOG_VERBOSE, "Verify that INQUIRY is still allowed while "
+ "SANITIZE is in progress");
+ ret = inquiry(sd, NULL, 0, 0, 255,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Send an ABORT TASK");
- ret = iscsi_task_mgmt_abort_task_sync(sd->iscsi_ctx, sanitize_task);
- if (ret != 0) {
- logging(LOG_NORMAL, "ABORT TASK failed. %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
+ logging(LOG_VERBOSE, "Send an ABORT TASK");
+ ret = iscsi_task_mgmt_abort_task_sync(sd->iscsi_ctx, sanitize_task);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "ABORT TASK failed. %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
- logging(LOG_VERBOSE, "Send an ABORT TASK SET");
- ret = iscsi_task_mgmt_abort_task_set_sync(sd->iscsi_ctx, sd->iscsi_lun);
- if (ret != 0) {
- logging(LOG_NORMAL, "ABORT TASK SET failed. %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
+ logging(LOG_VERBOSE, "Send an ABORT TASK SET");
+ ret = iscsi_task_mgmt_abort_task_set_sync(sd->iscsi_ctx, sd->iscsi_lun);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "ABORT TASK SET failed. %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
- logging(LOG_VERBOSE, "Send a LUN Reset");
- ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
- if (ret != 0) {
- logging(LOG_NORMAL, "LUN reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
- }
+ logging(LOG_VERBOSE, "Send a LUN Reset");
+ ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "LUN reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
+ }
- logging(LOG_VERBOSE, "Send a Warm Reset");
- ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
- if (ret != 0) {
- logging(LOG_NORMAL, "Warm reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
- }
+ logging(LOG_VERBOSE, "Send a Warm Reset");
+ ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "Warm reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
+ }
- logging(LOG_VERBOSE, "Send a Cold Reset");
- ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
- if (ret != 0) {
- logging(LOG_NORMAL, "Cold reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
- }
+ logging(LOG_VERBOSE, "Send a Cold Reset");
+ ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "Cold reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
+ }
- logging(LOG_VERBOSE, "Disconnect from the target.");
- iscsi_destroy_context(sd->iscsi_ctx);
+ logging(LOG_VERBOSE, "Disconnect from the target.");
+ iscsi_destroy_context(sd->iscsi_ctx);
- logging(LOG_VERBOSE, "Sleep for one seconds incase the target is "
- "slow to reset");
- sleep(1);
+ logging(LOG_VERBOSE, "Sleep for one seconds incase the target is "
+ "slow to reset");
+ sleep(1);
- logging(LOG_VERBOSE, "Reconnect to target");
- sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
- if (sd->iscsi_ctx == NULL) {
- logging(LOG_VERBOSE, "Failed to login to target");
- return;
- }
+ logging(LOG_VERBOSE, "Reconnect to target");
+ sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
+ if (sd->iscsi_ctx == NULL) {
+ logging(LOG_VERBOSE, "Failed to login to target");
+ return;
+ }
- logging(LOG_VERBOSE, "Verify that the SANITIZE is still going.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify that the SANITIZE is still going.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Wait until the SANITIZE operation has finished");
- while (testunitready_clear_ua(sd)) {
- sleep(60);
- }
+ logging(LOG_VERBOSE, "Wait until the SANITIZE operation has finished");
+ while (testunitready_clear_ua(sd)) {
+ sleep(60);
+ }
}
diff --git a/test-tool/test_startstopunit_noloej.c b/test-tool/test_startstopunit_noloej.c
index b128ed2..48b6d00 100644
--- a/test-tool/test_startstopunit_noloej.c
+++ b/test-tool/test_startstopunit_noloej.c
@@ -29,79 +29,79 @@
void
test_startstopunit_noloej(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test STARTSTOPUNIT LOEJ==0");
- if (!inq->rmb) {
- logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. "
- "Skipping test.");
- return;
- }
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test STARTSTOPUNIT LOEJ==0");
+ if (!inq->rmb) {
+ logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. "
+ "Skipping test.");
+ return;
+ }
- logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==0");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 0, 0,
+ logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==0");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==1");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 0, 1,
+ logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==1");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 0, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==0");
- STARTSTOPUNIT(sd, 1, 0, 0, 0, 0, 0,
+ logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==0");
+ STARTSTOPUNIT(sd, 1, 0, 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==1");
- STARTSTOPUNIT(sd, 1, 0, 0, 0, 0, 1,
+ logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==1");
+ STARTSTOPUNIT(sd, 1, 0, 0, 0, 0, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==0");
- STARTSTOPUNIT(sd, 0, 0, 0, 1, 0, 0,
+ logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==0");
+ STARTSTOPUNIT(sd, 0, 0, 0, 1, 0, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==1");
- STARTSTOPUNIT(sd, 0, 0, 0, 1, 0, 1,
+ logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==1");
+ STARTSTOPUNIT(sd, 0, 0, 0, 1, 0, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==0");
- STARTSTOPUNIT(sd, 1, 0, 0, 1, 0, 0,
+ logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==0");
+ STARTSTOPUNIT(sd, 1, 0, 0, 1, 0, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==1");
- STARTSTOPUNIT(sd, 1, 0, 0, 1, 0, 1,
+ logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==1");
+ STARTSTOPUNIT(sd, 1, 0, 0, 1, 0, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "In case the target did eject the medium, load it again.");
- STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
- EXPECT_STATUS_GOOD);
+ logging(LOG_VERBOSE, "In case the target did eject the medium, load it again.");
+ STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
+ EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_startstopunit_pwrcnd.c b/test-tool/test_startstopunit_pwrcnd.c
index 0fac705..be72c71 100644
--- a/test-tool/test_startstopunit_pwrcnd.c
+++ b/test-tool/test_startstopunit_pwrcnd.c
@@ -29,27 +29,27 @@
void
test_startstopunit_pwrcnd(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test STARTSTOPUNIT PowerCondition");
- if (!inq->rmb) {
- logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. "
- "Skipping test.");
- return;
- }
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test STARTSTOPUNIT PowerCondition");
+ if (!inq->rmb) {
+ logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. "
+ "Skipping test.");
+ return;
+ }
- logging(LOG_VERBOSE, "Test that media is not ejected when PC!=0");
- for (i = 1; i < 16; i++) {
- STARTSTOPUNIT(sd, 1, 0, i, 0, 1, 0,
+ logging(LOG_VERBOSE, "Test that media is not ejected when PC!=0");
+ for (i = 1; i < 16; i++) {
+ STARTSTOPUNIT(sd, 1, 0, i, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- }
+ }
- logging(LOG_VERBOSE, "In case the target did eject the medium, load it again.");
- STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
- EXPECT_STATUS_GOOD);
+ logging(LOG_VERBOSE, "In case the target did eject the medium, load it again.");
+ STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
+ EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_startstopunit_simple.c b/test-tool/test_startstopunit_simple.c
index f97d047..66cbd7f 100644
--- a/test-tool/test_startstopunit_simple.c
+++ b/test-tool/test_startstopunit_simple.c
@@ -29,54 +29,54 @@
void
test_startstopunit_simple(void)
{
- int ret;
+ int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test basic STARTSTOPUNIT");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test basic STARTSTOPUNIT");
- logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1");
- if (inq->rmb) {
- logging(LOG_VERBOSE, "Media is removable. STARTSTOPUNIT should work");
- } else {
- logging(LOG_VERBOSE, "Media is not removable. STARTSTOPUNIT should fail");
- }
+ logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1");
+ if (inq->rmb) {
+ logging(LOG_VERBOSE, "Media is removable. STARTSTOPUNIT should work");
+ } else {
+ logging(LOG_VERBOSE, "Media is not removable. STARTSTOPUNIT should fail");
+ }
- ret = startstopunit(sd, 1, 0, 0, 0, 1, 0,
- EXPECT_STATUS_GOOD);
- if (!inq->rmb) {
- CU_ASSERT_NOT_EQUAL(ret, 0);
- return;
- }
- CU_ASSERT_EQUAL(ret, 0);
+ ret = startstopunit(sd, 1, 0, 0, 0, 1, 0,
+ EXPECT_STATUS_GOOD);
+ if (!inq->rmb) {
+ CU_ASSERT_NOT_EQUAL(ret, 0);
+ return;
+ }
+ CU_ASSERT_EQUAL(ret, 0);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is ejected.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
- logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1");
- STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1");
+ STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we can read from the media.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can read from the media.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
- logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
+ logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is ejected.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is ejected.");
+ TESTUNITREADY(sd,
EXPECT_NO_MEDIUM);
- logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1");
- STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
+ logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1");
+ STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify we can access the media again.");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, "Verify we can access the media again.");
+ TESTUNITREADY(sd,
EXPECT_SANITIZE);
}
diff --git a/test-tool/test_testunitready_simple.c b/test-tool/test_testunitready_simple.c
index 9b46fb4..d9c0385 100644
--- a/test-tool/test_testunitready_simple.c
+++ b/test-tool/test_testunitready_simple.c
@@ -27,8 +27,8 @@
void
test_testunitready_simple(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test TESTUNITREADY");
- TESTUNITREADY(sd,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test TESTUNITREADY");
+ TESTUNITREADY(sd,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_unmap_0blocks.c b/test-tool/test_unmap_0blocks.c
index b726fa3..2f85cfd 100644
--- a/test-tool/test_unmap_0blocks.c
+++ b/test-tool/test_unmap_0blocks.c
@@ -29,50 +29,50 @@
void
test_unmap_0blocks(void)
{
- int i;
- struct unmap_list list[257];
+ int i;
+ struct unmap_list list[257];
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 as a single descriptor");
- for (i = 0; i < 256; i++) {
- list[0].lba = i;
- list[0].num = 0;
- UNMAP(sd, 0, list, 1,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 as a single descriptor");
+ for (i = 0; i < 256; i++) {
+ list[0].lba = i;
+ list[0].num = 0;
+ UNMAP(sd, 0, list, 1,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at end-of-LUN");
- list[0].lba = num_blocks;
- list[0].num = 0;
- UNMAP(sd, 0, list, 1,
+ logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at end-of-LUN");
+ list[0].lba = num_blocks;
+ list[0].num = 0;
+ UNMAP(sd, 0, list, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test UNMAP without any descriptors.");
- UNMAP(sd, 0, list, 0,
+ logging(LOG_VERBOSE, "Test UNMAP without any descriptors.");
+ UNMAP(sd, 0, list, 0,
EXPECT_STATUS_GOOD);
- if (inq_bl->max_unmap_bdc <= 1) {
- CU_PASS("[SKIPPING] Test UNMAP of 0 blocks with multiple descriptos not supported");
- return;
- }
+ if (inq_bl->max_unmap_bdc <= 1) {
+ CU_PASS("[SKIPPING] Test UNMAP of 0 blocks with multiple descriptos not supported");
+ return;
+ }
- logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 with one descriptor per block");
- for (i = 0; i < 256; i++) {
- list[i].lba = i;
- list[i].num = 0;
- UNMAP(sd, 0, list, i + 1,
+ logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 with one descriptor per block");
+ for (i = 0; i < 256; i++) {
+ list[i].lba = i;
+ list[i].num = 0;
+ UNMAP(sd, 0, list, i + 1,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 with one descriptor per block, possibly \"overlapping\".");
- for (i = 0; i < 256; i++) {
- list[i].lba = i/2;
- list[i].num = 0;
- }
- UNMAP(sd, 0, list, 256,
+ logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 with one descriptor per block, possibly \"overlapping\".");
+ for (i = 0; i < 256; i++) {
+ list[i].lba = i/2;
+ list[i].num = 0;
+ }
+ UNMAP(sd, 0, list, 256,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_unmap_simple.c b/test-tool/test_unmap_simple.c
index 21c1eab..b751f95 100644
--- a/test-tool/test_unmap_simple.c
+++ b/test-tool/test_unmap_simple.c
@@ -29,86 +29,86 @@
void
test_unmap_simple(void)
{
- int i, ret;
- struct unmap_list list[257];
+ int i, ret;
+ struct unmap_list list[257];
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test basic UNMAP");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test basic UNMAP");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the "
- "LUN as a single descriptor");
+ logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the "
+ "LUN as a single descriptor");
- logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
- memset(scratch, 'a', 256 * block_size);
- WRITE10(sd, 0, 256 * block_size,
+ logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
+ memset(scratch, 'a', 256 * block_size);
+ WRITE10(sd, 0, 256 * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- for (i = 1; i <= 256; i++) {
- logging(LOG_VERBOSE, "UNMAP blocks 0-%d", i);
- list[0].lba = 0;
- list[0].num = i;
- UNMAP(sd, 0, list, 1,
+ for (i = 1; i <= 256; i++) {
+ logging(LOG_VERBOSE, "UNMAP blocks 0-%d", i);
+ list[0].lba = 0;
+ list[0].num = i;
+ UNMAP(sd, 0, list, 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read blocks 0-%d", i);
- READ10(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, "Read blocks 0-%d", i);
+ READ10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16 && rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
- "should read back as 0");
- if (all_zeroes(scratch, i * block_size) == 0) {
- logging(LOG_NORMAL, "[FAILED] Blocks did not "
- "read back as zero");
- CU_FAIL("[FAILED] Blocks did not read back "
- "as zero");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
- "back as zero");
- }
- }
- }
+ if (rc16 && rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
+ "should read back as 0");
+ if (all_zeroes(scratch, i * block_size) == 0) {
+ logging(LOG_NORMAL, "[FAILED] Blocks did not "
+ "read back as zero");
+ CU_FAIL("[FAILED] Blocks did not read back "
+ "as zero");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
+ "back as zero");
+ }
+ }
+ }
- logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the "
- "LUN with one descriptor per block");
+ logging(LOG_VERBOSE, "Test UNMAP of 1-256 blocks at the start of the "
+ "LUN with one descriptor per block");
- logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
- memset(scratch, 'a', 256 * block_size);
- WRITE10(sd, 0, 256 * block_size,
+ logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
+ memset(scratch, 'a', 256 * block_size);
+ WRITE10(sd, 0, 256 * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
- for (i = 0; i < 256; i++) {
- list[i].lba = i;
- list[i].num = 1;
- UNMAP(sd, 0, list, i + 1,
+ CU_ASSERT_EQUAL(ret, 0);
+ for (i = 0; i < 256; i++) {
+ list[i].lba = i;
+ list[i].num = 1;
+ UNMAP(sd, 0, list, i + 1,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read blocks 0-%d", i);
- READ10(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, "Read blocks 0-%d", i);
+ READ10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16 && rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
- "should read back as 0");
- if (all_zeroes(scratch, i * block_size) == 0) {
- logging(LOG_NORMAL, "[FAILED] Blocks did not "
- "read back as zero");
- CU_FAIL("[FAILED] Blocks did not read back "
- "as zero");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
- "back as zero");
- }
- }
- }
+ if (rc16 && rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ==1 All UNMAPPED blocks "
+ "should read back as 0");
+ if (all_zeroes(scratch, i * block_size) == 0) {
+ logging(LOG_NORMAL, "[FAILED] Blocks did not "
+ "read back as zero");
+ CU_FAIL("[FAILED] Blocks did not read back "
+ "as zero");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] Blocks read "
+ "back as zero");
+ }
+ }
+ }
}
diff --git a/test-tool/test_unmap_vpd.c b/test-tool/test_unmap_vpd.c
index d41910c..606601f 100644
--- a/test-tool/test_unmap_vpd.c
+++ b/test-tool/test_unmap_vpd.c
@@ -29,52 +29,52 @@
void
test_unmap_vpd(void)
{
- int ret;
- struct unmap_list list[1];
+ int ret;
+ struct unmap_list list[1];
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test UNMAP availability is consistent with VPD settings");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test UNMAP availability is consistent with VPD settings");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Check if UNMAP is available.");
- list[0].lba = 0;
- list[0].num = 0;
- ret = unmap(sd, 0, list, 1,
- EXPECT_STATUS_GOOD);
- if (ret != 0) {
- logging(LOG_VERBOSE, "UNMAP is not available. Verify that VPD "
- "settings reflect this.");
+ logging(LOG_VERBOSE, "Check if UNMAP is available.");
+ list[0].lba = 0;
+ list[0].num = 0;
+ ret = unmap(sd, 0, list, 1,
+ EXPECT_STATUS_GOOD);
+ if (ret != 0) {
+ logging(LOG_VERBOSE, "UNMAP is not available. Verify that VPD "
+ "settings reflect this.");
- logging(LOG_VERBOSE, "Verify that LBPU is clear.");
- if (inq_lbp && inq_lbp->lbpu) {
- logging(LOG_NORMAL, "[FAILED] UNMAP is not implemented "
- "but LBPU is set");
- CU_FAIL("[FAILED] UNMAP is unavailable but LBPU==1");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] LBPU is clear.");
- }
- } else {
- logging(LOG_VERBOSE, "UNMAP is available. Verify that VPD "
- "settings reflect this.");
+ logging(LOG_VERBOSE, "Verify that LBPU is clear.");
+ if (inq_lbp && inq_lbp->lbpu) {
+ logging(LOG_NORMAL, "[FAILED] UNMAP is not implemented "
+ "but LBPU is set");
+ CU_FAIL("[FAILED] UNMAP is unavailable but LBPU==1");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPU is clear.");
+ }
+ } else {
+ logging(LOG_VERBOSE, "UNMAP is available. Verify that VPD "
+ "settings reflect this.");
- logging(LOG_VERBOSE, "Verify that LBPME is set.");
- if (rc16 && rc16->lbpme) {
- logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
- } else {
- logging(LOG_NORMAL, "[FAILED] UNMAP is implemented "
- "but LBPME is not set");
- CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
- }
+ logging(LOG_VERBOSE, "Verify that LBPME is set.");
+ if (rc16 && rc16->lbpme) {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] UNMAP is implemented "
+ "but LBPME is not set");
+ CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
+ }
- logging(LOG_VERBOSE, "Verify that LBPU is set.");
- if (inq_lbp && inq_lbp->lbpu) {
- logging(LOG_VERBOSE, "[SUCCESS] LBPU is set.");
- } else {
- logging(LOG_NORMAL, "[FAILED] UNMAP is implemented "
- "but LBPU is not set");
- CU_FAIL("[FAILED] UNMAP is available but LBPU==0");
- }
- }
+ logging(LOG_VERBOSE, "Verify that LBPU is set.");
+ if (inq_lbp && inq_lbp->lbpu) {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPU is set.");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] UNMAP is implemented "
+ "but LBPU is not set");
+ CU_FAIL("[FAILED] UNMAP is available but LBPU==0");
+ }
+ }
}
diff --git a/test-tool/test_verify10_0blocks.c b/test-tool/test_verify10_0blocks.c
index cfdf24b..49b6220 100644
--- a/test-tool/test_verify10_0blocks.c
+++ b/test-tool/test_verify10_0blocks.c
@@ -27,18 +27,18 @@
void
test_verify10_0blocks(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==0");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==0");
- logging(LOG_VERBOSE, "Test VERIFY10 0-blocks one block past end-of-LUN");
- VERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY10 0-blocks one block past end-of-LUN");
+ VERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==2^31");
- VERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==2^31");
+ VERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==-1");
- VERIFY10(sd, -1, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY10 0-blocks at LBA==-1");
+ VERIFY10(sd, -1, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_verify10_beyond_eol.c b/test-tool/test_verify10_beyond_eol.c
index ea3b418..cf9e562 100644
--- a/test-tool/test_verify10_beyond_eol.c
+++ b/test-tool/test_verify10_beyond_eol.c
@@ -29,52 +29,52 @@
void
test_verify10_beyond_eol(void)
{
- int i;
+ int i;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with VERIFY10. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with VERIFY10. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY10(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY10(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY10(sd, 0x80000000,
+ logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY10(sd, 0x80000000,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY10(sd, -1, i * block_size, block_size, 0, 0, 1, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY10 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY10(sd, -1, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY10 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY10(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test VERIFY10 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY10(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_verify10_dpo.c b/test-tool/test_verify10_dpo.c
index 3ac3308..29582e8 100644
--- a/test-tool/test_verify10_dpo.c
+++ b/test-tool/test_verify10_dpo.c
@@ -29,68 +29,68 @@
void
test_verify10_dpo(void)
{
- int dpofua, usage_data_dpo;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpo;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY10 DPO flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY10 DPO flag");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test VERIFY10 with DPO==1");
- if (dpofua) {
- VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY10 with DPO==1");
+ if (dpofua) {
+ VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, scratch,
+ } else {
+ VERIFY10(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for VERIFY10");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for VERIFY10");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_VERIFY10,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
- "is set in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
- } else {
- logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
- "flag is clear in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
- }
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
+ "is set in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
+ "flag is clear in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_verify10_flags.c b/test-tool/test_verify10_flags.c
index dd17521..71a36d9 100644
--- a/test-tool/test_verify10_flags.c
+++ b/test-tool/test_verify10_flags.c
@@ -29,13 +29,13 @@
void
test_verify10_flags(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY10 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY10 flags");
- READ10(sd, NULL, 0, block_size,
- block_size, 0, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test VERIFY10 with BYTCHK==1");
- VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, scratch,
+ READ10(sd, NULL, 0, block_size,
+ block_size, 0, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Test VERIFY10 with BYTCHK==1");
+ VERIFY10(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_verify10_mismatch.c b/test-tool/test_verify10_mismatch.c
index ccecc20..6aabf04 100644
--- a/test-tool/test_verify10_mismatch.c
+++ b/test-tool/test_verify10_mismatch.c
@@ -30,45 +30,45 @@
void
test_verify10_mismatch(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY10 for blocks 1-255");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY10 for blocks 1-255");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, 0, i * block_size,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
+ VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, num_blocks - i,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY10(sd, num_blocks - i,
+ VERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
- }
+ }
}
diff --git a/test-tool/test_verify10_mismatch_no_cmp.c b/test-tool/test_verify10_mismatch_no_cmp.c
index 5f2a77f..646b87d 100644
--- a/test-tool/test_verify10_mismatch_no_cmp.c
+++ b/test-tool/test_verify10_mismatch_no_cmp.c
@@ -30,45 +30,45 @@
void
test_verify10_mismatch_no_cmp(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY10 without BYTCHK for blocks 1-255");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY10 without BYTCHK for blocks 1-255");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, 0, i * block_size,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
+ VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY10 without BYTCHK of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, "Test VERIFY10 without BYTCHK of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, num_blocks - i,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY10(sd, num_blocks - i,
+ VERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_verify10_simple.c b/test-tool/test_verify10_simple.c
index 5b1a4dc..049684d 100644
--- a/test-tool/test_verify10_simple.c
+++ b/test-tool/test_verify10_simple.c
@@ -30,31 +30,31 @@
void
test_verify10_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
+ VERIFY10(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ10(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Test VERIFY10 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ10(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- VERIFY10(sd, num_blocks - i,
+ VERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_verify10_vrprotect.c b/test-tool/test_verify10_vrprotect.c
index f5294b0..bed61fe 100644
--- a/test-tool/test_verify10_vrprotect.c
+++ b/test-tool/test_verify10_vrprotect.c
@@ -30,25 +30,25 @@
void
test_verify10_vrprotect(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY10 with non-zero VRPROTECT");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY10 with non-zero VRPROTECT");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- READ10(sd, NULL, 0, block_size,
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ READ10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- VERIFY10(sd, 0, block_size,
+ VERIFY10(sd, 0, block_size,
block_size, i, 0, 1, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_verify12_0blocks.c b/test-tool/test_verify12_0blocks.c
index c196f71..a5bd481 100644
--- a/test-tool/test_verify12_0blocks.c
+++ b/test-tool/test_verify12_0blocks.c
@@ -27,18 +27,18 @@
void
test_verify12_0blocks(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==0");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==0");
- logging(LOG_VERBOSE, "Test VERIFY12 0-blocks one block past end-of-LUN");
- VERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY12 0-blocks one block past end-of-LUN");
+ VERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==2^31");
- VERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==2^31");
+ VERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==-1");
- VERIFY12(sd, -1, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY12 0-blocks at LBA==-1");
+ VERIFY12(sd, -1, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_verify12_beyond_eol.c b/test-tool/test_verify12_beyond_eol.c
index b08379e..9692c26 100644
--- a/test-tool/test_verify12_beyond_eol.c
+++ b/test-tool/test_verify12_beyond_eol.c
@@ -29,52 +29,52 @@
void
test_verify12_beyond_eol(void)
{
- int i;
+ int i;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with VERIFY12. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with VERIFY12. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY12(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY12(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY12(sd, 0x80000000,
+ logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY12(sd, 0x80000000,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY12(sd, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test VERIFY12 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY12(sd, -1, i * block_size,
block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY12 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY12(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test VERIFY12 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY12(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_verify12_dpo.c b/test-tool/test_verify12_dpo.c
index 6f0fafd..d63cb89 100644
--- a/test-tool/test_verify12_dpo.c
+++ b/test-tool/test_verify12_dpo.c
@@ -29,68 +29,68 @@
void
test_verify12_dpo(void)
{
- int dpofua, usage_data_dpo;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpo;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY12 DPO flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY12 DPO flag");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test VERIFY12 with DPO==1");
- if (dpofua) {
- VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY12 with DPO==1");
+ if (dpofua) {
+ VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, scratch,
+ } else {
+ VERIFY12(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for VERIFY12");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for VERIFY12");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_VERIFY12,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
- "is set in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
- } else {
- logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
- "flag is clear in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
- }
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
+ "is set in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
+ "flag is clear in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_verify12_flags.c b/test-tool/test_verify12_flags.c
index 170bb89..35a8ded 100644
--- a/test-tool/test_verify12_flags.c
+++ b/test-tool/test_verify12_flags.c
@@ -30,13 +30,13 @@
void
test_verify12_flags(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY12 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY12 flags");
- READ12(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ READ12(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test VERIFY12 with BYTCHK==1");
- VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY12 with BYTCHK==1");
+ VERIFY12(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_verify12_mismatch.c b/test-tool/test_verify12_mismatch.c
index 2b92bf9..d83030f 100644
--- a/test-tool/test_verify12_mismatch.c
+++ b/test-tool/test_verify12_mismatch.c
@@ -30,45 +30,45 @@
void
test_verify12_mismatch(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY12 for blocks 1-255");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY12 for blocks 1-255");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, 0, i * block_size,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
+ VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, num_blocks - i,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY12(sd, num_blocks - i,
+ VERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
- }
+ }
}
diff --git a/test-tool/test_verify12_mismatch_no_cmp.c b/test-tool/test_verify12_mismatch_no_cmp.c
index d0b9935..67198f3 100644
--- a/test-tool/test_verify12_mismatch_no_cmp.c
+++ b/test-tool/test_verify12_mismatch_no_cmp.c
@@ -30,45 +30,45 @@
void
test_verify12_mismatch_no_cmp(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY12 without BYTCHK for blocks 1-255");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY12 without BYTCHK for blocks 1-255");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, 0, i * block_size,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
+ VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY12 without BYTCHK of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, "Test VERIFY12 without BYTCHK of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, num_blocks - i,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY12(sd, num_blocks - i,
+ VERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_verify12_simple.c b/test-tool/test_verify12_simple.c
index 3aae55f..7d2cc8d 100644
--- a/test-tool/test_verify12_simple.c
+++ b/test-tool/test_verify12_simple.c
@@ -30,31 +30,31 @@
void
test_verify12_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
+ VERIFY12(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ12(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Test VERIFY12 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ12(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- VERIFY12(sd, num_blocks - i,
+ VERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_verify12_vrprotect.c b/test-tool/test_verify12_vrprotect.c
index eedcbab..a34557a 100644
--- a/test-tool/test_verify12_vrprotect.c
+++ b/test-tool/test_verify12_vrprotect.c
@@ -30,25 +30,25 @@
void
test_verify12_vrprotect(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY12 with non-zero VRPROTECT");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY12 with non-zero VRPROTECT");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- READ10(sd, NULL, 0, block_size,
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ READ10(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
VERIFY12(sd, 0, block_size,
block_size, i, 0, 1, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_verify16_0blocks.c b/test-tool/test_verify16_0blocks.c
index aa056d6..61a650f 100644
--- a/test-tool/test_verify16_0blocks.c
+++ b/test-tool/test_verify16_0blocks.c
@@ -27,18 +27,18 @@
void
test_verify16_0blocks(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==0");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==0");
- logging(LOG_VERBOSE, "Test VERIFY16 0-blocks one block past end-of-LUN");
- VERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY16 0-blocks one block past end-of-LUN");
+ VERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==2^63");
- VERIFY16(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==2^63");
+ VERIFY16(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==-1");
- VERIFY16(sd, -1, 0, block_size, 0, 0, 1, NULL,
+ logging(LOG_VERBOSE, "Test VERIFY16 0-blocks at LBA==-1");
+ VERIFY16(sd, -1, 0, block_size, 0, 0, 1, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_verify16_beyond_eol.c b/test-tool/test_verify16_beyond_eol.c
index 0f49083..b0cc2b9 100644
--- a/test-tool/test_verify16_beyond_eol.c
+++ b/test-tool/test_verify16_beyond_eol.c
@@ -29,46 +29,46 @@
void
test_verify16_beyond_eol(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY16(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY16(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks at LBA==2^63");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY16(sd, 0x8000000000000000ULL,
+ logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks at LBA==2^63");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY16(sd, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY16(sd, -1, i * block_size, block_size, 0, 0, 1, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY16 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY16(sd, -1, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY16 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- VERIFY16(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test VERIFY16 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ VERIFY16(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_verify16_dpo.c b/test-tool/test_verify16_dpo.c
index aa206f9..f2bbf2b 100644
--- a/test-tool/test_verify16_dpo.c
+++ b/test-tool/test_verify16_dpo.c
@@ -29,69 +29,69 @@
void
test_verify16_dpo(void)
{
- int dpofua, usage_data_dpo;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpo;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY16 DPO flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY16 DPO flag");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test VERIFY16 with DPO==1");
- if (dpofua) {
- VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY16 with DPO==1");
+ if (dpofua) {
+ VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, scratch,
+ } else {
+ VERIFY16(sd, 0, block_size, block_size, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for VERIFY16");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for VERIFY16");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_VERIFY16,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
- "is set in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
- } else {
- logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
- "flag is clear in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
- }
+ usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
+ "is set in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
+ "flag is clear in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_verify16_flags.c b/test-tool/test_verify16_flags.c
index 851e2bb..c6b8743 100644
--- a/test-tool/test_verify16_flags.c
+++ b/test-tool/test_verify16_flags.c
@@ -30,13 +30,13 @@
void
test_verify16_flags(void)
{
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY16 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY16 flags");
- READ16(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ READ16(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test VERIFY16 with BYTCHK==1");
- VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, scratch,
+ logging(LOG_VERBOSE, "Test VERIFY16 with BYTCHK==1");
+ VERIFY16(sd, 0, block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_verify16_mismatch.c b/test-tool/test_verify16_mismatch.c
index 4f092ec..74126e4 100644
--- a/test-tool/test_verify16_mismatch.c
+++ b/test-tool/test_verify16_mismatch.c
@@ -30,45 +30,45 @@
void
test_verify16_mismatch(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY16 for blocks 1-255");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY16 for blocks 1-255");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, 0, i * block_size,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
+ VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, num_blocks - i,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY16(sd, num_blocks - i,
+ VERIFY16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_MISCOMPARE);
- }
+ }
}
diff --git a/test-tool/test_verify16_mismatch_no_cmp.c b/test-tool/test_verify16_mismatch_no_cmp.c
index 1ddcc76..edeae99 100644
--- a/test-tool/test_verify16_mismatch_no_cmp.c
+++ b/test-tool/test_verify16_mismatch_no_cmp.c
@@ -30,45 +30,45 @@
void
test_verify16_mismatch_no_cmp(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY16 without BYTCHK for blocks 1-255");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY16 without BYTCHK for blocks 1-255");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, 0, i * block_size,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
+ VERIFY16(sd, 0, i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY16 without BYTCHK of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- int offset = random() % (i * block_size);
+ logging(LOG_VERBOSE, "Test VERIFY16 without BYTCHK of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ int offset = random() % (i * block_size);
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, num_blocks - i,
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- /* flip a random byte in the data */
- scratch[offset] ^= 'X';
- logging(LOG_VERBOSE, "Flip some bits in the data");
+ /* flip a random byte in the data */
+ scratch[offset] ^= 'X';
+ logging(LOG_VERBOSE, "Flip some bits in the data");
- VERIFY16(sd, num_blocks - i,
+ VERIFY16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_verify16_simple.c b/test-tool/test_verify16_simple.c
index ed1ce4c..55edb7b 100644
--- a/test-tool/test_verify16_simple.c
+++ b/test-tool/test_verify16_simple.c
@@ -30,32 +30,32 @@
void
test_verify16_simple(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- VERIFY16(sd, 0, i * block_size,
+ VERIFY16(sd, 0, i * block_size,
block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- READ16(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Test VERIFY16 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ READ16(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- VERIFY16(sd, num_blocks - i,
+ VERIFY16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 1, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_verify16_vrprotect.c b/test-tool/test_verify16_vrprotect.c
index 1739ec4..7e8e3a8 100644
--- a/test-tool/test_verify16_vrprotect.c
+++ b/test-tool/test_verify16_vrprotect.c
@@ -30,25 +30,25 @@
void
test_verify16_vrprotect(void)
{
- int i;
+ int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test VERIFY16 with non-zero VRPROTECT");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test VERIFY16 with non-zero VRPROTECT");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- READ16(sd, NULL, 0, block_size,
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ READ16(sd, NULL, 0, block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- VERIFY16(sd, 0, block_size,
+ VERIFY16(sd, 0, block_size,
block_size, i, 0, 1, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_write10_0blocks.c b/test-tool/test_write10_0blocks.c
index 754778b..86b52f3 100644
--- a/test-tool/test_write10_0blocks.c
+++ b/test-tool/test_write10_0blocks.c
@@ -27,27 +27,27 @@
void
test_write10_0blocks(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==0");
- WRITE10(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==0");
+ WRITE10(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with WRITE10. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with WRITE10. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, "Test WRITE10 0-blocks one block past end-of-LUN");
- WRITE10(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE10 0-blocks one block past end-of-LUN");
+ WRITE10(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==2^31");
- WRITE10(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==2^31");
+ WRITE10(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==-1");
- WRITE10(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE10 0-blocks at LBA==-1");
+ WRITE10(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_write10_beyond_eol.c b/test-tool/test_write10_beyond_eol.c
index 244fa6a..b7b4467 100644
--- a/test-tool/test_write10_beyond_eol.c
+++ b/test-tool/test_write10_beyond_eol.c
@@ -29,54 +29,54 @@
void
test_write10_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for write-beyond-eol tests with WRITE10. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for write-beyond-eol tests with WRITE10. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE10(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE10(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE10(sd, 0x80000000,
+ logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE10(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE10(sd, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test WRITE10 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE10(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE10 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE10(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test WRITE10 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE10(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_write10_dpofua.c b/test-tool/test_write10_dpofua.c
index f13a207..18babd7 100644
--- a/test-tool/test_write10_dpofua.c
+++ b/test-tool/test_write10_dpofua.c
@@ -29,77 +29,77 @@
void
test_write10_dpofua(void)
{
- int dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE10 DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE10 DPO/FUA flags");
- CHECK_FOR_SBC;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test WRITE10 with DPO==1");
- memset(scratch, 0xa6, block_size);
- if (dpofua) {
- WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ if (dpofua) {
+ WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ } else {
+ WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE10 with FUA==1");
- if (dpofua) {
- WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 with FUA==1");
+ if (dpofua) {
+ WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ } else {
+ WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1");
- if (dpofua) {
- WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1");
+ if (dpofua) {
+ WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
+ } else {
+ WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for WRITE10");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for WRITE10");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_WRITE10,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -120,5 +120,5 @@ test_write10_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_write10_flags.c b/test-tool/test_write10_flags.c
index 284bdae..d8e0365 100644
--- a/test-tool/test_write10_flags.c
+++ b/test-tool/test_write10_flags.c
@@ -30,29 +30,29 @@
void
test_write10_flags(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE10 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE10 flags");
- logging(LOG_VERBOSE, "Test WRITE10 with DPO==1");
- memset(scratch, 0xa6, block_size);
- WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ WRITE10(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==0");
- WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==0");
+ WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==1");
- WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 with FUA==1 FUA_NV==1");
+ WRITE10(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE10 with FUA==0 FUA_NV==1");
- WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 with FUA==0 FUA_NV==1");
+ WRITE10(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1 FUA_NV==1");
- WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE10 with DPO==1 FUA==1 FUA_NV==1");
+ WRITE10(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_write10_residuals.c b/test-tool/test_write10_residuals.c
index fd6371a..8e3ab31 100644
--- a/test-tool/test_write10_residuals.c
+++ b/test-tool/test_write10_residuals.c
@@ -31,362 +31,362 @@
void
test_write10_residuals(void)
{
- struct scsi_task *task_ret;
- unsigned char buf[10000];
- struct iscsi_data data;
- int ok;
- unsigned int i;
+ struct scsi_task *task_ret;
+ unsigned char buf[10000];
+ struct iscsi_data data;
+ int ok;
+ unsigned int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE10 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE10 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This WRITE10 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This WRITE10 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* Try a write10 of 1 block but xferlength == 0 */
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ /* Try a write10 of 1 block but xferlength == 0 */
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
- && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
- CU_PASS("WRITE10 is not implemented.");
- return;
- }
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
+ && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
+ CU_PASS("WRITE10 is not implemented.");
+ return;
+ }
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 10000;
- memset(buf, 0xa6, sizeof(buf));
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ memset(buf, 0xa6, sizeof(buf));
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 200;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- ok = task->status == SCSI_STATUS_GOOD ||
- (task->status == SCSI_STATUS_CHECK_CONDITION &&
- task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
- task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
- if (!ok) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT(ok);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ ok = task->status == SCSI_STATUS_GOOD ||
+ (task->status == SCSI_STATUS_CHECK_CONDITION &&
+ task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
+ task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
+ if (!ok) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT(ok);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE10;
- task->cdb[8] = 2;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE10;
+ task->cdb[8] = 2;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE10(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE10(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 2 * block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 2 * block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ10(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ10(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE10(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE10(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE10;
- task->cdb[8] = 2;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE10;
+ task->cdb[8] = 2;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ10(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ10(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
}
diff --git a/test-tool/test_write10_simple.c b/test-tool/test_write10_simple.c
index d5a4dc2..b30d2b6 100644
--- a/test-tool/test_write10_simple.c
+++ b/test-tool/test_write10_simple.c
@@ -30,29 +30,29 @@
void
test_write10_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE10(sd, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the start of the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE10(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE10(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITE10 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_write10_wrprotect.c b/test-tool/test_write10_wrprotect.c
index 07a3a8a..071b189 100644
--- a/test-tool/test_write10_wrprotect.c
+++ b/test-tool/test_write10_wrprotect.c
@@ -30,27 +30,27 @@
void
test_write10_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE10 with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE10 with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0xa6, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITE10(sd, 0, block_size, block_size,
+ memset(scratch, 0xa6, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITE10(sd, 0, block_size, block_size,
i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_write12_0blocks.c b/test-tool/test_write12_0blocks.c
index 1581802..bf2ad67 100644
--- a/test-tool/test_write12_0blocks.c
+++ b/test-tool/test_write12_0blocks.c
@@ -27,27 +27,27 @@
void
test_write12_0blocks(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with WRITE12. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with WRITE12. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==0");
- WRITE12(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==0");
+ WRITE12(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE12 0-blocks one block past end-of-LUN");
- WRITE12(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE12 0-blocks one block past end-of-LUN");
+ WRITE12(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==2^31");
- WRITE12(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==2^31");
+ WRITE12(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==-1");
- WRITE12(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE12 0-blocks at LBA==-1");
+ WRITE12(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_write12_beyond_eol.c b/test-tool/test_write12_beyond_eol.c
index eeb8c24..b135730 100644
--- a/test-tool/test_write12_beyond_eol.c
+++ b/test-tool/test_write12_beyond_eol.c
@@ -29,54 +29,54 @@
void
test_write12_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for write-beyond-eol tests with WRITE12. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for write-beyond-eol tests with WRITE12. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE12(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE12(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE12(sd, 0x80000000,
+ logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE12(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE12(sd, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test WRITE12 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE12(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE12 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE12(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test WRITE12 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE12(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_write12_dpofua.c b/test-tool/test_write12_dpofua.c
index 196892f..f472d7c 100644
--- a/test-tool/test_write12_dpofua.c
+++ b/test-tool/test_write12_dpofua.c
@@ -29,77 +29,77 @@
void
test_write12_dpofua(void)
{
- int dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE12 DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE12 DPO/FUA flags");
- CHECK_FOR_SBC;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test WRITE12 with DPO==1");
- memset(scratch, 0xa6, block_size);
- if (dpofua) {
- WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ if (dpofua) {
+ WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ } else {
+ WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE12 with FUA==1");
- if (dpofua) {
- WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 with FUA==1");
+ if (dpofua) {
+ WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ } else {
+ WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1");
- if (dpofua) {
- WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1");
+ if (dpofua) {
+ WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
+ } else {
+ WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for WRITE12");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for WRITE12");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_WRITE12,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -120,5 +120,5 @@ test_write12_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_write12_flags.c b/test-tool/test_write12_flags.c
index 7ee2a4f..1aff3f4 100644
--- a/test-tool/test_write12_flags.c
+++ b/test-tool/test_write12_flags.c
@@ -30,29 +30,29 @@
void
test_write12_flags(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE12 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE12 flags");
- logging(LOG_VERBOSE, "Test WRITE12 with DPO==1");
- memset(scratch, 0xa6, block_size);
- WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ WRITE12(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==0");
- WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==0");
+ WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==1");
- WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 with FUA==1 FUA_NV==1");
+ WRITE12(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE12 with FUA==0 FUA_NV==1");
- WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 with FUA==0 FUA_NV==1");
+ WRITE12(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1 FUA_NV==1");
- WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE12 with DPO==1 FUA==1 FUA_NV==1");
+ WRITE12(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_write12_residuals.c b/test-tool/test_write12_residuals.c
index f052402..bb055ad 100644
--- a/test-tool/test_write12_residuals.c
+++ b/test-tool/test_write12_residuals.c
@@ -31,361 +31,361 @@
void
test_write12_residuals(void)
{
- struct scsi_task *task_ret;
- unsigned char buf[10000];
- struct iscsi_data data;
- int ok;
- unsigned int i;
+ struct scsi_task *task_ret;
+ unsigned char buf[10000];
+ struct iscsi_data data;
+ int ok;
+ unsigned int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE12 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE12 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This WRITE12 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This WRITE12 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* Try a write12 of 1 block but xferlength == 0 */
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ /* Try a write12 of 1 block but xferlength == 0 */
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
- && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- logging(LOG_NORMAL, "[SKIPPED] WRITE12 is not implemented.");
- CU_PASS("WRITE12 is not implemented.");
- return;
- }
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
+ && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITE12 is not implemented.");
+ CU_PASS("WRITE12 is not implemented.");
+ return;
+ }
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 10000;
- memset(buf, 0xa6, sizeof(buf));
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ memset(buf, 0xa6, sizeof(buf));
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 200;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- ok = task->status == SCSI_STATUS_GOOD ||
- (task->status == SCSI_STATUS_CHECK_CONDITION &&
- task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
- task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
- if (!ok) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT(ok);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ ok = task->status == SCSI_STATUS_GOOD ||
+ (task->status == SCSI_STATUS_CHECK_CONDITION &&
+ task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
+ task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
+ if (!ok) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT(ok);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE12;
- task->cdb[9] = 2;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE12;
+ task->cdb[9] = 2;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE12(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE12(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 2 * block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 2 * block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ12(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ12(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE12(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE12(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE12;
- task->cdb[9] = 2;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE12;
+ task->cdb[9] = 2;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ12(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ12(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
}
diff --git a/test-tool/test_write12_simple.c b/test-tool/test_write12_simple.c
index 6741225..04c0ea4 100644
--- a/test-tool/test_write12_simple.c
+++ b/test-tool/test_write12_simple.c
@@ -30,29 +30,29 @@
void
test_write12_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE12(sd, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the start of the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE12(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE12(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_write12_wrprotect.c b/test-tool/test_write12_wrprotect.c
index faa6046..1133771 100644
--- a/test-tool/test_write12_wrprotect.c
+++ b/test-tool/test_write12_wrprotect.c
@@ -30,27 +30,27 @@
void
test_write12_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE12 with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE12 with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0xa6, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITE12(sd, 0, block_size, block_size,
+ memset(scratch, 0xa6, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITE12(sd, 0, block_size, block_size,
i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_write16_0blocks.c b/test-tool/test_write16_0blocks.c
index abc6b9b..2bd371c 100644
--- a/test-tool/test_write16_0blocks.c
+++ b/test-tool/test_write16_0blocks.c
@@ -27,23 +27,23 @@
void
test_write16_0blocks(void)
{
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==0");
- WRITE16(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==0");
+ WRITE16(sd, 0, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE16 0-blocks one block past end-of-LUN");
- WRITE16(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE16 0-blocks one block past end-of-LUN");
+ WRITE16(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==2^63");
- WRITE16(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==2^63");
+ WRITE16(sd, 0x8000000000000000ULL, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==-1");
- WRITE16(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITE16 0-blocks at LBA==-1");
+ WRITE16(sd, -1, 0, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_write16_beyond_eol.c b/test-tool/test_write16_beyond_eol.c
index 29b7982..8c4f537 100644
--- a/test-tool/test_write16_beyond_eol.c
+++ b/test-tool/test_write16_beyond_eol.c
@@ -29,50 +29,50 @@
void
test_write16_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks at LBA==2^63");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, 0x8000000000000000ULL,
+ logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks at LBA==2^63");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test WRITE16 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE16 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test WRITE16 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_write16_dpofua.c b/test-tool/test_write16_dpofua.c
index 60f486a..cec7400 100644
--- a/test-tool/test_write16_dpofua.c
+++ b/test-tool/test_write16_dpofua.c
@@ -29,77 +29,77 @@
void
test_write16_dpofua(void)
{
- int dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE16 DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE16 DPO/FUA flags");
- CHECK_FOR_SBC;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test WRITE16 with DPO==1");
- memset(scratch, 0xa6, block_size);
- if (dpofua) {
- WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ if (dpofua) {
+ WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ } else {
+ WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE16 with FUA==1");
- if (dpofua) {
- WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 with FUA==1");
+ if (dpofua) {
+ WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ } else {
+ WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1");
- if (dpofua) {
- WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1");
+ if (dpofua) {
+ WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
+ } else {
+ WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for WRITE16");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for WRITE16");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_WRITE16,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -120,5 +120,5 @@ test_write16_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_write16_flags.c b/test-tool/test_write16_flags.c
index c67e072..26902b8 100644
--- a/test-tool/test_write16_flags.c
+++ b/test-tool/test_write16_flags.c
@@ -30,30 +30,30 @@
void
test_write16_flags(void)
{
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE16 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE16 flags");
- logging(LOG_VERBOSE, "Test WRITE16 with DPO==1");
- memset(scratch, 0xa6, block_size);
- WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ WRITE16(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==0");
- WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==0");
+ WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==1");
- WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 with FUA==1 FUA_NV==1");
+ WRITE16(sd, 0, block_size, block_size, 0, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE16 with FUA==0 FUA_NV==1");
- WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 with FUA==0 FUA_NV==1");
+ WRITE16(sd, 0, block_size, block_size, 0, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1 FUA_NV==1");
- WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITE16 with DPO==1 FUA==1 FUA_NV==1");
+ WRITE16(sd, 0, block_size, block_size, 0, 1, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_write16_residuals.c b/test-tool/test_write16_residuals.c
index ee02864..643f9e5 100644
--- a/test-tool/test_write16_residuals.c
+++ b/test-tool/test_write16_residuals.c
@@ -31,361 +31,361 @@
void
test_write16_residuals(void)
{
- struct scsi_task *task_ret;
- unsigned char buf[10000];
- struct iscsi_data data;
- int ok;
- unsigned int i;
+ struct scsi_task *task_ret;
+ unsigned char buf[10000];
+ struct iscsi_data data;
+ int ok;
+ unsigned int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE16 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE16 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This WRITE16 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This WRITE16 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* Try a write16 of 1 block but xferlength == 0 */
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ /* Try a write16 of 1 block but xferlength == 0 */
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
- && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
- CU_PASS("WRITE16 is not implemented.");
- return;
- }
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
+ && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
+ CU_PASS("WRITE16 is not implemented.");
+ return;
+ }
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 10000;
- memset(buf, 0xa6, sizeof(buf));
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ memset(buf, 0xa6, sizeof(buf));
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 200;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- ok = task->status == SCSI_STATUS_GOOD ||
- (task->status == SCSI_STATUS_CHECK_CONDITION &&
- task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
- task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
- if (!ok) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT(ok);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ ok = task->status == SCSI_STATUS_GOOD ||
+ (task->status == SCSI_STATUS_CHECK_CONDITION &&
+ task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
+ task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
+ if (!ok) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT(ok);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE16;
- task->cdb[13] = 2;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE16;
+ task->cdb[13] = 2;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE16(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE16(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 2 * block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 2 * block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ16(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ16(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE16(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE16(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE16;
- task->cdb[13] = 2;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE16;
+ task->cdb[13] = 2;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ16(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ16(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
}
diff --git a/test-tool/test_write16_simple.c b/test-tool/test_write16_simple.c
index c4d89af..85adda7 100644
--- a/test-tool/test_write16_simple.c
+++ b/test-tool/test_write16_simple.c
@@ -30,30 +30,30 @@
void
test_write16_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the start of the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITE16(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITE16 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITE16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_write16_wrprotect.c b/test-tool/test_write16_wrprotect.c
index 8d24577..ee04801 100644
--- a/test-tool/test_write16_wrprotect.c
+++ b/test-tool/test_write16_wrprotect.c
@@ -30,27 +30,27 @@
void
test_write16_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITE16 with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITE16 with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0xa6, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITE16(sd, 0, block_size, block_size,
+ memset(scratch, 0xa6, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITE16(sd, 0, block_size, block_size,
i, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_writeatomic16_0blocks.c b/test-tool/test_writeatomic16_0blocks.c
index 19d272f..10253f5 100644
--- a/test-tool/test_writeatomic16_0blocks.c
+++ b/test-tool/test_writeatomic16_0blocks.c
@@ -27,33 +27,33 @@
void
test_writeatomic16_0blocks(void)
{
- int align;
+ int align;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (!inq_bl) {
- CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
- return;
- }
+ if (!inq_bl) {
+ CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
- align = inq_bl->atomic_align ? inq_bl->atomic_align : 1;
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==0");
- WRITEATOMIC16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
+ align = inq_bl->atomic_align ? inq_bl->atomic_align : 1;
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==0");
+ WRITEATOMIC16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks one alignment past end-of-LUN");
- WRITEATOMIC16(sd, num_blocks + align, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks one alignment past end-of-LUN");
+ WRITEATOMIC16(sd, num_blocks + align, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==2^63");
- WRITEATOMIC16(sd, 0x8000000000000000ULL, 0,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==2^63");
+ WRITEATOMIC16(sd, 0x8000000000000000ULL, 0,
block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==-");
- WRITEATOMIC16(sd, -align, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 0-blocks at LBA==-");
+ WRITEATOMIC16(sd, -align, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_writeatomic16_beyond_eol.c b/test-tool/test_writeatomic16_beyond_eol.c
index ac53a33..897cb0f 100644
--- a/test-tool/test_writeatomic16_beyond_eol.c
+++ b/test-tool/test_writeatomic16_beyond_eol.c
@@ -29,65 +29,65 @@
void
test_writeatomic16_beyond_eol(void)
{
- int align, i, gran;
- const size_t bufsz = 256 * 2 * block_size;
+ int align, i, gran;
+ const size_t bufsz = 256 * 2 * block_size;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (!inq_bl) {
- CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
- return;
- }
+ if (!inq_bl) {
+ CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
- memset(scratch, 0xa6, bufsz);
- align = inq_bl->atomic_align ? inq_bl->atomic_align : 1;
- gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
- WRITEATOMIC16(sd, 0, block_size * gran, block_size, 0, 0, 0, 0, scratch,
+ memset(scratch, 0xa6, bufsz);
+ align = inq_bl->atomic_align ? inq_bl->atomic_align : 1;
+ gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
+ WRITEATOMIC16(sd, 0, block_size * gran, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks blocks beyond the end");
- for (i = gran; i <= 256; i += gran) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEATOMIC16(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks blocks beyond the end");
+ for (i = gran; i <= 256; i += gran) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEATOMIC16(sd, num_blocks - i,
2 * i * block_size, block_size,
0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks at LBA==2^63");
- for (i = gran; i <= 256; i += gran) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEATOMIC16(sd, 0x8000000000000000ULL,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks at LBA==2^63");
+ for (i = gran; i <= 256; i += gran) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEATOMIC16(sd, 0x8000000000000000ULL,
i * block_size, block_size,
0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks at LBA==-");
- for (i = gran; i <= 256; i += gran) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEATOMIC16(sd, -align, i * block_size,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 1-256 blocks at LBA==-");
+ for (i = gran; i <= 256; i += gran) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEATOMIC16(sd, -align, i * block_size,
block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 2-256 blocks all but one block beyond the end");
- for (i = 2 * gran; i <= 256; i += gran) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEATOMIC16(sd, num_blocks - gran,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 2-256 blocks all but one block beyond the end");
+ for (i = 2 * gran; i <= 256; i += gran) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEATOMIC16(sd, num_blocks - gran,
i * block_size, block_size,
0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_writeatomic16_dpofua.c b/test-tool/test_writeatomic16_dpofua.c
index 2193d90..930d299 100644
--- a/test-tool/test_writeatomic16_dpofua.c
+++ b/test-tool/test_writeatomic16_dpofua.c
@@ -29,90 +29,90 @@
void
test_writeatomic16_dpofua(void)
{
- int gran, dpofua, usage_data_dpofua;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int gran, dpofua, usage_data_dpofua;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 DPO/FUA flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 DPO/FUA flags");
- CHECK_FOR_SBC;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
- if (!inq_bl) {
- CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
- return;
- }
+ if (!inq_bl) {
+ CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
+ return;
+ }
- gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
+ gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1");
- memset(scratch, 0xa6, block_size);
- if (dpofua) {
- WRITEATOMIC16(sd, 0, gran * block_size,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ if (dpofua) {
+ WRITEATOMIC16(sd, 0, gran * block_size,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITEATOMIC16(sd, 0, gran * block_size,
+ } else {
+ WRITEATOMIC16(sd, 0, gran * block_size,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 with FUA==1");
- if (dpofua) {
- WRITEATOMIC16(sd, 0, gran * block_size,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 with FUA==1");
+ if (dpofua) {
+ WRITEATOMIC16(sd, 0, gran * block_size,
block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITEATOMIC16(sd, 0, gran * block_size,
+ } else {
+ WRITEATOMIC16(sd, 0, gran * block_size,
block_size, 0, 0, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1 FUA==1");
- if (dpofua) {
- WRITEATOMIC16(sd, 0, gran * block_size,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 with DPO==1 FUA==1");
+ if (dpofua) {
+ WRITEATOMIC16(sd, 0, gran * block_size,
block_size, 0, 1, 1, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITEATOMIC16(sd, 0, gran * block_size,
+ } else {
+ WRITEATOMIC16(sd, 0, gran * block_size,
block_size, 0, 1, 1, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for WRITEATOMIC16");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for WRITEATOMIC16");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_WRITE_ATOMIC16,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18;
if (dpofua) {
@@ -133,5 +133,5 @@ test_writeatomic16_dpofua(void)
}
}
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_writeatomic16_simple.c b/test-tool/test_writeatomic16_simple.c
index 649ec5e..e6f151d 100644
--- a/test-tool/test_writeatomic16_simple.c
+++ b/test-tool/test_writeatomic16_simple.c
@@ -30,42 +30,42 @@
void
test_writeatomic16_simple(void)
{
- int i, gran;
- const size_t bufsz = 256 * block_size;
+ int i, gran;
+ const size_t bufsz = 256 * block_size;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (!inq_bl) {
- CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
- return;
- }
+ if (!inq_bl) {
+ CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
- memset(scratch, 0, bufsz);
- gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
- WRITEATOMIC16(sd, 0, block_size * gran, block_size, 0, 0, 0, 0, scratch,
+ memset(scratch, 0, bufsz);
+ gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
+ WRITEATOMIC16(sd, 0, block_size * gran, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = gran; i <= 256; i += gran) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEATOMIC16(sd, 0, i * block_size,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 of 1-256 blocks at the start of the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = gran; i <= 256; i += gran) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEATOMIC16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 of 1-256 blocks at the end of the LUN");
- for (i = gran; i <= 256; i += gran) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEATOMIC16(sd, num_blocks - i, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 of 1-256 blocks at the end of the LUN");
+ for (i = gran; i <= 256; i += gran) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEATOMIC16(sd, num_blocks - i, i * block_size, block_size,
0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_writeatomic16_vpd.c b/test-tool/test_writeatomic16_vpd.c
index b7b9249..c2796f8 100644
--- a/test-tool/test_writeatomic16_vpd.c
+++ b/test-tool/test_writeatomic16_vpd.c
@@ -29,108 +29,108 @@
void
test_writeatomic16_vpd(void)
{
- int ret;
- struct scsi_inquiry_block_limits *bl;
- struct scsi_task *bl_task = NULL;
- int gran;
+ int ret;
+ struct scsi_inquiry_block_limits *bl;
+ struct scsi_task *bl_task = NULL;
+ int gran;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 VPD data");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 VPD data");
- CHECK_FOR_SBC;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, "Block device. Verify that we can read Block "
- "Limits VPD");
- ret = inquiry(sd, &bl_task,
- 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 255,
- EXPECT_STATUS_GOOD);
- CU_ASSERT_EQUAL(ret, 0);
- if (ret != 0) {
- logging(LOG_NORMAL, "[FAILURE] failed to read Block Limits VDP");
- CU_FAIL("[FAILURE] failed to read Block Limits VDP");
- goto finished;
- }
- bl = scsi_datain_unmarshall(bl_task);
- if (bl == NULL) {
- logging(LOG_NORMAL, "[FAILURE] failed to unmarshall Block Limits VDP");
- CU_FAIL("[FAILURE] failed to unmarshall Block Limits VDP");
- goto finished;
- }
+ logging(LOG_VERBOSE, "Block device. Verify that we can read Block "
+ "Limits VPD");
+ ret = inquiry(sd, &bl_task,
+ 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 255,
+ EXPECT_STATUS_GOOD);
+ CU_ASSERT_EQUAL(ret, 0);
+ if (ret != 0) {
+ logging(LOG_NORMAL, "[FAILURE] failed to read Block Limits VDP");
+ CU_FAIL("[FAILURE] failed to read Block Limits VDP");
+ goto finished;
+ }
+ bl = scsi_datain_unmarshall(bl_task);
+ if (bl == NULL) {
+ logging(LOG_NORMAL, "[FAILURE] failed to unmarshall Block Limits VDP");
+ CU_FAIL("[FAILURE] failed to unmarshall Block Limits VDP");
+ goto finished;
+ }
- logging(LOG_VERBOSE, "Check if WRITEATOMIC16 is supported");
- gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
- memset(scratch , 0x00, block_size * gran);
- ret = writeatomic16(sd, 0, block_size * gran,
- block_size, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- logging(LOG_VERBOSE, "WRITEATOMIC16 is NOT supported by the target.");
+ logging(LOG_VERBOSE, "Check if WRITEATOMIC16 is supported");
+ gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
+ memset(scratch , 0x00, block_size * gran);
+ ret = writeatomic16(sd, 0, block_size * gran,
+ block_size, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ logging(LOG_VERBOSE, "WRITEATOMIC16 is NOT supported by the target.");
- logging(LOG_VERBOSE, "Verify that MAXIMUM_ATOMIC_TRANSFER_LENGTH is zero");
- if (bl->max_atomic_xfer_len) {
- logging(LOG_VERBOSE, "MAXIMUM_ATOMIC_TRANSFER_LENGTH is non-zero but target does not support ATOMICWRITE16");
- CU_FAIL("MAXIMUM_ATOMIC_TRANSFER_LENGTH is non-zero but target does not support ATOMICWRITE16");
- }
+ logging(LOG_VERBOSE, "Verify that MAXIMUM_ATOMIC_TRANSFER_LENGTH is zero");
+ if (bl->max_atomic_xfer_len) {
+ logging(LOG_VERBOSE, "MAXIMUM_ATOMIC_TRANSFER_LENGTH is non-zero but target does not support ATOMICWRITE16");
+ CU_FAIL("MAXIMUM_ATOMIC_TRANSFER_LENGTH is non-zero but target does not support ATOMICWRITE16");
+ }
- logging(LOG_VERBOSE, "Verify that ATOMIC_ALIGNMENT is zero");
- if (bl->atomic_align) {
- logging(LOG_VERBOSE, "ATOMIC_ALIGNMENT is non-zero but target does not support ATOMICWRITE16");
- CU_FAIL("ATOMIC_ALIGNMENT is non-zero but target does not support ATOMICWRITE16");
- }
+ logging(LOG_VERBOSE, "Verify that ATOMIC_ALIGNMENT is zero");
+ if (bl->atomic_align) {
+ logging(LOG_VERBOSE, "ATOMIC_ALIGNMENT is non-zero but target does not support ATOMICWRITE16");
+ CU_FAIL("ATOMIC_ALIGNMENT is non-zero but target does not support ATOMICWRITE16");
+ }
- logging(LOG_VERBOSE, "Verify that ATOMIC_GRANULARITY is zero");
- if (bl->atomic_gran) {
- logging(LOG_VERBOSE, "ATOMIC_GRANULARITY is non-zero but target does not support ATOMICWRITE16");
- CU_FAIL("ATOMIC_GRANULARITY is non-zero but target does not support ATOMICWRITE16");
- }
- goto finished;
- }
+ logging(LOG_VERBOSE, "Verify that ATOMIC_GRANULARITY is zero");
+ if (bl->atomic_gran) {
+ logging(LOG_VERBOSE, "ATOMIC_GRANULARITY is non-zero but target does not support ATOMICWRITE16");
+ CU_FAIL("ATOMIC_GRANULARITY is non-zero but target does not support ATOMICWRITE16");
+ }
+ goto finished;
+ }
- logging(LOG_VERBOSE, "WRITEATOMIC16 IS supported by the target.");
- logging(LOG_VERBOSE, "Verify that MAXIMUM_ATOMIC_TRANSFER_LENGTH is non-zero");
- if (!bl->max_atomic_xfer_len) {
- logging(LOG_VERBOSE, "[WARNING] MAXIMUM_ATOMIC_TRANSFER_LENGTH is zero but target supports ATOMICWRITE16");
- CU_FAIL("[WARNING] MAXIMUM_ATOMIC_TRANSFER_LENGTH is zero but target supports ATOMICWRITE16");
- }
+ logging(LOG_VERBOSE, "WRITEATOMIC16 IS supported by the target.");
+ logging(LOG_VERBOSE, "Verify that MAXIMUM_ATOMIC_TRANSFER_LENGTH is non-zero");
+ if (!bl->max_atomic_xfer_len) {
+ logging(LOG_VERBOSE, "[WARNING] MAXIMUM_ATOMIC_TRANSFER_LENGTH is zero but target supports ATOMICWRITE16");
+ CU_FAIL("[WARNING] MAXIMUM_ATOMIC_TRANSFER_LENGTH is zero but target supports ATOMICWRITE16");
+ }
- logging(LOG_VERBOSE, "Verify that MAXIMUM_ATOMIC_TRANSFER_LENGTH is less than or equal to MAXIMUM_TRANSFER_LENGTH");
- if (bl->max_atomic_xfer_len > bl->max_xfer_len) {
- logging(LOG_VERBOSE, "[FAILED] MAXIMUM_ATOMIC_TRANSFER_LENGTH is greater than MAXIMUM_TRANSFER_LENGTH");
- CU_FAIL("[FAILED] MAXIMUM_ATOMIC_TRANSFER_LENGTH is greater than MAXIMUM_TRANSFER_LENGTH");
- }
+ logging(LOG_VERBOSE, "Verify that MAXIMUM_ATOMIC_TRANSFER_LENGTH is less than or equal to MAXIMUM_TRANSFER_LENGTH");
+ if (bl->max_atomic_xfer_len > bl->max_xfer_len) {
+ logging(LOG_VERBOSE, "[FAILED] MAXIMUM_ATOMIC_TRANSFER_LENGTH is greater than MAXIMUM_TRANSFER_LENGTH");
+ CU_FAIL("[FAILED] MAXIMUM_ATOMIC_TRANSFER_LENGTH is greater than MAXIMUM_TRANSFER_LENGTH");
+ }
- logging(LOG_VERBOSE, "Check handling on misaligned writes");
- if (bl->atomic_align < 2) {
- logging(LOG_VERBOSE, "[SKIPPED] No alignment restrictions on this LUN");
- } else {
- logging(LOG_VERBOSE, "Atomic Write at LBA 1 should fail due to misalignment");
- ret = writeatomic16(sd, 1, block_size * gran,
- block_size, 0, 0, 0, 0, scratch,
- EXPECT_INVALID_FIELD_IN_CDB);
- if (ret) {
- logging(LOG_VERBOSE, "[FAILED] Misaligned write did NOT fail with INVALID_FIELD_IN_CDB");
- CU_FAIL("[FAILED] Misaligned write did NOT fail with INVALID_FIELD_IN_CDB");
- }
- }
+ logging(LOG_VERBOSE, "Check handling on misaligned writes");
+ if (bl->atomic_align < 2) {
+ logging(LOG_VERBOSE, "[SKIPPED] No alignment restrictions on this LUN");
+ } else {
+ logging(LOG_VERBOSE, "Atomic Write at LBA 1 should fail due to misalignment");
+ ret = writeatomic16(sd, 1, block_size * gran,
+ block_size, 0, 0, 0, 0, scratch,
+ EXPECT_INVALID_FIELD_IN_CDB);
+ if (ret) {
+ logging(LOG_VERBOSE, "[FAILED] Misaligned write did NOT fail with INVALID_FIELD_IN_CDB");
+ CU_FAIL("[FAILED] Misaligned write did NOT fail with INVALID_FIELD_IN_CDB");
+ }
+ }
- logging(LOG_VERBOSE, "Check handling on invalid granularity");
- if (bl->atomic_gran < 2) {
- logging(LOG_VERBOSE, "[SKIPPED] No granularity restrictions on this LUN");
- } else {
- logging(LOG_VERBOSE, "Atomic Write of 1 block should fail due to invalid granularity");
- ret = writeatomic16(sd, 0, block_size,
- block_size, 0, 0, 0, 0, scratch,
- EXPECT_INVALID_FIELD_IN_CDB);
- if (ret) {
- logging(LOG_VERBOSE, "[FAILED] Misgranularity write did NOT fail with INVALID_FIELD_IN_CDB");
- CU_FAIL("[FAILED] Misgranularity write did NOT fail with INVALID_FIELD_IN_CDB");
- }
- }
+ logging(LOG_VERBOSE, "Check handling on invalid granularity");
+ if (bl->atomic_gran < 2) {
+ logging(LOG_VERBOSE, "[SKIPPED] No granularity restrictions on this LUN");
+ } else {
+ logging(LOG_VERBOSE, "Atomic Write of 1 block should fail due to invalid granularity");
+ ret = writeatomic16(sd, 0, block_size,
+ block_size, 0, 0, 0, 0, scratch,
+ EXPECT_INVALID_FIELD_IN_CDB);
+ if (ret) {
+ logging(LOG_VERBOSE, "[FAILED] Misgranularity write did NOT fail with INVALID_FIELD_IN_CDB");
+ CU_FAIL("[FAILED] Misgranularity write did NOT fail with INVALID_FIELD_IN_CDB");
+ }
+ }
finished:
- scsi_free_scsi_task(bl_task);
+ scsi_free_scsi_task(bl_task);
}
diff --git a/test-tool/test_writeatomic16_wrprotect.c b/test-tool/test_writeatomic16_wrprotect.c
index 4ffd5f3..2f5cc95 100644
--- a/test-tool/test_writeatomic16_wrprotect.c
+++ b/test-tool/test_writeatomic16_wrprotect.c
@@ -30,34 +30,34 @@
void
test_writeatomic16_wrprotect(void)
{
- int i, gran;
+ int i, gran;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (!inq_bl) {
- CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
- return;
- }
+ if (!inq_bl) {
+ CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
- gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
- memset(scratch, 0, block_size);
- WRITEATOMIC16(sd, 0, block_size * gran, block_size, 0, 0, 0, 0, scratch,
+ gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
+ memset(scratch, 0, block_size);
+ WRITEATOMIC16(sd, 0, block_size * gran, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITEATOMIC16 with non-zero WRPROTECT");
- memset(scratch, 0xa6, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITEATOMIC16(sd, 0, gran * block_size, block_size,
+ logging(LOG_VERBOSE, "Test WRITEATOMIC16 with non-zero WRPROTECT");
+ memset(scratch, 0xa6, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITEATOMIC16(sd, 0, gran * block_size, block_size,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_writesame10_0blocks.c b/test-tool/test_writesame10_0blocks.c
index 6783893..929f1d9 100644
--- a/test-tool/test_writesame10_0blocks.c
+++ b/test-tool/test_writesame10_0blocks.c
@@ -27,56 +27,56 @@
void
test_writesame10_0blocks(void)
{
- int ret;
+ int ret;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for write-beyond-eol tests with WRITESAME10. Skipping test.\n");
- return;
- }
- if (!inq_bl) {
- CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for write-beyond-eol tests with WRITESAME10. Skipping test.\n");
+ return;
+ }
+ if (!inq_bl) {
+ CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==0 (WSNZ=%d)",
- inq_bl->wsnz);
- memset(scratch, 0, block_size);
+ logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==0 (WSNZ=%d)",
+ inq_bl->wsnz);
+ memset(scratch, 0, block_size);
- if (inq_bl->wsnz) {
- WRITESAME10(sd, 0, block_size, 0, 0, 0, 0, 0, scratch,
+ if (inq_bl->wsnz) {
+ WRITESAME10(sd, 0, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks.");
- return;
- }
+ logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks.");
+ return;
+ }
- ret = writesame10(sd, 0,
- block_size, 0, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
- return;
- } else if (ret == -3) {
- CU_PASS("[SKIPPED] Target does not support WRITESAME10 with NUMBER OF LOGICAL BLOCKS == 0");
- } else if (ret == -4) {
- CU_PASS("[SKIPPED] Number of WRITESAME10 logical blocks to be written exceeds MAXIMUM WRITE SAME LENGTH");
- } else {
- CU_ASSERT_EQUAL(ret, 0);
- }
+ ret = writesame10(sd, 0,
+ block_size, 0, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ CU_PASS("[SKIPPED] Target does not support WRITESAME10. Skipping test");
+ return;
+ } else if (ret == -3) {
+ CU_PASS("[SKIPPED] Target does not support WRITESAME10 with NUMBER OF LOGICAL BLOCKS == 0");
+ } else if (ret == -4) {
+ CU_PASS("[SKIPPED] Number of WRITESAME10 logical blocks to be written exceeds MAXIMUM WRITE SAME LENGTH");
+ } else {
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks one block past end-of-LUN");
- WRITESAME10(sd, num_blocks + 1, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks one block past end-of-LUN");
+ WRITESAME10(sd, num_blocks + 1, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==2^31");
- WRITESAME10(sd, 0x80000000, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==2^31");
+ WRITESAME10(sd, 0x80000000, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==-1");
- WRITESAME10(sd, -1, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==-1");
+ WRITESAME10(sd, -1, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_writesame10_beyond_eol.c b/test-tool/test_writesame10_beyond_eol.c
index 757a70b..72b59e8 100644
--- a/test-tool/test_writesame10_beyond_eol.c
+++ b/test-tool/test_writesame10_beyond_eol.c
@@ -29,42 +29,42 @@
void
test_writesame10_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for write-beyond-eol tests with WRITESAME10. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for write-beyond-eol tests with WRITESAME10. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks one block beyond the end");
- memset(scratch, 0, block_size);
- for (i = 1; i <= 256; i++) {
- WRITESAME10(sd, num_blocks - i + 1,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks one block beyond the end");
+ memset(scratch, 0, block_size);
+ for (i = 1; i <= 256; i++) {
+ WRITESAME10(sd, num_blocks - i + 1,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- WRITESAME10(sd, 0x80000000,
+ logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ WRITESAME10(sd, 0x80000000,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- WRITESAME10(sd, -1, block_size, i, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME10 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ WRITESAME10(sd, -1, block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME10 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- WRITESAME10(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test WRITESAME10 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ WRITESAME10(sd, num_blocks - 1,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_writesame10_simple.c b/test-tool/test_writesame10_simple.c
index 055c49e..405854c 100644
--- a/test-tool/test_writesame10_simple.c
+++ b/test-tool/test_writesame10_simple.c
@@ -30,24 +30,24 @@
void
test_writesame10_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of the LUN");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0, block_size);
- for (i = 1; i <= 256; i++) {
- WRITESAME10(sd, 0, block_size, i, 0, 0, 0, 0, scratch,
+ memset(scratch, 0, block_size);
+ for (i = 1; i <= 256; i++) {
+ WRITESAME10(sd, 0, block_size, i, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- WRITESAME10(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ WRITESAME10(sd, num_blocks - i,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_writesame10_unmap.c b/test-tool/test_writesame10_unmap.c
index 5234b6e..349beb0 100644
--- a/test-tool/test_writesame10_unmap.c
+++ b/test-tool/test_writesame10_unmap.c
@@ -30,143 +30,143 @@
void
test_writesame10_unmap(void)
{
- unsigned int i;
+ unsigned int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_LBPWS10;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_LBPWS10;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of "
- "the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, i * block_size);
- WRITE10(sd, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the start of "
+ "the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, i * block_size);
+ WRITE10(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
- memset(scratch, 0, block_size);
- WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
+ memset(scratch, 0, block_size);
+ WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ10(sd, NULL, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ10(sd, NULL, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- }
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of "
- "the LUN");
- for (i = 1; i <= 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, i * block_size);
+ logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of "
+ "the LUN");
+ for (i = 1; i <= 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, i * block_size);
WRITE10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
- memset(scratch, 0, block_size);
- WRITESAME10(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
+ memset(scratch, 0, block_size);
+ WRITESAME10(sd, num_blocks - i,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ10(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ10(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- }
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ }
- logging(LOG_VERBOSE, "Verify that WRITESAME10 ANCHOR==1 + UNMAP==0 is "
- "invalid");
- WRITESAME10(sd, 0, block_size, 1, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Verify that WRITESAME10 ANCHOR==1 + UNMAP==0 is "
+ "invalid");
+ WRITESAME10(sd, 0, block_size, 1, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- if (inq_lbp->anc_sup) {
- logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0");
- memset(scratch, 0, block_size);
- WRITESAME10(sd, 0, block_size, 1, 1, 1, 0, 0, scratch,
+ if (inq_lbp->anc_sup) {
+ logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0");
+ memset(scratch, 0, block_size);
+ WRITESAME10(sd, 0, block_size, 1, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0 no "
- "ANC_SUP so expecting to fail");
- WRITESAME10(sd, 0, block_size, 1, 1, 1, 0, 0, scratch,
+ } else {
+ logging(LOG_VERBOSE, "Test WRITESAME10 ANCHOR==1 + UNMAP==0 no "
+ "ANC_SUP so expecting to fail");
+ WRITESAME10(sd, 0, block_size, 1, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
-
- if (inq_bl == NULL) {
- logging(LOG_VERBOSE, "[FAILED] WRITESAME10 works but "
- "BlockLimits VPD is missing.");
- CU_FAIL("[FAILED] WRITESAME10 works but "
- "BlockLimits VPD is missing.");
- return;
- }
+ }
+
+ if (inq_bl == NULL) {
+ logging(LOG_VERBOSE, "[FAILED] WRITESAME10 works but "
+ "BlockLimits VPD is missing.");
+ CU_FAIL("[FAILED] WRITESAME10 works but "
+ "BlockLimits VPD is missing.");
+ return;
+ }
- i = 256;
- if (i <= num_blocks
- && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
- logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
- "as either 0 (==no limit) or >= %d. Test Unmapping "
- "%d blocks to verify that it can handle 2-byte "
- "lengths", i, i);
+ i = 256;
+ if (i <= num_blocks
+ && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
+ logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
+ "as either 0 (==no limit) or >= %d. Test Unmapping "
+ "%d blocks to verify that it can handle 2-byte "
+ "lengths", i, i);
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, i * block_size);
- WRITE10(sd, 0,
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, i * block_size);
+ WRITE10(sd, 0,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
- memset(scratch, 0, block_size);
- WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
+ memset(scratch, 0, block_size);
+ WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ10(sd, NULL, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ10(sd, NULL, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- } else if (i <= num_blocks) {
- logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
- "as <256. Verify that a 256 block unmap fails with "
- "INVALID_FIELD_IN_CDB.");
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ } else if (i <= num_blocks) {
+ logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
+ "as <256. Verify that a 256 block unmap fails with "
+ "INVALID_FIELD_IN_CDB.");
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
- WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
+ WRITESAME10(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
}
diff --git a/test-tool/test_writesame10_unmap_unaligned.c b/test-tool/test_writesame10_unmap_unaligned.c
index a631885..e0c19df 100644
--- a/test-tool/test_writesame10_unmap_unaligned.c
+++ b/test-tool/test_writesame10_unmap_unaligned.c
@@ -29,20 +29,20 @@
void
test_writesame10_unmap_unaligned(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_LBPWS10;
- CHECK_FOR_LBPPB_GT_1;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_LBPWS10;
+ CHECK_FOR_LBPPB_GT_1;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that unaligned WRITESAME10 Unmap succeeds. LBPPB==%d", lbppb);
- memset(scratch, 0xa6, block_size);
- for (i = 1; i < lbppb; i++) {
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10 at LBA:%d", lbppb - i, i);
- WRITESAME10(sd, i, block_size, lbppb - i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that unaligned WRITESAME10 Unmap succeeds. LBPPB==%d", lbppb);
+ memset(scratch, 0xa6, block_size);
+ for (i = 1; i < lbppb; i++) {
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10 at LBA:%d", lbppb - i, i);
+ WRITESAME10(sd, i, block_size, lbppb - i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_writesame10_unmap_until_end.c b/test-tool/test_writesame10_unmap_until_end.c
index dc21646..3b6c47f 100644
--- a/test-tool/test_writesame10_unmap_until_end.c
+++ b/test-tool/test_writesame10_unmap_until_end.c
@@ -29,47 +29,47 @@
void
test_writesame10_unmap_until_end(void)
{
- unsigned int i;
+ unsigned int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_LBPWS10;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_LBPWS10;
+ CHECK_FOR_SBC;
- if (inq_bl->wsnz) {
- logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks.");
- CU_PASS("[SKIPPED] WRITESAME10 does not support 0-blocks.");
- return;
- }
+ if (inq_bl->wsnz) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks.");
+ CU_PASS("[SKIPPED] WRITESAME10 does not support 0-blocks.");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0");
- for (i = 1; i <= 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, block_size * i);
- WRITE10(sd, num_blocks - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0");
+ for (i = 1; i <= 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, block_size * i);
+ WRITE10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
- WRITESAME10(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i);
+ WRITESAME10(sd, num_blocks - i,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ10(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ10(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- }
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ }
}
diff --git a/test-tool/test_writesame10_unmap_vpd.c b/test-tool/test_writesame10_unmap_vpd.c
index f8d8e0b..b6915a2 100644
--- a/test-tool/test_writesame10_unmap_vpd.c
+++ b/test-tool/test_writesame10_unmap_vpd.c
@@ -30,53 +30,53 @@
void
test_writesame10_unmap_vpd(void)
{
- int ret;
+ int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME10 UNMAP availability is "
- "consistent with VPD settings");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME10 UNMAP availability is "
+ "consistent with VPD settings");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Check if WRITESAME10 can be used for UNMAP.");
- logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME10");
- memset(scratch, 0, block_size);
- ret = writesame10(sd, 0, block_size, 1, 0, 1, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret != 0) {
- logging(LOG_VERBOSE, "WRITESAME10 UNMAP is not available. "
- "Verify that VPD settings reflect this.");
+ logging(LOG_VERBOSE, "Check if WRITESAME10 can be used for UNMAP.");
+ logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME10");
+ memset(scratch, 0, block_size);
+ ret = writesame10(sd, 0, block_size, 1, 0, 1, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret != 0) {
+ logging(LOG_VERBOSE, "WRITESAME10 UNMAP is not available. "
+ "Verify that VPD settings reflect this.");
- logging(LOG_VERBOSE, "Verify that LBPWS10 is clear.");
- if (inq_lbp && inq_lbp->lbpws10) {
- logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is not "
- "implemented but LBPWS10 is set");
- CU_FAIL("[FAILED] WRITESAME10 UNMAP is unavailable but "
- "LBPWS10==1");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] LBPWS10 is clear.");
- }
- } else {
- logging(LOG_VERBOSE, "WRITESAME10 UNMAP is available. Verify "
- "that VPD settings reflect this.");
+ logging(LOG_VERBOSE, "Verify that LBPWS10 is clear.");
+ if (inq_lbp && inq_lbp->lbpws10) {
+ logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is not "
+ "implemented but LBPWS10 is set");
+ CU_FAIL("[FAILED] WRITESAME10 UNMAP is unavailable but "
+ "LBPWS10==1");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPWS10 is clear.");
+ }
+ } else {
+ logging(LOG_VERBOSE, "WRITESAME10 UNMAP is available. Verify "
+ "that VPD settings reflect this.");
- logging(LOG_VERBOSE, "Verify that LBPME is set.");
- if (rc16 && rc16->lbpme) {
- logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
- } else {
- logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is "
- "implemented but LBPME is not set");
- CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
- }
+ logging(LOG_VERBOSE, "Verify that LBPME is set.");
+ if (rc16 && rc16->lbpme) {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is "
+ "implemented but LBPME is not set");
+ CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
+ }
- logging(LOG_VERBOSE, "Verify that LBPWS10 is set.");
- if (inq_lbp && inq_lbp->lbpws10) {
- logging(LOG_VERBOSE, "[SUCCESS] LBPWS10 is set.");
- } else {
- logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is "
- "implemented but LBPWS10 is not set");
- CU_FAIL("[FAILED] UNMAP is available but LBPWS10==0");
- }
- }
+ logging(LOG_VERBOSE, "Verify that LBPWS10 is set.");
+ if (inq_lbp && inq_lbp->lbpws10) {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPWS10 is set.");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is "
+ "implemented but LBPWS10 is not set");
+ CU_FAIL("[FAILED] UNMAP is available but LBPWS10==0");
+ }
+ }
}
diff --git a/test-tool/test_writesame10_wrprotect.c b/test-tool/test_writesame10_wrprotect.c
index 3a7c30b..91314da 100644
--- a/test-tool/test_writesame10_wrprotect.c
+++ b/test-tool/test_writesame10_wrprotect.c
@@ -30,26 +30,26 @@
void
test_writesame10_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME10 with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME10 with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITESAME10(sd, 0, block_size, 1, 0, 0, i, 0, scratch,
+ memset(scratch, 0, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITESAME10(sd, 0, block_size, 1, 0, 0, i, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_writesame16_0blocks.c b/test-tool/test_writesame16_0blocks.c
index 28c74c5..4eef6aa 100644
--- a/test-tool/test_writesame16_0blocks.c
+++ b/test-tool/test_writesame16_0blocks.c
@@ -27,52 +27,52 @@
void
test_writesame16_0blocks(void)
{
- int ret;
+ int ret;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (!inq_bl) {
- CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
- return;
- }
+ if (!inq_bl) {
+ CU_PASS("BlockLimits VPD is not available. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==0 (WSNZ=%d)",
- inq_bl->wsnz);
- memset(scratch, 0, block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==0 (WSNZ=%d)",
+ inq_bl->wsnz);
+ memset(scratch, 0, block_size);
- if (inq_bl->wsnz) {
- WRITESAME16(sd, 0, block_size, 0, 0, 0, 0, 0, scratch,
+ if (inq_bl->wsnz) {
+ WRITESAME16(sd, 0, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 does not support 0-blocks.");
- return;
- }
+ logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 does not support 0-blocks.");
+ return;
+ }
- ret = writesame16(sd, 0, block_size, 0, 0, 0, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret == -2) {
- logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
- CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
- return;
- } else if (ret == -3) {
- CU_PASS("[SKIPPED] Target does not support WRITESAME16 with NUMBER OF LOGICAL BLOCKS == 0");
- } else if (ret == -4) {
- CU_PASS("[SKIPPED] Number of WRITESAME16 logical blocks to be written exceeds MAXIMUM WRITE SAME LENGTH");
- } else {
- CU_ASSERT_EQUAL(ret, 0);
- }
+ ret = writesame16(sd, 0, block_size, 0, 0, 0, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret == -2) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");
+ CU_PASS("[SKIPPED] Target does not support WRITESAME16. Skipping test");
+ return;
+ } else if (ret == -3) {
+ CU_PASS("[SKIPPED] Target does not support WRITESAME16 with NUMBER OF LOGICAL BLOCKS == 0");
+ } else if (ret == -4) {
+ CU_PASS("[SKIPPED] Number of WRITESAME16 logical blocks to be written exceeds MAXIMUM WRITE SAME LENGTH");
+ } else {
+ CU_ASSERT_EQUAL(ret, 0);
+ }
- logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks one block past end-of-LUN");
- WRITESAME16(sd, num_blocks + 1, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks one block past end-of-LUN");
+ WRITESAME16(sd, num_blocks + 1, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==2^63");
- WRITESAME16(sd, 0x8000000000000000ULL,
+ logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==2^63");
+ WRITESAME16(sd, 0x8000000000000000ULL,
block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==-1");
- WRITESAME16(sd, -1, block_size, 0, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==-1");
+ WRITESAME16(sd, -1, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_writesame16_beyond_eol.c b/test-tool/test_writesame16_beyond_eol.c
index 82ea042..6759883 100644
--- a/test-tool/test_writesame16_beyond_eol.c
+++ b/test-tool/test_writesame16_beyond_eol.c
@@ -29,37 +29,37 @@
void
test_writesame16_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks one block beyond the end");
- memset(scratch, 0, block_size);
- for (i = 1; i <= 256; i++) {
- WRITESAME16(sd, num_blocks - i + 1,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks one block beyond the end");
+ memset(scratch, 0, block_size);
+ for (i = 1; i <= 256; i++) {
+ WRITESAME16(sd, num_blocks - i + 1,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==2^63");
- for (i = 1; i <= 256; i++) {
- WRITESAME16(sd, 0x8000000000000000ULL,
+ logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==2^63");
+ for (i = 1; i <= 256; i++) {
+ WRITESAME16(sd, 0x8000000000000000ULL,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- WRITESAME16(sd, -1, block_size, i, 0, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITESAME16 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ WRITESAME16(sd, -1, block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME16 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- WRITESAME16(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test WRITESAME16 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ WRITESAME16(sd, num_blocks - 1,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_writesame16_simple.c b/test-tool/test_writesame16_simple.c
index d0cbfab..165357f 100644
--- a/test-tool/test_writesame16_simple.c
+++ b/test-tool/test_writesame16_simple.c
@@ -30,24 +30,24 @@
void
test_writesame16_simple(void)
{
- int i;
-
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ int i;
+
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0, block_size);
- for (i = 1; i <= 256; i++) {
- WRITESAME16(sd, 0, block_size, i, 0, 0, 0, 0, scratch,
+ memset(scratch, 0, block_size);
+ for (i = 1; i <= 256; i++) {
+ WRITESAME16(sd, 0, block_size, i, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- WRITESAME16(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ WRITESAME16(sd, num_blocks - i,
block_size, i, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_writesame16_unmap.c b/test-tool/test_writesame16_unmap.c
index dd5082e..e5ccb55 100644
--- a/test-tool/test_writesame16_unmap.c
+++ b/test-tool/test_writesame16_unmap.c
@@ -29,180 +29,180 @@
void
test_writesame16_unmap(void)
{
- unsigned int i;
+ unsigned int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_LBPWS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_LBPWS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN");
- for (i = 1; i <= 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, i * block_size);
- WRITE16(sd, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the start of the LUN");
+ for (i = 1; i <= 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, i * block_size);
+ WRITE16(sd, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
- memset(scratch, 0, block_size);
- WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
+ memset(scratch, 0, block_size);
+ WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ16(sd, NULL, 0, i * block_size, block_size,
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ16(sd, NULL, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- }
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ }
- logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, i * block_size);
- WRITE16(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, i * block_size);
+ WRITE16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
- memset(scratch, 0, block_size);
- WRITESAME16(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
+ memset(scratch, 0, block_size);
+ WRITESAME16(sd, num_blocks - i,
block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ16(sd, NULL, num_blocks - i,
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ16(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- }
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ }
- logging(LOG_VERBOSE, "Verify that WRITESAME16 ANCHOR==1 + UNMAP==0 is invalid");
- WRITESAME16(sd, 0, block_size, 1, 1, 0, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Verify that WRITESAME16 ANCHOR==1 + UNMAP==0 is invalid");
+ WRITESAME16(sd, 0, block_size, 1, 1, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- if (inq_lbp->anc_sup) {
- logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0");
- memset(scratch, 0, block_size);
- WRITESAME16(sd, 0, block_size, 1, 1, 1, 0, 0, scratch,
+ if (inq_lbp->anc_sup) {
+ logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0");
+ memset(scratch, 0, block_size);
+ WRITESAME16(sd, 0, block_size, 1, 1, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0 no ANC_SUP so expecting to fail");
- WRITESAME16(sd, 0, block_size, 1, 1, 1, 0, 0, scratch,
+ } else {
+ logging(LOG_VERBOSE, "Test WRITESAME16 ANCHOR==1 + UNMAP==0 no ANC_SUP so expecting to fail");
+ WRITESAME16(sd, 0, block_size, 1, 1, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- if (inq_bl == NULL) {
- logging(LOG_VERBOSE, "[FAILED] WRITESAME16 works but "
- "BlockLimits VPD is missing.");
- CU_FAIL("[FAILED] WRITESAME16 works but "
- "BlockLimits VPD is missing.");
+ if (inq_bl == NULL) {
+ logging(LOG_VERBOSE, "[FAILED] WRITESAME16 works but "
+ "BlockLimits VPD is missing.");
+ CU_FAIL("[FAILED] WRITESAME16 works but "
+ "BlockLimits VPD is missing.");
return;
- }
+ }
- i = 256;
- if (i <= num_blocks
- && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
- logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
- "as either 0 (==no limit) or >= %d. Test Unmapping "
- "%d blocks to verify that it can handle 2-byte "
- "lengths", i, i);
+ i = 256;
+ if (i <= num_blocks
+ && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
+ logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
+ "as either 0 (==no limit) or >= %d. Test Unmapping "
+ "%d blocks to verify that it can handle 2-byte "
+ "lengths", i, i);
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, i * block_size);
- WRITE16(sd, 0,
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, i * block_size);
+ WRITE16(sd, 0,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
- memset(scratch, 0, block_size);
- WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
+ memset(scratch, 0, block_size);
+ WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ16(sd, NULL, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ16(sd, NULL, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- } else if (i <= num_blocks) {
- logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
- "as <256. Verify that a 256 block unmap fails with "
- "INVALID_FIELD_IN_CDB.");
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ } else if (i <= num_blocks) {
+ logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
+ "as <256. Verify that a 256 block unmap fails with "
+ "INVALID_FIELD_IN_CDB.");
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
- WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
+ WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- i = 65536;
- if (i <= num_blocks
- && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
- logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
- "as either 0 (==no limit) or >= %d. Test Unmapping "
- "%d blocks to verify that it can handle 4-byte "
- "lengths", i, i);
+ i = 65536;
+ if (i <= num_blocks
+ && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) {
+ logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
+ "as either 0 (==no limit) or >= %d. Test Unmapping "
+ "%d blocks to verify that it can handle 4-byte "
+ "lengths", i, i);
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, i * block_size);
- WRITE16(sd, 0,
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, i * block_size);
+ WRITE16(sd, 0,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
- memset(scratch, 0, block_size);
- WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
+ memset(scratch, 0, block_size);
+ WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ16(sd, NULL, 0, i * block_size, block_size,
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ16(sd, NULL, 0, i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- } else if (i <= num_blocks) {
- logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
- "as <256. Verify that a 256 block unmap fails with "
- "INVALID_FIELD_IN_CDB.");
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ } else if (i <= num_blocks) {
+ logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN "
+ "as <256. Verify that a 256 block unmap fails with "
+ "INVALID_FIELD_IN_CDB.");
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
- WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
+ WRITESAME16(sd, 0, block_size, i, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
}
diff --git a/test-tool/test_writesame16_unmap_unaligned.c b/test-tool/test_writesame16_unmap_unaligned.c
index a94977e..e9a775c 100644
--- a/test-tool/test_writesame16_unmap_unaligned.c
+++ b/test-tool/test_writesame16_unmap_unaligned.c
@@ -29,20 +29,20 @@
void
test_writesame16_unmap_unaligned(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_LBPWS;
- CHECK_FOR_LBPPB_GT_1;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_LBPWS;
+ CHECK_FOR_LBPPB_GT_1;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test that unaligned WRITESAME16 Unmap succeeds. LBPPB==%d", lbppb);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test that unaligned WRITESAME16 Unmap succeeds. LBPPB==%d", lbppb);
- for (i = 1; i < lbppb; i++) {
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16 at LBA:%d", lbppb - i, i);
- WRITESAME16(sd, i, 0, lbppb - i, 0, 1, 0, 0, NULL,
+ for (i = 1; i < lbppb; i++) {
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16 at LBA:%d", lbppb - i, i);
+ WRITESAME16(sd, i, 0, lbppb - i, 0, 1, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_writesame16_unmap_until_end.c b/test-tool/test_writesame16_unmap_until_end.c
index e033077..62a4205 100644
--- a/test-tool/test_writesame16_unmap_until_end.c
+++ b/test-tool/test_writesame16_unmap_until_end.c
@@ -30,49 +30,49 @@
void
test_writesame16_unmap_until_end(void)
{
- unsigned int i;
+ unsigned int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_THIN_PROVISIONING;
- CHECK_FOR_LBPWS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_THIN_PROVISIONING;
+ CHECK_FOR_LBPWS;
+ CHECK_FOR_SBC;
- if (inq_bl->wsnz) {
- logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks.");
- CU_PASS("[SKIPPED] WRITESAME10 does not support 0-blocks.");
- return;
- }
+ if (inq_bl->wsnz) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks.");
+ CU_PASS("[SKIPPED] WRITESAME10 does not support 0-blocks.");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
- memset(scratch, 0xff, block_size * i);
- WRITE16(sd, num_blocks - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME16 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i);
+ memset(scratch, 0xff, block_size * i);
+ WRITE16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
- memset(scratch, 0, block_size);
- WRITESAME16(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i);
+ memset(scratch, 0, block_size);
+ WRITESAME16(sd, num_blocks - i,
block_size, 0, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- if (rc16->lbprz) {
- logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
- "blocks back and verify they are all zero");
+ if (rc16->lbprz) {
+ logging(LOG_VERBOSE, "LBPRZ is set. Read the unmapped "
+ "blocks back and verify they are all zero");
- logging(LOG_VERBOSE, "Read %d blocks and verify they "
- "are now zero", i);
- READ16(sd, NULL, num_blocks - i,
+ logging(LOG_VERBOSE, "Read %d blocks and verify they "
+ "are now zero", i);
+ READ16(sd, NULL, num_blocks - i,
i * block_size, block_size,
0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- CU_ASSERT(all_zeroes(scratch, i * block_size));
- } else {
- logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
- "and verify zero test");
- }
- }
+ CU_ASSERT(all_zeroes(scratch, i * block_size));
+ } else {
+ logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read "
+ "and verify zero test");
+ }
+ }
}
diff --git a/test-tool/test_writesame16_unmap_vpd.c b/test-tool/test_writesame16_unmap_vpd.c
index 0f32363..ab4496b 100644
--- a/test-tool/test_writesame16_unmap_vpd.c
+++ b/test-tool/test_writesame16_unmap_vpd.c
@@ -30,54 +30,54 @@
void
test_writesame16_unmap_vpd(void)
{
- int ret;
+ int ret;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME16 UNMAP availability is "
- "consistent with VPD settings");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME16 UNMAP availability is "
+ "consistent with VPD settings");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, "Check if WRITESAME16 can be used for UNMAP.");
+ logging(LOG_VERBOSE, "Check if WRITESAME16 can be used for UNMAP.");
- logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME16");
- memset(scratch, 0, block_size);
- ret = writesame16(sd, 0, block_size, 1, 0, 1, 0, 0, scratch,
- EXPECT_STATUS_GOOD);
- if (ret != 0) {
- logging(LOG_VERBOSE, "WRITESAME16 UNMAP is not available. "
- "Verify that VPD settings reflect this.");
+ logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME16");
+ memset(scratch, 0, block_size);
+ ret = writesame16(sd, 0, block_size, 1, 0, 1, 0, 0, scratch,
+ EXPECT_STATUS_GOOD);
+ if (ret != 0) {
+ logging(LOG_VERBOSE, "WRITESAME16 UNMAP is not available. "
+ "Verify that VPD settings reflect this.");
- logging(LOG_VERBOSE, "Verify that LBPWS is clear.");
- if (inq_lbp && inq_lbp->lbpws) {
- logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is not "
- "implemented but LBPWS is set");
- CU_FAIL("[FAILED] WRITESAME16 UNMAP is unavailable but "
- "LBPWS==1");
- } else {
- logging(LOG_VERBOSE, "[SUCCESS] LBPWS is clear.");
- }
- } else {
- logging(LOG_VERBOSE, "WRITESAME16 UNMAP is available. Verify "
- "that VPD settings reflect this.");
+ logging(LOG_VERBOSE, "Verify that LBPWS is clear.");
+ if (inq_lbp && inq_lbp->lbpws) {
+ logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is not "
+ "implemented but LBPWS is set");
+ CU_FAIL("[FAILED] WRITESAME16 UNMAP is unavailable but "
+ "LBPWS==1");
+ } else {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPWS is clear.");
+ }
+ } else {
+ logging(LOG_VERBOSE, "WRITESAME16 UNMAP is available. Verify "
+ "that VPD settings reflect this.");
- logging(LOG_VERBOSE, "Verify that LBPME is set.");
- if (rc16 && rc16->lbpme) {
- logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
- } else {
- logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is "
- "implemented but LBPME is not set");
- CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
- }
+ logging(LOG_VERBOSE, "Verify that LBPME is set.");
+ if (rc16 && rc16->lbpme) {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is "
+ "implemented but LBPME is not set");
+ CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
+ }
- logging(LOG_VERBOSE, "Verify that LBPWS is set.");
- if (inq_lbp && inq_lbp->lbpws) {
- logging(LOG_VERBOSE, "[SUCCESS] LBPWS is set.");
- } else {
- logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is "
- "implemented but LBPWS is not set");
- CU_FAIL("[FAILED] UNMAP is available but LBPWS==0");
- }
- }
+ logging(LOG_VERBOSE, "Verify that LBPWS is set.");
+ if (inq_lbp && inq_lbp->lbpws) {
+ logging(LOG_VERBOSE, "[SUCCESS] LBPWS is set.");
+ } else {
+ logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is "
+ "implemented but LBPWS is not set");
+ CU_FAIL("[FAILED] UNMAP is available but LBPWS==0");
+ }
+ }
}
diff --git a/test-tool/test_writesame16_wrprotect.c b/test-tool/test_writesame16_wrprotect.c
index c11796f..cb7ef34 100644
--- a/test-tool/test_writesame16_wrprotect.c
+++ b/test-tool/test_writesame16_wrprotect.c
@@ -30,26 +30,26 @@
void
test_writesame16_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITESAME16 with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITESAME16 with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITESAME16(sd, 0, block_size, 1, 0, 0, i, 0, scratch,
+ memset(scratch, 0, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITESAME16(sd, 0, block_size, 1, 0, 0, i, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_writeverify10_0blocks.c b/test-tool/test_writeverify10_0blocks.c
index 2cdb054..6f3139c 100644
--- a/test-tool/test_writeverify10_0blocks.c
+++ b/test-tool/test_writeverify10_0blocks.c
@@ -27,27 +27,27 @@
void
test_writeverify10_0blocks(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with WRITEVERIFY10. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with WRITEVERIFY10. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==0");
- WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==0");
+ WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks one block past end-of-LUN");
- WRITEVERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks one block past end-of-LUN");
+ WRITEVERIFY10(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==2^31");
- WRITEVERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==2^31");
+ WRITEVERIFY10(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==-1");
- WRITEVERIFY10(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 0-blocks at LBA==-1");
+ WRITEVERIFY10(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_writeverify10_beyond_eol.c b/test-tool/test_writeverify10_beyond_eol.c
index 69e11df..b656b01 100644
--- a/test-tool/test_writeverify10_beyond_eol.c
+++ b/test-tool/test_writeverify10_beyond_eol.c
@@ -29,54 +29,54 @@
void
test_writeverify10_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for write-beyond-eol tests with WRITEVERIFY10. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for write-beyond-eol tests with WRITEVERIFY10. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY10(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY10(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY10(sd, 0x80000000,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY10(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY10(sd, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY10(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY10(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY10(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_writeverify10_dpo.c b/test-tool/test_writeverify10_dpo.c
index bbd8873..4d650c9 100644
--- a/test-tool/test_writeverify10_dpo.c
+++ b/test-tool/test_writeverify10_dpo.c
@@ -29,72 +29,72 @@
void
test_writeverify10_dpo(void)
{
- int dpofua, usage_data_dpo;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpo;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 DPO flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 DPO flag");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1");
- if (dpofua) {
- WRITEVERIFY10(sd, 0, block_size,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 with DPO==1");
+ if (dpofua) {
+ WRITEVERIFY10(sd, 0, block_size,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITEVERIFY10(sd, 0, block_size,
+ } else {
+ WRITEVERIFY10(sd, 0, block_size,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for WRITEVERIFY10");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for WRITEVERIFY10");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_WRITE_VERIFY10,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
- "is set in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
- } else {
- logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
- "flag is clear in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
- }
+ usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
+ "is set in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
+ "flag is clear in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_writeverify10_flags.c b/test-tool/test_writeverify10_flags.c
index b5e3009..74df6c3 100644
--- a/test-tool/test_writeverify10_flags.c
+++ b/test-tool/test_writeverify10_flags.c
@@ -30,14 +30,14 @@
void
test_writeverify10_flags(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 flags");
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1");
- memset(scratch, 0xa6, block_size);
- WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 with BYTCHK==1");
+ memset(scratch, 0xa6, block_size);
+ WRITEVERIFY10(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_writeverify10_residuals.c b/test-tool/test_writeverify10_residuals.c
index eda0aa7..322c7cb 100644
--- a/test-tool/test_writeverify10_residuals.c
+++ b/test-tool/test_writeverify10_residuals.c
@@ -31,366 +31,366 @@
void
test_writeverify10_residuals(void)
{
- struct scsi_task *task_ret;
- unsigned char buf[10000];
- struct iscsi_data data;
- int ok;
- unsigned int i;
+ struct scsi_task *task_ret;
+ unsigned char buf[10000];
+ struct iscsi_data data;
+ int ok;
+ unsigned int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This WRITEVERIFY10 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This WRITEVERIFY10 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* check if writeverify10 is supported */
- WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
+ /* check if writeverify10 is supported */
+ WRITEVERIFY10(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- /* Try a writeverify10 of 1 block but xferlength == 0 */
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ /* Try a writeverify10 of 1 block but xferlength == 0 */
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
- && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented.");
- CU_PASS("WRITEVERIFY10 is not implemented.");
- return;
- }
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
+ && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY10 is not implemented.");
+ CU_PASS("WRITEVERIFY10 is not implemented.");
+ return;
+ }
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 10000;
- memset(buf, 0xa6, sizeof(buf));
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ memset(buf, 0xa6, sizeof(buf));
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 200;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- ok = task->status == SCSI_STATUS_GOOD ||
- (task->status == SCSI_STATUS_CHECK_CONDITION &&
- task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
- task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
- if (!ok) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT(ok);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ ok = task->status == SCSI_STATUS_GOOD ||
+ (task->status == SCSI_STATUS_CHECK_CONDITION &&
+ task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
+ task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
+ if (!ok) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT(ok);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
- task->cdb[8] = 2;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
+ task->cdb[8] = 2;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE10(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE10(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
- task->cdb[8] = 1;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 2 * block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
+ task->cdb[8] = 1;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 2 * block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ10(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ10(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE10(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE10(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
- task->cdb[8] = 2;
- task->cdb_size = 10;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY10;
+ task->cdb[8] = 2;
+ task->cdb_size = 10;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ10(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ10(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
}
diff --git a/test-tool/test_writeverify10_simple.c b/test-tool/test_writeverify10_simple.c
index 2d7122d..99368d2 100644
--- a/test-tool/test_writeverify10_simple.c
+++ b/test-tool/test_writeverify10_simple.c
@@ -30,29 +30,29 @@
void
test_writeverify10_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY10(sd, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the start of the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY10(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY10(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY10(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_writeverify10_wrprotect.c b/test-tool/test_writeverify10_wrprotect.c
index 910b587..9ffc86c 100644
--- a/test-tool/test_writeverify10_wrprotect.c
+++ b/test-tool/test_writeverify10_wrprotect.c
@@ -30,27 +30,27 @@
void
test_writeverify10_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY10 with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY10 with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0xa6, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITEVERIFY10(sd, 0, block_size, block_size,
+ memset(scratch, 0xa6, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITEVERIFY10(sd, 0, block_size, block_size,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_writeverify12_0blocks.c b/test-tool/test_writeverify12_0blocks.c
index cae5ec4..3b7a1bc 100644
--- a/test-tool/test_writeverify12_0blocks.c
+++ b/test-tool/test_writeverify12_0blocks.c
@@ -27,27 +27,27 @@
void
test_writeverify12_0blocks(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for read-beyond-eol tests with WRITEVERIFY12. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for read-beyond-eol tests with WRITEVERIFY12. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==0");
- WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==0");
+ WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks one block past end-of-LUN");
- WRITEVERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks one block past end-of-LUN");
+ WRITEVERIFY12(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==2^31");
- WRITEVERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==2^31");
+ WRITEVERIFY12(sd, 0x80000000, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==-1");
- WRITEVERIFY12(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 0-blocks at LBA==-1");
+ WRITEVERIFY12(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_writeverify12_beyond_eol.c b/test-tool/test_writeverify12_beyond_eol.c
index fc52d4d..07ac438 100644
--- a/test-tool/test_writeverify12_beyond_eol.c
+++ b/test-tool/test_writeverify12_beyond_eol.c
@@ -29,54 +29,54 @@
void
test_writeverify12_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- if (num_blocks >= 0x80000000) {
- CU_PASS("LUN is too big for write-beyond-eol tests with WRITEVERIFY12. Skipping test.\n");
- return;
- }
+ if (num_blocks >= 0x80000000) {
+ CU_PASS("LUN is too big for write-beyond-eol tests with WRITEVERIFY12. Skipping test.\n");
+ return;
+ }
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY12(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY12(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==2^31");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY12(sd, 0x80000000,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==2^31");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY12(sd, 0x80000000,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY12(sd, -1, i * block_size,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY12(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY12(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY12(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_writeverify12_dpo.c b/test-tool/test_writeverify12_dpo.c
index d71576a..458b5ff 100644
--- a/test-tool/test_writeverify12_dpo.c
+++ b/test-tool/test_writeverify12_dpo.c
@@ -29,71 +29,71 @@
void
test_writeverify12_dpo(void)
{
- int dpofua, usage_data_dpo;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpo;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 DPO flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 DPO flag");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1");
- if (dpofua) {
- WRITEVERIFY12(sd, 0, block_size,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 with DPO==1");
+ if (dpofua) {
+ WRITEVERIFY12(sd, 0, block_size,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITEVERIFY12(sd, 0, block_size,
+ } else {
+ WRITEVERIFY12(sd, 0, block_size,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for WRITEVERIFY12");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for WRITEVERIFY12");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_WRITE_VERIFY12,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
- "is set in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
- } else {
- logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
- "flag is clear in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
- }
+ usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
+ "is set in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
+ "flag is clear in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_writeverify12_flags.c b/test-tool/test_writeverify12_flags.c
index 4269fb6..66043e1 100644
--- a/test-tool/test_writeverify12_flags.c
+++ b/test-tool/test_writeverify12_flags.c
@@ -30,14 +30,14 @@
void
test_writeverify12_flags(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 flags");
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1");
- memset(scratch, 0xa6, block_size);
- WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 with BYTCHK==1");
+ memset(scratch, 0xa6, block_size);
+ WRITEVERIFY12(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_writeverify12_residuals.c b/test-tool/test_writeverify12_residuals.c
index b7555a5..f4b4ee6 100644
--- a/test-tool/test_writeverify12_residuals.c
+++ b/test-tool/test_writeverify12_residuals.c
@@ -31,366 +31,366 @@
void
test_writeverify12_residuals(void)
{
- struct scsi_task *task_ret;
- unsigned char buf[10000];
- struct iscsi_data data;
- int ok;
- unsigned int i;
+ struct scsi_task *task_ret;
+ unsigned char buf[10000];
+ struct iscsi_data data;
+ int ok;
+ unsigned int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This WRITEVERIFY12 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This WRITEVERIFY12 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* check if writeverify12 is supported */
- WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
+ /* check if writeverify12 is supported */
+ WRITEVERIFY12(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- /* Try a writeverify12 of 1 block but xferlength == 0 */
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ /* Try a writeverify12 of 1 block but xferlength == 0 */
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
- && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented.");
- CU_PASS("WRITEVERIFY12 is not implemented.");
- return;
- }
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
+ && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY12 is not implemented.");
+ CU_PASS("WRITEVERIFY12 is not implemented.");
+ return;
+ }
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 10000;
- memset(buf, 0xa6, sizeof(buf));
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ memset(buf, 0xa6, sizeof(buf));
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 200;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- ok = task->status == SCSI_STATUS_GOOD ||
- (task->status == SCSI_STATUS_CHECK_CONDITION &&
- task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
- task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
- if (!ok) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT(ok);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ ok = task->status == SCSI_STATUS_GOOD ||
+ (task->status == SCSI_STATUS_CHECK_CONDITION &&
+ task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
+ task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
+ if (!ok) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT(ok);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
- task->cdb[9] = 2;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
+ task->cdb[9] = 2;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE12(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE12(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
- task->cdb[9] = 1;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 2 * block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
+ task->cdb[9] = 1;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 2 * block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ12(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ12(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE12(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE12(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
- task->cdb[9] = 2;
- task->cdb_size = 12;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY12;
+ task->cdb[9] = 2;
+ task->cdb_size = 12;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ12(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ12(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
}
diff --git a/test-tool/test_writeverify12_simple.c b/test-tool/test_writeverify12_simple.c
index fb32b68..9826096 100644
--- a/test-tool/test_writeverify12_simple.c
+++ b/test-tool/test_writeverify12_simple.c
@@ -30,29 +30,29 @@
void
test_writeverify12_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY12(sd, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 of 1-256 blocks at the start of the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY12(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY12(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITE12 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_writeverify12_wrprotect.c b/test-tool/test_writeverify12_wrprotect.c
index ea8362d..f8028f9 100644
--- a/test-tool/test_writeverify12_wrprotect.c
+++ b/test-tool/test_writeverify12_wrprotect.c
@@ -30,27 +30,27 @@
void
test_writeverify12_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY12 with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY12 with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0xa6, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITEVERIFY12(sd, 0, block_size, block_size,
+ memset(scratch, 0xa6, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITEVERIFY12(sd, 0, block_size, block_size,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}
diff --git a/test-tool/test_writeverify16_0blocks.c b/test-tool/test_writeverify16_0blocks.c
index de186e7..987aa86 100644
--- a/test-tool/test_writeverify16_0blocks.c
+++ b/test-tool/test_writeverify16_0blocks.c
@@ -27,24 +27,24 @@
void
test_writeverify16_0blocks(void)
{
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==0");
- WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==0");
+ WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks one block past end-of-LUN");
- WRITEVERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks one block past end-of-LUN");
+ WRITEVERIFY16(sd, num_blocks + 1, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==2^63");
- WRITEVERIFY16(sd, 0x8000000000000000ULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==2^63");
+ WRITEVERIFY16(sd, 0x8000000000000000ULL,
0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==-1");
- WRITEVERIFY16(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 0-blocks at LBA==-1");
+ WRITEVERIFY16(sd, -1, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
}
diff --git a/test-tool/test_writeverify16_beyond_eol.c b/test-tool/test_writeverify16_beyond_eol.c
index d56feaf..7a0f561 100644
--- a/test-tool/test_writeverify16_beyond_eol.c
+++ b/test-tool/test_writeverify16_beyond_eol.c
@@ -29,50 +29,50 @@
void
test_writeverify16_beyond_eol(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks one block beyond the end");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY16(sd, num_blocks + 1 - i,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks one block beyond the end");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY16(sd, num_blocks + 1 - i,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==2^63");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY16(sd, 0x8000000000000000ULL,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==2^63");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY16(sd, 0x8000000000000000ULL,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==-1");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY16(sd, -1,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 1-256 blocks at LBA==-1");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY16(sd, -1,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 2-256 blocks all but one block beyond the end");
- for (i = 2; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY16(sd, num_blocks - 1,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 2-256 blocks all but one block beyond the end");
+ for (i = 2; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY16(sd, num_blocks - 1,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_LBA_OOB);
- }
+ }
}
diff --git a/test-tool/test_writeverify16_dpo.c b/test-tool/test_writeverify16_dpo.c
index 8cc1473..bdf0ef5 100644
--- a/test-tool/test_writeverify16_dpo.c
+++ b/test-tool/test_writeverify16_dpo.c
@@ -29,73 +29,73 @@
void
test_writeverify16_dpo(void)
{
- int dpofua, usage_data_dpo;
- struct scsi_task *ms_task = NULL;
- struct scsi_mode_sense *ms;
- struct scsi_task *rso_task = NULL;
- struct scsi_report_supported_op_codes_one_command *rsoc;
+ int dpofua, usage_data_dpo;
+ struct scsi_task *ms_task = NULL;
+ struct scsi_mode_sense *ms;
+ struct scsi_task *rso_task = NULL;
+ struct scsi_report_supported_op_codes_one_command *rsoc;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 DPO flag");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 DPO flag");
- CHECK_FOR_SBC;
+ CHECK_FOR_SBC;
- READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
+ READ10(sd, NULL, 0, block_size, block_size, 0, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
- MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
+ logging(LOG_VERBOSE, "Read the DPOFUA flag from mode sense data");
+ MODESENSE6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
- ms = scsi_datain_unmarshall(ms_task);
- dpofua = ms && (ms->device_specific_parameter & 0x10);
- scsi_free_scsi_task(ms_task);
+ logging(LOG_VERBOSE, "[SUCCESS] Mode sense returned status GOOD");
+ ms = scsi_datain_unmarshall(ms_task);
+ dpofua = ms && (ms->device_specific_parameter & 0x10);
+ scsi_free_scsi_task(ms_task);
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
- "DPO/FUA flags in CDBs");
- } else {
- logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
- "CDBs with DPO/FUA set");
- }
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA flag is set. Device should allow "
+ "DPO/FUA flags in CDBs");
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA flag is clear. Device should fail "
+ "CDBs with DPO/FUA set");
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1");
- memset(scratch, 0xa6, block_size);
- if (dpofua) {
- WRITEVERIFY16(sd, 0, block_size,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 with DPO==1");
+ memset(scratch, 0xa6, block_size);
+ if (dpofua) {
+ WRITEVERIFY16(sd, 0, block_size,
block_size, 0, 1, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- } else {
- WRITEVERIFY16(sd, 0, block_size,
+ } else {
+ WRITEVERIFY16(sd, 0, block_size,
block_size, 0, 1, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
+ }
- logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
- "for WRITEVERIFY16");
- REPORT_SUPPORTED_OPCODES(sd, &rso_task,
+ logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES "
+ "for WRITEVERIFY16");
+ REPORT_SUPPORTED_OPCODES(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPCODE,
SCSI_OPCODE_WRITE_VERIFY16,
0,
65535,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
- rsoc = scsi_datain_unmarshall(rso_task);
- CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
+ logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
+ rsoc = scsi_datain_unmarshall(rso_task);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc);
- usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
- if (dpofua) {
- logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
- "is set in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
- } else {
- logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
- "flag is clear in the CDB_USAGE_DATA");
- CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
- }
+ usage_data_dpo = rsoc ? rsoc->cdb_usage_data[1] & 0x10 : -1;
+ if (dpofua) {
+ logging(LOG_VERBOSE, "DPOFUA is set. Verify the DPO flag "
+ "is set in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x10);
+ } else {
+ logging(LOG_VERBOSE, "DPOFUA is clear. Verify the DPO "
+ "flag is clear in the CDB_USAGE_DATA");
+ CU_ASSERT_EQUAL(usage_data_dpo, 0x00);
+ }
- scsi_free_scsi_task(rso_task);
+ scsi_free_scsi_task(rso_task);
}
diff --git a/test-tool/test_writeverify16_flags.c b/test-tool/test_writeverify16_flags.c
index 93e6d0f..9831b81 100644
--- a/test-tool/test_writeverify16_flags.c
+++ b/test-tool/test_writeverify16_flags.c
@@ -30,14 +30,14 @@
void
test_writeverify16_flags(void)
{
- CHECK_FOR_DATALOSS;
+ CHECK_FOR_DATALOSS;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 flags");
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 flags");
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1");
- memset(scratch, 0xa6, block_size);
- WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 with BYTCHK==1");
+ memset(scratch, 0xa6, block_size);
+ WRITEVERIFY16(sd, 0, block_size, block_size, 0, 0, 1, 0, scratch,
EXPECT_STATUS_GOOD);
}
diff --git a/test-tool/test_writeverify16_residuals.c b/test-tool/test_writeverify16_residuals.c
index ad55c90..836a723 100644
--- a/test-tool/test_writeverify16_residuals.c
+++ b/test-tool/test_writeverify16_residuals.c
@@ -31,372 +31,372 @@
void
test_writeverify16_residuals(void)
{
- struct scsi_task *task_ret;
- unsigned char buf[10000];
- struct iscsi_data data;
- int ok;
- unsigned int i;
+ struct scsi_task *task_ret;
+ unsigned char buf[10000];
+ struct iscsi_data data;
+ int ok;
+ unsigned int i;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 commands with residuals");
- logging(LOG_VERBOSE, "Block size is %zu", block_size);
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 commands with residuals");
+ logging(LOG_VERBOSE, "Block size is %zu", block_size);
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] This WRITEVERIFY16 test is only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] This WRITEVERIFY16 test is only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* check if writeverify16 is supported */
- WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
+ /* check if writeverify16 is supported */
+ WRITEVERIFY16(sd, 0, 0, block_size, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
- if (sd->iscsi_ctx == NULL) {
- const char *err = "[SKIPPED] WRITEVERIFY16 tests are only "
- "supported for iSCSI backends";
- logging(LOG_NORMAL, "%s", err);
- CU_PASS(err);
- return;
- }
+ if (sd->iscsi_ctx == NULL) {
+ const char *err = "[SKIPPED] WRITEVERIFY16 tests are only "
+ "supported for iSCSI backends";
+ logging(LOG_NORMAL, "%s", err);
+ CU_PASS(err);
+ return;
+ }
- /* Try a writeverify16 of 1 block but xferlength == 0 */
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ /* Try a writeverify16 of 1 block but xferlength == 0 */
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 0;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 0;
- /*
- * we don't want autoreconnect since some targets will drop the session
- * on this condition.
- */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
+ /*
+ * we don't want autoreconnect since some targets will drop the session
+ * on this condition.
+ */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==0");
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
- if (task->status == SCSI_STATUS_CHECK_CONDITION
- && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
- && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented.");
- CU_PASS("WRITEVERIFY16 is not implemented.");
- return;
- }
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ if (task->status == SCSI_STATUS_CHECK_CONDITION
+ && task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
+ && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
+ logging(LOG_NORMAL, "[SKIPPED] WRITEVERIFY16 is not implemented.");
+ CU_PASS("WRITEVERIFY16 is not implemented.");
+ return;
+ }
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size);
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size);
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- /* in case the previous test failed the session */
- iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
+ /* in case the previous test failed the session */
+ iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==10000");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 10000;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 10000;
- memset(buf, 0xa6, sizeof(buf));
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ memset(buf, 0xa6, sizeof(buf));
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
- 10000 - block_size);
- if (task->residual != 10000 - block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- 10000 - block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual underflow",
+ 10000 - block_size);
+ if (task->residual != 10000 - block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ 10000 - block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, 10000 - block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing one block but with iSCSI expected transfer length==200");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 200;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 200;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- ok = task->status == SCSI_STATUS_GOOD ||
- (task->status == SCSI_STATUS_CHECK_CONDITION &&
- task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
- task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
- if (!ok) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT(ok);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ ok = task->status == SCSI_STATUS_GOOD ||
+ (task->status == SCSI_STATUS_CHECK_CONDITION &&
+ task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST &&
+ task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_INFORMATION_UNIT);
+ if (!ok) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT(ok);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
- block_size - 200);
- if (task->residual != block_size - 200) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size - 200, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size - 200);
+ logging(LOG_VERBOSE, "Verify we got %zu bytes of residual overflow",
+ block_size - 200);
+ if (task->residual != block_size - 200) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size - 200, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size - 200);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
- "transfer length==%zu (==one block)", block_size);
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Try writing two blocks but iSCSI expected "
+ "transfer length==%zu (==one block)", block_size);
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
- task->cdb[13] = 2;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
+ task->cdb[13] = 2;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL > SCSI TL then we only write SCSI TL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE16(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE16(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write one block of 'b' but set iSCSI EDTL to 2 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
- task->cdb[13] = 1;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = 2 * block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
+ task->cdb[13] = 1;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = 2 * block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual underflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "underflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
+ logging(LOG_VERBOSE, "Verify residual underflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "underflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_UNDERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual underflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ16(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ16(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
+ logging(LOG_VERBOSE, "Verify that if iSCSI EDTL < SCSI TL then we only write iSCSI EDTL amount of data");
- logging(LOG_VERBOSE, "Write two blocks of 'a'");
- memset(buf, 'a', 10000);
- WRITE16(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Write two blocks of 'a'");
+ memset(buf, 'a', 10000);
+ WRITE16(sd, 0, 2 * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
- task = malloc(sizeof(struct scsi_task));
- CU_ASSERT_PTR_NOT_NULL_FATAL(task);
+ logging(LOG_VERBOSE, "Write two blocks of 'b' but set iSCSI EDTL to 1 blocks.");
+ task = malloc(sizeof(struct scsi_task));
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task);
- memset(buf, 'b', 10000);
+ memset(buf, 'b', 10000);
- memset(task, 0, sizeof(struct scsi_task));
- task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
- task->cdb[13] = 2;
- task->cdb_size = 16;
- task->xfer_dir = SCSI_XFER_WRITE;
- task->expxferlen = block_size;
+ memset(task, 0, sizeof(struct scsi_task));
+ task->cdb[0] = SCSI_OPCODE_WRITE_VERIFY16;
+ task->cdb[13] = 2;
+ task->cdb_size = 16;
+ task->xfer_dir = SCSI_XFER_WRITE;
+ task->expxferlen = block_size;
- data.size = task->expxferlen;
- data.data = &buf[0];
- task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
- CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
+ data.size = task->expxferlen;
+ data.data = &buf[0];
+ task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
+ CU_ASSERT_PTR_NOT_NULL_FATAL(task_ret);
- logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
- if (task->status != SCSI_STATUS_GOOD) {
- logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
- iscsi_get_error(sd->iscsi_ctx));
- }
- CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
+ logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
+ iscsi_get_error(sd->iscsi_ctx));
+ }
+ CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify residual overflow flag is set");
- if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
- "overflow flag");
- }
- CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
+ logging(LOG_VERBOSE, "Verify residual overflow flag is set");
+ if (task->residual_status != SCSI_RESIDUAL_OVERFLOW) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set residual "
+ "overflow flag");
+ }
+ CU_ASSERT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW);
- logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
- if (task->residual != block_size) {
- logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
- "amount of residual. Expected %zu but got %zu.",
- block_size, task->residual);
- }
- CU_ASSERT_EQUAL(task->residual, block_size);
- scsi_free_scsi_task(task);
- task = NULL;
+ logging(LOG_VERBOSE, "Verify we got one block of residual overflow");
+ if (task->residual != block_size) {
+ logging(LOG_VERBOSE, "[FAILED] Target did not set correct "
+ "amount of residual. Expected %zu but got %zu.",
+ block_size, task->residual);
+ }
+ CU_ASSERT_EQUAL(task->residual, block_size);
+ scsi_free_scsi_task(task);
+ task = NULL;
- logging(LOG_VERBOSE, "Read the two blocks");
- READ16(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
+ logging(LOG_VERBOSE, "Read the two blocks");
+ READ16(sd, NULL, 0, 2* block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
- logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
- for (i = 0; i < block_size; i++) {
- if (buf[i] != 'b') {
- logging(LOG_NORMAL, "First block did not contain expected 'b'");
- CU_FAIL("Block was not written correctly");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the first block was changed to 'b'");
+ for (i = 0; i < block_size; i++) {
+ if (buf[i] != 'b') {
+ logging(LOG_NORMAL, "First block did not contain expected 'b'");
+ CU_FAIL("Block was not written correctly");
+ break;
+ }
+ }
- logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
- for (i = block_size; i < 2 * block_size; i++) {
- if (buf[i] != 'a') {
- logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
- CU_FAIL("Second block was incorrectly overwritten");
- break;
- }
- }
+ logging(LOG_VERBOSE, "Verify that the second block was NOT overwritten and still contains 'a'");
+ for (i = block_size; i < 2 * block_size; i++) {
+ if (buf[i] != 'a') {
+ logging(LOG_NORMAL, "Second block was overwritten and no longer contain 'a'");
+ CU_FAIL("Second block was incorrectly overwritten");
+ break;
+ }
+ }
}
diff --git a/test-tool/test_writeverify16_simple.c b/test-tool/test_writeverify16_simple.c
index f4acc71..877b9db 100644
--- a/test-tool/test_writeverify16_simple.c
+++ b/test-tool/test_writeverify16_simple.c
@@ -30,30 +30,30 @@
void
test_writeverify16_simple(void)
{
- int i;
+ int i;
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the start of the LUN");
- memset(scratch, 0xa6, 256 * block_size);
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY16(sd, 0, i * block_size,
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the start of the LUN");
+ memset(scratch, 0xa6, 256 * block_size);
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the end of the LUN");
- for (i = 1; i <= 256; i++) {
- if (maximum_transfer_length && maximum_transfer_length < i) {
- break;
- }
- WRITEVERIFY16(sd, num_blocks - i,
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 of 1-256 blocks at the end of the LUN");
+ for (i = 1; i <= 256; i++) {
+ if (maximum_transfer_length && maximum_transfer_length < i) {
+ break;
+ }
+ WRITEVERIFY16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
- }
+ }
}
diff --git a/test-tool/test_writeverify16_wrprotect.c b/test-tool/test_writeverify16_wrprotect.c
index 1b7a2e6..e51ed32 100644
--- a/test-tool/test_writeverify16_wrprotect.c
+++ b/test-tool/test_writeverify16_wrprotect.c
@@ -31,27 +31,27 @@
void
test_writeverify16_wrprotect(void)
{
- int i;
+ int i;
- /*
- * Try out different non-zero values for WRPROTECT.
- */
- logging(LOG_VERBOSE, LOG_BLANK_LINE);
- logging(LOG_VERBOSE, "Test WRITEVERIFY16 with non-zero WRPROTECT");
+ /*
+ * Try out different non-zero values for WRPROTECT.
+ */
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test WRITEVERIFY16 with non-zero WRPROTECT");
- CHECK_FOR_DATALOSS;
- CHECK_FOR_SBC;
+ CHECK_FOR_DATALOSS;
+ CHECK_FOR_SBC;
- memset(scratch, 0xa6, block_size);
- if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
- logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
- for (i = 1; i < 8; i++) {
- WRITEVERIFY16(sd, 0, block_size, block_size,
+ memset(scratch, 0xa6, block_size);
+ if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
+ logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
+ for (i = 1; i < 8; i++) {
+ WRITEVERIFY16(sd, 0, block_size, block_size,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
- }
- return;
- }
+ }
+ return;
+ }
- logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
+ logging(LOG_NORMAL, "No tests for devices that support protection information yet.");
}