TESTS: Add tests for PREFETCH10/16 to the new test suite

This commit is contained in:
Ronnie Sahlberg
2013-01-26 18:07:25 -08:00
parent 0dbffe1a5d
commit 8e85b87092
12 changed files with 591 additions and 58 deletions

View File

@@ -176,7 +176,14 @@ bin_iscsi_test_cu_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/test-tool \
bin_iscsi_test_cu_LDFLAGS = -ldl -lcunit
bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
test-tool/iscsi-support.c \
test-tool/test_testunitready_simple.c \
test-tool/test_prefetch10_simple.c \
test-tool/test_prefetch10_beyond_eol.c \
test-tool/test_prefetch10_0blocks.c \
test-tool/test_prefetch10_flags.c \
test-tool/test_prefetch16_simple.c \
test-tool/test_prefetch16_beyond_eol.c \
test-tool/test_prefetch16_0blocks.c \
test-tool/test_prefetch16_flags.c \
test-tool/test_read6_simple.c \
test-tool/test_read6_beyond_eol.c \
test-tool/test_read6_0blocks.c \
@@ -199,6 +206,7 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
test-tool/test_readcapacity10_simple.c \
test-tool/test_readcapacity16_simple.c \
test-tool/test_readcapacity16_alloclen.c \
test-tool/test_testunitready_simple.c \
test-tool/test_unmap_simple.c \
test-tool/test_unmap_0blocks.c \
test-tool/test_verify10_simple.c \

View File

