From 74a50052cd5fd73137fbddee089bd18794727562 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 18 Sep 2014 18:37:35 -0700 Subject: [PATCH] TESTS: get rid of iscsic2 Signed-off-by: Ronnie Sahlberg --- test-tool/iscsi-test-cu.c | 36 ++---------------- test-tool/iscsi-test-cu.h | 2 - test-tool/test_prout_reserve_access.c | 48 ++++++++++++++++++------ test-tool/test_prout_reserve_ownership.c | 48 ++++++++++++++++++------ test-tool/test_reserve6_2initiators.c | 1 - test-tool/test_reserve6_itnexus_loss.c | 1 - 6 files changed, 75 insertions(+), 61 deletions(-) diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c index 3ee2ca0..b51fb4b 100644 --- a/test-tool/iscsi-test-cu.c +++ b/test-tool/iscsi-test-cu.c @@ -410,7 +410,6 @@ typedef struct libiscsi_suite_info { } libiscsi_suite_info; #define NON_PGR_FUNCS suite_init, suite_cleanup, test_setup, test_teardown -#define PGR_FUNCS suite_init_pgr, suite_cleanup_pgr, test_setup, test_teardown /* SCSI protocol tests */ static libiscsi_suite_info scsi_suites[] = { @@ -427,7 +426,7 @@ static libiscsi_suite_info scsi_suites[] = { { "PrinReadKeys", NON_PGR_FUNCS, tests_prin_read_keys }, { "PrinServiceactionRange", NON_PGR_FUNCS, tests_prin_serviceaction_range }, { "ProutRegister", NON_PGR_FUNCS, tests_prout_register }, - { "ProutReserve", PGR_FUNCS, tests_prout_reserve }, + { "ProutReserve", NON_PGR_FUNCS, tests_prout_reserve }, { "Read6", NON_PGR_FUNCS, tests_read6 }, { "Read10", NON_PGR_FUNCS, tests_read10 }, { "Read12", NON_PGR_FUNCS, tests_read12 }, @@ -508,7 +507,7 @@ static libiscsi_suite_info all_suites[] = { { "PrinServiceactionRange", NON_PGR_FUNCS, tests_prin_serviceaction_range }, { "ProutRegister", NON_PGR_FUNCS, tests_prout_register }, - { "ProutReserve", PGR_FUNCS, tests_prout_reserve }, + { "ProutReserve", NON_PGR_FUNCS, tests_prout_reserve }, { "Read6", NON_PGR_FUNCS, tests_read6 }, { "Read10", NON_PGR_FUNCS, tests_read10 }, { "Read12", NON_PGR_FUNCS, tests_read12 }, @@ -553,7 +552,7 @@ static libiscsi_suite_info scsi_usb_sbc_suites[] = { { "PrinServiceactionRange", NON_PGR_FUNCS, tests_prin_serviceaction_range }, { "ProutRegister", NON_PGR_FUNCS, tests_prout_register }, - { "ProutReserve", PGR_FUNCS, tests_prout_reserve }, + { "ProutReserve", NON_PGR_FUNCS, tests_prout_reserve }, { "Read6", NON_PGR_FUNCS, tests_read6 }, { "Read10", NON_PGR_FUNCS, tests_read10 }, { "Read12", NON_PGR_FUNCS, tests_read12 }, @@ -597,11 +596,8 @@ static struct test_family families[] = { * globals for test setup and teardown */ struct scsi_task *task; -int tgt_lun2; -struct iscsi_context *iscsic2; unsigned char *read_write_buf; - static void print_usage(void) { @@ -710,32 +706,6 @@ suite_cleanup(void) return 0; } -int -suite_init_pgr(void) -{ - suite_init(); - iscsic2 = iscsi_context_login(initiatorname2, sd->iscsi_url, &tgt_lun2); - if (iscsic2 == NULL) { - fprintf(stderr, - "error: Failed to login to target for test set-up\n"); - suite_cleanup(); - return 1; - } - return 0; -} - -int -suite_cleanup_pgr(void) -{ - if (iscsic2) { - iscsi_logout_sync(iscsic2); - iscsi_destroy_context(iscsic2); - iscsic2 = NULL; - } - suite_cleanup(); - 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 638a802..cd82f74 100644 --- a/test-tool/iscsi-test-cu.h +++ b/test-tool/iscsi-test-cu.h @@ -33,8 +33,6 @@ /* globals between setup, tests, and teardown */ extern struct scsi_task *task; -extern struct iscsi_context *iscsic2; -extern int tgt_lun2; extern unsigned char *read_write_buf; #ifndef HAVE_CU_SUITEINFO_PSETUPFUNC diff --git a/test-tool/test_prout_reserve_access.c b/test-tool/test_prout_reserve_access.c index 94a1f63..ff39f89 100644 --- a/test-tool/test_prout_reserve_access.c +++ b/test-tool/test_prout_reserve_access.c @@ -124,11 +124,15 @@ test_prout_reserve_access_ea(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_access(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS, 0, 0, 0, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -136,11 +140,15 @@ test_prout_reserve_access_we(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_access(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE, 1, 0, 1, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -148,11 +156,15 @@ test_prout_reserve_access_earo(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_access(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY, 1, 1, 0, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -160,11 +172,15 @@ test_prout_reserve_access_wero(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_access(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY, 1, 1, 1, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -172,11 +188,15 @@ test_prout_reserve_access_eaar(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_access(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS, 1, 1, 0, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -184,9 +204,13 @@ test_prout_reserve_access_wear(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_access(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS, 1, 1, 1, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } diff --git a/test-tool/test_prout_reserve_ownership.c b/test-tool/test_prout_reserve_ownership.c index 6898e08..d57e600 100644 --- a/test-tool/test_prout_reserve_ownership.c +++ b/test-tool/test_prout_reserve_ownership.c @@ -98,10 +98,14 @@ test_prout_reserve_ownership_ea(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_ownership(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -109,10 +113,14 @@ test_prout_reserve_ownership_we(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_ownership(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -120,10 +128,14 @@ test_prout_reserve_ownership_earo(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_ownership(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -131,10 +143,14 @@ test_prout_reserve_ownership_wero(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_ownership(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY, 0); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -142,10 +158,14 @@ test_prout_reserve_ownership_eaar(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_ownership(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS, 1); + iscsi_destroy_context(sd2.iscsi_ctx); } void @@ -153,8 +173,12 @@ test_prout_reserve_ownership_wear(void) { struct scsi_device sd2; - sd2.iscsi_ctx = iscsic2; - sd2.iscsi_lun = tgt_lun2; + sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun); + if (sd2.iscsi_ctx == NULL) { + logging(LOG_VERBOSE, "Failed to login to target"); + return; + } verify_persistent_reserve_ownership(sd, &sd2, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS, 1); + iscsi_destroy_context(sd2.iscsi_ctx); } diff --git a/test-tool/test_reserve6_2initiators.c b/test-tool/test_reserve6_2initiators.c index 54ed817..f063925 100644 --- a/test-tool/test_reserve6_2initiators.c +++ b/test-tool/test_reserve6_2initiators.c @@ -94,5 +94,4 @@ test_reserve6_2initiators(void) iscsi_logout_sync(sd2.iscsi_ctx); iscsi_destroy_context(sd2.iscsi_ctx); - iscsic2 = NULL; } diff --git a/test-tool/test_reserve6_itnexus_loss.c b/test-tool/test_reserve6_itnexus_loss.c index 369d3e1..adfa771 100644 --- a/test-tool/test_reserve6_itnexus_loss.c +++ b/test-tool/test_reserve6_itnexus_loss.c @@ -80,5 +80,4 @@ test_reserve6_itnexus_loss(void) finished: iscsi_logout_sync(sd2.iscsi_ctx); iscsi_destroy_context(sd2.iscsi_ctx); - iscsic2 = NULL; }