From c7238aa426ff2dab9aef7027fe887700b5dd8798 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 14 May 2013 20:37:20 -0700 Subject: [PATCH] TESTS: Relax the tests for BlockLimit VPD page length. Discussions on linux-scsi indicate that some SBC-2 devices may provide some SBC-3 features and thus a SBC-3 BlockLimit page. Supporting more than you claim is a transgression but a relatively minor one, so lets turn a blind eye to it. Supporting less than you claim is a serious transgression and will always result in a harsh test failure. --- test-tool/test_inquiry_block_limits.c | 33 +++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/test-tool/test_inquiry_block_limits.c b/test-tool/test_inquiry_block_limits.c index f643b20..df65c48 100644 --- a/test-tool/test_inquiry_block_limits.c +++ b/test-tool/test_inquiry_block_limits.c @@ -27,7 +27,7 @@ void test_inquiry_block_limits(void) { - int ret, expected_pl; + int ret; struct scsi_inquiry_block_limits *inq_bl; struct scsi_task *bl_task = NULL; struct scsi_inquiry_logical_block_provisioning *lbp = NULL; @@ -67,23 +67,28 @@ test_inquiry_block_limits(void) /* if it is not SBC3 then we assume it must be SBC2 */ if (sbc3_support) { logging(LOG_VERBOSE, "Device claims SBC-3. Verify that " "PageLength == 0x3C"); - expected_pl = 0x3c; } else { logging(LOG_VERBOSE, "Device is not SBC-3. Verify that " - "PageLength == 0x0C"); - expected_pl = 0x0c; - } - CU_ASSERT_EQUAL(bl_task->datain.data[3], expected_pl); - if (bl_task->datain.data[3] != expected_pl) { - logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned. " - "Was %d but expected %d", - bl_task->datain.data[3], expected_pl); - } else { - logging(LOG_VERBOSE, "[SUCCESS] PageLength matches SCSI SBC " - "level"); + "PageLength == 0x0C (but allow 0x3C too. Some SBC-2 " + "devices support some SBC-3 features."); + } + switch (bl_task->datain.data[3]) { + case 0x3c: + /* accept 0x3c (==SBC-3) for all levels */ + break; + case 0x0c: + /* only accept 0x0c for levels < SBC-3 */ + if (!sbc3_support) { + break; + } + /* fallthrough */ + default: + CU_FAIL("[FAILED] Invalid pagelength returned"); + logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned."); } - if (!sbc3_support) { + + if (bl_task->datain.data[3] != 0x3c) { goto finished; }