TESTS: convert most of SANITIZE to new saner api
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -115,13 +115,6 @@ static const char *scsi_status_str(int status)
|
|||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|
||||||
static int status_is_invalid_field_in_cdb(struct scsi_task *task)
|
|
||||||
{
|
|
||||||
return task->status == SCSI_STATUS_CHECK_CONDITION
|
|
||||||
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
|
|
||||||
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There is no agreement among the T10 committee whether a SCSI target should
|
* There is no agreement among the T10 committee whether a SCSI target should
|
||||||
* report "invalid opcode", "invalid field in CDB" or "invalid field in
|
* report "invalid opcode", "invalid field in CDB" or "invalid field in
|
||||||
@@ -1236,82 +1229,34 @@ synchronizecache16(struct scsi_device *sdev, uint64_t lba, int num, int sync_nv,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sanitize(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data)
|
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;
|
struct scsi_task *task;
|
||||||
|
int ret;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send SANITIZE IMMED:%d AUSE:%d SA:%d "
|
logging(LOG_VERBOSE, "Send SANITIZE (Expecting %s) IMMED:%d AUSE:%d "
|
||||||
"PARAM_LEN:%d",
|
"SA:%d PARAM_LEN:%d",
|
||||||
|
scsi_status_str(status),
|
||||||
immed, ause, sa, param_len);
|
immed, ause, sa, param_len);
|
||||||
|
|
||||||
|
if (!data_loss) {
|
||||||
|
printf("--dataloss flag is not set in. Skipping sanitize\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
task = iscsi_sanitize_sync(sdev->iscsi_ctx, sdev->iscsi_lun, immed, ause, sa, param_len,
|
task = iscsi_sanitize_sync(sdev->iscsi_ctx, sdev->iscsi_lun, immed, ause, sa, param_len,
|
||||||
data);
|
data);
|
||||||
if (task == NULL) {
|
task = scsi_cdb_sanitize(immed, ause, sa, param_len);
|
||||||
logging(LOG_NORMAL,
|
|
||||||
"[FAILED] Failed to send SANITIZE command: %s",
|
|
||||||
iscsi_get_error(sdev->iscsi_ctx));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (status_is_invalid_opcode(task)) {
|
|
||||||
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
|
|
||||||
"implemented on target");
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
if (task->status != SCSI_STATUS_GOOD) {
|
|
||||||
logging(LOG_NORMAL,
|
|
||||||
"[FAILED] SANITIZE 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] SANITIZE returned SUCCESS.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sanitize_invalidfieldincdb(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data)
|
assert(task != NULL);
|
||||||
{
|
|
||||||
struct scsi_task *task;
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send SANITIZE (Expecting INVALID_FIELD_IN_CDB) "
|
task = send_scsi_command(sdev, task, data);
|
||||||
"IMMED:%d AUSE:%d SA:%d "
|
|
||||||
"PARAM_LEN:%d",
|
|
||||||
immed, ause, sa, param_len);
|
|
||||||
|
|
||||||
task = iscsi_sanitize_sync(sdev->iscsi_ctx, sdev->iscsi_lun, immed, ause, sa, param_len,
|
ret = check_result("SANITIZE", sdev, task, status, key, ascq, num_ascq);
|
||||||
data);
|
if (task) {
|
||||||
if (task == NULL) {
|
|
||||||
logging(LOG_NORMAL,
|
|
||||||
"[FAILED] Failed to send SANITIZE command: %s",
|
|
||||||
iscsi_get_error(sdev->iscsi_ctx));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (status_is_invalid_opcode(task)) {
|
|
||||||
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
|
|
||||||
"implemented on target");
|
|
||||||
scsi_free_scsi_task(task);
|
scsi_free_scsi_task(task);
|
||||||
return -2;
|
|
||||||
}
|
}
|
||||||
if (task->status == SCSI_STATUS_GOOD) {
|
return ret;
|
||||||
logging(LOG_NORMAL, "[FAILED] SANITIZE successful but should "
|
|
||||||
"have failed with ILLEGAL_REQUEST/INVALID_FIELD_IN_CDB");
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (!status_is_invalid_field_in_cdb(task)) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] SANITIZE failed with wrong "
|
|
||||||
"sense. Should have failed with ILLEGAL_REQUEST/"
|
|
||||||
"INVALID_FIELD_IN_CDB. Sense:%s\n",
|
|
||||||
iscsi_get_error(sdev->iscsi_ctx));
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
logging(LOG_VERBOSE, "[OK] SANITIZE returned ILLEGAL_REQUEST/"
|
|
||||||
"INVALID_FIELD_IB_CDB.");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int sanitize_conflict(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data)
|
int sanitize_conflict(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data)
|
||||||
@@ -1349,45 +1294,6 @@ int sanitize_conflict(struct scsi_device *sdev, int immed, int ause, int sa, int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sanitize_writeprotected(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data)
|
|
||||||
{
|
|
||||||
struct scsi_task *task;
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send SANITIZE (Expecting WRITE_PROTECTED) "
|
|
||||||
"IMMED:%d AUSE:%d SA:%d "
|
|
||||||
"PARAM_LEN:%d",
|
|
||||||
immed, ause, sa, param_len);
|
|
||||||
|
|
||||||
task = iscsi_sanitize_sync(sdev->iscsi_ctx, sdev->iscsi_lun, immed, ause, sa, param_len,
|
|
||||||
data);
|
|
||||||
if (task == NULL) {
|
|
||||||
logging(LOG_NORMAL,
|
|
||||||
"[FAILED] Failed to send SANITIZE command: %s",
|
|
||||||
iscsi_get_error(sdev->iscsi_ctx));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (task->status == SCSI_STATUS_GOOD) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] SANITIZE successful but should "
|
|
||||||
"have failed with DATA_PROTECTION/WRITE_PROTECTED");
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
|
||||||
|| task->sense.key != SCSI_SENSE_DATA_PROTECTION
|
|
||||||
|| task->sense.ascq != SCSI_SENSE_ASCQ_WRITE_PROTECTED) {
|
|
||||||
logging(LOG_NORMAL, "[FAILED] SANITIZE failed with wrong "
|
|
||||||
"sense. Should have failed with DATA_PRTOTECTION/"
|
|
||||||
"WRITE_PROTECTED. Sense:%s\n",
|
|
||||||
iscsi_get_error(sdev->iscsi_ctx));
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
scsi_free_scsi_task(task);
|
|
||||||
logging(LOG_VERBOSE, "[OK] SANITIZE returned DATA_PROTECTION/WRITE_PROTECTED.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
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;
|
struct scsi_task *task;
|
||||||
|
|||||||
@@ -287,10 +287,8 @@ int report_supported_opcodes(struct scsi_device *sdev, struct scsi_task **save_t
|
|||||||
int release6(struct scsi_device *sdev);
|
int release6(struct scsi_device *sdev);
|
||||||
int reserve6(struct scsi_device *sdev);
|
int reserve6(struct scsi_device *sdev);
|
||||||
int reserve6_conflict(struct scsi_device *sdev);
|
int reserve6_conflict(struct scsi_device *sdev);
|
||||||
int sanitize(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
|
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);
|
||||||
int sanitize_conflict(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
|
int sanitize_conflict(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
|
||||||
int sanitize_invalidfieldincdb(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
|
|
||||||
int sanitize_writeprotected(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
|
|
||||||
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);
|
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);
|
||||||
int synchronizecache10(struct scsi_device *sdev, uint32_t lba, int num_blocks, int sync_nv, int immed, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
int synchronizecache10(struct scsi_device *sdev, uint32_t lba, int num_blocks, int sync_nv, int immed, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||||
int synchronizecache16(struct scsi_device *sdev, uint64_t lba, int num_blocks, int sync_nv, int immed, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
int synchronizecache16(struct scsi_device *sdev, uint64_t lba, int num_blocks, int sync_nv, int immed, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
|
||||||
|
|||||||
@@ -325,8 +325,8 @@ test_sanitize_block_erase(void)
|
|||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Test we can perform basic BLOCK ERASE SANITIZE");
|
logging(LOG_VERBOSE, "Test we can perform basic BLOCK ERASE SANITIZE");
|
||||||
ret = sanitize(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
|
||||||
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
|
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
|
||||||
@@ -341,8 +341,8 @@ test_sanitize_block_erase(void)
|
|||||||
logging(LOG_VERBOSE, "BLOCK_ERASE parameter list length must be 0");
|
logging(LOG_VERBOSE, "BLOCK_ERASE parameter list length must be 0");
|
||||||
logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
|
logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
|
||||||
"BLOCK ERASE");
|
"BLOCK ERASE");
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 8, &data,
|
||||||
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 8, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
if (inq_bdc) {
|
if (inq_bdc) {
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ void test_sanitize_block_erase_reserved(void)
|
|||||||
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
|
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
|
||||||
"bit in byte 1 set to 1");
|
"bit in byte 1 set to 1");
|
||||||
change_num = 1;
|
change_num = 1;
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
|
||||||
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
|
logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
|
||||||
"implemented on target.");
|
"implemented on target.");
|
||||||
@@ -79,8 +79,8 @@ void test_sanitize_block_erase_reserved(void)
|
|||||||
"byte %d set to non-zero", i);
|
"byte %d set to non-zero", i);
|
||||||
change_num = i;
|
change_num = i;
|
||||||
|
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
|
||||||
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,8 +184,8 @@ test_sanitize_crypto_erase(void)
|
|||||||
|
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE");
|
logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE");
|
||||||
ret = sanitize(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
|
||||||
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
|
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
|
||||||
@@ -202,8 +202,8 @@ return;
|
|||||||
logging(LOG_VERBOSE, "CRYPTO_ERASE parameter list length must be 0");
|
logging(LOG_VERBOSE, "CRYPTO_ERASE parameter list length must be 0");
|
||||||
logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
|
logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
|
||||||
"CRYPTO ERASE");
|
"CRYPTO ERASE");
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 8, &data,
|
||||||
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 8, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
if (inq_bdc) {
|
if (inq_bdc) {
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ void test_sanitize_crypto_erase_reserved(void)
|
|||||||
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
|
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
|
||||||
"bit in byte 1 set to 1");
|
"bit in byte 1 set to 1");
|
||||||
change_num = 1;
|
change_num = 1;
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
|
||||||
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
|
logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
|
||||||
"implemented on target.");
|
"implemented on target.");
|
||||||
@@ -79,8 +79,8 @@ void test_sanitize_crypto_erase_reserved(void)
|
|||||||
"byte %d set to non-zero", i);
|
"byte %d set to non-zero", i);
|
||||||
change_num = i;
|
change_num = i;
|
||||||
|
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
|
||||||
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ test_sanitize_exit_failure_mode(void)
|
|||||||
"be 0");
|
"be 0");
|
||||||
logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
|
logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
|
||||||
"EXIT_FAILURE_MODE");
|
"EXIT_FAILURE_MODE");
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_EXIT_FAILURE_MODE, 8, &data,
|
||||||
0, 0, SCSI_SANITIZE_EXIT_FAILURE_MODE, 8, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ test_sanitize_invalid_serviceaction(void)
|
|||||||
logging(LOG_VERBOSE, "Verify that ServiceAction:0x%02d is "
|
logging(LOG_VERBOSE, "Verify that ServiceAction:0x%02d is "
|
||||||
"an error.", i);
|
"an error.", i);
|
||||||
|
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, i, 0, NULL,
|
||||||
0, 0, i, 0, NULL);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
|
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
|
||||||
"implemented.");
|
"implemented.");
|
||||||
|
|||||||
@@ -124,8 +124,8 @@ test_sanitize_overwrite(void)
|
|||||||
data.data[1] = 0x00;
|
data.data[1] = 0x00;
|
||||||
data.data[2] = block_size >> 8;
|
data.data[2] = block_size >> 8;
|
||||||
data.data[3] = block_size & 0xff;
|
data.data[3] = block_size & 0xff;
|
||||||
ret = sanitize(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
|
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
|
||||||
@@ -140,8 +140,8 @@ test_sanitize_overwrite(void)
|
|||||||
data.data[2] = (block_size / 2) >> 8;
|
data.data[2] = (block_size / 2) >> 8;
|
||||||
data.data[3] = (block_size / 2 ) & 0xff;
|
data.data[3] = (block_size / 2 ) & 0xff;
|
||||||
|
|
||||||
ret = sanitize(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
|
||||||
@@ -151,8 +151,8 @@ test_sanitize_overwrite(void)
|
|||||||
data.data[2] = 0;
|
data.data[2] = 0;
|
||||||
data.data[3] = 4;
|
data.data[3] = 4;
|
||||||
|
|
||||||
ret = sanitize(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
EXPECT_STATUS_GOOD);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "OVERWRITE parameter list length must "
|
logging(LOG_VERBOSE, "OVERWRITE parameter list length must "
|
||||||
@@ -161,8 +161,8 @@ test_sanitize_overwrite(void)
|
|||||||
logging(LOG_VERBOSE, "Test OVERWRITE with ParamLen:%d is an "
|
logging(LOG_VERBOSE, "Test OVERWRITE with ParamLen:%d is an "
|
||||||
"error.", i);
|
"error.", i);
|
||||||
|
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, i, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, i, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
|
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
|
||||||
"implemented.");
|
"implemented.");
|
||||||
@@ -180,8 +180,9 @@ test_sanitize_overwrite(void)
|
|||||||
data.size = block_size + 8;
|
data.size = block_size + 8;
|
||||||
data.data = alloca(block_size + 8); /* so we can send IP > blocksize */
|
data.data = alloca(block_size + 8); /* so we can send IP > blocksize */
|
||||||
memset(data.data, 0, data.size);
|
memset(data.data, 0, data.size);
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, block_size + 5, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, block_size + 5, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
|
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
|
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
|
||||||
"implemented.");
|
"implemented.");
|
||||||
@@ -199,8 +200,8 @@ test_sanitize_overwrite(void)
|
|||||||
data.data[1] = 0x00;
|
data.data[1] = 0x00;
|
||||||
data.data[2] = block_size >> 8;
|
data.data[2] = block_size >> 8;
|
||||||
data.data[3] = block_size & 0xff;
|
data.data[3] = block_size & 0xff;
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
|
||||||
@@ -212,8 +213,8 @@ test_sanitize_overwrite(void)
|
|||||||
data.data[1] = 0x00;
|
data.data[1] = 0x00;
|
||||||
data.data[2] = 0x00;
|
data.data[2] = 0x00;
|
||||||
data.data[3] = 0x00;
|
data.data[3] = 0x00;
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
|
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ test_sanitize_overwrite(void)
|
|||||||
data.data[1] = 0x00;
|
data.data[1] = 0x00;
|
||||||
data.data[2] = (block_size + 4) >> 8;
|
data.data[2] = (block_size + 4) >> 8;
|
||||||
data.data[3] = (block_size + 4) & 0xff;
|
data.data[3] = (block_size + 4) & 0xff;
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ void test_sanitize_overwrite_reserved(void)
|
|||||||
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
|
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
|
||||||
"bit in byte 1 set to 1");
|
"bit in byte 1 set to 1");
|
||||||
change_num = 1;
|
change_num = 1;
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
|
logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
|
||||||
"implemented on target.");
|
"implemented on target.");
|
||||||
@@ -89,8 +89,9 @@ void test_sanitize_overwrite_reserved(void)
|
|||||||
"byte %d set to non-zero", i);
|
"byte %d set to non-zero", i);
|
||||||
change_num = i;
|
change_num = i;
|
||||||
|
|
||||||
ret = sanitize_invalidfieldincdb(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
&data,
|
||||||
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,8 +89,9 @@ test_sanitize_readonly(void)
|
|||||||
data.data[1] = 0x00;
|
data.data[1] = 0x00;
|
||||||
data.data[2] = block_size >> 8;
|
data.data[2] = block_size >> 8;
|
||||||
data.data[3] = block_size & 0xff;
|
data.data[3] = block_size & 0xff;
|
||||||
ret = sanitize_writeprotected(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size,
|
||||||
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data);
|
&data,
|
||||||
|
EXPECT_WRITE_PROTECTED);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,8 +105,8 @@ test_sanitize_readonly(void)
|
|||||||
"implemented according to REPORT_SUPPORTED_OPCODES.");
|
"implemented according to REPORT_SUPPORTED_OPCODES.");
|
||||||
} else {
|
} else {
|
||||||
logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE");
|
logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE");
|
||||||
ret = sanitize_writeprotected(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
|
||||||
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL);
|
EXPECT_WRITE_PROTECTED);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,8 +119,8 @@ test_sanitize_readonly(void)
|
|||||||
"implemented according to REPORT_SUPPORTED_OPCODES.");
|
"implemented according to REPORT_SUPPORTED_OPCODES.");
|
||||||
} else {
|
} else {
|
||||||
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE");
|
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE");
|
||||||
ret = sanitize_writeprotected(sd,
|
ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
|
||||||
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL);
|
EXPECT_WRITE_PROTECTED);
|
||||||
CU_ASSERT_EQUAL(ret, 0);
|
CU_ASSERT_EQUAL(ret, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user