TESTS: CompareAndWrite are bounded by the max block setting in BlockLimits
Make sure that we check that a target returns an error if we try to compare and write too much.
This commit is contained in:
@@ -33,10 +33,18 @@ test_compareandwrite_simple(void)
|
||||
int i, ret;
|
||||
unsigned j;
|
||||
unsigned char *buf = alloca(2 * 256 * block_size);
|
||||
int maxbl;
|
||||
|
||||
CHECK_FOR_DATALOSS;
|
||||
CHECK_FOR_SBC;
|
||||
|
||||
if (inq_bl && inq_bl->max_cmp) {
|
||||
maxbl = inq_bl->max_cmp;
|
||||
} else {
|
||||
/* Assume we are not limited */
|
||||
maxbl = 256;
|
||||
}
|
||||
|
||||
logging(LOG_VERBOSE, LOG_BLANK_LINE);
|
||||
logging(LOG_VERBOSE, "Test COMPARE_AND_WRITE of 1-256 blocks at the "
|
||||
"start of the LUN");
|
||||
@@ -55,12 +63,31 @@ test_compareandwrite_simple(void)
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
if (i > maxbl) {
|
||||
logging(LOG_VERBOSE, "Number of blocks %d is greater than "
|
||||
"BlockLimits.MaximumCompareAndWriteLength(%d). "
|
||||
"Command should fail with INVALID_FIELD_IN_CDB",
|
||||
i, maxbl);
|
||||
ret = compareandwrite_invalidfieldincdb(iscsic, tgt_lun, 0,
|
||||
buf, 2 * i * block_size, block_size,
|
||||
0, 0, 0, 0);
|
||||
if (ret == -2) {
|
||||
CU_PASS("[SKIPPED] Target does not support "
|
||||
"COMPARE_AND_WRITE. Skipping test");
|
||||
return;
|
||||
}
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(buf + i * block_size, 'B', i * block_size);
|
||||
|
||||
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
|
||||
"at LBA:0 (if they all contain 'A')", i);
|
||||
ret = compareandwrite(iscsic, tgt_lun, 0,
|
||||
buf, 2 * i * block_size, block_size, 0, 0, 0, 0);
|
||||
buf, 2 * i * block_size, block_size,
|
||||
0, 0, 0, 0);
|
||||
if (ret == -2) {
|
||||
CU_PASS("[SKIPPED] Target does not support "
|
||||
"COMPARE_AND_WRITE. Skipping test");
|
||||
@@ -98,6 +125,18 @@ test_compareandwrite_simple(void)
|
||||
block_size, 0, 0, 0, 0, 0, buf);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
if (i > maxbl) {
|
||||
logging(LOG_VERBOSE, "Number of blocks %d is greater than "
|
||||
"BlockLimits.MaximumCompareAndWriteLength(%d). "
|
||||
"Command should fail with INVALID_FIELD_IN_CDB",
|
||||
i, maxbl);
|
||||
ret = compareandwrite_invalidfieldincdb(iscsic, tgt_lun, 0,
|
||||
buf, 2 * i * block_size, block_size,
|
||||
0, 0, 0, 0);
|
||||
CU_ASSERT_EQUAL(ret, 0);
|
||||
|
||||
continue;
|
||||
}
|
||||
memset(buf + i * block_size, 'B', i * block_size);
|
||||
|
||||
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
|
||||
|
||||
Reference in New Issue
Block a user