@@ -743,29 +743,32 @@ prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num, int imme
{
struct scsi_task *task;
printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d ... ", lba, num, immed, group);
logging(LOG_VERBOSE, "Send PREFETCH10 LBA:%d blocks:%d"
" immed:%d group:%d",
lba, num, immed, group);
task = iscsi_prefetch10_sync(iscsi, lun, lba, num, immed, group);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREFETCH10 command: %s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] Failed to send PREFETCH10 command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("PREFETCH10 is not implemented on target\n");
logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREFETCH10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] PREFETCH10 command: "
"failed with sense. %s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
logging(LOG_VERBOSE, "[OK] PREFETCH10 returned SUCCESS.");
return 0;
}
@@ -775,32 +778,39 @@ prefetch10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba,
{
struct scsi_task *task;
printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d (expecting ILLEGAL_REQUEST/LBA_OUT_OF_RANGE) ... ", lba, num, immed, group);
logging(LOG_VERBOSE, "Send PREFETCH10 (expecting ILLEGAL_REQUEST/"
"LBA_OUT_OF_RANGE) LBA:%d blocks:%d"
" immed:%d group:%d",
lba, num, immed, group);
task = iscsi_prefetch10_sync(iscsi, lun, lba, num, immed, group);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREFETCH10 command: %s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] Failed to send PREFETCH10 command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("PREFETCH10 is not implemented on target\n");
logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] PREFETCH10 returned SUCCESS. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
scsi_free_scsi_task(task);
return -1;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("PREFETCH10 should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] PREFETCH10 failed with the wrong sense code. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE but failed with sense:%s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
printf("[OK]\n");
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] PREFETCH10 returned ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
return 0;
}
@@ -810,136 +820,163 @@ prefetch10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba,
{
struct scsi_task *task;
printf("Send PREFETCH10 LBA:%d Count:%d IMEMD:%d GROUP:%d (expecting NOT_READY/MEDIUM_NOT_PRESENT) ... ", lba, num, immed, group);
logging(LOG_VERBOSE, "Send PREFETCH10 (expecting NOT_READY/"
"MEDIUM_NOT_PRESENT) LBA:%d blocks:%d"
" immed:%d group:%d",
lba, num, immed, group);
task = iscsi_prefetch10_sync(iscsi, lun, lba, num, immed, group);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREFETCH10 command: %s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] Failed to send PREFETCH10 command: %s",
iscsi_get_error(iscsi));
return -1;
return -1;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("PREFETCH10 is not implemented on target\n");
logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] PREFETCH10 returned SUCCESS. Should have failed with NOT_READY/MEDIUM_NOT_PRESENT.");
scsi_free_scsi_task(task);
return -1;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_NOT_READY
|| (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) {
printf("[FAILED]\n");
printf("PREFETCH10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n");
logging(LOG_NORMAL, "[FAILED] PREFETCH10 failed with the wrong sense code. Should have failed with NOT_READY/MEDIUM_NOT_PRESENT but failed with sense:%s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
printf("[OK]\n");
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] PREFETCH10 returned NOT_READY/MEDIUM_NOT_PRESENT.");
return 0;
}
int
prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num,
int immed, int group)
prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num, int immed, int group)
{
struct scsi_task *task;
printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d ... ", lba, num, immed, group);
logging(LOG_VERBOSE, "Send PREFETCH16 LBA:%" PRIu64 " blocks:%d"
" immed:%d group:%d",
lba, num, immed, group);
task = iscsi_prefetch16_sync(iscsi, lun, lba, num, immed, group);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREFETCH16 command: %s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] Failed to send PREFETCH16 command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("PREFETCH16 is not implemented on target\n");
logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("PREFETCH16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] PREFETCH16 command: "
"failed with sense. %s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
logging(LOG_VERBOSE, "[OK] PREFETCH16 returned SUCCESS.");
return 0;
}
int
prefetch16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, int num, int immed, int group)
prefetch16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba,
int num, int immed, int group)
{
struct scsi_task *task;
printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d (expecting ILLEGAL_REQUEST/LBA_OUT_OF_RANGE) ... ", lba, num, immed, group);
logging(LOG_VERBOSE, "Send PREFETCH16 (expecting ILLEGAL_REQUEST/"
"LBA_OUT_OF_RANGE) LBA:%" PRIu64 " blocks:%d"
" immed:%d group:%d",
lba, num, immed, group);
task = iscsi_prefetch16_sync(iscsi, lun, lba, num, immed, group);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREFETCH16 command: %s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] Failed to send PREFETCH16 command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("PREFETCH16 is not implemented on target\n");
logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] PREFETCH16 returned SUCCESS. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
scsi_free_scsi_task(task);
return -1;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE) {
printf("[FAILED]\n");
printf("PREFETCH16 should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] PREFETCH16 failed with the wrong sense code. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE but failed with sense:%s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
printf("[OK]\n");
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] PREFETCH16 returned ILLEGAL_REQUEST/LBA_OUT_OF_RANGE.");
return 0;
}
int
prefetch16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, int num, int immed, int group)
prefetch16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba,
int num, int immed, int group)
{
struct scsi_task *task;
printf("Send PREFETCH16 LBA:%" PRIu64 " Count:%d IMEMD:%d GROUP:%d (expecting NOT_READY/MEDIUM_NOT_PRESENT) ... ", lba, num, immed, group);
logging(LOG_VERBOSE, "Send PREFETCH16 (expecting NOT_READY/"
"MEDIUM_NOT_PRESENT) LBA:%" PRIu64 " blocks:%d"
" immed:%d group:%d",
lba, num, immed, group);
task = iscsi_prefetch16_sync(iscsi, lun, lba, num, immed, group);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send PREFETCH16 command: %s\n", iscsi_get_error(iscsi));
logging(LOG_NORMAL, "[FAILED] Failed to send PREFETCH16 command: %s",
iscsi_get_error(iscsi));
return -1;
return -1;
}
if (task->status == SCSI_STATUS_CHECK_CONDITION
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
&& task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
printf("[SKIPPED]\n");
printf("PREFETCH16 is not implemented on target\n");
logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented on target");
scsi_free_scsi_task(task);
return -2;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] PREFETCH16 returned SUCCESS. Should have failed with NOT_READY/MEDIUM_NOT_PRESENT.");
scsi_free_scsi_task(task);
return -1;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_NOT_READY
|| (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN
&& task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) {
printf("[FAILED]\n");
printf("PREFETCH16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n");
logging(LOG_NORMAL, "[FAILED] PREFETCH16 failed with the wrong sense code. Should have failed with NOT_READY/MEDIUM_NOT_PRESENT but failed with sense:%s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
printf("[OK]\n");
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] PREFETCH16 returned NOT_READY/MEDIUM_NOT_PRESENT.");
return 0;
}

