[PATCH 6/6] ported group reservation access control test to CUnit

15 views
Skip to first unread message

Lee Duncan

unread,
Feb 16, 2013, 4:56:22 PM2/16/13
to ronnies...@gmail.com, libi...@googlegroups.com, Lee Duncan
From: Lee Duncan <ldu...@suse.de>

Ported group reservation access control test to CUnit format.
This is the final group reservation test to be ported.
---
Makefile.am | 1 +
test-tool/iscsi-support.c | 26 ++++++
test-tool/iscsi-support.h | 2 +-
test-tool/iscsi-test-cu.c | 62 +++++++++++-
test-tool/iscsi-test-cu.h | 11 +++
test-tool/test_prout_reserve_access.c | 166 +++++++++++++++++++++++++++++++++
6 files changed, 262 insertions(+), 6 deletions(-)
create mode 100644 test-tool/test_prout_reserve_access.c

diff --git a/Makefile.am b/Makefile.am
index 76d9497..427c862 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -190,6 +190,7 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
test-tool/test_prin_serviceaction_range.c \
test-tool/test_prout_register_simple.c \
test-tool/test_prout_reserve_simple.c \
+ test-tool/test_prout_reserve_access.c \
test-tool/test_read6_simple.c \
test-tool/test_read6_beyond_eol.c \
test-tool/test_read6_0blocks.c \
diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c
index 634c4b9..7639ed3 100644
--- a/test-tool/iscsi-support.c
+++ b/test-tool/iscsi-support.c
@@ -817,6 +817,32 @@ testunitready(struct iscsi_context *iscsi, int lun)
}

int
+testunitready_clear_ua(struct iscsi_context *iscsi, int lun)
+{
+ struct scsi_task *task;
+
+
+ logging(LOG_VERBOSE,
+ "Send TESTUNITREADY (To Clear Possible UA) init=%s",
+ iscsi->initiator_name);
+
+ task = iscsi_testunitready_sync(iscsi, lun);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send TESTUNITREADY command: %s",
+ iscsi_get_error(iscsi));
+ return -1;
+ }
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[INFO] TESTUNITREADY command: failed with sense. %s",
+ iscsi_get_error(iscsi));
+ }
+ scsi_free_scsi_task(task);
+ return 0;
+}
+
+int
testunitready_nomedium(struct iscsi_context *iscsi, int lun)
{
struct scsi_task *task;
diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h
index 3b69f14..46bd4f7 100644
--- a/test-tool/iscsi-support.h
+++ b/test-tool/iscsi-support.h
@@ -187,7 +187,6 @@ int verify_read_works(struct iscsi_context *iscsi, int lun, unsigned char *buf);
int verify_write_works(struct iscsi_context *iscsi, int lun, unsigned char *buf);
int verify_read_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf);
int verify_write_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf);
-
int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize);
int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group);
@@ -209,6 +208,7 @@ int read16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba,
int read16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int readcapacity10(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi);
int readcapacity16(struct iscsi_context *iscsi, int lun, int alloc_len);
+int testunitready_clear_ua(struct iscsi_context *iscsi, int lun);
int testunitready(struct iscsi_context *iscsi, int lun);
int testunitready_nomedium(struct iscsi_context *iscsi, int lun);
int testunitready_conflict(struct iscsi_context *iscsi, int lun);
diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c
index d45f7ce..098a424 100644
--- a/test-tool/iscsi-test-cu.c
+++ b/test-tool/iscsi-test-cu.c
@@ -232,6 +232,16 @@ static CU_TestInfo tests_prout_register[] = {

static CU_TestInfo tests_prout_reserve[] = {
{ (char *)"testProutReserveSimple", test_prout_reserve_simple },
+ { (char *)"testProutReserveAccessEA", test_prout_reserve_access_ea },
+ { (char *)"testProutReserveAccessWE", test_prout_reserve_access_we },
+ { (char *)"testProutReserveAccessEARO",
+ test_prout_reserve_access_earo },
+ { (char *)"testProutReserveAccessWERO",
+ test_prout_reserve_access_wero },
+ { (char *)"testProutReserveAccessEAAR",
+ test_prout_reserve_access_eaar },
+ { (char *)"testProutReserveAccessWEAR",
+ test_prout_reserve_access_wear },
CU_TEST_INFO_NULL
};

@@ -240,6 +250,7 @@ static CU_TestInfo tests_prin_serviceaction_range[] = {
CU_TEST_INFO_NULL
};

+
static CU_SuiteInfo suites[] = {
{ (char *)"TestGetLBAStatus", test_setup, test_teardown,
tests_get_lba_status },
@@ -285,7 +296,7 @@ static CU_SuiteInfo suites[] = {
tests_prin_serviceaction_range },
{ (char *)"TestProutRegister", test_setup, test_teardown,
tests_prout_register },
- { (char *)"TestProutReserve", test_setup, test_teardown,
+ { (char *)"TestProutReserve", test_setup_pgr, test_teardown_pgr,
tests_prout_reserve },
CU_SUITE_INFO_NULL
};
@@ -296,6 +307,9 @@ static CU_SuiteInfo suites[] = {
int tgt_lun;
struct iscsi_context *iscsic;
struct scsi_task *task;
+int tgt_lun2;
+struct iscsi_context *iscsic2;
+unsigned char *read_write_buf;


static void
@@ -352,7 +366,6 @@ print_usage(void)
fprintf(stderr, "\n");
}

-
int
test_setup(void)
{
@@ -366,17 +379,56 @@ test_setup(void)
return 0;
}

+int
+test_setup_pgr(void)
+{
+ task = NULL;
+ read_write_buf = NULL;
+
+ iscsic = iscsi_context_login(initiatorname1, tgt_url, &tgt_lun);
+ if (iscsic == NULL) {
+ fprintf(stderr,
+ "error: Failed to login to target for test set-up\n");
+ return 1;
+ }
+
+ iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun2);
+ if (iscsic2 == NULL) {
+ fprintf(stderr,
+ "error: Failed to login to target for test set-up\n");
+ iscsi_logout_sync(iscsic);
+ iscsi_destroy_context(iscsic);
+ iscsic = NULL;
+ return 1;
+ }
+ return 0;
+}

int
test_teardown(void)
{
- if (task)
+ if (task) {
scsi_free_scsi_task(task);
- iscsi_logout_sync(iscsic);
- iscsi_destroy_context(iscsic);
+ task = NULL;
+ }
+ if (iscsic) {
+ iscsi_logout_sync(iscsic);
+ iscsi_destroy_context(iscsic);
+ iscsic = NULL;
+ }
return 0;
}

+int
+test_teardown_pgr(void)
+{
+ test_teardown();
+ if (read_write_buf != NULL) {
+ free(read_write_buf);
+ read_write_buf = NULL;
+ }
+ return 0;
+}

static void
list_all_tests(void)
diff --git a/test-tool/iscsi-test-cu.h b/test-tool/iscsi-test-cu.h
index 8acd32d..6b4a6ca 100644
--- a/test-tool/iscsi-test-cu.h
+++ b/test-tool/iscsi-test-cu.h
@@ -31,9 +31,14 @@
extern struct iscsi_context *iscsic;
extern int tgt_lun;
extern struct scsi_task *task;
+extern struct iscsi_context *iscsic2;
+extern int tgt_lun2;
+extern unsigned char *read_write_buf;

int test_setup(void);
int test_teardown(void);
+int test_setup_pgr(void);
+int test_teardown_pgr(void);

void test_get_lba_status_simple(void);

@@ -144,5 +149,11 @@ void test_prin_read_keys_simple(void);
void test_prin_serviceaction_range(void);
void test_prout_register_simple(void);
void test_prout_reserve_simple(void);
+void test_prout_reserve_access_ea(void);
+void test_prout_reserve_access_we(void);
+void test_prout_reserve_access_earo(void);
+void test_prout_reserve_access_wero(void);
+void test_prout_reserve_access_eaar(void);
+void test_prout_reserve_access_wear(void);

#endif /* _ISCSI_TEST_CU_H_ */
diff --git a/test-tool/test_prout_reserve_access.c b/test-tool/test_prout_reserve_access.c
new file mode 100644
index 0000000..d139b30
--- /dev/null
+++ b/test-tool/test_prout_reserve_access.c
@@ -0,0 +1,166 @@
+/*
+ Copyright (C) 2013 by Lee Duncan <leeman...@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 <arpa/inet.h>
+// #include <string.h>
+
+#include <CUnit/CUnit.h>
+
+#include "iscsi.h"
+#include "scsi-lowlevel.h"
+#include "iscsi-test-cu.h"
+
+
+static void
+verify_persistent_reserve(struct iscsi_context *iscsi1, int lun1,
+ struct iscsi_context *iscsi2, int lun2,
+ const enum scsi_persistent_out_type pr_type,
+ int reg_i2_can_read,
+ int reg_i2_can_write,
+ int unreg_i2_can_read,
+ int unreg_i2_can_write)
+{
+ int ret;
+ const unsigned long long key = rand_key();
+ const unsigned long long key2 = rand_key();
+
+
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE,
+ "Verify access for reservation type: %s",
+ scsi_pr_type_str(pr_type));
+
+ /* send TURs to clear possible check conditions */
+ (void) testunitready_clear_ua(iscsi1, lun1);
+ (void) testunitready_clear_ua(iscsi2, lun2);
+
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(iscsi1, lun1, key);
+ CU_ASSERT_EQUAL(0, ret);
+ ret = prout_register_and_ignore(iscsi2, lun2, key2);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* reserve the target through initiator 1 */
+ ret = prout_reserve(iscsi1, lun1, key, pr_type);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* verify target reservation */
+ ret = prin_verify_reserved_as(iscsi1, lun1,
+ pr_type_is_all_registrants(pr_type) ? 0 : key,
+ pr_type);
+ CU_ASSERT_EQUAL(0, ret);
+
+ read_write_buf = malloc(512); /* allocate a buffer */
+ CU_ASSERT_PTR_NOT_NULL(read_write_buf);
+
+ /* make sure init1 can read */
+ ret = verify_read_works(iscsi1, lun1, read_write_buf);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* make sure init1 can write */
+ ret = verify_write_works(iscsi1, lun1, read_write_buf);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* verify registered init2 read access */
+ if (reg_i2_can_read)
+ ret = verify_read_works(iscsi2, lun2, read_write_buf);
+ else
+ ret = verify_read_fails(iscsi2, lun2, read_write_buf);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* verify registered init2 write access */
+ if (reg_i2_can_write)
+ ret = verify_write_works(iscsi2, lun2, read_write_buf);
+ else
+ ret = verify_write_fails(iscsi2, lun2, read_write_buf);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* unregister init2 */
+ ret = prout_register_key(iscsi2, lun2, 0, key);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* verify unregistered init2 read access */
+ if (unreg_i2_can_read)
+ ret = verify_read_works(iscsi2, lun2, read_write_buf);
+ else
+ ret = verify_read_fails(iscsi2, lun2, read_write_buf);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* verify unregistered init2 write access */
+ if (unreg_i2_can_write)
+ ret = verify_write_works(iscsi2, lun2, read_write_buf);
+ else
+ ret = verify_write_fails(iscsi2, lun2, read_write_buf);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* release our reservation */
+ ret = prout_release(iscsi1, lun1, key, pr_type);
+ CU_ASSERT_EQUAL(0, ret);
+
+ /* remove our key from the target */
+ ret = prout_register_key(iscsi1, lun1, 0, key);
+ CU_ASSERT_EQUAL(0, ret);
+}
+
+void
+test_prout_reserve_access_ea(void)
+{
+ verify_persistent_reserve(iscsic, tgt_lun, iscsic2, tgt_lun2,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
+ 0, 0, 0, 0);
+}
+
+void
+test_prout_reserve_access_we(void)
+{
+ verify_persistent_reserve(iscsic, tgt_lun, iscsic2, tgt_lun2,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
+ 1, 0, 1, 0);
+}
+
+void
+test_prout_reserve_access_earo(void)
+{
+ verify_persistent_reserve(iscsic, tgt_lun, iscsic2, tgt_lun2,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
+ 1, 1, 0, 0);
+}
+
+void
+test_prout_reserve_access_wero(void)
+{
+ verify_persistent_reserve(iscsic, tgt_lun, iscsic2, tgt_lun2,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
+ 1, 1, 1, 0);
+}
+
+void
+test_prout_reserve_access_eaar(void)
+{
+ verify_persistent_reserve(iscsic, tgt_lun, iscsic2, tgt_lun2,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
+ 1, 1, 0, 0);
+}
+
+void
+test_prout_reserve_access_wear(void)
+{
+ verify_persistent_reserve(iscsic, tgt_lun, iscsic2, tgt_lun2,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
+ 1, 1, 1, 0);
+}
--
1.7.10.4

