From 4d1e3aecd022dbdc906b05ae99a7621eefa5d80e Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 21 Feb 2016 08:30:37 -0800 Subject: [PATCH] Tests: add helper macro for REPORT_SUPPORTED_OPCODES Signed-off-by: Ronnie Sahlberg --- test-tool/iscsi-support.h | 15 ++ test-tool/test_compareandwrite_dpofua.c | 63 ++++---- test-tool/test_orwrite_dpofua.c | 63 ++++---- test-tool/test_read10_dpofua.c | 63 ++++---- test-tool/test_read12_dpofua.c | 63 ++++---- test-tool/test_read16_dpofua.c | 63 ++++---- ...est_report_supported_opcodes_one_command.c | 140 +++++------------- .../test_report_supported_opcodes_rctd.c | 44 ++---- .../test_report_supported_opcodes_servactv.c | 32 +--- .../test_report_supported_opcodes_simple.c | 18 +-- test-tool/test_verify10_dpo.c | 20 +-- test-tool/test_verify12_dpo.c | 20 +-- test-tool/test_verify16_dpo.c | 21 +-- test-tool/test_write10_dpofua.c | 64 ++++---- test-tool/test_write12_dpofua.c | 64 ++++---- test-tool/test_write16_dpofua.c | 64 ++++---- test-tool/test_writeatomic16_dpofua.c | 64 ++++---- test-tool/test_writeverify10_dpo.c | 22 ++- test-tool/test_writeverify12_dpo.c | 21 +-- test-tool/test_writeverify16_dpo.c | 23 ++- 20 files changed, 360 insertions(+), 587 deletions(-) diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 7f5e3d8..56748e3 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -195,6 +195,21 @@ do { \ CU_ASSERT_EQUAL(_r, 0); \ } while (0); +#define REPORT_SUPPORTED_OPCODES(...) \ + do { \ + int _r; \ + _r = report_supported_opcodes(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] REPORT_SUPPORTED" \ + "_OPCODES is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "REPORT_SUPPORTED_OPCODES. Skipping " \ + "test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + #define VERIFY10(...) \ do { \ int _r; \ diff --git a/test-tool/test_compareandwrite_dpofua.c b/test-tool/test_compareandwrite_dpofua.c index 4fb6f5c..428dff3 100644 --- a/test-tool/test_compareandwrite_dpofua.c +++ b/test-tool/test_compareandwrite_dpofua.c @@ -104,45 +104,34 @@ test_compareandwrite_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for COMPAREANDWRITE"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_COMPARE_AND_WRITE, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_orwrite_dpofua.c b/test-tool/test_orwrite_dpofua.c index 9a9a5dd..fc48753 100644 --- a/test-tool/test_orwrite_dpofua.c +++ b/test-tool/test_orwrite_dpofua.c @@ -111,45 +111,34 @@ test_orwrite_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for ORWRITE"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_ORWRITE, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_read10_dpofua.c b/test-tool/test_read10_dpofua.c index 79f10ab..5bbb605 100644 --- a/test-tool/test_read10_dpofua.c +++ b/test-tool/test_read10_dpofua.c @@ -100,45 +100,34 @@ test_read10_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for READ10"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_READ10, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_read12_dpofua.c b/test-tool/test_read12_dpofua.c index f114dfc..adde535 100644 --- a/test-tool/test_read12_dpofua.c +++ b/test-tool/test_read12_dpofua.c @@ -99,45 +99,34 @@ test_read12_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for READ12"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_READ12, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_read16_dpofua.c b/test-tool/test_read16_dpofua.c index f15d064..25353bb 100644 --- a/test-tool/test_read16_dpofua.c +++ b/test-tool/test_read16_dpofua.c @@ -100,45 +100,34 @@ test_read16_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for READ16"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_READ16, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_report_supported_opcodes_one_command.c b/test-tool/test_report_supported_opcodes_one_command.c index 156f1c2..889e01b 100644 --- a/test-tool/test_report_supported_opcodes_one_command.c +++ b/test-tool/test_report_supported_opcodes_one_command.c @@ -29,7 +29,7 @@ void test_report_supported_opcodes_one_command(void) { - int i, ret; + int i; struct scsi_task *rso_task; struct scsi_task *one_task; struct scsi_report_supported_op_codes *rsoc; @@ -38,32 +38,15 @@ test_report_supported_opcodes_one_command(void) 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"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPS_ALL, - 0, 0, 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " - "implemented."); - CU_PASS("READ_SUPPORTED_OPCODES is not implemented."); - goto out; - } - CU_ASSERT_EQUAL(ret, 0); - if (ret != 0) - goto out; + 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_NOT_EQUAL(rsoc, NULL); - if (!rsoc) { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - goto out; - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); logging(LOG_VERBOSE, "Verify read one-command works for all supported " "opcodes"); @@ -74,86 +57,43 @@ test_report_supported_opcodes_one_command(void) if (rsoc->descriptors[i].servactv) { logging(LOG_VERBOSE, "This opcode has service actions. " "Reporting Options 001b should fail"); - ret = report_supported_opcodes(sd, NULL, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - rsoc->descriptors[i].opcode, - rsoc->descriptors[i].sa, - 65535, - EXPECT_INVALID_FIELD_IN_CDB); + 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"); - ret = report_supported_opcodes( - sd, NULL, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - rsoc->descriptors[i].opcode, - rsoc->descriptors[i].sa, - 65535, - EXPECT_STATUS_GOOD); - } - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] SCSI_REPORT_SUPPORTING_OPCODE is not " - "implemented."); - CU_PASS("SCSI_REPORT_SUPPORTING_OPCODE is not implemented."); - } else { - CU_ASSERT_EQUAL(ret, 0); - } - if (ret != 0 && ret != -2) { - if (rsoc->descriptors[i].servactv) - logging(LOG_NORMAL, "[FAILED] Opcode" - " %#02x/%#02x: got unexpected response" - " for reporting option 001b", - rsoc->descriptors[i].opcode, - rsoc->descriptors[i].sa); - else - logging(LOG_NORMAL, "[FAILED] Opcode %#02x: got" - " unexpected response for reporting" - " option 001b", - rsoc->descriptors[i].opcode); + 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"); - ret = report_supported_opcodes( - sd, NULL, - 0, SCSI_REPORT_SUPPORTING_SERVICEACTION, - rsoc->descriptors[i].opcode, - rsoc->descriptors[i].sa, - 65535, - EXPECT_STATUS_GOOD); + 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"); - ret = report_supported_opcodes( - sd, NULL, - 0, SCSI_REPORT_SUPPORTING_SERVICEACTION, - rsoc->descriptors[i].opcode, - rsoc->descriptors[i].sa, - 65535, - EXPECT_INVALID_FIELD_IN_CDB); - } - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] SCSI_REPORT_SUPPORTING_SERVICEACTION is not " - "implemented."); - CU_PASS("SCSI_REPORT_SUPPORTING_SERVICEACTION is not implemented."); - } else { - CU_ASSERT_EQUAL(ret, 0); - } - if (ret != 0 && ret != -2) { - if (rsoc->descriptors[i].servactv) - logging(LOG_NORMAL, "[FAILED] Opcode" - " %#02x/%#02x: got unexpected response" - " for reporting option 002b", - rsoc->descriptors[i].opcode, - rsoc->descriptors[i].sa); - else - logging(LOG_NORMAL, "[FAILED] Opcode %#02x: got" - " unexpected response for reporting" - " option 002b", - rsoc->descriptors[i].opcode); + REPORT_SUPPORTED_OPCODES(sd, NULL, 0, + SCSI_REPORT_SUPPORTING_SERVICEACTION, + rsoc->descriptors[i].opcode, + rsoc->descriptors[i].sa, + 65535, + EXPECT_INVALID_FIELD_IN_CDB); } } @@ -164,19 +104,18 @@ test_report_supported_opcodes_one_command(void) "ServiceAction:0x%02x", rsoc->descriptors[i].opcode, rsoc->descriptors[i].sa); - ret = report_supported_opcodes( - sd, &one_task, 0, - rsoc->descriptors[i].servactv ? - SCSI_REPORT_SUPPORTING_SERVICEACTION : - SCSI_REPORT_SUPPORTING_OPCODE, - rsoc->descriptors[i].opcode, - rsoc->descriptors[i].sa, - 65535, - EXPECT_STATUS_GOOD); + REPORT_SUPPORTED_OPCODES(sd, &one_task, 0, + rsoc->descriptors[i].servactv ? + SCSI_REPORT_SUPPORTING_SERVICEACTION : + SCSI_REPORT_SUPPORTING_OPCODE, + rsoc->descriptors[i].opcode, + rsoc->descriptors[i].sa, + 65535, + EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer"); rsoc_one = scsi_datain_unmarshall(one_task); - CU_ASSERT_NOT_EQUAL(rsoc_one, NULL); + 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); @@ -198,6 +137,5 @@ test_report_supported_opcodes_one_command(void) scsi_free_scsi_task(one_task); } -out: 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 554ae66..5c3acc7 100644 --- a/test-tool/test_report_supported_opcodes_rctd.c +++ b/test-tool/test_report_supported_opcodes_rctd.c @@ -29,41 +29,23 @@ void test_report_supported_opcodes_rctd(void) { - int i, ret; + 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, "Test READ_SUPPORTED_OPCODES report ALL opcodes " "without timeout descriptors. RCTD==0"); - ret = report_supported_opcodes( - sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " - "implemented."); - CU_PASS("READ_SUPPORTED_OPCODES is not implemented."); - goto out; - } - CU_ASSERT_EQUAL(ret, 0); - if (ret != 0) - goto out; + 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_NOT_EQUAL(rsoc, NULL); - if (!rsoc) { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - goto out; - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); logging(LOG_VERBOSE, "Verify that all returned command descriptors " "lack timeout description"); @@ -75,20 +57,15 @@ test_report_supported_opcodes_rctd(void) "CTDP set"); } } - scsi_free_scsi_task(rso_task); logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes " "with timeout descriptors. RCTD==1"); - ret = report_supported_opcodes( - sd, &rso_task, - 1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, - 65535, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); - if (ret != 0) - goto out; + 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); @@ -117,6 +94,5 @@ test_report_supported_opcodes_rctd(void) } } -out: 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 d6df1c4..8109e12 100644 --- a/test-tool/test_report_supported_opcodes_servactv.c +++ b/test-tool/test_report_supported_opcodes_servactv.c @@ -29,40 +29,21 @@ void test_report_supported_opcodes_servactv(void) { - int i, ret; + 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"); + REPORT_SUPPORTED_OPCODES(sd, &rso_task, + 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, + 65535, + EXPECT_STATUS_GOOD); - ret = report_supported_opcodes( - sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " - "implemented."); - CU_PASS("READ_SUPPORTED_OPCODES is not implemented."); - goto out; - } - CU_ASSERT_EQUAL(ret, 0); - if (ret != 0) - goto out; - logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer"); rsoc = scsi_datain_unmarshall(rso_task); - CU_ASSERT_NOT_EQUAL(rsoc, NULL); - if (!rsoc) { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - goto out; - } - + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); logging(LOG_VERBOSE, "Verify that when SERVACTV is clear then " "ServiceAction must be zero."); @@ -75,6 +56,5 @@ test_report_supported_opcodes_servactv(void) } } -out: 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 bd6f147..5fbe906 100644 --- a/test-tool/test_report_supported_opcodes_simple.c +++ b/test-tool/test_report_supported_opcodes_simple.c @@ -29,21 +29,11 @@ void test_report_supported_opcodes_simple(void) { - int ret; - logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test basic READ_SUPPORTED_OPCODES"); - ret = report_supported_opcodes( - sd, NULL, - 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, - 1024, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " - "implemented."); - CU_PASS("READ_SUPPORTED_OPCODES is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + REPORT_SUPPORTED_OPCODES(sd, NULL, + 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, + 1024, + EXPECT_STATUS_GOOD); } diff --git a/test-tool/test_verify10_dpo.c b/test-tool/test_verify10_dpo.c index 27b63c9..730de83 100644 --- a/test-tool/test_verify10_dpo.c +++ b/test-tool/test_verify10_dpo.c @@ -74,20 +74,15 @@ test_verify10_dpo(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for VERIFY10"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_VERIFY10, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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_NOT_EQUAL(rsoc, NULL); + 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 " @@ -99,6 +94,5 @@ test_verify10_dpo(void) CU_ASSERT_EQUAL(usage_data_dpo, 0x00); } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_verify12_dpo.c b/test-tool/test_verify12_dpo.c index b62766d..55e2666 100644 --- a/test-tool/test_verify12_dpo.c +++ b/test-tool/test_verify12_dpo.c @@ -74,20 +74,15 @@ test_verify12_dpo(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for VERIFY12"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_VERIFY12, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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_NOT_EQUAL(rsoc, NULL); + 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 " @@ -99,6 +94,5 @@ test_verify12_dpo(void) CU_ASSERT_EQUAL(usage_data_dpo, 0x00); } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_verify16_dpo.c b/test-tool/test_verify16_dpo.c index 8f0b32f..6fa5052 100644 --- a/test-tool/test_verify16_dpo.c +++ b/test-tool/test_verify16_dpo.c @@ -74,20 +74,16 @@ test_verify16_dpo(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for VERIFY16"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_VERIFY16, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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_NOT_EQUAL(rsoc, NULL); + 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 " @@ -99,6 +95,5 @@ test_verify16_dpo(void) CU_ASSERT_EQUAL(usage_data_dpo, 0x00); } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_write10_dpofua.c b/test-tool/test_write10_dpofua.c index 9d5a973..ce39ff5 100644 --- a/test-tool/test_write10_dpofua.c +++ b/test-tool/test_write10_dpofua.c @@ -91,45 +91,35 @@ test_write10_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for WRITE10"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_WRITE10, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_write12_dpofua.c b/test-tool/test_write12_dpofua.c index 0437dd9..44adb4f 100644 --- a/test-tool/test_write12_dpofua.c +++ b/test-tool/test_write12_dpofua.c @@ -90,45 +90,35 @@ test_write12_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for WRITE12"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_WRITE12, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_write16_dpofua.c b/test-tool/test_write16_dpofua.c index 026e577..bafc8aa 100644 --- a/test-tool/test_write16_dpofua.c +++ b/test-tool/test_write16_dpofua.c @@ -91,45 +91,35 @@ test_write16_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for WRITE16"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_WRITE16, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_writeatomic16_dpofua.c b/test-tool/test_writeatomic16_dpofua.c index 0a5b298..389f404 100644 --- a/test-tool/test_writeatomic16_dpofua.c +++ b/test-tool/test_writeatomic16_dpofua.c @@ -119,45 +119,35 @@ test_writeatomic16_dpofua(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for WRITEATOMIC16"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_WRITE_ATOMIC16, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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); - if (rsoc) { - usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; - if (dpofua) { - logging(LOG_VERBOSE, "DPOFUA is set. Verify the " - "DPO/FUA flags are set in the CDB_USAGE_DATA"); - if (!usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not set " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); - } - } else { - logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " - "DPO/FUA flags are clear in the CDB_USAGE_DATA"); - if (usage_data_dpofua) { - logging(LOG_NORMAL, "[FAILED] DpoFua not clear " - "in CDB_USAGE_DATE"); - CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); - } - } - } else { - logging(LOG_NORMAL, "[FAILED] Target did not return any data " - "for ReportSupportedOpcodes\n"); - CU_FAIL("Target did not return any data for " - "ReportSupportedOpcodes"); - } + CU_ASSERT_PTR_NOT_NULL_FATAL(rsoc); + + usage_data_dpofua = rsoc->cdb_usage_data[1] & 0x18; + if (dpofua) { + logging(LOG_VERBOSE, "DPOFUA is set. Verify the " + "DPO/FUA flags are set in the CDB_USAGE_DATA"); + if (!usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not set " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not set in CDB_USAGE_DATE"); + } + } else { + logging(LOG_VERBOSE, "DPOFUA is clear. Verify the " + "DPO/FUA flags are clear in the CDB_USAGE_DATA"); + if (usage_data_dpofua) { + logging(LOG_NORMAL, "[FAILED] DpoFua not clear " + "in CDB_USAGE_DATE"); + CU_FAIL("DpoFua not clear in CDB_USAGE_DATE"); + } + } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_writeverify10_dpo.c b/test-tool/test_writeverify10_dpo.c index ec59793..2ba5b26 100644 --- a/test-tool/test_writeverify10_dpo.c +++ b/test-tool/test_writeverify10_dpo.c @@ -76,20 +76,17 @@ test_writeverify10_dpo(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for WRITEVERIFY10"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_WRITE_VERIFY10, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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_NOT_EQUAL(rsoc, NULL); + 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 " @@ -101,6 +98,5 @@ test_writeverify10_dpo(void) CU_ASSERT_EQUAL(usage_data_dpo, 0x00); } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_writeverify12_dpo.c b/test-tool/test_writeverify12_dpo.c index c84dd60..2d4e1ee 100644 --- a/test-tool/test_writeverify12_dpo.c +++ b/test-tool/test_writeverify12_dpo.c @@ -76,20 +76,16 @@ test_writeverify12_dpo(void) logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for WRITEVERIFY12"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_WRITE_VERIFY12, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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_NOT_EQUAL(rsoc, NULL); + 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 " @@ -101,6 +97,5 @@ test_writeverify12_dpo(void) CU_ASSERT_EQUAL(usage_data_dpo, 0x00); } -out: scsi_free_scsi_task(rso_task); } diff --git a/test-tool/test_writeverify16_dpo.c b/test-tool/test_writeverify16_dpo.c index 08a4721..2f9ec39 100644 --- a/test-tool/test_writeverify16_dpo.c +++ b/test-tool/test_writeverify16_dpo.c @@ -75,23 +75,19 @@ test_writeverify16_dpo(void) EXPECT_INVALID_FIELD_IN_CDB); } - logging(LOG_VERBOSE, "Try fetching REPORT_SUPPORTED_OPCODES " "for WRITEVERIFY16"); - ret = report_supported_opcodes(sd, &rso_task, - 0, SCSI_REPORT_SUPPORTING_OPCODE, - SCSI_OPCODE_WRITE_VERIFY16, - 0, - 65535, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "REPORT_SUPPORTED_OPCODES not implemented. " - "Skipping this part of the test"); - goto out; - } + 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_NOT_EQUAL(rsoc, NULL); + 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 " @@ -103,6 +99,5 @@ test_writeverify16_dpo(void) CU_ASSERT_EQUAL(usage_data_dpo, 0x00); } -out: scsi_free_scsi_task(rso_task); }