TESTS: Verify that SANITIZE does wipe the data

This commit is contained in:
Ronnie Sahlberg
2013-07-05 20:15:52 -07:00
parent b1983aeec1
commit 03ce9dc4b1
4 changed files with 169 additions and 10 deletions
+43
View File
@@ -26,6 +26,7 @@
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
static void
check_wacereq(void)
{
@@ -98,12 +99,42 @@ check_wacereq(void)
scsi_free_scsi_task(task_ret);
}
static void
init_lun_with_data(unsigned char *buf, uint64_t lba)
{
int ret;
memset(buf, 'a', 256 * block_size);
ret = write16(iscsic, tgt_lun, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0);
}
static void
check_lun_is_wiped(unsigned char *buf, uint64_t lba)
{
int ret;
unsigned char *rbuf = alloca(256 * block_size);
ret = read16(iscsic, tgt_lun, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, rbuf);
CU_ASSERT_EQUAL(ret, 0);
if (!memcmp(buf, rbuf, 256 * block_size)) {
logging(LOG_NORMAL, "[FAILED] Blocks were not wiped");
CU_FAIL("[FAILED] Blocks were not wiped");
} else {
logging(LOG_VERBOSE, "[SUCCESS] Blocks were wiped");
}
}
void
test_sanitize_crypto_erase(void)
{
int ret;
struct iscsi_data data;
struct scsi_command_descriptor *cd;
unsigned char *buf = alloca(256 * block_size);
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO ERASE");
@@ -143,11 +174,23 @@ test_sanitize_crypto_erase(void)
}
logging(LOG_VERBOSE, "Write 'a' to the first 256 LBAs");
init_lun_with_data(buf, 0);
logging(LOG_VERBOSE, "Write 'a' to the last 256 LBAs");
init_lun_with_data(buf, num_blocks - 256);
logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE");
ret = sanitize(iscsic, tgt_lun,
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
check_lun_is_wiped(buf, 0);
logging(LOG_VERBOSE, "Check that the last 256 LBAs are wiped.");
check_lun_is_wiped(buf, num_blocks - 256);
return;
data.size = 8;
data.data = alloca(data.size);