From ff61508aa7b635e0ccb50b6c073e4ab8d477e15c Mon Sep 17 00:00:00 2001 From: Chris Zankel Date: Wed, 22 Apr 2015 17:07:37 -0700 Subject: [PATCH 1/6] gitignore: exclude test/Makefile and test/Makefile.in Signed-off-by: Chris Zankel --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index a34f892..28a1522 100644 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,8 @@ TAGS /test-tool/Makefile.in /test-tool/Makefile /test-tool/iscsi-test-cu +/tests/Makefile.in +/tests/Makefile /utils/Makefile.in /utils/Makefile /utils/iscsi-inq From e1861690640e184d380a552356f74c7534285c41 Mon Sep 17 00:00:00 2001 From: Chris Zankel Date: Wed, 22 Apr 2015 17:08:04 -0700 Subject: [PATCH 2/6] build: fix 'out-of-tree' build Prefix include paths with '${srcdir}' to allow 'out-of-tree' builds: cd $BUILD $LIBISCSI/configure make Signed-off-by: Chris Zankel --- examples/Makefile.am | 2 +- lib/Makefile.am | 4 ++-- test-tool/Makefile.am | 3 ++- utils/Makefile.am | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index ecf049d..42ad818 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS=-I. -I../include "-D_U_=__attribute__((unused))" \ +AM_CPPFLAGS=-I. -I${srcdir}/../include "-D_U_=__attribute__((unused))" \ "-D_R_(A,B)=__attribute__((format(printf,A,B)))" AM_CFLAGS=$(WARN_CFLAGS) LDADD = ../lib/libiscsi.la diff --git a/lib/Makefile.am b/lib/Makefile.am index 039e3e2..e7aeb75 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -15,9 +15,9 @@ SOREVISON=0 SOAGE=1 libiscsi_la_LDFLAGS = \ -version-info $(SOCURRENT):$(SOREVISON):$(SOAGE) -bindir $(bindir) \ - -no-undefined -export-symbols libiscsi.syms + -no-undefined -export-symbols ${srcdir}/libiscsi.syms -libiscsi_la_CPPFLAGS = -I../include -I$(srcdir)/include \ +libiscsi_la_CPPFLAGS = -I${srcdir}/../include -I$(srcdir)/include \ "-D_U_=__attribute__((unused))" \ "-D_R_(A,B)=__attribute__((format(printf,A,B)))" diff --git a/test-tool/Makefile.am b/test-tool/Makefile.am index 53740b2..f062c21 100644 --- a/test-tool/Makefile.am +++ b/test-tool/Makefile.am @@ -1,4 +1,5 @@ -AM_CPPFLAGS=-I. -I../include "-D_U_=__attribute__((unused))" \ +AM_CPPFLAGS=-I. -I${srcdir}/../include \ + "-D_U_=__attribute__((unused)) " \ "-D_R_(A,B)=__attribute__((format(printf,A,B)))" AM_CFLAGS=$(WARN_CFLAGS) LDADD = ../lib/libiscsi.la diff --git a/utils/Makefile.am b/utils/Makefile.am index 6624880..bde1c81 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -1,4 +1,4 @@ -AM_CPPFLAGS = -I../include "-D_U_=__attribute__((unused))" \ +AM_CPPFLAGS = -I${srcdir}/../include "-D_U_=__attribute__((unused))" \ "-D_R_(A,B)=__attribute__((format(printf,A,B)))" AM_CFLAGS = $(WARN_CFLAGS) LDADD = ../lib/libiscsi.la From 9068f23f9540093663b9c7afd5543154787926cd Mon Sep 17 00:00:00 2001 From: Chris Zankel Date: Wed, 22 Apr 2015 17:55:36 -0700 Subject: [PATCH 3/6] test-tool: print (logging) the actual sense code if mismatch Print (log) the actual sense code that was returned if it doesn't match the expected value. Signed-off-by: Chris Zankel --- test-tool/iscsi-support.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 54f788a..1421518 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -196,13 +196,14 @@ static int check_result(const char *opcode, struct scsi_device *sdev, || task->sense.key != key || !ascq_ok)) { logging(LOG_NORMAL, "[FAILED] %s failed with wrong sense. " - "Should have failed with %s(0x%02x)/%s(0x%04x)" - "but failed with Sense:%s\n", + "Should have failed with %s(0x%02x)/%s(0x%04x) " + "but failed with Sense: %s(0x%02x)/(0x%04x)\n", opcode, scsi_sense_key_str(key), key, num_ascq ? scsi_sense_ascq_str(ascq[0]) : "NO ASCQ", num_ascq ? ascq[0] : 0, - sdev->error_str); + sdev->error_str, + task->sense.key, task->sense.ascq); return -1; } logging(LOG_VERBOSE, "[OK] %s returned %s %s(0x%02x) %s(0x%04x)", From fff67ba7dd5978ae12d068b807e9d69d300eb761 Mon Sep 17 00:00:00 2001 From: Chris Zankel Date: Wed, 22 Apr 2015 18:05:13 -0700 Subject: [PATCH 4/6] test_writesame*_0blocks: skip 0-block test if unsupported Skip 0-block WRITE SAME tests for targets that don't support these operations, ie. they have write_same_no_zero (WSNZ) set in the block limits vpd. Also, fix the test: "Test WRITESAME10 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0" to actually pass 0 blocks instead of the number of remaining blocks to the end. Signed-off-by: Chris Zankel --- test-tool/test_writesame10_0blocks.c | 16 +++++++++----- test-tool/test_writesame10_unmap_until_end.c | 8 ++++++- test-tool/test_writesame16_0blocks.c | 22 +++++++++++++------- test-tool/test_writesame16_unmap_until_end.c | 6 ++++++ 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/test-tool/test_writesame10_0blocks.c b/test-tool/test_writesame10_0blocks.c index 4bcd001..b14e2bd 100644 --- a/test-tool/test_writesame10_0blocks.c +++ b/test-tool/test_writesame10_0blocks.c @@ -41,6 +41,16 @@ test_writesame10_0blocks(void) logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks at LBA==0 (WSNZ=%d)", inq_bl->wsnz); memset(buf, 0, block_size); + + if (inq_bl->wsnz) { + ret = writesame10(sd, 0, + block_size, 0, 0, 0, 0, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); + logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 does not support 0-blocks."); + CU_ASSERT_EQUAL(ret, 0); + return; + } + ret = writesame10(sd, 0, block_size, 0, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD); @@ -52,11 +62,7 @@ test_writesame10_0blocks(void) } else if (ret == -4) { CU_PASS("[SKIPPED] Number of WRITESAME10 logical blocks to be written exceeds MAXIMUM WRITE SAME LENGTH"); } else { - if (inq_bl->wsnz) { - CU_ASSERT_EQUAL(ret, -1); - } else { - CU_ASSERT_EQUAL(ret, 0); - } + CU_ASSERT_EQUAL(ret, 0); } logging(LOG_VERBOSE, "Test WRITESAME10 0-blocks one block past end-of-LUN"); diff --git a/test-tool/test_writesame10_unmap_until_end.c b/test-tool/test_writesame10_unmap_until_end.c index 6b9bfdd..7e60cac 100644 --- a/test-tool/test_writesame10_unmap_until_end.c +++ b/test-tool/test_writesame10_unmap_until_end.c @@ -40,6 +40,12 @@ test_writesame10_unmap_until_end(void) zeroBlock = alloca(block_size); memset(zeroBlock, 0, block_size); + if (inq_bl->wsnz) { + logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks."); + CU_PASS("[SKIPPED] WRITESAME10 does not support 0-blocks."); + return; + } + logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test WRITESAME10 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0"); for (i = 1; i <= 256; i++) { @@ -54,7 +60,7 @@ test_writesame10_unmap_until_end(void) logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME10", i); ret = writesame10(sd, num_blocks - i, - block_size, i, 0, 1, 0, 0, buf, + block_size, 0, 0, 1, 0, 0, buf, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); diff --git a/test-tool/test_writesame16_0blocks.c b/test-tool/test_writesame16_0blocks.c index b9091c4..41f4d68 100644 --- a/test-tool/test_writesame16_0blocks.c +++ b/test-tool/test_writesame16_0blocks.c @@ -36,6 +36,16 @@ test_writesame16_0blocks(void) logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==0 (WSNZ=%d)", inq_bl->wsnz); memset(buf, 0, block_size); + + if (inq_bl->wsnz) { + ret = writesame16(sd, 0, + block_size, 0, 0, 0, 0, 0, buf, + EXPECT_INVALID_FIELD_IN_CDB); + logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 does not support 0-blocks."); + CU_ASSERT_EQUAL(ret, 0); + return; + } + ret = writesame16(sd, 0, block_size, 0, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD); @@ -48,30 +58,26 @@ test_writesame16_0blocks(void) } else if (ret == -4) { CU_PASS("[SKIPPED] Number of WRITESAME16 logical blocks to be written exceeds MAXIMUM WRITE SAME LENGTH"); } else { - if (inq_bl->wsnz) { - CU_ASSERT_EQUAL(ret, -1); - } else { - CU_ASSERT_EQUAL(ret, 0); - } + CU_ASSERT_EQUAL(ret, 0); } logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks one block past end-of-LUN"); ret = writesame16(sd, num_blocks + 1, - block_size, inq_bl->wsnz, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, buf, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==2^63"); ret = writesame16(sd, 0x8000000000000000ULL, - block_size, inq_bl->wsnz, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, buf, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); logging(LOG_VERBOSE, "Test WRITESAME16 0-blocks at LBA==-1"); ret = writesame16(sd, -1, - block_size, inq_bl->wsnz, 0, 0, 0, 0, buf, + block_size, 0, 0, 0, 0, 0, buf, EXPECT_LBA_OOB); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_writesame16_unmap_until_end.c b/test-tool/test_writesame16_unmap_until_end.c index a24b59f..be2d187 100644 --- a/test-tool/test_writesame16_unmap_until_end.c +++ b/test-tool/test_writesame16_unmap_until_end.c @@ -39,6 +39,12 @@ test_writesame16_unmap_until_end(void) CHECK_FOR_LBPWS; CHECK_FOR_SBC; + if (inq_bl->wsnz) { + logging(LOG_NORMAL, "[SKIPPED] WRITESAME10 does not support 0-blocks."); + CU_PASS("[SKIPPED] WRITESAME10 does not support 0-blocks."); + return; + } + zeroBlock = alloca(block_size); memset(zeroBlock, 0, block_size); From de512a58882001226272d6c7a0d28221c2d805db Mon Sep 17 00:00:00 2001 From: Chris Zankel Date: Wed, 22 Apr 2015 18:01:00 -0700 Subject: [PATCH 5/6] test_unmap_0blocks: skip multi-descriptor test if unsupported Some targets only support a single descriptor for unmap operations, so skip (CU_PASS) the test cases that use multiple descriptors in those cases. Only run the tests if maximum_unmap_block_descriptor_count is less than 2. Also the test "Test UNMAP of 0 blocks at LBA:0-255 with one descriptor per block") was passing one less descriptor. Signed-off-by: Chris Zankel --- test-tool/test_unmap_0blocks.c | 35 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/test-tool/test_unmap_0blocks.c b/test-tool/test_unmap_0blocks.c index 063b798..76a7387 100644 --- a/test-tool/test_unmap_0blocks.c +++ b/test-tool/test_unmap_0blocks.c @@ -45,15 +45,6 @@ test_unmap_0blocks(void) CU_ASSERT_EQUAL(ret, 0); } - logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 with one descriptor per block"); - for (i = 0; i < 256; i++) { - list[i].lba = i; - list[i].num = 0; - ret = unmap(sd, 0, list, i, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); - } - logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at end-of-LUN"); list[0].lba = num_blocks; list[0].num = 0; @@ -61,6 +52,25 @@ test_unmap_0blocks(void) EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); + logging(LOG_VERBOSE, "Test UNMAP without any descriptors."); + ret = unmap(sd, 0, list, 0, + EXPECT_STATUS_GOOD); + CU_ASSERT_EQUAL(ret, 0); + + + if (inq_bl->max_unmap_bdc <= 1) { + CU_PASS("[SKIPPING] Test UNMAP of 0 blocks with multiple descriptos not supported"); + return; + } + + logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 with one descriptor per block"); + for (i = 0; i < 256; i++) { + list[i].lba = i; + list[i].num = 0; + ret = unmap(sd, 0, list, i + 1, + EXPECT_STATUS_GOOD); + CU_ASSERT_EQUAL(ret, 0); + } logging(LOG_VERBOSE, "Test UNMAP of 0 blocks at LBA:0-255 with one descriptor per block, possibly \"overlapping\"."); for (i = 0; i < 256; i++) { @@ -70,11 +80,4 @@ test_unmap_0blocks(void) ret = unmap(sd, 0, list, 256, EXPECT_STATUS_GOOD); CU_ASSERT_EQUAL(ret, 0); - - - logging(LOG_VERBOSE, "Test UNMAP without any descriptors."); - ret = unmap(sd, 0, list, 0, - EXPECT_STATUS_GOOD); - CU_ASSERT_EQUAL(ret, 0); - } From a4bde6adfd63e1783a89b289fb2f8bed5aa61382 Mon Sep 17 00:00:00 2001 From: Chris Zankel Date: Thu, 23 Apr 2015 15:16:37 -0700 Subject: [PATCH 6/6] test_writesame16_unmap_until_end: pass 0 blocks instead of 0-length block The test: "Test WRITESAME16 of 1-256 blocks at the end of the LUN by setting number-of-blocks==0" was passing 0 for the data length instead of the block count. Signed-off-by: Chris Zankel --- test-tool/test_writesame16_unmap_until_end.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-tool/test_writesame16_unmap_until_end.c b/test-tool/test_writesame16_unmap_until_end.c index be2d187..2e6f69f 100644 --- a/test-tool/test_writesame16_unmap_until_end.c +++ b/test-tool/test_writesame16_unmap_until_end.c @@ -58,8 +58,9 @@ test_writesame16_unmap_until_end(void) i * block_size, block_size, 0, 0, 0, 0, 0, buf, EXPECT_STATUS_GOOD); logging(LOG_VERBOSE, "Unmap %d blocks using WRITESAME16", i); + memset(buf, 0, block_size); ret = writesame16(sd, num_blocks - i, - 0, i, 0, 1, 0, 0, NULL, + block_size, 0, 0, 1, 0, 0, buf, EXPECT_STATUS_GOOD); if (ret == -2) { logging(LOG_NORMAL, "[SKIPPED] WRITESAME16 is not implemented.");