From 9d7103e5ac58f8ad4fed70004bc55ca83c72c0d4 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 21 Feb 2016 11:14:39 -0800 Subject: [PATCH] Tests: helpers for READ6 Signed-off-by: Ronnie Sahlberg --- test-tool/iscsi-support.h | 14 ++++++++++++++ test-tool/test_read6_beyond_eol.c | 29 +++++++++-------------------- test-tool/test_read6_simple.c | 31 +++++++++---------------------- 3 files changed, 32 insertions(+), 42 deletions(-) diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 35eca74..a85236c 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -223,6 +223,20 @@ do { \ CU_ASSERT_EQUAL(_r, 0); \ } while (0); +#define READ6(...) \ + do { \ + int _r; \ + _r = read6(__VA_ARGS__); \ + if (_r == -2) { \ + logging(LOG_NORMAL, "[SKIPPED] READ6 " \ + "is not implemented."); \ + CU_PASS("[SKIPPED] Target does not support " \ + "READ6. Skipping test"); \ + return; \ + } \ + CU_ASSERT_EQUAL(_r, 0); \ + } while (0); + #define READ10(...) \ do { \ int _r; \ diff --git a/test-tool/test_read6_beyond_eol.c b/test-tool/test_read6_beyond_eol.c index 050e36b..6747057 100644 --- a/test-tool/test_read6_beyond_eol.c +++ b/test-tool/test_read6_beyond_eol.c @@ -28,35 +28,25 @@ void test_read6_beyond_eol(void) { - int i, ret; + int i; 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++) { - ret = read6(sd, NULL, num_blocks + 1 - i, - i * block_size, block_size, NULL, - EXPECT_LBA_OOB); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented."); - CU_PASS("READ6 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + 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++) { - ret = read6(sd, NULL, 0x1fffff, - i * block_size, block_size, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + READ6(sd, NULL, 0x1fffff, i * block_size, block_size, NULL, + EXPECT_LBA_OOB); } if (num_blocks == 0) { @@ -66,9 +56,8 @@ test_read6_beyond_eol(void) logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end"); for (i = 2; i <= 255; i++) { - ret = read6(sd, NULL, num_blocks - 1, - i * block_size, block_size, NULL, - EXPECT_LBA_OOB); - CU_ASSERT_EQUAL(ret, 0); + 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 1fffad6..9cb09da 100644 --- a/test-tool/test_read6_simple.c +++ b/test-tool/test_read6_simple.c @@ -29,8 +29,7 @@ void test_read6_simple(void) { - int i, ret; - + int i; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN"); @@ -38,19 +37,10 @@ test_read6_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = read6(sd, NULL, 0, i * block_size, - block_size, NULL, - EXPECT_STATUS_GOOD); - if (ret == -2) { - logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented."); - CU_PASS("READ6 is not implemented."); - return; - } - CU_ASSERT_EQUAL(ret, 0); + 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"); @@ -59,22 +49,19 @@ test_read6_simple(void) if (maximum_transfer_length && maximum_transfer_length < i) { break; } - - ret = read6(sd, NULL, num_blocks - i, - i * block_size, block_size, NULL, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); + 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"); - ret = read6(sd, &task, 0, - 256 * block_size, block_size, NULL, - EXPECT_STATUS_GOOD); + 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 );