View File

@@ -57,8 +57,19 @@ int (*real_iscsi_queue_pdu)(struct iscsi_context *iscsi, struct iscsi_pdu *pdu);
* list of tests and test suites
*
*****************************************************************/
static CU_TestInfo tests_testunitready[] = {
{ (char *)"testTurSimple", test_testunitready_simple },
static CU_TestInfo tests_prefetch10[] = {
{ (char *)"testPrefetch10Simple", test_prefetch10_simple },
{ (char *)"testPrefetch10BeyondEol", test_prefetch10_beyond_eol },
{ (char *)"testPrefetch10ZeroBlocks", test_prefetch10_0blocks },
{ (char *)"testPrefetch10Flags", test_prefetch10_flags },
CU_TEST_INFO_NULL
};
static CU_TestInfo tests_prefetch16[] = {
{ (char *)"testPrefetch16Simple", test_prefetch16_simple },
{ (char *)"testPrefetch16BeyondEol", test_prefetch16_beyond_eol },
{ (char *)"testPrefetch16ZeroBlocks", test_prefetch16_0blocks },
{ (char *)"testPrefetch16Flags", test_prefetch16_flags },
CU_TEST_INFO_NULL
};
@@ -108,6 +119,11 @@ static CU_TestInfo tests_readcapacity16[] = {
CU_TEST_INFO_NULL
};
static CU_TestInfo tests_testunitready[] = {
{ (char *)"testTurSimple", test_testunitready_simple },
CU_TEST_INFO_NULL
};
static CU_TestInfo tests_unmap[] = {
{ (char *)"testUnmapSimple", test_unmap_simple },
{ (char *)"testUnmapZeroBlocks", test_unmap_0blocks },
@@ -195,8 +211,10 @@ static CU_TestInfo tests_writesame16[] = {
};
static CU_SuiteInfo suites[] = {
{ (char *)"TestTestUnitReady", test_setup, test_teardown,
tests_testunitready },
{ (char *)"TestPrefetch10", test_setup, test_teardown,
tests_prefetch10 },
{ (char *)"TestPrefetch16", test_setup, test_teardown,
tests_prefetch16 },
{ (char *)"TestRead6", test_setup, test_teardown,
tests_read6 },
{ (char *)"TestRead10", test_setup, test_teardown,
@@ -209,6 +227,8 @@ static CU_SuiteInfo suites[] = {
tests_readcapacity10 },
{ (char *)"TestReadCapacity16", test_setup, test_teardown,
tests_readcapacity16 },
{ (char *)"TestTestUnitReady", test_setup, test_teardown,
tests_testunitready },
{ (char *)"TestUnmap", test_setup, test_teardown,
tests_unmap },
{ (char *)"TestVerify10", test_setup, test_teardown,

View File

@@ -35,7 +35,15 @@ extern struct scsi_task *task;
int test_setup(void);
int test_teardown(void);
void test_testunitready_simple(void);
void test_prefetch10_simple(void);
void test_prefetch10_beyond_eol(void);
void test_prefetch10_0blocks(void);
void test_prefetch10_flags(void);
void test_prefetch16_simple(void);
void test_prefetch16_beyond_eol(void);
void test_prefetch16_0blocks(void);
void test_prefetch16_flags(void);
void test_read6_simple(void);
void test_read6_beyond_eol(void);
@@ -67,6 +75,8 @@ void test_readcapacity10_simple(void);
void test_readcapacity16_simple(void);
void test_readcapacity16_alloclen(void);
void test_testunitready_simple(void);
void test_unmap_simple(void);
void test_unmap_0blocks(void);

View File

@@ -0,0 +1,62 @@
/*
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-test-cu.h"
void
test_prefetch10_0blocks(void)
{
int ret;
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==0");
ret = prefetch10(iscsic, tgt_lun, 0,
0, 0, 0);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support PREFETCH10. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
if (num_blocks > 0x80000000) {
CU_PASS("[SKIPPED] LUN is too big");
return;
}
logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks one block past end-of-LUN");
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1,
0, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==2^31");
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
0, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==-1");
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, -1,
0, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -0,0 +1,72 @@
/*
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-test-cu.h"
void
test_prefetch10_beyond_eol(void)
{
int i, ret;
if (num_blocks >= 0x80000000) {
CU_PASS("LUN is too big for read-beyond-eol tests with PREFETCH10. Skipping test.\n");
return;
}
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i, 0, 0);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support PREFETCH10. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) {
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, 0x80000000,
i, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, -1,
i, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test PREFETCH10 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -0,0 +1,50 @@
/*
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 <stdlib.h>
#include <string.h>
#include <CUnit/CUnit.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
void
test_prefetch10_flags(void)
{
int ret;
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test PREFETCH10 flags");
logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED==1");
ret = prefetch10(iscsic, tgt_lun, 0,
1, 1, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH10 with GROUP==3");
ret = prefetch10(iscsic, tgt_lun, 0,
1, 0, 3);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED=1 and GROUP==3");
ret = prefetch10(iscsic, tgt_lun, 0,
1, 1, 3);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -0,0 +1,50 @@
/*
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_prefetch10_simple(void)
{
int i, ret;
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
ret = prefetch10(iscsic, tgt_lun, 0, i, 0, 0);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support PREFETCH10. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
ret = prefetch10(iscsic, tgt_lun, num_blocks - i, i, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -0,0 +1,57 @@
/*
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-test-cu.h"
void
test_prefetch16_0blocks(void)
{
int ret;
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==0");
ret = prefetch16(iscsic, tgt_lun, 0,
0, 0, 0);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support PREFETCH16. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks one block past end-of-LUN");
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1,
0, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==2^63");
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000,
0, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==-1");
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, -1,
0, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -0,0 +1,67 @@
/*
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-test-cu.h"
void
test_prefetch16_beyond_eol(void)
{
int i, ret;
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) {
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i,
i, 0, 0);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support PREFETCH16. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) {
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000,
i, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) {
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, -1,
i, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test PREFETCH16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) {
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1,
i, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}
}

View File

@@ -0,0 +1,50 @@
/*
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 <stdlib.h>
#include <string.h>
#include <CUnit/CUnit.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test-cu.h"
void
test_prefetch16_flags(void)
{
int ret;
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test PREFETCH16 flags");
logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED==1");
ret = prefetch16(iscsic, tgt_lun, 0,
1, 1, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 with GROUP==3");
ret = prefetch16(iscsic, tgt_lun, 0,
1, 0, 3);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED=1 and GROUP==3");
ret = prefetch16(iscsic, tgt_lun, 0,
1, 1, 3);
CU_ASSERT_EQUAL(ret, 0);
}

View File

@@ -0,0 +1,50 @@
/*
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_prefetch16_simple(void)
{
int i, ret;
logging(LOG_VERBOSE, "");
logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) {
ret = prefetch16(iscsic, tgt_lun, 0, i, 0, 0);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support PREFETCH16. Skipping test");
return;
}
CU_ASSERT_EQUAL(ret, 0);
}
logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) {
ret = prefetch16(iscsic, tgt_lun, num_blocks - i, i, 0, 0);
CU_ASSERT_EQUAL(ret, 0);
}
}