Lee Duncan

unread,
Feb 16, 2013, 4:56:21 PM2/16/13
to ronnies...@gmail.com, libi...@googlegroups.com, Lee Duncan
From: Lee Duncan <ldu...@suse.de>

Ported 3 more group reservation tests to new the CUnit format.
---
Makefile.am | 3 ++
test-tool/iscsi-support.c | 43 +++++++++++++++
test-tool/iscsi-support.h | 3 +-
test-tool/iscsi-test-cu.c | 23 +++++++-
test-tool/iscsi-test-cu.h | 3 ++
test-tool/test_prin_serviceaction_range.c | 54 +++++++++++++++++++
test-tool/test_prout_register_simple.c | 58 +++++++++++++++++++++
test-tool/test_prout_reserve_simple.c | 81 +++++++++++++++++++++++++++++
8 files changed, 266 insertions(+), 2 deletions(-)
create mode 100644 test-tool/test_prin_serviceaction_range.c
create mode 100644 test-tool/test_prout_register_simple.c
create mode 100644 test-tool/test_prout_reserve_simple.c

diff --git a/Makefile.am b/Makefile.am
index ed67040..76d9497 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -187,6 +187,9 @@ bin_iscsi_test_cu_SOURCES = test-tool/iscsi-test-cu.c \
test-tool/test_prefetch16_0blocks.c \
test-tool/test_prefetch16_flags.c \
test-tool/test_prin_read_keys_simple.c \
+ test-tool/test_prin_serviceaction_range.c \
+ test-tool/test_prout_register_simple.c \
+ test-tool/test_prout_reserve_simple.c \
test-tool/test_read6_simple.c \
test-tool/test_read6_beyond_eol.c \
test-tool/test_read6_0blocks.c \
diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c
index b349caa..634c4b9 100644
--- a/test-tool/iscsi-support.c
+++ b/test-tool/iscsi-support.c
@@ -188,6 +188,49 @@ iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
}

int
+prin_task(struct iscsi_context *iscsi, int lun, int service_action,
+ int success_expected)
+{
+ const int buf_sz = 16384;
+ struct scsi_task *task;
+ int ret = 0;
+
+
+ logging(LOG_VERBOSE, "Send PRIN/SA=0x%02x, expect %s", service_action,
+ success_expected ? "success" : "failure");
+
+ task = iscsi_persistent_reserve_in_sync(iscsi, lun,
+ service_action, buf_sz);
+ if (task == NULL) {
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
+ iscsi_get_error(iscsi));
+ return -1;
+ }
+
+ if (success_expected) {
+ if (task->status != SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN/SA=0x%x failed: %s",
+ service_action, iscsi_get_error(iscsi));
+ ret = -1;
+ }
+ } else {
+ if (task->status == SCSI_STATUS_GOOD) {
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN/SA=0x%x succeeded with invalid serviceaction",
+ service_action);
+ ret = -1;
+ }
+ }
+
+ scsi_free_scsi_task(task);
+ task = NULL;
+
+ return ret;
+}
+
+int
prin_read_keys(struct iscsi_context *iscsi, int lun, struct scsi_task **tp,
struct scsi_persistent_reserve_in_read_keys **rkp)
{
diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h
index e543c31..3b69f14 100644
--- a/test-tool/iscsi-support.h
+++ b/test-tool/iscsi-support.h
@@ -165,9 +165,10 @@ static inline int pr_type_is_all_registrants(
}
}

