From d4ac9ef1b5265f14d34149a22a27fc07ef6ed03f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 18 Aug 2014 10:58:49 +0200 Subject: [PATCH] Skip test_writesame1[06]_unmap large len test for small disks Only perform the test with 65536 blocks on block devices with at least that number of blocks. Fix the 65536 block test log message. Generalize the WRITE SAME(10) 256-block test log messages. Fix interpretation of the MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT field. A quote from SPC-4: "If there is no limit on the number of UNMAP block descriptors contained in the parameter data, then the device server shall set the MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT field to FFFF_FFFFh." Signed-off-by: Bart Van Assche --- test-tool/test_writesame10_unmap.c | 15 ++++++++------- test-tool/test_writesame16_unmap.c | 22 ++++++++++++---------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/test-tool/test_writesame10_unmap.c b/test-tool/test_writesame10_unmap.c index c52ff53..bc950d6 100644 --- a/test-tool/test_writesame10_unmap.c +++ b/test-tool/test_writesame10_unmap.c @@ -29,8 +29,8 @@ void test_writesame10_unmap(void) { - int i, ret; - unsigned int j; + int ret; + unsigned int i, j; unsigned char *buf = alloca(256 * block_size); CHECK_FOR_DATALOSS; @@ -148,11 +148,12 @@ test_writesame10_unmap(void) } i = 256; - if (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= 256) { + if (i <= num_blocks + && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) { logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN " - "as either 0 (==no limit) or >= 256. Test Unmapping " - "256 blocks to verify that it can handle 2-byte " - "lengths"); + "as either 0 (==no limit) or >= %d. Test Unmapping " + "%d blocks to verify that it can handle 2-byte " + "lengths", i, i); logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); memset(buf, 0xff, i * block_size); @@ -186,7 +187,7 @@ test_writesame10_unmap(void) logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); } - } else { + } else if (i <= num_blocks) { logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN " "as <256. Verify that a 256 block unmap fails with " "INVALID_FIELD_IN_CDB."); diff --git a/test-tool/test_writesame16_unmap.c b/test-tool/test_writesame16_unmap.c index 202ad7d..513cb5d 100644 --- a/test-tool/test_writesame16_unmap.c +++ b/test-tool/test_writesame16_unmap.c @@ -146,11 +146,12 @@ test_writesame16_unmap(void) } i = 256; - if (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= 256) { + if (i <= num_blocks + && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) { logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN " - "as either 0 (==no limit) or >= 256. Test Unmapping " - "256 blocks to verify that it can handle 2-byte " - "lengths"); + "as either 0 (==no limit) or >= %d. Test Unmapping " + "%d blocks to verify that it can handle 2-byte " + "lengths", i, i); logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); memset(buf, 0xff, i * block_size); @@ -182,7 +183,7 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); } - } else { + } else if (i <= num_blocks) { logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN " "as <256. Verify that a 256 block unmap fails with " "INVALID_FIELD_IN_CDB."); @@ -196,11 +197,12 @@ test_writesame16_unmap(void) i = 65536; - if (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= 256) { + if (i <= num_blocks + && (inq_bl->max_ws_len == 0 || inq_bl->max_ws_len >= i)) { logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN " - "as either 0 (==no limit) or >= 256. Test Unmapping " - "256 blocks to verify that it can handle 2-byte " - "lengths"); + "as either 0 (==no limit) or >= %d. Test Unmapping " + "%d blocks to verify that it can handle 4-byte " + "lengths", i, i); logging(LOG_VERBOSE, "Write %d blocks of 0xFF", i); memset(buf, 0xff, i * block_size); @@ -232,7 +234,7 @@ test_writesame16_unmap(void) logging(LOG_VERBOSE, "LBPRZ is clear. Skip the read " "and verify zero test"); } - } else { + } else if (i <= num_blocks) { logging(LOG_VERBOSE, "Block Limits VPD page reports MAX_WS_LEN " "as <256. Verify that a 256 block unmap fails with " "INVALID_FIELD_IN_CDB.");