diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index ed73fe7..eecc840 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -209,6 +209,20 @@ do { \ CU_ASSERT_EQUAL(_r, 0); \ } while (0); +#define ORWRITE(...) \ + do { \ + int _r; \ + _r = orwrite(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] ORWRITE " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "ORWRITE. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + #define RECEIVE_COPY_RESULTS(...) \ do { \ int _r; \ diff --git a/test-tool/test_orwrite_0blocks.c b/test-tool/test_orwrite_0blocks.c index 43fe9cc..cc53387 100644 --- a/test-tool/test_orwrite_0blocks.c +++ b/test-tool/test_orwrite_0blocks.c @@ -27,40 +27,23 @@ void test_orwrite_0blocks(void) { - int ret; - CHECK_FOR_DATALOSS; CHECK_FOR_SBC; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==0"); - ret = orwrite(sd, 0, - 0, block_size, 0, 0, 0, 0, 0, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); - CU_PASS("ORWRITE is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 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"); - ret = orwrite(sd, num_blocks + 1, - 0, block_size, 0, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + 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"); - ret = orwrite(sd, 0x8000000000000000ULL, - 0, block_size, 0, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); - + 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"); - ret = orwrite(sd, -1, - 0, block_size, 0, 0, 0, 0, 0, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + 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 ed5e121..92d0168 100644 --- a/test-tool/test_orwrite_beyond_eol.c +++ b/test-tool/test_orwrite_beyond_eol.c @@ -29,7 +29,7 @@ void test_orwrite_beyond_eol(void) { - int i, ret; + int i; CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -41,15 +41,9 @@ test_orwrite_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = orwrite(sd, num_blocks + 1 - i, - i * block_size, block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); - CU_PASS("ORWRITE is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + ORWRITE(sd, num_blocks + 1 - i, + i * block_size, block_size, 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } @@ -58,11 +52,9 @@ test_orwrite_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = orwrite(sd, 0x8000000000000000ULL, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + ORWRITE(sd, 0x8000000000000000ULL, i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } @@ -71,11 +63,9 @@ test_orwrite_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = orwrite(sd, -1, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + ORWRITE(sd, -1, i * block_size, block_size, + 0, 0, 0, 0, 0, scratch, + EXPECT_LBA_OOB); } @@ -84,10 +74,8 @@ test_orwrite_beyond_eol(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = orwrite(sd, num_blocks - 1, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + 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 fc48753..af7febe 100644 --- a/test-tool/test_orwrite_dpofua.c +++ b/test-tool/test_orwrite_dpofua.c @@ -62,51 +62,29 @@ test_orwrite_dpofua(void) logging(LOG_VERBOSE, "Test ORWRITE with DPO==1"); memset(scratch, 0xa6, block_size); if (dpofua) { - ret = orwrite(sd, 0, block_size, - block_size, 0, 1, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); - CU_PASS("ORWRITE is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + ORWRITE(sd, 0, block_size, block_size, 0, 1, 0, 0, 0, scratch, + EXPECT_STATUS_GOOD); } else { - ret = orwrite(sd, 0, block_size, - block_size, 0, 1, 0, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); - CU_PASS("ORWRITE is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + 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) { - ret = orwrite(sd, 0, block_size, - block_size, 0, 0, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + ORWRITE(sd, 0, block_size, block_size, 0, 0, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); } else { - ret = orwrite(sd, 0, block_size, - block_size, 0, 0, 1, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - CU_ASSERT_EQUAL(ret, 0); + 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) { - ret = orwrite(sd, 0, block_size, - block_size, 0, 1, 1, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + ORWRITE(sd, 0, block_size, block_size, 0, 1, 1, 0, 0, scratch, + EXPECT_STATUS_GOOD); } else { - ret = orwrite(sd, 0, block_size, - block_size, 0, 1, 1, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - CU_ASSERT_EQUAL(ret, 0); + 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 " diff --git a/test-tool/test_orwrite_simple.c b/test-tool/test_orwrite_simple.c index 838bb25..d29bea4 100644 --- a/test-tool/test_orwrite_simple.c +++ b/test-tool/test_orwrite_simple.c @@ -30,7 +30,7 @@ void test_orwrite_simple(void) { - int i, ret; + int i; CHECK_FOR_DATALOSS; CHECK_FOR_SBC; @@ -42,15 +42,9 @@ test_orwrite_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = orwrite(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); - CU_PASS("ORWRITE is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + 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"); @@ -58,11 +52,8 @@ test_orwrite_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - ret = orwrite(sd, num_blocks - i, - i * block_size, block_size, - 0, 0, 0, 0, 0, scratch, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + 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 9216d31..434be38 100644 --- a/test-tool/test_orwrite_verify.c +++ b/test-tool/test_orwrite_verify.c @@ -55,15 +55,9 @@ test_orwrite_verify(void) logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i); memset(buf, 0xa5, block_size * i); - ret = orwrite(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); - CU_PASS("ORWRITE is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + 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); ret = read10(sd, NULL, 0, i * block_size, @@ -77,10 +71,9 @@ test_orwrite_verify(void) logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i); memset(buf, 0x5a, block_size * i); - ret = orwrite(sd, 0, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + 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, @@ -107,10 +100,9 @@ test_orwrite_verify(void) logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i); memset(buf, 0xa5, block_size * i); - ret = orwrite(sd, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + 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); ret = read16(sd, NULL, num_blocks - i, i * block_size, @@ -124,10 +116,9 @@ test_orwrite_verify(void) logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i); memset(buf, 0x5a, block_size * i); - ret = orwrite(sd, num_blocks - i, i * block_size, - block_size, 0, 0, 0, 0, 0, buf, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + 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); ret = read16(sd, NULL, num_blocks - i, i * block_size, diff --git a/test-tool/test_orwrite_wrprotect.c b/test-tool/test_orwrite_wrprotect.c index f3f9632..9183036 100644 --- a/test-tool/test_orwrite_wrprotect.c +++ b/test-tool/test_orwrite_wrprotect.c @@ -30,7 +30,7 @@ void test_orwrite_wrprotect(void) { - int i, ret; + int i; /* * Try out different non-zero values for WRPROTECT. @@ -45,16 +45,9 @@ test_orwrite_wrprotect(void) 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++) { - ret = orwrite(sd, 0, block_size, - block_size, i, 0, 0, 0, 0, scratch, - EXPECT_INVALID_FIELD_IN_CDB); - - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); - CU_PASS("ORWRITE is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + ORWRITE(sd, 0, block_size, + block_size, i, 0, 0, 0, 0, scratch, + EXPECT_INVALID_FIELD_IN_CDB); } return; }