+int prin_task(struct iscsi_context *iscsi, int lun, int service_action,
+ int success_expected);
int prin_read_keys(struct iscsi_context *iscsi, int lun, struct scsi_task **tp,
struct scsi_persistent_reserve_in_read_keys **rkp);
-
int prout_register_and_ignore(struct iscsi_context *iscsi, int lun,
unsigned long long key);
int prout_register_key(struct iscsi_context *iscsi, int lun,
diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c
index 649b3ea..d45f7ce 100644
--- a/test-tool/iscsi-test-cu.c
+++ b/test-tool/iscsi-test-cu.c
@@ -225,6 +225,21 @@ static CU_TestInfo tests_prin_read_keys[] = {
CU_TEST_INFO_NULL
};

+static CU_TestInfo tests_prout_register[] = {
+ { (char *)"testProutRegisterSimple", test_prout_register_simple },
+ CU_TEST_INFO_NULL
+};
+
+static CU_TestInfo tests_prout_reserve[] = {
+ { (char *)"testProutReserveSimple", test_prout_reserve_simple },
+ CU_TEST_INFO_NULL
+};
+
+static CU_TestInfo tests_prin_serviceaction_range[] = {
+ { (char *)"testPrinServiceactionRange", test_prin_serviceaction_range },
+ CU_TEST_INFO_NULL
+};
+
static CU_SuiteInfo suites[] = {
{ (char *)"TestGetLBAStatus", test_setup, test_teardown,
tests_get_lba_status },
@@ -266,6 +281,12 @@ static CU_SuiteInfo suites[] = {
tests_writesame16 },
{ (char *)"TestPrinReadKeys", test_setup, test_teardown,
tests_prin_read_keys },
+ { (char *)"TestPrinServiceactionRange", test_setup, test_teardown,
+ tests_prin_serviceaction_range },
+ { (char *)"TestProutRegister", test_setup, test_teardown,
+ tests_prout_register },
+ { (char *)"TestProutReserve", test_setup, test_teardown,
+ tests_prout_reserve },
CU_SUITE_INFO_NULL
};

@@ -312,7 +333,7 @@ print_usage(void)
fprintf(stderr,
" -v|--verbose Test Mode: Verbose [DEFAULT]\n");
fprintf(stderr,
- "-V|--Verbose-scsi Enable verbose SCSI logging [default SILENT]\n");
+ " -V|--Verbose-scsi Enable verbose SCSI logging [default SILENT]\n");
fprintf(stderr, "\n");
fprintf(stderr,
"Where <iscsi-url> iSCSI URL format is: %s\n", ISCSI_URL_SYNTAX);
diff --git a/test-tool/iscsi-test-cu.h b/test-tool/iscsi-test-cu.h
index a6cc7bd..8acd32d 100644
--- a/test-tool/iscsi-test-cu.h
+++ b/test-tool/iscsi-test-cu.h
@@ -141,5 +141,8 @@ void test_writesame16_unmap_unaligned(void);
void test_writesame16_unmap_until_end(void);

void test_prin_read_keys_simple(void);
+void test_prin_serviceaction_range(void);
+void test_prout_register_simple(void);
+void test_prout_reserve_simple(void);

