TESTS: Add tests for WriteSame10/16 UNMAP.

If UNMAP is available, verify that both LBPME and LBPWS[10] are set.
If unmap is not available, verify that LBPWS[10] is clear.
This commit is contained in:
Ronnie Sahlberg
2013-05-14 22:55:05 -07:00
parent dc6c603106
commit e28a94ce77
6 changed files with 178 additions and 6 deletions

View File

@@ -315,6 +315,7 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
test-tool/test_writesame10_unmap.c \
test-tool/test_writesame10_unmap_unaligned.c \
test-tool/test_writesame10_unmap_until_end.c \
test-tool/test_writesame10_unmap_vpd.c \
test-tool/test_writesame16_simple.c \
test-tool/test_writesame16_beyond_eol.c \
test-tool/test_writesame16_0blocks.c \
@@ -322,6 +323,7 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
test-tool/test_writesame16_unmap.c \
test-tool/test_writesame16_unmap_unaligned.c \
test-tool/test_writesame16_unmap_until_end.c \
test-tool/test_writesame16_unmap_vpd.c \
test-tool/test_writeverify10_simple.c \
test-tool/test_writeverify10_beyond_eol.c \
test-tool/test_writeverify10_0blocks.c \

View File

@@ -319,6 +319,7 @@ static CU_TestInfo tests_writesame10[] = {
{ (char *)"WriteSame10Unmap", test_writesame10_unmap },
{ (char *)"WriteSame10UnmapUnaligned", test_writesame10_unmap_unaligned },
{ (char *)"WriteSame10UnmapUntilEnd", test_writesame10_unmap_until_end },
{ (char *)"WriteSame10UnmapVPD", test_writesame10_unmap_vpd },
CU_TEST_INFO_NULL
};
@@ -330,6 +331,7 @@ static CU_TestInfo tests_writesame16[] = {
{ (char *)"WriteSame16Unmap", test_writesame16_unmap },
{ (char *)"WriteSame16UnmapUnaligned", test_writesame16_unmap_unaligned },
{ (char *)"WriteSame16UnmapUntilEnd", test_writesame16_unmap_until_end },
{ (char *)"WriteSame16UnmapVPD", test_writesame16_unmap_vpd },
CU_TEST_INFO_NULL
};
@@ -1098,14 +1100,14 @@ main(int argc, char *argv[])
}
scsi_free_scsi_task(task);
iscsi_logout_sync(iscsic);
iscsi_destroy_context(iscsic);
if (is_usb) {
printf("USB device. Clamping maximum transfer length to 120k\n");
maximum_transfer_length = 120 *1024 / block_size;
}
iscsi_logout_sync(iscsic);
iscsi_destroy_context(iscsic);
if (CU_initialize_registry() != 0) {
fprintf(stderr, "error: unable to initialize test registry\n");
return 1;
@@ -1137,7 +1139,7 @@ main(int argc, char *argv[])
free(discard_const(tgt_url));
scsi_free_scsi_task(inq_task);
scsi_free_scsi_task(inq_lbp_task);
//scsi_free_scsi_task(inq_lbp_task);
scsi_free_scsi_task(rc16_task);
return 0;

View File

@@ -208,6 +208,7 @@ void test_writesame10_wrprotect(void);
void test_writesame10_unmap(void);
void test_writesame10_unmap_unaligned(void);
void test_writesame10_unmap_until_end(void);
void test_writesame10_unmap_vpd(void);
void test_writesame16_simple(void);
void test_writesame16_beyond_eol(void);
@@ -216,6 +217,7 @@ void test_writesame16_wrprotect(void);
void test_writesame16_unmap(void);
void test_writesame16_unmap_unaligned(void);
void test_writesame16_unmap_until_end(void);
void test_writesame16_unmap_vpd(void);
void test_writeverify10_simple(void);
void test_writeverify10_beyond_eol(void);

View File

@@ -31,11 +31,11 @@ test_unmap_vpd(void)
int ret;
struct unmap_list list[1];
CHECK_FOR_SBC;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test UNMAP availability is consistent with VPD settings");
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Check if UNMAP is available.");
list[0].lba = 0;

View File

@@ -0,0 +1,83 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <CUnit/CUnit.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-support.h"
#include "iscsi-test-cu.h"
void
test_writesame10_unmap_vpd(void)
{
int ret;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME10 UNMAP availability is "
"consistent with VPD settings");
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Check if WRITESAME10 can be used for UNMAP.");
logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME10");
ret = writesame10(iscsic, tgt_lun, 0,
block_size, 1,
0, 1, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) {
logging(LOG_VERBOSE, "WRITESAME10 UNMAP is not available. "
"Verify that VPD settings reflect this.");
logging(LOG_VERBOSE, "Verify that LBPWS10 is clear.");
if (inq_lbp && inq_lbp->lbpws10) {
logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is not "
"implemented but LBPWS10 is set");
CU_FAIL("[FAILED] WRITESAME10 UNMAP is unavailable but "
"LBPWS10==1");
} else {
logging(LOG_VERBOSE, "[SUCCESS] LBPWS10 is clear.");
}
} else {
logging(LOG_VERBOSE, "WRITESAME10 UNMAP is available. Verify "
"that VPD settings reflect this.");
logging(LOG_VERBOSE, "Verify that LBPME is set.");
if (rc16 && rc16->lbpme) {
logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
} else {
logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is "
"implemented but LBPME is not set");
CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
}
logging(LOG_VERBOSE, "Verify that LBPWS10 is set.");
if (inq_lbp && inq_lbp->lbpws10) {
logging(LOG_VERBOSE, "[SUCCESS] LBPWS10 is set.");
} else {
logging(LOG_NORMAL, "[FAILED] WRITESAME10 UNMAP is "
"implemented but LBPWS10 is not set");
CU_FAIL("[FAILED] UNMAP is available but LBPWS10==0");
}
}
}

