Tests: add helper for WRITEATOMIC16

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-02-21 09:07:38 -08:00
parent 0b5b724f17
commit d18dbe49aa
6 changed files with 75 additions and 134 deletions

View File

@@ -30,7 +30,7 @@
void
test_writeatomic16_wrprotect(void)
{
int i, gran, ret;
int i, gran;
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
@@ -44,34 +44,17 @@ test_writeatomic16_wrprotect(void)
gran = inq_bl->atomic_gran ? inq_bl->atomic_gran : 1;
memset(scratch, 0, block_size);
ret = writeatomic16(sd, 0,
block_size * gran,
block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
CU_PASS("WRITEATOMIC16 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
WRITEATOMIC16(sd, 0, block_size * gran, block_size, 0, 0, 0, 0, scratch,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Test WRITEATOMIC16 with non-zero WRPROTECT");
memset(scratch, 0xa6, block_size);
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) {
ret = writeatomic16(sd, 0,
gran * block_size, block_size,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITEATOMIC16 is not implemented.");
CU_PASS("WRITEATOMIC16 is not implemented.");
return;
}
CU_ASSERT_EQUAL(ret, 0);
WRITEATOMIC16(sd, 0, gran * block_size, block_size,
i, 0, 0, 0, scratch,
EXPECT_INVALID_FIELD_IN_CDB);
}
return;
}