#endif /* _ISCSI_TEST_CU_H_ */
diff --git a/test-tool/test_prin_serviceaction_range.c b/test-tool/test_prin_serviceaction_range.c
new file mode 100644
index 0000000..7e3420b
--- /dev/null
+++ b/test-tool/test_prin_serviceaction_range.c
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2013 by Lee Duncan <l...@gonzoleeman.net>
+
+ 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 <arpa/inet.h>
+
+#include <CUnit/CUnit.h>
+
+#include "iscsi.h"
+#include "scsi-lowlevel.h"
+#include "iscsi-support.h"
+#include "iscsi-test-cu.h"
+
+
+void
+test_prin_serviceaction_range(void)
+{
+ int ret = 0;
+ int i;
+
+
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve IN Serviceaction range.");
+
+ /* verify PRIN/READ_KEYS works -- XXX redundant -- remove this? */
+ ret = prin_read_keys(iscsic, tgt_lun, &task, NULL);
+ CU_ASSERT_EQUAL(ret, 0);
+
+ /* verify that PRIN/SA={0,1,2,3} works ... */
+ for (i = 0; i < 4; i++) {
+ ret = prin_task(iscsic, tgt_lun, i, 1);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
+
+ /* verify that PRIN/SA={4..0x20} fails ... */
+ for (i = 4; i < 0x20; i++) {
+ ret = prin_task(iscsic, tgt_lun, i, 0);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
+}
diff --git a/test-tool/test_prout_register_simple.c b/test-tool/test_prout_register_simple.c
new file mode 100644
index 0000000..4cdd6eb
--- /dev/null
+++ b/test-tool/test_prout_register_simple.c
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2013 by Lee Duncan <l...@gonzoleeman.net>
+
+ 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 <arpa/inet.h>
+
+#include <CUnit/CUnit.h>
+
+#include "iscsi.h"
+#include "scsi-lowlevel.h"
+#include "iscsi-support.h"
+#include "iscsi-test-cu.h"
+
+
+void
+test_prout_register_simple(void)
+{
+ const unsigned long long key = rand_key();
+ int ret = 0;
+
+
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve IN REGISTER works.");
+
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(iscsic, tgt_lun, key);
+ CU_ASSERT_EQUAL(ret, 0);
+
+ /* verify we can read the registration */
+ ret = prin_verify_key_presence(iscsic, tgt_lun, key, 1);
+ CU_ASSERT_EQUAL(ret, 0);
+
+ /* try to reregister, which should fail */
+ ret = prout_reregister_key_fails(iscsic, tgt_lun, key+1);
+ CU_ASSERT_EQUAL(ret, 0);
+
+ /* release from the target */
+ ret = prout_register_key(iscsic, tgt_lun, 0, key);
+ CU_ASSERT_EQUAL(ret, 0);
+
+ /* Verify the registration is gone */
+ ret = prin_verify_key_presence(iscsic, tgt_lun, key, 0);
+ CU_ASSERT_EQUAL(ret, 0);
+}
diff --git a/test-tool/test_prout_reserve_simple.c b/test-tool/test_prout_reserve_simple.c
new file mode 100644
index 0000000..9266711
--- /dev/null
+++ b/test-tool/test_prout_reserve_simple.c
@@ -0,0 +1,81 @@
+/*
+ Copyright (C) 2013 by Lee Duncan <l...@gonzoleeman.net>
+
+ 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 <arpa/inet.h>
+
+#include <CUnit/CUnit.h>
+
+#include "iscsi.h"
+#include "scsi-lowlevel.h"
+#include "iscsi-support.h"
+#include "iscsi-test-cu.h"
+
+
+/*
+ * list of persistent reservation types to test, in order
+ */
+static enum scsi_persistent_out_type pr_types_to_test[] = {
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
+ SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
+ SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
+ 0
+};
+
+
+void
+test_prout_reserve_simple(void)
+{
+ int ret = 0;
+ int i;
+ const unsigned long long key = rand_key();
+
+
+ logging(LOG_VERBOSE, LOG_BLANK_LINE);
+ logging(LOG_VERBOSE, "Test Persistent Reserve IN RESERVE works.");
+
+ /* register our reservation key with the target */
+ ret = prout_register_and_ignore(iscsic, tgt_lun, key);
+ CU_ASSERT_EQUAL(ret, 0);
+
+ /* test each reservatoin type */
+ for (i = 0; pr_types_to_test[i] != 0; i++) {
+ enum scsi_persistent_out_type pr_type = pr_types_to_test[i];
+
+ /* reserve the target */
+ ret = prout_reserve(iscsic, tgt_lun, key, pr_type);
+ CU_ASSERT_EQUAL(ret, 0);
+
+ /* verify target reservation */
+ ret = prin_verify_reserved_as(iscsic, tgt_lun,
+ pr_type_is_all_registrants(pr_type) ? 0 : key,
+ pr_type);
+ CU_ASSERT_EQUAL(ret, 0);
+
+ /* release our reservation */
+ ret = prout_release(iscsic, tgt_lun, key, pr_type);
+ CU_ASSERT_EQUAL(ret, 0);
+ }
+
+ /* remove our key from the target */
+ ret = prout_register_key(iscsic, tgt_lun, 0, key);
+ CU_ASSERT_EQUAL(ret, 0);
+
+}
--
1.7.10.4

Lee Duncan

unread,
Feb 16, 2013, 4:56:20 PM2/16/13
to ronnies...@gmail.com, libi...@googlegroups.com, Lee Duncan
From: Lee Duncan <ldu...@suse.de>

Converted group reservation functions to use loggin(), and
cleaned up those functions a little as well.
---
test-tool/iscsi-support.c | 325 ++++++++++++++++++++++++---------------------
1 file changed, 171 insertions(+), 154 deletions(-)

diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c
index 915b1c8..b349caa 100644
--- a/test-tool/iscsi-support.c
+++ b/test-tool/iscsi-support.c
@@ -231,10 +231,12 @@ prout_register_and_ignore(struct iscsi_context *iscsi, int lun,
{
struct scsi_persistent_reserve_out_basic poc;
struct scsi_task *task;
+ int ret = 0;


/* register our reservation key with the target */
- printf("Send PROUT/REGISTER_AND_IGNORE to register init=%s ... ",
+ logging(LOG_VERBOSE,
+ "Send PROUT/REGISTER_AND_IGNORE to register init=%s",
iscsi->initiator_name);

if (!data_loss) {
@@ -248,44 +250,42 @@ prout_register_and_ignore(struct iscsi_context *iscsi, int lun,
SCSI_PERSISTENT_RESERVE_REGISTER_AND_IGNORE_EXISTING_KEY,
SCSI_PERSISTENT_RESERVE_SCOPE_LU, 0, &poc);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send PROUT command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT 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("PROUT Not Supported\n");
- scsi_free_scsi_task(task);
- return -2;
+ logging(LOG_NORMAL, "[SKIPPED] PROUT Not Supported");
+ ret = -2;
+ goto dun;
}
if (task->status != SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("PROUT command: failed with sense. %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense. %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
}

+ dun:
scsi_free_scsi_task(task);
- printf("[OK]\n");
-
- return 0;
+ return ret;
}

-
int
prout_register_key(struct iscsi_context *iscsi, int lun,
unsigned long long sark, unsigned long long rk)
{
struct scsi_persistent_reserve_out_basic poc;
struct scsi_task *task;
+ int ret = 0;


- /* register our reservation key with the target */
- printf("Send PROUT/REGISTER to %s init=%s... ",
+ /* register/unregister our reservation key with the target */
+
+ logging(LOG_VERBOSE, "Send PROUT/REGISTER to %s init=%s",
sark != 0 ? "register" : "unregister",
iscsi->initiator_name);

@@ -301,26 +301,23 @@ prout_register_key(struct iscsi_context *iscsi, int lun,
SCSI_PERSISTENT_RESERVE_REGISTER,
SCSI_PERSISTENT_RESERVE_SCOPE_LU, 0, &poc);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send PROUT command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status != SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("PROUT command: failed with sense. %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense: %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
}

scsi_free_scsi_task(task);
- printf("[OK]\n");

- return 0;
+ return ret;
}

-
int
prin_verify_key_presence(struct iscsi_context *iscsi, int lun,
unsigned long long key, int present)
@@ -330,56 +327,60 @@ prin_verify_key_presence(struct iscsi_context *iscsi, int lun,
int i;
int key_found;
struct scsi_persistent_reserve_in_read_keys *rk = NULL;
+ int ret = 0;


- printf("Send PRIN/READ_KEYS to verify key %s init=%s... ",
+ logging(LOG_VERBOSE,
+ "Send PRIN/READ_KEYS to verify key %s init=%s... ",
present ? "present" : "absent",
iscsi->initiator_name);
+
task = iscsi_persistent_reserve_in_sync(iscsi, lun,
SCSI_PERSISTENT_RESERVE_READ_KEYS, buf_sz);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send PRIN command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
iscsi_get_error(iscsi));
return -1;
}
+
if (task->status != SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("PRIN command: failed with sense. %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN command: failed with sense. %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
+ goto dun;
}
+
rk = scsi_datain_unmarshall(task);
if (rk == NULL) {
- printf("failed to unmarshall PRIN/READ_KEYS data. %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] failed to unmarshall PRIN/READ_KEYS data. %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
+ goto dun;
}

- scsi_free_scsi_task(task);
-
key_found = 0;
for (i = 0; i < rk->num_keys; i++) {
if (rk->keys[i] == key)
key_found = 1;
}

- if ((present && key_found) ||
- (!present && !key_found)) {
- printf("[OK]\n");
- return 0;
- } else {
- printf("[FAILED]\n");
+ if ((present && !key_found) || (!present && key_found)) {
if (present)
- printf("Key found when none expected\n");
+ logging(LOG_NORMAL,
+ "[FAILED] Key found when none expected");
else
- printf("Key not found when expected\n");
- return -1;
+ logging(LOG_NORMAL,
+ "[FAILED] Key not found when expected");
+ ret = -1;
}
-}

+ dun:
+ scsi_free_scsi_task(task);
+ return ret;
+}

int
prout_reregister_key_fails(struct iscsi_context *iscsi, int lun,
@@ -387,9 +388,11 @@ prout_reregister_key_fails(struct iscsi_context *iscsi, int lun,
{
struct scsi_persistent_reserve_out_basic poc;
struct scsi_task *task;
+ int ret = 0;


- printf("Send PROUT/REGISTER to ensure reregister fails init=%s... ",
+ logging(LOG_VERBOSE,
+ "Send PROUT/REGISTER to ensure reregister fails init=%s",
iscsi->initiator_name);

if (!data_loss) {
@@ -405,8 +408,8 @@ prout_reregister_key_fails(struct iscsi_context *iscsi, int lun,
SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
&poc);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send PROUT command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
iscsi_get_error(iscsi));
return -1;
}
@@ -414,35 +417,34 @@ prout_reregister_key_fails(struct iscsi_context *iscsi, int lun,
if (task->status != SCSI_STATUS_CHECK_CONDITION ||
task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST ||
task->sense.ascq != SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) {
- printf("[FAILED]\n");
- printf("PROUT/REGISTER when already registered should fail\n");
- scsi_free_scsi_task(task);
- return -1;
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT/REGISTER when already registered should fail");
+ ret = -1;
+ goto dun;
}
if (task->status == SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("PROUT/REGISTER command: succeeded when it should not have!\n");
- scsi_free_scsi_task(task);
- return -1;
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT/REGISTER command: succeeded when it should not have");
+ ret = -1;
}

+ dun:
scsi_free_scsi_task(task);
- printf("[OK]\n");
-
- return 0;
+ return ret;
}

-
int
prout_reserve(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type)
{
struct scsi_persistent_reserve_out_basic poc;
struct scsi_task *task;
+ int ret = 0;


/* reserve the target using specified reservation type */
- printf("Send PROUT/RESERVE to reserve, type=%d (%s) init=%s ... ",
+ logging(LOG_VERBOSE,
+ "Send PROUT/RESERVE to reserve, type=%d (%s) init=%s",
pr_type, scsi_pr_type_str(pr_type),
iscsi->initiator_name);

@@ -458,36 +460,34 @@ prout_reserve(struct iscsi_context *iscsi, int lun,
SCSI_PERSISTENT_RESERVE_SCOPE_LU,
pr_type, &poc);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send PROUT command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
iscsi_get_error(iscsi));
return -1;
}
+
if (task->status != SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("PROUT command: failed with sense. %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense. %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
}

scsi_free_scsi_task(task);
- printf("[OK]\n");
-
- return 0;
+ return ret;
}

-
int
prout_release(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type)
{
struct scsi_persistent_reserve_out_basic poc;
struct scsi_task *task;
+ int ret = 0;


- /* release the target using specified reservation type */
- printf("Send PROUT/RELEASE to release reservation, type=%d init=%s ... ",
+ logging(LOG_VERBOSE,
+ "Send PROUT/RELEASE to release reservation, type=%d init=%s",
pr_type, iscsi->initiator_name);

if (!data_loss) {
@@ -502,23 +502,21 @@ prout_release(struct iscsi_context *iscsi, int lun,
SCSI_PERSISTENT_RESERVE_SCOPE_LU,
pr_type, &poc);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send PROUT command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PROUT command: %s",
iscsi_get_error(iscsi));
return -1;
}
+
if (task->status != SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("PROUT command: failed with sense. %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] PROUT command: failed with sense. %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
}

scsi_free_scsi_task(task);
- printf("[OK]\n");
-
- return 0;
+ return ret;
}

int
@@ -528,56 +526,63 @@ prin_verify_reserved_as(struct iscsi_context *iscsi, int lun,
struct scsi_task *task;
const int buf_sz = 16384;
struct scsi_persistent_reserve_in_read_reservation *rr = NULL;
+ int ret = 0;


- printf("Send PRIN/READ_RESERVATION to verify type=%d init=%s... ",
+ logging(LOG_VERBOSE,
+ "Send PRIN/READ_RESERVATION to verify type=%d init=%s... ",
pr_type, iscsi->initiator_name);
+
task = iscsi_persistent_reserve_in_sync(iscsi, lun,
SCSI_PERSISTENT_RESERVE_READ_RESERVATION, buf_sz);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send PRIN command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send PRIN command: %s",
iscsi_get_error(iscsi));
return -1;
}
+
if (task->status != SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("PRIN command: failed with sense. %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] PRIN command: failed with sense: %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
+ goto dun;
}
rr = scsi_datain_unmarshall(task);
if (rr == NULL) {
- printf("failed to unmarshall PRIN/READ_RESERVATION data. %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to unmarshall PRIN/READ_RESERVATION data. %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
+ goto dun;
}
-
- scsi_free_scsi_task(task);
-
-
if (!rr->reserved) {
- printf("[FAILED]\n");
- printf("Failed to find Target reserved as expected.\n");
- return -1;
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to find Target reserved as expected.");
+ ret = -1;
+ goto dun;
}
if (rr->reservation_key != key) {
- printf("[FAILED]\n");
- printf("Failed to find reservation key 0x%llx: found 0x%lx.\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to find reservation key 0x%llx: found 0x%lx.",
key, rr->reservation_key);
- return -1;
+ ret = -1;
+ goto dun;
}
if (rr->pr_type != pr_type) {
- printf("[FAILED]\n");
- printf("Failed to find reservation type %d: found %d.\n",
+ logging(LOG_NORMAL,
+ "Failed to find reservation type %d: found %d.",
pr_type, rr->pr_type);
return -1;
+ ret = -1;
+ goto dun;
}

- printf("[OK]\n");
- return 0;
+ dun:
+ /* ??? free rr? */
+ scsi_free_scsi_task(task);
+ return ret;
}

int
@@ -587,33 +592,37 @@ verify_read_works(struct iscsi_context *iscsi, int lun, unsigned char *buf)
const uint32_t lba = 1;
const int blksize = 512;
const uint32_t datalen = 1 * blksize;
+ int ret = 0;
+

/*
* try to read the second 512-byte block
*/

- printf("Send READ10 to verify READ works init=%s ... ",
+ logging(LOG_VERBOSE, "Send READ10 to verify READ works init=%s",
iscsi->initiator_name);

- task = iscsi_read10_sync(iscsi, lun, lba, datalen, blksize, 0, 0, 0, 0, 0);
+ task = iscsi_read10_sync(iscsi, lun, lba, datalen, blksize,
+ 0, 0, 0, 0, 0);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send READ10 command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send READ10 command: %s",
iscsi_get_error(iscsi));
return -1;
}
+
if (task->status != SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("READ10 command: failed with sense: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] READ10 command: failed with sense: %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
+ goto dun;
}
memcpy(buf, task->datain.data, task->datain.size);
- scsi_free_scsi_task(task);

- printf("[OK]\n");
- return 0;
+ dun:
+ scsi_free_scsi_task(task);
+ return ret;
}

int
@@ -623,35 +632,35 @@ verify_write_works(struct iscsi_context *iscsi, int lun, unsigned char *buf)
const uint32_t lba = 1;
const int blksize = 512;
const uint32_t datalen = 1 * blksize;
+ int ret = 0;
+

/*
* try to write the second 512-byte block
*/

- printf("Send WRITE10 to verify WRITE works init=%s ... ",
+ logging(LOG_VERBOSE, "Send WRITE10 to verify WRITE works init=%s",
iscsi->initiator_name);

- task = iscsi_write10_sync(iscsi, lun, lba, buf, datalen, blksize, 0, 0, 0, 0, 0);
+ task = iscsi_write10_sync(iscsi, lun, lba, buf, datalen, blksize,
+ 0, 0, 0, 0, 0);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send WRITE10 command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send WRITE10 command: %s",
iscsi_get_error(iscsi));
return -1;
}
+
if (task->status != SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("WRITE10 command: failed with sense: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] WRITE10 command: failed with sense: %s",
iscsi_get_error(iscsi));
- scsi_free_scsi_task(task);
- return -1;
+ ret = -1;
}
scsi_free_scsi_task(task);
-
- printf("[OK]\n");
- return 0;
+ return ret;
}

-
int
verify_read_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf)
{
@@ -659,37 +668,41 @@ verify_read_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf)
const uint32_t lba = 1;
const int blksize = 512;
const uint32_t datalen = 1 * blksize;
+ int ret = 0;
+

/*
* try to read the second 512-byte block -- should fail
*/

- printf("Send READ10 to verify READ does not work init=%s ... ",
+ logging(LOG_VERBOSE,
+ "Send READ10 to verify READ does not work init=%s",
iscsi->initiator_name);

- task = iscsi_read10_sync(iscsi, lun, lba, datalen, blksize, 0, 0, 0, 0, 0);
+ task = iscsi_read10_sync(iscsi, lun, lba, datalen, blksize,
+ 0, 0, 0, 0, 0);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send READ10 command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send READ10 command: %s",
iscsi_get_error(iscsi));
return -1;
}
+
if (task->status == SCSI_STATUS_GOOD) {
memcpy(buf, task->datain.data, task->datain.size);
- printf("[FAILED]\n");
- printf("READ10 command succeeded when expected to fail\n");
- scsi_free_scsi_task(task);
- return -1;
+ logging(LOG_NORMAL,
+ "[FAILED] READ10 command succeeded when expected to fail");
+ ret = -1;
+ goto dun;
}

/*
* XXX should we verify sense data?
*/

+ dun:
scsi_free_scsi_task(task);
-
- printf("[OK]\n");
- return 0;
+ return ret;
}

int
@@ -699,36 +712,40 @@ verify_write_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf)
const uint32_t lba = 1;
const int blksize = 512;
const uint32_t datalen = 1 * blksize;
+ int ret = 0;
+

/*
* try to write the second 512-byte block
*/

- printf("Send WRITE10 to verify WRITE does not work init=%s ... ",
+ logging(LOG_VERBOSE,
+ "Send WRITE10 to verify WRITE does not work init=%s",
iscsi->initiator_name);

- task = iscsi_write10_sync(iscsi, lun, lba, buf, datalen, blksize, 0, 0, 0, 0, 0);
+ task = iscsi_write10_sync(iscsi, lun, lba, buf, datalen, blksize,
+ 0, 0, 0, 0, 0);
if (task == NULL) {
- printf("[FAILED]\n");
- printf("Failed to send WRITE10 command: %s\n",
+ logging(LOG_NORMAL,
+ "[FAILED] Failed to send WRITE10 command: %s",
iscsi_get_error(iscsi));
return -1;
}
+
if (task->status == SCSI_STATUS_GOOD) {
- printf("[FAILED]\n");
- printf("WRITE10 command: succeeded when exptec to fail\n");
- scsi_free_scsi_task(task);
- return -1;
+ logging(LOG_NORMAL,
+ "[FAILED] WRITE10 command: succeeded when exptec to fail");
+ ret = -1;
+ goto dun;
}

/*
* XXX should we verify sense data?
*/

+ dun:
scsi_free_scsi_task(task);
-
- printf("[OK]\n");
- return 0;
+ return ret;
}

int
--
1.7.10.4

Lee Duncan

unread,
Feb 16, 2013, 4:56:16 PM2/16/13
to ronnies...@gmail.com, libi...@googlegroups.com

I am submitting the following group reservation testing patches:

[PATCH 1/6] Renamed group reservation routines with prin_*/prout_*
[PATCH 2/6] Cleaned up prin_read_keys since task always passed in
[PATCH 3/6] Added dataloss checks for prout_* functions
[PATCH 4/6] group reservation tests logging and cleanup
[PATCH 5/6] ported 3 more group reservation tests to CUnit
[PATCH 6/6] ported group reservation access control test to CUnit


Makefile.am | 4 +
test-tool/1120_persistent_register_simple.c | 10 +--
test-tool/1130_persistent_reserve_simple.c | 10 +--
test-tool/1140_persistent_reserve_access_check_ea.c | 14 +--
test-tool/1141_persistent_reserve_access_check_we.c | 14 +--
test-tool/1142_persistent_reserve_access_check_earo.c | 14 +--
test-tool/1143_persistent_reserve_access_check_wero.c | 14 +--
test-tool/1144_persistent_reserve_access_check_eaar.c | 14 +--
test-tool/1145_persistent_reserve_access_check_wear.c | 14 +--
test-tool/iscsi-support.c | 459 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------
test-tool/iscsi-support.h | 19 ++--
test-tool/iscsi-test-cu.c | 83 +++++++++++++++--
test-tool/iscsi-test-cu.h | 14 +++
test-tool/test_prin_serviceaction_range.c | 54 ++++++++++++
test-tool/test_prout_register_simple.c | 58 ++++++++++++
test-tool/test_prout_reserve_access.c | 166 ++++++++++++++++++++++++++++++++++
test-tool/test_prout_reserve_simple.c | 81 +++++++++++++++++
17 files changed, 796 insertions(+), 246 deletions(-)

--
Lee Duncan
SUSE Labs

Lee Duncan

unread,
Feb 16, 2013, 4:56:18 PM2/16/13
to ronnies...@gmail.com, libi...@googlegroups.com, Lee Duncan
From: Lee Duncan <ldu...@suse.de>

Cleaned up prin_read_keys() to assume task is always
passed in, since that is the case.
---
test-tool/iscsi-support.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c
index 978564b..52b9181 100644
--- a/test-tool/iscsi-support.c
+++ b/test-tool/iscsi-support.c
@@ -194,47 +194,36 @@ prin_read_keys(struct iscsi_context *iscsi, int lun, struct scsi_task **tp,
{
const int buf_sz = 16384;
struct scsi_persistent_reserve_in_read_keys *rk = NULL;
- struct scsi_task *task;


logging(LOG_VERBOSE, "Send PRIN/READ_KEYS");

- task = iscsi_persistent_reserve_in_sync(iscsi, lun,
+ *tp = iscsi_persistent_reserve_in_sync(iscsi, lun,
SCSI_PERSISTENT_RESERVE_READ_KEYS, buf_sz);
- if (task == NULL) {
+ if (*tp == NULL) {
logging(LOG_NORMAL,
"[FAILED] Failed to send PRIN command: %s",
iscsi_get_error(iscsi));
return -1;
}
- if (tp != NULL)
- *tp = task;

- if (task->status != SCSI_STATUS_GOOD) {
+ if ((*tp)->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL,
"[FAILED] PRIN command: failed with sense. %s",
iscsi_get_error(iscsi));
- if (tp == NULL)
- scsi_free_scsi_task(task);
return -1;
}

- rk = scsi_datain_unmarshall(task);
+ rk = scsi_datain_unmarshall(*tp);
if (rk == NULL) {
logging(LOG_NORMAL,
"[FAIL] failed to unmarshall PRIN/READ_KEYS data. %s",
iscsi_get_error(iscsi));
- if (tp == NULL)
- scsi_free_scsi_task(task);
return -1;
}
if (rkp != NULL)
*rkp = rk;

- /* clean up if we are managing our own task */
- if (tp == NULL)
- scsi_free_scsi_task(task);
-
return 0;
}

--
1.7.10.4

Lee Duncan

unread,
Feb 16, 2013, 4:56:17 PM2/16/13
to ronnies...@gmail.com, libi...@googlegroups.com, Lee Duncan
From: Lee Duncan <ldu...@suse.de>

Renamed group reservation helper functions with prin_* or prout_*,
making it more clear what they are doing.
---
test-tool/1120_persistent_register_simple.c | 10 +++++-----
test-tool/1130_persistent_reserve_simple.c | 10 +++++-----
test-tool/1140_persistent_reserve_access_check_ea.c | 14 +++++++-------
test-tool/1141_persistent_reserve_access_check_we.c | 14 +++++++-------
test-tool/1142_persistent_reserve_access_check_earo.c | 14 +++++++-------
test-tool/1143_persistent_reserve_access_check_wero.c | 14 +++++++-------
test-tool/1144_persistent_reserve_access_check_eaar.c | 14 +++++++-------
test-tool/1145_persistent_reserve_access_check_wear.c | 14 +++++++-------
test-tool/iscsi-support.c | 15 +++++++--------
test-tool/iscsi-support.h | 14 +++++++-------
10 files changed, 66 insertions(+), 67 deletions(-)

diff --git a/test-tool/1120_persistent_register_simple.c b/test-tool/1120_persistent_register_simple.c
index a52a5a6..8e83b14 100644
--- a/test-tool/1120_persistent_register_simple.c
+++ b/test-tool/1120_persistent_register_simple.c
@@ -60,32 +60,32 @@ int T1120_persistent_register_simple(const char *initiator, const char *url)
ret = 0;

/* register our reservation key with the target */
- ret = register_and_ignore(iscsi, lun, key);
+ ret = prout_register_and_ignore(iscsi, lun, key);
if (ret != 0) {
goto finished;
}

/* verify we can read the registration */
- ret = verify_key_presence(iscsi, lun, key, 1);
+ ret = prin_verify_key_presence(iscsi, lun, key, 1);
if (ret != 0) {
goto finished;
}

/* try to reregister, which should fail */
- ret = reregister_key_fails(iscsi, lun, key+1);
+ ret = prout_reregister_key_fails(iscsi, lun, key+1);
if (ret != 0) {
goto finished;
}

/* release from the target */
- ret = register_key(iscsi, lun, 0, key);
+ ret = prout_register_key(iscsi, lun, 0, key);
if (ret != 0) {
goto finished;
}

/* Verify the registration is gone */
/* verify we can read the registration */
- ret = verify_key_presence(iscsi, lun, key, 0);
+ ret = prin_verify_key_presence(iscsi, lun, key, 0);
if (ret != 0) {
goto finished;
}
diff --git a/test-tool/1130_persistent_reserve_simple.c b/test-tool/1130_persistent_reserve_simple.c
index 8b75b7b..8127c5d 100644
--- a/test-tool/1130_persistent_reserve_simple.c
+++ b/test-tool/1130_persistent_reserve_simple.c
@@ -78,7 +78,7 @@ int T1130_persistent_reserve_simple(const char *initiator, const char *url)
ret = 0;

/* register our reservation key with the target */
- ret = register_and_ignore(iscsi, lun, key);
+ ret = prout_register_and_ignore(iscsi, lun, key);
if (ret != 0)
goto finished;

@@ -87,25 +87,25 @@ int T1130_persistent_reserve_simple(const char *initiator, const char *url)
enum scsi_persistent_out_type pr_type = pr_types_to_test[i];

/* reserve the target */
- ret = reserve(iscsi, lun, key, pr_type);
+ ret = prout_reserve(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* verify target reservation */
- ret = verify_reserved_as(iscsi, lun,
+ ret = prin_verify_reserved_as(iscsi, lun,
pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type);
if (ret != 0)
goto finished;

/* release our reservation */
- ret = release(iscsi, lun, key, pr_type);
+ ret = prout_release(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;
}

/* remove our key from the target */
- ret = register_key(iscsi, lun, 0, key);
+ ret = prout_register_key(iscsi, lun, 0, key);
if (ret != 0)
goto finished;

diff --git a/test-tool/1140_persistent_reserve_access_check_ea.c b/test-tool/1140_persistent_reserve_access_check_ea.c
index 79bffe7..79e5738 100644
--- a/test-tool/1140_persistent_reserve_access_check_ea.c
+++ b/test-tool/1140_persistent_reserve_access_check_ea.c
@@ -76,20 +76,20 @@ int T1140_persistent_reserve_access_check_ea(const char *initiator,
}

/* register our reservation key with the target */
- ret = register_and_ignore(iscsi, lun, key);
+ ret = prout_register_and_ignore(iscsi, lun, key);
if (ret != 0)
goto finished;
- ret = register_and_ignore(iscsi2, lun2, key2);
+ ret = prout_register_and_ignore(iscsi2, lun2, key2);
if (ret != 0)
goto finished;

/* reserve the target through initiator 1 */
- ret = reserve(iscsi, lun, key, pr_type);
+ ret = prout_reserve(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* verify target reservation */
- ret = verify_reserved_as(iscsi, lun,
+ ret = prin_verify_reserved_as(iscsi, lun,
pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type);
if (ret != 0)
@@ -123,7 +123,7 @@ int T1140_persistent_reserve_access_check_ea(const char *initiator,
goto finished;

/* unregister init2 */
- ret = register_key(iscsi2, lun2, 0, key);
+ ret = prout_register_key(iscsi2, lun2, 0, key);
if (ret != 0) {
goto finished;
}
@@ -139,12 +139,12 @@ int T1140_persistent_reserve_access_check_ea(const char *initiator,
goto finished;

/* release our reservation */
- ret = release(iscsi, lun, key, pr_type);
+ ret = prout_release(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* remove our key from the target */
- ret = register_key(iscsi, lun, 0, key);
+ ret = prout_register_key(iscsi, lun, 0, key);
if (ret != 0)
goto finished;

diff --git a/test-tool/1141_persistent_reserve_access_check_we.c b/test-tool/1141_persistent_reserve_access_check_we.c
index db73566..239b8af 100644
--- a/test-tool/1141_persistent_reserve_access_check_we.c
+++ b/test-tool/1141_persistent_reserve_access_check_we.c
@@ -76,20 +76,20 @@ int T1141_persistent_reserve_access_check_we(const char *initiator,
}

/* register our reservation key with the target */
- ret = register_and_ignore(iscsi, lun, key);
+ ret = prout_register_and_ignore(iscsi, lun, key);
if (ret != 0)
goto finished;
- ret = register_and_ignore(iscsi2, lun2, key2);
+ ret = prout_register_and_ignore(iscsi2, lun2, key2);
if (ret != 0)
goto finished;

/* reserve the target through initiator 1 */
- ret = reserve(iscsi, lun, key, pr_type);
+ ret = prout_reserve(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* verify target reservation */
- ret = verify_reserved_as(iscsi, lun,
+ ret = prin_verify_reserved_as(iscsi, lun,
pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type);
if (ret != 0)
@@ -123,7 +123,7 @@ int T1141_persistent_reserve_access_check_we(const char *initiator,
goto finished;

/* unregister init2 */
- ret = register_key(iscsi2, lun2, 0, key);
+ ret = prout_register_key(iscsi2, lun2, 0, key);
if (ret != 0) {
goto finished;
}
@@ -139,12 +139,12 @@ int T1141_persistent_reserve_access_check_we(const char *initiator,
goto finished;

/* release our reservation */
- ret = release(iscsi, lun, key, pr_type);
+ ret = prout_release(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* remove our key from the target */
- ret = register_key(iscsi, lun, 0, key);
+ ret = prout_register_key(iscsi, lun, 0, key);
if (ret != 0)
goto finished;

diff --git a/test-tool/1142_persistent_reserve_access_check_earo.c b/test-tool/1142_persistent_reserve_access_check_earo.c
index 90f8af2..b3e8877 100644
--- a/test-tool/1142_persistent_reserve_access_check_earo.c
+++ b/test-tool/1142_persistent_reserve_access_check_earo.c
@@ -76,20 +76,20 @@ int T1142_persistent_reserve_access_check_earo(const char *initiator,
}

/* register our reservation key with the target */
- ret = register_and_ignore(iscsi, lun, key);
+ ret = prout_register_and_ignore(iscsi, lun, key);
if (ret != 0)
goto finished;
- ret = register_and_ignore(iscsi2, lun2, key2);
+ ret = prout_register_and_ignore(iscsi2, lun2, key2);
if (ret != 0)
goto finished;

/* reserve the target through initiator 1 */
- ret = reserve(iscsi, lun, key, pr_type);
+ ret = prout_reserve(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* verify target reservation */
- ret = verify_reserved_as(iscsi, lun,
+ ret = prin_verify_reserved_as(iscsi, lun,
pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type);
if (ret != 0)
@@ -123,7 +123,7 @@ int T1142_persistent_reserve_access_check_earo(const char *initiator,
goto finished;

/* unregister init2 */
- ret = register_key(iscsi2, lun2, 0, key);
+ ret = prout_register_key(iscsi2, lun2, 0, key);
if (ret != 0) {
goto finished;
}
@@ -139,12 +139,12 @@ int T1142_persistent_reserve_access_check_earo(const char *initiator,
goto finished;

/* release our reservation */
- ret = release(iscsi, lun, key, pr_type);
+ ret = prout_release(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* remove our key from the target */
- ret = register_key(iscsi, lun, 0, key);
+ ret = prout_register_key(iscsi, lun, 0, key);
if (ret != 0)
goto finished;

diff --git a/test-tool/1143_persistent_reserve_access_check_wero.c b/test-tool/1143_persistent_reserve_access_check_wero.c
index ac766d9..faf32c6 100644
--- a/test-tool/1143_persistent_reserve_access_check_wero.c
+++ b/test-tool/1143_persistent_reserve_access_check_wero.c
@@ -76,20 +76,20 @@ int T1143_persistent_reserve_access_check_wero(const char *initiator,
}

/* register our reservation key with the target */
- ret = register_and_ignore(iscsi, lun, key);
+ ret = prout_register_and_ignore(iscsi, lun, key);
if (ret != 0)
goto finished;
- ret = register_and_ignore(iscsi2, lun2, key2);
+ ret = prout_register_and_ignore(iscsi2, lun2, key2);
if (ret != 0)
goto finished;

/* reserve the target through initiator 1 */
- ret = reserve(iscsi, lun, key, pr_type);
+ ret = prout_reserve(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* verify target reservation */
- ret = verify_reserved_as(iscsi, lun,
+ ret = prin_verify_reserved_as(iscsi, lun,
pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type);
if (ret != 0)
@@ -123,7 +123,7 @@ int T1143_persistent_reserve_access_check_wero(const char *initiator,
goto finished;

/* unregister init2 */
- ret = register_key(iscsi2, lun2, 0, key);
+ ret = prout_register_key(iscsi2, lun2, 0, key);
if (ret != 0) {
goto finished;
}
@@ -139,12 +139,12 @@ int T1143_persistent_reserve_access_check_wero(const char *initiator,
goto finished;

/* release our reservation */
- ret = release(iscsi, lun, key, pr_type);
+ ret = prout_release(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* remove our key from the target */
- ret = register_key(iscsi, lun, 0, key);
+ ret = prout_register_key(iscsi, lun, 0, key);
if (ret != 0)
goto finished;

diff --git a/test-tool/1144_persistent_reserve_access_check_eaar.c b/test-tool/1144_persistent_reserve_access_check_eaar.c
index 511172c..fdf955a 100644
--- a/test-tool/1144_persistent_reserve_access_check_eaar.c
+++ b/test-tool/1144_persistent_reserve_access_check_eaar.c
@@ -76,20 +76,20 @@ int T1144_persistent_reserve_access_check_eaar(const char *initiator,
}

/* register our reservation key with the target */
- ret = register_and_ignore(iscsi, lun, key);
+ ret = prout_register_and_ignore(iscsi, lun, key);
if (ret != 0)
goto finished;
- ret = register_and_ignore(iscsi2, lun2, key2);
+ ret = prout_register_and_ignore(iscsi2, lun2, key2);
if (ret != 0)
goto finished;

/* reserve the target through initiator 1 */
- ret = reserve(iscsi, lun, key, pr_type);
+ ret = prout_reserve(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* verify target reservation */
- ret = verify_reserved_as(iscsi, lun,
+ ret = prin_verify_reserved_as(iscsi, lun,
pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type);
if (ret != 0)
@@ -123,7 +123,7 @@ int T1144_persistent_reserve_access_check_eaar(const char *initiator,
goto finished;

/* unregister init2 */
- ret = register_key(iscsi2, lun2, 0, key);
+ ret = prout_register_key(iscsi2, lun2, 0, key);
if (ret != 0) {
goto finished;
}
@@ -139,12 +139,12 @@ int T1144_persistent_reserve_access_check_eaar(const char *initiator,
goto finished;

/* release our reservation */
- ret = release(iscsi, lun, key, pr_type);
+ ret = prout_release(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* remove our key from the target */
- ret = register_key(iscsi, lun, 0, key);
+ ret = prout_register_key(iscsi, lun, 0, key);
if (ret != 0)
goto finished;

diff --git a/test-tool/1145_persistent_reserve_access_check_wear.c b/test-tool/1145_persistent_reserve_access_check_wear.c
index 36f9af0..002d2cd 100644
--- a/test-tool/1145_persistent_reserve_access_check_wear.c
+++ b/test-tool/1145_persistent_reserve_access_check_wear.c
@@ -76,20 +76,20 @@ int T1145_persistent_reserve_access_check_wear(const char *initiator,
}

/* register our reservation key with the target */
- ret = register_and_ignore(iscsi, lun, key);
+ ret = prout_register_and_ignore(iscsi, lun, key);
if (ret != 0)
goto finished;
- ret = register_and_ignore(iscsi2, lun2, key2);
+ ret = prout_register_and_ignore(iscsi2, lun2, key2);
if (ret != 0)
goto finished;

/* reserve the target through initiator 1 */
- ret = reserve(iscsi, lun, key, pr_type);
+ ret = prout_reserve(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* verify target reservation */
- ret = verify_reserved_as(iscsi, lun,
+ ret = prin_verify_reserved_as(iscsi, lun,
pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type);
if (ret != 0)
@@ -123,7 +123,7 @@ int T1145_persistent_reserve_access_check_wear(const char *initiator,
goto finished;

/* unregister init2 */
- ret = register_key(iscsi2, lun2, 0, key);
+ ret = prout_register_key(iscsi2, lun2, 0, key);
if (ret != 0) {
goto finished;
}
@@ -139,12 +139,12 @@ int T1145_persistent_reserve_access_check_wear(const char *initiator,
goto finished;

/* release our reservation */
- ret = release(iscsi, lun, key, pr_type);
+ ret = prout_release(iscsi, lun, key, pr_type);
if (ret != 0)
goto finished;

/* remove our key from the target */
- ret = register_key(iscsi, lun, 0, key);
+ ret = prout_register_key(iscsi, lun, 0, key);
if (ret != 0)
goto finished;

diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c
index 1d32c31..978564b 100644
--- a/test-tool/iscsi-support.c
+++ b/test-tool/iscsi-support.c
@@ -240,7 +240,7 @@ prin_read_keys(struct iscsi_context *iscsi, int lun, struct scsi_task **tp,


int
-register_and_ignore(struct iscsi_context *iscsi, int lun,
+prout_register_and_ignore(struct iscsi_context *iscsi, int lun,
unsigned long long sark)
{
struct scsi_persistent_reserve_out_basic poc;
@@ -285,7 +285,7 @@ register_and_ignore(struct iscsi_context *iscsi, int lun,


int
-register_key(struct iscsi_context *iscsi, int lun,
+prout_register_key(struct iscsi_context *iscsi, int lun,
unsigned long long sark, unsigned long long rk)
{
struct scsi_persistent_reserve_out_basic poc;
@@ -324,7 +324,7 @@ register_key(struct iscsi_context *iscsi, int lun,


int
-verify_key_presence(struct iscsi_context *iscsi, int lun,
+prin_verify_key_presence(struct iscsi_context *iscsi, int lun,
unsigned long long key, int present)
{
struct scsi_task *task;
@@ -384,7 +384,7 @@ verify_key_presence(struct iscsi_context *iscsi, int lun,


int
-reregister_key_fails(struct iscsi_context *iscsi, int lun,
+prout_reregister_key_fails(struct iscsi_context *iscsi, int lun,
unsigned long long sark)
{
struct scsi_persistent_reserve_out_basic poc;
@@ -430,7 +430,7 @@ reregister_key_fails(struct iscsi_context *iscsi, int lun,


int
-reserve(struct iscsi_context *iscsi, int lun,
+prout_reserve(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type)
{
struct scsi_persistent_reserve_out_basic poc;
@@ -470,7 +470,7 @@ reserve(struct iscsi_context *iscsi, int lun,


int
-release(struct iscsi_context *iscsi, int lun,
+prout_release(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type)
{
struct scsi_persistent_reserve_out_basic poc;
@@ -508,7 +508,7 @@ release(struct iscsi_context *iscsi, int lun,
}

int
-verify_reserved_as(struct iscsi_context *iscsi, int lun,
+prin_verify_reserved_as(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type)
{
struct scsi_task *task;
@@ -566,7 +566,6 @@ verify_reserved_as(struct iscsi_context *iscsi, int lun,
return 0;
}

-
int
verify_read_works(struct iscsi_context *iscsi, int lun, unsigned char *buf)
{
diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h
index 9b39215..e543c31 100644
--- a/test-tool/iscsi-support.h
+++ b/test-tool/iscsi-support.h
@@ -168,19 +168,19 @@ static inline int pr_type_is_all_registrants(
int prin_read_keys(struct iscsi_context *iscsi, int lun, struct scsi_task **tp,
struct scsi_persistent_reserve_in_read_keys **rkp);

-int register_and_ignore(struct iscsi_context *iscsi, int lun,
+int prout_register_and_ignore(struct iscsi_context *iscsi, int lun,
unsigned long long key);
-int register_key(struct iscsi_context *iscsi, int lun,
+int prout_register_key(struct iscsi_context *iscsi, int lun,
unsigned long long sark, unsigned long long rk);
-int verify_key_presence(struct iscsi_context *iscsi, int lun,
+int prin_verify_key_presence(struct iscsi_context *iscsi, int lun,
unsigned long long key, int present);
-int reregister_key_fails(struct iscsi_context *iscsi, int lun,
+int prout_reregister_key_fails(struct iscsi_context *iscsi, int lun,
unsigned long long sark);
-int reserve(struct iscsi_context *iscsi, int lun,
+int prout_reserve(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type);
-int release(struct iscsi_context *iscsi, int lun,
+int prout_release(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type);
-int verify_reserved_as(struct iscsi_context *iscsi, int lun,
+int prin_verify_reserved_as(struct iscsi_context *iscsi, int lun,
unsigned long long key, enum scsi_persistent_out_type pr_type);
int verify_read_works(struct iscsi_context *iscsi, int lun, unsigned char *buf);
int verify_write_works(struct iscsi_context *iscsi, int lun, unsigned char *buf);
--
1.7.10.4

Reply all
Reply to author
Forward
0 new messages