View File

@@ -0,0 +1,83 @@
/*
Copyright (C) 2013 Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <CUnit/CUnit.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-support.h"
#include "iscsi-test-cu.h"
void
test_writesame16_unmap_vpd(void)
{
int ret;
logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test WRITESAME16 UNMAP availability is "
"consistent with VPD settings");
CHECK_FOR_DATALOSS;
CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Check if WRITESAME16 can be used for UNMAP.");
logging(LOG_VERBOSE, "Unmap 1 block using WRITESAME16");
ret = writesame16(iscsic, tgt_lun, 0,
block_size, 1,
0, 1, 0, 0, NULL);
CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) {
logging(LOG_VERBOSE, "WRITESAME16 UNMAP is not available. "
"Verify that VPD settings reflect this.");
logging(LOG_VERBOSE, "Verify that LBPWS is clear.");
if (inq_lbp && inq_lbp->lbpws) {
logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is not "
"implemented but LBPWS is set");
CU_FAIL("[FAILED] WRITESAME16 UNMAP is unavailable but "
"LBPWS==1");
} else {
logging(LOG_VERBOSE, "[SUCCESS] LBPWS is clear.");
}
} else {
logging(LOG_VERBOSE, "WRITESAME16 UNMAP is available. Verify "
"that VPD settings reflect this.");
logging(LOG_VERBOSE, "Verify that LBPME is set.");
if (rc16 && rc16->lbpme) {
logging(LOG_VERBOSE, "[SUCCESS] LBPME is set.");
} else {
logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is "
"implemented but LBPME is not set");
CU_FAIL("[FAILED] UNMAP is available but LBPME==0");
}
logging(LOG_VERBOSE, "Verify that LBPWS is set.");
if (inq_lbp && inq_lbp->lbpws) {
logging(LOG_VERBOSE, "[SUCCESS] LBPWS is set.");
} else {
logging(LOG_NORMAL, "[FAILED] WRITESAME16 UNMAP is "
"implemented but LBPWS is not set");
CU_FAIL("[FAILED] UNMAP is available but LBPWS==0");
}
}
}