From 08ed1c2aea48b9909a1d27498d03b304ec9d4637 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sat, 8 Jun 2013 11:09:36 +0200 Subject: [PATCH] Add two additional READ16-beyond-eol tests This helps testing SCSI target implementations that represent the byte offset from the start of the device as a signed or unsigned 64-bit integer. Signed-off-by: Bart Van Assche --- test-tool/test_read16_beyond_eol.c | 41 ++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test-tool/test_read16_beyond_eol.c b/test-tool/test_read16_beyond_eol.c index c8f30be..4a910bb 100644 --- a/test-tool/test_read16_beyond_eol.c +++ b/test-tool/test_read16_beyond_eol.c @@ -24,6 +24,17 @@ #include "iscsi-test-cu.h" +static int ilog2(size_t i) +{ + int j = -1; + + while (i) { + i >>= 1; + j++; + } + return j; +} + void test_read16_beyond_eol(void) { @@ -63,6 +74,36 @@ test_read16_beyond_eol(void) } + 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; + } + + ret = read16_lbaoutofrange(iscsic, tgt_lun, + 1ULL << (64 - ilog2(block_size)), + i * block_size, block_size, + 0, 0, 0, 0, 0, NULL); + CU_ASSERT_EQUAL(ret, 0); + } + + + 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; + } + + ret = read16_lbaoutofrange(iscsic, tgt_lun, + 1ULL << (63 - ilog2(block_size)), + i * block_size, block_size, + 0, 0, 0, 0, 0, NULL); + CU_ASSERT_EQUAL(ret, 0); + } + + 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) {