From de512a58882001226272d6c7a0d28221c2d805db Mon Sep 17 00:00:00 2001 From: Chris Zankel Date: Wed, 22 Apr 2015 18:01:00 -0700 Subject: [PATCH] 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); - }