From 5135836ee596eafe0206e2261ca0be11b508e09b Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sat, 11 May 2013 17:07:59 -0700 Subject: [PATCH] TESTS: keep the unmarshalled std inq structure around --- test-tool/0103_read10_rdprotect.c | 6 ++-- test-tool/0104_read10_flags.c | 7 ++-- test-tool/0202_read16_flags.c | 7 ++-- test-tool/0212_read12_flags.c | 7 ++-- test-tool/0222_write16_flags.c | 7 ++-- test-tool/0232_write12_flags.c | 7 ++-- test-tool/0292_write10_flags.c | 7 ++-- test-tool/0300_readonly.c | 15 ++++---- test-tool/0360_startstopunit_simple.c | 6 ++-- test-tool/0361_startstopunit_pwrcnd.c | 2 +- test-tool/0362_startstopunit_noloej.c | 2 +- test-tool/0370_nomedia.c | 2 +- test-tool/0380_preventallow_simple.c | 6 ++-- test-tool/0381_preventallow_eject.c | 6 ++-- test-tool/0382_preventallow_itnexus_loss.c | 6 ++-- .../0383_preventallow_target_warm_reset.c | 6 ++-- .../0384_preventallow_target_cold_reset.c | 6 ++-- test-tool/0385_preventallow_lun_reset.c | 6 ++-- test-tool/0386_preventallow_2_it_nexuses.c | 6 ++-- test-tool/0390_mandatory_opcodes_sbc.c | 34 +++++++++---------- test-tool/0400_inquiry_basic.c | 32 ++++++++--------- test-tool/0403_inquiry_supported_vpd.c | 12 +++---- test-tool/0404_inquiry_all_reported_vpd.c | 30 ++++++++-------- test-tool/0410_readtoc_basic.c | 8 ++--- test-tool/iscsi-support.c | 5 ++- test-tool/iscsi-support.h | 14 ++++---- test-tool/iscsi-test-cu.c | 27 +++++++-------- test-tool/iscsi-test.c | 31 +++++++---------- test-tool/iscsi-test.h | 1 - test-tool/test_inquiry_alloc_length.c | 12 +++---- test-tool/test_inquiry_standard.c | 30 ++++++++-------- test-tool/test_inquiry_supported_vpd.c | 14 ++++---- test-tool/test_nomedia_sbc.c | 2 +- test-tool/test_read10_flags.c | 7 +--- test-tool/test_read10_rdprotect.c | 8 ++--- test-tool/test_read12_flags.c | 7 +--- test-tool/test_read12_rdprotect.c | 9 ++--- test-tool/test_startstopunit_noloej.c | 2 +- test-tool/test_startstopunit_pwrcnd.c | 2 +- test-tool/test_startstopunit_simple.c | 4 +-- 40 files changed, 186 insertions(+), 222 deletions(-) diff --git a/test-tool/0103_read10_rdprotect.c b/test-tool/0103_read10_rdprotect.c index 64db44e..9932385 100644 --- a/test-tool/0103_read10_rdprotect.c +++ b/test-tool/0103_read10_rdprotect.c @@ -43,12 +43,12 @@ int T0103_read10_rdprotect(const char *initiator, const char *url) return -1; } - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("LUN is not SBC device. Skipping test\n"); + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); return -2; } - ret = 0; /* Try out Different non-zero values for RDPROTECT. They should all fail */ diff --git a/test-tool/0104_read10_flags.c b/test-tool/0104_read10_flags.c index 94bc31f..e0a6955 100644 --- a/test-tool/0104_read10_flags.c +++ b/test-tool/0104_read10_flags.c @@ -47,13 +47,12 @@ int T0104_read10_flags(const char *initiator, const char *url) return -1; } - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("LUN is not SBC device. Skipping test\n"); + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); return -2; } - ret = 0; diff --git a/test-tool/0202_read16_flags.c b/test-tool/0202_read16_flags.c index 89077d3..ed2c3af 100644 --- a/test-tool/0202_read16_flags.c +++ b/test-tool/0202_read16_flags.c @@ -44,13 +44,12 @@ int T0202_read16_flags(const char *initiator, const char *url) return -1; } - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("LUN is not SBC device. Skipping test\n"); + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); return -2; } - printf("Read16 with DPO "); task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 1, 0, 0, 0); if (task == NULL) { diff --git a/test-tool/0212_read12_flags.c b/test-tool/0212_read12_flags.c index 995fb8f..da26717 100644 --- a/test-tool/0212_read12_flags.c +++ b/test-tool/0212_read12_flags.c @@ -44,13 +44,12 @@ int T0212_read12_flags(const char *initiator, const char *url) return -1; } - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("LUN is not SBC device. Skipping test\n"); + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); return -2; } - printf("Read12 with DPO "); task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 1, 0, 0, 0); if (task == NULL) { diff --git a/test-tool/0222_write16_flags.c b/test-tool/0222_write16_flags.c index c80a549..f5a7b48 100644 --- a/test-tool/0222_write16_flags.c +++ b/test-tool/0222_write16_flags.c @@ -45,13 +45,12 @@ int T0222_write16_flags(const char *initiator, const char *url) return -1; } - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("LUN is not SBC device. Skipping test\n"); + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); return -2; } - printf("Write16 with DPO "); task = iscsi_write16_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); if (task == NULL) { diff --git a/test-tool/0232_write12_flags.c b/test-tool/0232_write12_flags.c index 96541b9..b40368a 100644 --- a/test-tool/0232_write12_flags.c +++ b/test-tool/0232_write12_flags.c @@ -45,13 +45,12 @@ int T0232_write12_flags(const char *initiator, const char *url) return -1; } - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("LUN is not SBC device. Skipping test\n"); + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); return -2; } - printf("Write12 with DPO "); task = iscsi_write12_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); if (task == NULL) { diff --git a/test-tool/0292_write10_flags.c b/test-tool/0292_write10_flags.c index 3ea948d..e725ced 100644 --- a/test-tool/0292_write10_flags.c +++ b/test-tool/0292_write10_flags.c @@ -45,13 +45,12 @@ int T0292_write10_flags(const char *initiator, const char *url) return -1; } - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("LUN is not SBC device. Skipping test\n"); + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); return -2; } - printf("Write10 with DPO "); task = iscsi_write10_sync(iscsi, lun, 0, data, block_size, block_size, 0, 1, 0, 0, 0); if (task == NULL) { diff --git a/test-tool/0300_readonly.c b/test-tool/0300_readonly.c index eab361e..6e11bbf 100644 --- a/test-tool/0300_readonly.c +++ b/test-tool/0300_readonly.c @@ -59,15 +59,14 @@ int T0300_readonly(const char *initiator, const char *url) return -1; } - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); + return -2; } - - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("LUN is not SBC device. Skipping test\n"); + if (!data_loss) { + logging(LOG_VERBOSE, "[SKIPPED] --dataloss flag not set." + " Skipping test"); return -2; } diff --git a/test-tool/0360_startstopunit_simple.c b/test-tool/0360_startstopunit_simple.c index a80a9cf..826ab4f 100644 --- a/test-tool/0360_startstopunit_simple.c +++ b/test-tool/0360_startstopunit_simple.c @@ -55,7 +55,7 @@ int T0360_startstopunit_simple(const char *initiator, const char *url) ret = 0; - if (removable) { + if (inq->rmb) { printf("Media is removable. STARTSTOPUNIT should work\n"); } else { printf("Media is not removable. STARTSTOPUNIT should fail\n"); @@ -80,7 +80,7 @@ int T0360_startstopunit_simple(const char *initiator, const char *url) scsi_free_scsi_task(task); printf("[OK]\n"); - if (removable) { + if (inq->rmb) { printf("Medium is removable. Check with TESTUNITREADY that was removed.\n"); ret = testunitready_nomedium(iscsi, lun); if (ret != 0) { @@ -138,7 +138,7 @@ int T0360_startstopunit_simple(const char *initiator, const char *url) scsi_free_scsi_task(task); printf("[OK]\n"); - if (removable) { + if (inq->rmb) { printf("Medium is removable. Check with TESTUNITREADY that was removed.\n"); ret = testunitready_nomedium(iscsi, lun); if (ret != 0) { diff --git a/test-tool/0361_startstopunit_pwrcnd.c b/test-tool/0361_startstopunit_pwrcnd.c index ba92b6a..03d17c2 100644 --- a/test-tool/0361_startstopunit_pwrcnd.c +++ b/test-tool/0361_startstopunit_pwrcnd.c @@ -53,7 +53,7 @@ int T0361_startstopunit_pwrcnd(const char *initiator, const char *url) ret = 0; - if (removable) { + if (inq->rmb) { printf("Media is removable. STARTSTOPUNIT should work\n"); } else { printf("Media is not removable. STARTSTOPUNIT should fail\n"); diff --git a/test-tool/0362_startstopunit_noloej.c b/test-tool/0362_startstopunit_noloej.c index 2d0b056..5bb8ce4 100644 --- a/test-tool/0362_startstopunit_noloej.c +++ b/test-tool/0362_startstopunit_noloej.c @@ -59,7 +59,7 @@ int T0362_startstopunit_noloej(const char *initiator, const char *url) ret = 0; - if (!removable) { + if (!inq->rmb) { printf("Media is not removable. SKIPPING tests\n"); ret = -2; goto finished; diff --git a/test-tool/0370_nomedia.c b/test-tool/0370_nomedia.c index dd4e6c1..60273ae 100644 --- a/test-tool/0370_nomedia.c +++ b/test-tool/0370_nomedia.c @@ -71,7 +71,7 @@ int T0370_nomedia(const char *initiator, const char *url) return -1; } - if (!removable) { + if (!inq->rmb) { printf("Media is not removable. Skipping test.\n"); ret = -2; goto finished; diff --git a/test-tool/0380_preventallow_simple.c b/test-tool/0380_preventallow_simple.c index abc8bbc..aa16b5b 100644 --- a/test-tool/0380_preventallow_simple.c +++ b/test-tool/0380_preventallow_simple.c @@ -53,7 +53,7 @@ int T0380_preventallow_simple(const char *initiator, const char *url) ret = 0; - if (removable) { + if (inq->rmb) { printf("Media is removable. PREVENTALLOW should work\n"); } else { printf("Media is not removable. PREVENTALLOW should fail\n"); @@ -70,7 +70,7 @@ int T0380_preventallow_simple(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); @@ -94,7 +94,7 @@ int T0380_preventallow_simple(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); diff --git a/test-tool/0381_preventallow_eject.c b/test-tool/0381_preventallow_eject.c index e3aee4b..d67cdaa 100644 --- a/test-tool/0381_preventallow_eject.c +++ b/test-tool/0381_preventallow_eject.c @@ -51,7 +51,7 @@ int T0381_preventallow_eject(const char *initiator, const char *url) goto finished; } - if (!removable) { + if (!inq->rmb) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; @@ -72,7 +72,7 @@ int T0381_preventallow_eject(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); @@ -132,7 +132,7 @@ int T0381_preventallow_eject(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); diff --git a/test-tool/0382_preventallow_itnexus_loss.c b/test-tool/0382_preventallow_itnexus_loss.c index 6c57da2..3eaf167 100644 --- a/test-tool/0382_preventallow_itnexus_loss.c +++ b/test-tool/0382_preventallow_itnexus_loss.c @@ -57,7 +57,7 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url) ret = 0; - if (!removable) { + if (!inq->rmb) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; @@ -75,7 +75,7 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); @@ -166,7 +166,7 @@ int T0382_preventallow_itnexus_loss(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); diff --git a/test-tool/0383_preventallow_target_warm_reset.c b/test-tool/0383_preventallow_target_warm_reset.c index 5c91591..6b4f970 100644 --- a/test-tool/0383_preventallow_target_warm_reset.c +++ b/test-tool/0383_preventallow_target_warm_reset.c @@ -71,7 +71,7 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url) goto finished; } - if (!removable) { + if (!inq->rmb) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; @@ -92,7 +92,7 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); @@ -200,7 +200,7 @@ again: /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); diff --git a/test-tool/0384_preventallow_target_cold_reset.c b/test-tool/0384_preventallow_target_cold_reset.c index 00eadbd..2f7ae27 100644 --- a/test-tool/0384_preventallow_target_cold_reset.c +++ b/test-tool/0384_preventallow_target_cold_reset.c @@ -71,7 +71,7 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url) goto finished; } - if (!removable) { + if (!inq->rmb) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; @@ -92,7 +92,7 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); @@ -201,7 +201,7 @@ again: /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); diff --git a/test-tool/0385_preventallow_lun_reset.c b/test-tool/0385_preventallow_lun_reset.c index bdb770b..77b9a76 100644 --- a/test-tool/0385_preventallow_lun_reset.c +++ b/test-tool/0385_preventallow_lun_reset.c @@ -71,7 +71,7 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url) goto finished; } - if (!removable) { + if (!inq->rmb) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; @@ -92,7 +92,7 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); @@ -201,7 +201,7 @@ again: /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); diff --git a/test-tool/0386_preventallow_2_it_nexuses.c b/test-tool/0386_preventallow_2_it_nexuses.c index bed2b99..37cb161 100644 --- a/test-tool/0386_preventallow_2_it_nexuses.c +++ b/test-tool/0386_preventallow_2_it_nexuses.c @@ -54,7 +54,7 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url) goto finished; } - if (!removable) { + if (!inq->rmb) { printf("Media is not removable. Skipping tests\n"); ret = -2; goto finished; @@ -75,7 +75,7 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); @@ -182,7 +182,7 @@ int T0386_preventallow_2_itl_nexuses(const char *initiator, const char *url) /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. */ - if (removable) { + if (inq->rmb) { if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); diff --git a/test-tool/0390_mandatory_opcodes_sbc.c b/test-tool/0390_mandatory_opcodes_sbc.c index fef9574..a8d31e7 100644 --- a/test-tool/0390_mandatory_opcodes_sbc.c +++ b/test-tool/0390_mandatory_opcodes_sbc.c @@ -62,18 +62,16 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) return -1; } - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - printf("Not a SBC device. Skipping test\n"); - ret = -2; - goto finished; + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { + logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." + " Skipping test"); + return -2; } - if (!data_loss) { - printf("--dataloss flag is not set. Skipping test\n"); - ret = -2; - goto finished; + logging(LOG_VERBOSE, "[SKIPPED] --dataloss flag not set." + " Skipping test"); + return -2; } - printf("Test FORMAT UNIT ... "); printf("[TEST NOT IMPLEMENTED YET]\n"); @@ -86,7 +84,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test MAINTENANCE IN ... "); - if (sccs == 0) { + if (inq->sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); } else { printf("[TEST NOT IMPLEMENTED YET]\n"); @@ -94,7 +92,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test MAINTENANCE OUT ... "); - if (sccs == 0) { + if (inq->sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); } else { printf("[TEST NOT IMPLEMENTED YET]\n"); @@ -138,7 +136,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test RECEIVE DIAGNOSTIC RESULT ... "); - if (encserv == 0) { + if (inq->encserv == 0) { printf("[ENCSERV == 0, SKIPPING TEST]\n"); } else { printf("[TEST NOT IMPLEMENTED YET]\n"); @@ -146,7 +144,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test REDUNDANCY GROUP IN ... "); - if (sccs == 0) { + if (inq->sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); } else { printf("[TEST NOT IMPLEMENTED YET]\n"); @@ -154,7 +152,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test REDUNDANCY GROUP OUT ... "); - if (sccs == 0) { + if (inq->sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); } else { printf("[TEST NOT IMPLEMENTED YET]\n"); @@ -188,7 +186,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test SPARE IN ... "); - if (sccs == 0) { + if (inq->sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); goto finished; } @@ -196,7 +194,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test SPARE OUT ... "); - if (sccs == 0) { + if (inq->sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); } else { printf("[TEST NOT IMPLEMENTED YET]\n"); @@ -232,7 +230,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test VOLUME SET IN ... "); - if (sccs == 0) { + if (inq->sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); } else { printf("[TEST NOT IMPLEMENTED YET]\n"); @@ -240,7 +238,7 @@ int T0390_mandatory_opcodes_sbc(const char *initiator, const char *url) printf("Test VOLUME SET OUT ... "); - if (sccs == 0) { + if (inq->sccs == 0) { printf("[SCCS == 0, SKIPPING TEST]\n"); } else { printf("[TEST NOT IMPLEMENTED YET]\n"); diff --git a/test-tool/0400_inquiry_basic.c b/test-tool/0400_inquiry_basic.c index ac9afdb..73c48e8 100644 --- a/test-tool/0400_inquiry_basic.c +++ b/test-tool/0400_inquiry_basic.c @@ -26,7 +26,7 @@ int T0400_inquiry_basic(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_standard *inq; + struct scsi_inquiry_standard *std_inq; int ret, lun, i; int full_size; @@ -90,8 +90,8 @@ int T0400_inquiry_basic(const char *initiator, const char *url) goto finished; } } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { + std_inq = scsi_datain_unmarshall(task); + if (std_inq == NULL) { printf("[FAILED]\n"); printf("failed to unmarshall inquiry datain blob\n"); scsi_free_scsi_task(task); @@ -111,14 +111,14 @@ int T0400_inquiry_basic(const char *initiator, const char *url) printf("[OK]\n"); printf("Check device-type is either of DISK, TAPE or CD/DVD ... "); - switch (inq->device_type) { + switch (std_inq->device_type) { case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS: case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_SEQUENTIAL_ACCESS: case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_MMC: break; default: printf("[FAILED]\n"); - printf("Device-type is not DISK, TAPE or CD/DVD. Device reported:%s\n", scsi_devtype_to_str(inq->device_type)); + printf("Device-type is not DISK, TAPE or CD/DVD. Device reported:%s\n", scsi_devtype_to_str(std_inq->device_type)); ret = -1; goto test4; } @@ -127,9 +127,9 @@ int T0400_inquiry_basic(const char *initiator, const char *url) test4: printf("Check PREIPHERAL QUALIFIER FIELD is 0 ... "); - if (inq->qualifier != 0) { + if (std_inq->qualifier != 0) { printf("[FAILED]\n"); - printf("QUALIFIER was not 0, it was %d\n", inq->qualifier); + printf("QUALIFIER was not 0, it was %d\n", std_inq->qualifier); ret = -1; goto test5; } @@ -137,14 +137,14 @@ test4: test5: printf("Check VERSION field is either 0x4, 0x5 or 0x6 ... "); - switch (inq->version) { + switch (std_inq->version) { case 0x4: /* SPC-2 */ case 0x5: /* SPC-3 */ case 0x6: /* SPC-4 */ break; default: printf("[FAILED]\n"); - printf("Invalid VERSION:%d. Should be 0x4, 0x5 or 0x6\n", inq->version); + printf("Invalid VERSION:%d. Should be 0x4, 0x5 or 0x6\n", std_inq->version); ret = -1; goto test6; } @@ -152,9 +152,9 @@ test5: test6: printf("Check RESPONSE DATA FORMAT is 2 ... "); - if (inq->response_data_format != 2) { + if (std_inq->response_data_format != 2) { printf("[FAILED]\n"); - printf("Invalid RESPONSE_DATA_FORMAT:%d. Should be 2\n", inq->response_data_format); + printf("Invalid RESPONSE_DATA_FORMAT:%d. Should be 2\n", std_inq->response_data_format); ret = -1; goto test7; } @@ -162,9 +162,9 @@ test6: test7: printf("Verify Additional-Length ... "); - if (inq->additional_length + 5 != full_size) { + if (std_inq->additional_length + 5 != full_size) { printf("[FAILED]\n"); - printf("Invalid additional-length. Was %d but should be %d\n", inq->additional_length, full_size-5); + printf("Invalid additional-length. Was %d but should be %d\n", std_inq->additional_length, full_size-5); ret = -1; goto test8; } @@ -172,7 +172,7 @@ test7: test8: printf("Verify HiSup is set ... "); - if (!inq->hisup) { + if (!std_inq->hisup) { printf("[FAILED]\n"); printf("HiSup flag is not set.\n"); ret = -1; @@ -236,7 +236,7 @@ test11: test12: printf("Verify AERC is clear in SPC-3 and later ... "); - if (task->datain.data[3] & 0x80 && inq->version >= 5) { + if (task->datain.data[3] & 0x80 && std_inq->version >= 5) { printf("[FAILED]\n"); printf("AERC is set but this device reports SPC-3 or later\n"); ret = -1; @@ -246,7 +246,7 @@ test12: test13: printf("Verify TrmTsk is clear in SPC-2 and later ... "); - if (task->datain.data[3] & 0x40 && inq->version >= 4) { + if (task->datain.data[3] & 0x40 && std_inq->version >= 4) { printf("[FAILED]\n"); printf("TrmTsk is set but this device reports SPC-2 or later\n"); ret = -1; diff --git a/test-tool/0403_inquiry_supported_vpd.c b/test-tool/0403_inquiry_supported_vpd.c index 9f0e239..b3ea50f 100644 --- a/test-tool/0403_inquiry_supported_vpd.c +++ b/test-tool/0403_inquiry_supported_vpd.c @@ -26,7 +26,7 @@ int T0403_inquiry_supported_vpd(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_supported_pages *inq; + struct scsi_inquiry_supported_pages *std_inq; size_t i; int ret, lun, j; int full_size; @@ -83,8 +83,8 @@ int T0403_inquiry_supported_vpd(const char *initiator, const char *url) goto finished; } } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { + std_inq = scsi_datain_unmarshall(task); + if (std_inq == NULL) { printf("[FAILED]\n"); printf("failed to unmarshall inquiry datain blob\n"); scsi_free_scsi_task(task); @@ -96,12 +96,12 @@ int T0403_inquiry_supported_vpd(const char *initiator, const char *url) printf("Verify we have all mandatory SPC VPD pages:\n"); for (i = 0; i < sizeof(required_spc_pages) / sizeof(enum scsi_inquiry_pagecode); i++) { printf("Verify the target supports page 0x%02x ... ", required_spc_pages[i]); - for (j = 0; j < inq->num_pages; j++) { - if (required_spc_pages[i] == inq->pages[j]) { + for (j = 0; j < std_inq->num_pages; j++) { + if (required_spc_pages[i] == std_inq->pages[j]) { break; } } - if (j == inq->num_pages) { + if (j == std_inq->num_pages) { printf("[FAILED]\n"); printf("Target did not report page 0x%02x. This page is mandatory in SPC.\n", required_spc_pages[i]); ret = -1; diff --git a/test-tool/0404_inquiry_all_reported_vpd.c b/test-tool/0404_inquiry_all_reported_vpd.c index 56d8e03..f990eaf 100644 --- a/test-tool/0404_inquiry_all_reported_vpd.c +++ b/test-tool/0404_inquiry_all_reported_vpd.c @@ -26,7 +26,7 @@ int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task; - struct scsi_inquiry_supported_pages *inq; + struct scsi_inquiry_supported_pages *sup_inq; int ret, lun, i; int full_size; enum scsi_inquiry_pagecode page_code; @@ -81,8 +81,8 @@ int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url) goto finished; } } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { + sup_inq = scsi_datain_unmarshall(task); + if (sup_inq == NULL) { printf("[FAILED]\n"); printf("failed to unmarshall inquiry datain blob\n"); scsi_free_scsi_task(task); @@ -92,11 +92,11 @@ int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url) printf("[OK]\n"); printf("Read each page and verify qualifier, type and page code:\n"); - for (i = 0; i < inq->num_pages; i++) { + for (i = 0; i < sup_inq->num_pages; i++) { struct scsi_task *pc_task; - printf("Verify page 0x%02x can be read ... ", inq->pages[i]); - pc_task = iscsi_inquiry_sync(iscsi, lun, 1, inq->pages[i], 255); + printf("Verify page 0x%02x can be read ... ", sup_inq->pages[i]); + pc_task = iscsi_inquiry_sync(iscsi, lun, 1, sup_inq->pages[i], 255); if (pc_task == NULL) { printf("[FAILED]\n"); printf("Failed to send INQUIRY command : %s\n", iscsi_get_error(iscsi)); @@ -112,11 +112,11 @@ int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url) } printf("[OK]\n"); - printf("Verify page 0x%02x qualifier ... ", inq->pages[i]); - if ((pc_task->datain.data[0] & 0xe0) >> 5 != inq->qualifier) { + printf("Verify page 0x%02x qualifier ... ", sup_inq->pages[i]); + if ((pc_task->datain.data[0] & 0xe0) >> 5 != sup_inq->qualifier) { printf("[FAILED]\n"); printf("Qualifier differs between VPD pages: %x != %x\n", - pc_task->datain.data[0] & 0xe0, inq->qualifier); + pc_task->datain.data[0] & 0xe0, sup_inq->qualifier); ret = -1; scsi_free_scsi_task(pc_task); continue; @@ -124,11 +124,11 @@ int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url) printf("[OK]\n"); } - printf("Verify page 0x%02x device type ... ", inq->pages[i]); - if ((pc_task->datain.data[0] & 0x1f) != inq->device_type) { + printf("Verify page 0x%02x device type ... ", sup_inq->pages[i]); + if ((pc_task->datain.data[0] & 0x1f) != sup_inq->device_type) { printf("[FAILED]\n"); printf("Device Type differs between VPD pages: %x != %x\n", - pc_task->datain.data[0] & 0x1f, inq->device_type); + pc_task->datain.data[0] & 0x1f, sup_inq->device_type); ret = -1; scsi_free_scsi_task(pc_task); continue; @@ -136,11 +136,11 @@ int T0404_inquiry_all_reported_vpd(const char *initiator, const char *url) printf("[OK]\n"); } - printf("Verify page 0x%02x page code ... ", inq->pages[i]); - if (pc_task->datain.data[1] != inq->pages[i]) { + printf("Verify page 0x%02x page code ... ", sup_inq->pages[i]); + if (pc_task->datain.data[1] != sup_inq->pages[i]) { printf("[FAILED]\n"); printf("Page code is wrong: %x != %x\n", - pc_task->datain.data[1], inq->pages[i]); + pc_task->datain.data[1], sup_inq->pages[i]); ret = -1; scsi_free_scsi_task(pc_task); continue; diff --git a/test-tool/0410_readtoc_basic.c b/test-tool/0410_readtoc_basic.c index 82bc84a..cdf5f93 100644 --- a/test-tool/0410_readtoc_basic.c +++ b/test-tool/0410_readtoc_basic.c @@ -26,7 +26,7 @@ int T0410_readtoc_basic(const char *initiator, const char *url) { struct iscsi_context *iscsi; struct scsi_task *task, *task1; - struct scsi_inquiry_standard *inq; + struct scsi_inquiry_standard *std_inq; struct scsi_readcapacity10 *rc10; struct scsi_readtoc_list *list, *list1; int ret, lun, i, toc_device, full_size; @@ -85,8 +85,8 @@ int T0410_readtoc_basic(const char *initiator, const char *url) goto finished; } } - inq = scsi_datain_unmarshall(task); - if (inq == NULL) { + std_inq = scsi_datain_unmarshall(task); + if (std_inq == NULL) { printf("[FAILED]\n"); printf("failed to unmarshall inquiry datain blob\n"); scsi_free_scsi_task(task); @@ -96,7 +96,7 @@ int T0410_readtoc_basic(const char *initiator, const char *url) printf("[OK]\n"); printf("Check device-type is either of DISK, TAPE or CD/DVD ... "); - switch (inq->device_type) { + switch (std_inq->device_type) { case SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_MMC: toc_device = 1; break; diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 68ef4ee..a4b937f 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -46,15 +46,14 @@ const char *initiatorname2 = const char *tgt_url; +struct scsi_inquiry_standard *inq; + size_t block_size; uint64_t num_blocks; int lbpme; int lbppb; int lbpme; -int removable; enum scsi_inquiry_peripheral_device_type device_type; -int sccs; -int encserv; int data_loss; int lbpws10; int lbpws; diff --git a/test-tool/iscsi-support.h b/test-tool/iscsi-support.h index 613081c..d5f82aa 100644 --- a/test-tool/iscsi-support.h +++ b/test-tool/iscsi-support.h @@ -47,8 +47,8 @@ do { \ if (!data_loss) { \ logging(LOG_VERBOSE, "[SKIPPED] --dataloss flag is not " \ "set. Skipping test."); \ - CU_PASS("[SKIPPED] --dataloss flag is not set. " \ - "Skipping test."); \ + CU_PASS("[SKIPPED] --dataloss flag is not set." \ + " Skipping test"); \ return; \ } \ } while (0); @@ -66,7 +66,7 @@ do { \ #define CHECK_FOR_REMOVABLE \ do { \ - if (!removable) { \ + if (!inq->rmb) { \ logging(LOG_VERBOSE, "[SKIPPED] Logical unit is not " \ "removable. Skipping test."); \ CU_PASS("[SKIPPED] Logical unit is not removable" \ @@ -119,7 +119,7 @@ do { \ #define CHECK_FOR_SBC \ do { \ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {\ + if (inq->device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) {\ logging(LOG_VERBOSE, "[SKIPPED] Not SBC device." \ " Skipping test"); \ CU_PASS("[SKIPPED] Not SBC device." \ @@ -128,16 +128,14 @@ do { \ } \ } while (0); +extern struct scsi_inquiry_standard *inq; + extern size_t block_size; extern uint64_t num_blocks; extern int lbpme; extern int lbppb; extern int lbpme; extern int data_loss; -extern int removable; -extern enum scsi_inquiry_peripheral_device_type device_type; -extern int sccs; -extern int encserv; extern int lbpws10; extern int lbpws; extern int anc_sup; diff --git a/test-tool/iscsi-test-cu.c b/test-tool/iscsi-test-cu.c index 59f3fae..bc38f4c 100644 --- a/test-tool/iscsi-test-cu.c +++ b/test-tool/iscsi-test-cu.c @@ -858,7 +858,7 @@ main(int argc, char *argv[]) int res; struct scsi_readcapacity10 *rc10; struct scsi_readcapacity16 *rc16; - struct scsi_inquiry_standard *inq; + struct scsi_task *inq_task; int full_size; int is_usb; static struct option long_opts[] = { @@ -1017,34 +1017,29 @@ main(int argc, char *argv[]) scsi_free_scsi_task(task); } - task = iscsi_inquiry_sync(iscsic, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { + inq_task = iscsi_inquiry_sync(iscsic, lun, 0, 0, 64); + if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) { printf("Inquiry command failed : %s\n", iscsi_get_error(iscsic)); return -1; } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); + full_size = scsi_datain_getfullsize(inq_task); + if (full_size > inq_task->datain.size) { + scsi_free_scsi_task(inq_task); /* we need more data for the full list */ - task = iscsi_inquiry_sync(iscsic, lun, 0, 0, full_size); - if (task == NULL) { + inq_task = iscsi_inquiry_sync(iscsic, lun, 0, 0, full_size); + if (inq_task == NULL) { printf("Inquiry command failed : %s\n", iscsi_get_error(iscsic)); return -1; } } - inq = scsi_datain_unmarshall(task); + inq = scsi_datain_unmarshall(inq_task); if (inq == NULL) { printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); + scsi_free_scsi_task(inq_task); return -1; } - removable = inq->rmb; - device_type = inq->device_type; - sccs = inq->sccs; - encserv = inq->encserv; - scsi_free_scsi_task(task); sbc3_support = 0; for (i = 0; i < 8; i++) { @@ -1150,5 +1145,7 @@ main(int argc, char *argv[]) free(testname_re); free(discard_const(tgt_url)); + scsi_free_scsi_task(inq_task); + return 0; } diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index ddfc2e6..16e6669 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -314,9 +314,9 @@ int main(int argc, char *argv[]) int lun; struct iscsi_context *iscsi; struct scsi_task *task; + struct scsi_task *inq_task; struct scsi_readcapacity10 *rc10; struct scsi_readcapacity16 *rc16; - struct scsi_inquiry_standard *inq; int full_size; int c; @@ -461,36 +461,27 @@ int main(int argc, char *argv[]) } - task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); - if (task == NULL || task->status != SCSI_STATUS_GOOD) { + inq_task = iscsi_inquiry_sync(iscsi, lun, 0, 0, 64); + if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) { printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); return -1; } - full_size = scsi_datain_getfullsize(task); - if (full_size > task->datain.size) { - scsi_free_scsi_task(task); + full_size = scsi_datain_getfullsize(inq_task); + if (full_size > inq_task->datain.size) { + scsi_free_scsi_task(inq_task); /* we need more data for the full list */ - if ((task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { + if ((inq_task = iscsi_inquiry_sync(iscsi, lun, 0, 0, full_size)) == NULL) { printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi)); return -1; } } - inq = scsi_datain_unmarshall(task); + inq = scsi_datain_unmarshall(inq_task); if (inq == NULL) { printf("failed to unmarshall inquiry datain blob\n"); - scsi_free_scsi_task(task); + scsi_free_scsi_task(inq_task); return -1; } - removable = inq->rmb; - device_type = inq->device_type; - sccs = inq->sccs; - encserv = inq->encserv; - scsi_free_scsi_task(task); - - - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); num_failed = num_skipped = 0; @@ -527,6 +518,10 @@ int main(int argc, char *argv[]) printf("\n"); } + scsi_free_scsi_task(inq_task); + iscsi_logout_sync(iscsi); + iscsi_destroy_context(iscsi); + free(discard_const(url)); return num_failed ? num_failed : num_skipped ? 77 : 0; diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h index d214fda..71c19f4 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -27,7 +27,6 @@ #include "iscsi-support.h" - extern int show_info; int T0000_testunitready_simple(const char *initiator, const char *url); diff --git a/test-tool/test_inquiry_alloc_length.c b/test-tool/test_inquiry_alloc_length.c index 9ec741d..c0379ff 100644 --- a/test-tool/test_inquiry_alloc_length.c +++ b/test-tool/test_inquiry_alloc_length.c @@ -28,7 +28,7 @@ void test_inquiry_alloc_length(void) { int ret, i; - struct scsi_inquiry_standard *inq; + struct scsi_inquiry_standard *std_inq; struct scsi_task *task2 = NULL; logging(LOG_VERBOSE, LOG_BLANK_LINE); @@ -48,16 +48,16 @@ test_inquiry_alloc_length(void) CU_ASSERT(task->datain.size >= 36); logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer"); - inq = scsi_datain_unmarshall(task); - CU_ASSERT_NOT_EQUAL(inq, NULL); - if (inq == NULL) { + std_inq = scsi_datain_unmarshall(task); + CU_ASSERT_NOT_EQUAL(std_inq, NULL); + if (std_inq == NULL) { logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN " "buffer"); return; } logging(LOG_VERBOSE, "Verify peripheral-qualifier is 0"); - CU_ASSERT_EQUAL(inq->qualifier, 0); + CU_ASSERT_EQUAL(std_inq->qualifier, 0); @@ -67,7 +67,7 @@ test_inquiry_alloc_length(void) target responds properly. */ logging(LOG_VERBOSE, "If version is SPC-3 or later INQUIRY supports 16-bit allocation lengths"); - switch (inq->version) { + switch (std_inq->version) { case 0x5: case 0x6: break; diff --git a/test-tool/test_inquiry_standard.c b/test-tool/test_inquiry_standard.c index e0bb8a4..ccc4452 100644 --- a/test-tool/test_inquiry_standard.c +++ b/test-tool/test_inquiry_standard.c @@ -28,7 +28,7 @@ void test_inquiry_standard(void) { int ret, i; - struct scsi_inquiry_standard *inq; + struct scsi_inquiry_standard *std_inq; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test of the standard INQUIRY page"); @@ -41,19 +41,19 @@ test_inquiry_standard(void) CU_ASSERT(task->datain.size >= 36); logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer"); - inq = scsi_datain_unmarshall(task); - CU_ASSERT_NOT_EQUAL(inq, NULL); - if (inq == NULL) { + std_inq = scsi_datain_unmarshall(task); + CU_ASSERT_NOT_EQUAL(std_inq, NULL); + if (std_inq == NULL) { logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN " "buffer"); return; } logging(LOG_VERBOSE, "Verify peripheral-qualifier is 0"); - CU_ASSERT_EQUAL(inq->qualifier, 0); + CU_ASSERT_EQUAL(std_inq->qualifier, 0); logging(LOG_VERBOSE, "Verify version field is either 0x4, 0x5 or 0x6"); - switch (inq->version) { + switch (std_inq->version) { case 0x0: logging(LOG_NORMAL, "[WARNING] Standard INQUIRY data claims " "conformance to no standard. Version==0. " @@ -67,27 +67,27 @@ test_inquiry_standard(void) default: logging(LOG_NORMAL, "[FAILED] Invalid version in standard " "INQUIRY data. Version %d found but only versions " - "0x4,0x4,0x6 are valid.", inq->version); + "0x4,0x4,0x6 are valid.", std_inq->version); CU_FAIL("Invalid version in INQUIRY data"); } logging(LOG_VERBOSE, "Verify response-data-format is 2 " "(SPC-2 or later)"); - if (inq->response_data_format != 2) { + if (std_inq->response_data_format != 2) { logging(LOG_NORMAL, "[FAILED] Response data format is " "invalid. Must be 2 but device returned %d", - inq->response_data_format); + std_inq->response_data_format); } - CU_ASSERT_EQUAL(inq->response_data_format, 2); + CU_ASSERT_EQUAL(std_inq->response_data_format, 2); logging(LOG_VERBOSE, "Verify additional-length is correct"); - if (inq->additional_length != task->datain.size - 5) { + if (std_inq->additional_length != task->datain.size - 5) { logging(LOG_NORMAL, "[FAILED] Bad additional length " "returned. Should be %d but device returned %d.", task->datain.size - 5, - inq->additional_length); + std_inq->additional_length); } - CU_ASSERT_EQUAL(inq->additional_length, task->datain.size - 5); + CU_ASSERT_EQUAL(std_inq->additional_length, task->datain.size - 5); logging(LOG_VERBOSE, "Verify VENDOR_IDENTIFICATION is in ASCII"); for (i = 8; i < 16; i++) { @@ -138,14 +138,14 @@ test_inquiry_standard(void) } logging(LOG_VERBOSE, "Verify AERC is clear in SPC-3 and later"); - if (task->datain.data[3] & 0x80 && inq->version >= 5) { + if (task->datain.data[3] & 0x80 && std_inq->version >= 5) { logging(LOG_NORMAL, "[FAILED] AERC is set but this device " "reports SPC-3 or later."); CU_FAIL("AERC is set but SPC-3+ is claimed"); } logging(LOG_VERBOSE, "Verify TRMTSK is clear in SPC-2 and later"); - if (task->datain.data[3] & 0x40 && inq->version >= 4) { + if (task->datain.data[3] & 0x40 && std_inq->version >= 4) { logging(LOG_NORMAL, "[FAILED] TRMTSK is set but this device " "reports SPC-2 or later."); CU_FAIL("TRMTSK is set but SPC-2+ is claimed"); diff --git a/test-tool/test_inquiry_supported_vpd.c b/test-tool/test_inquiry_supported_vpd.c index 3c81fee..cc21efa 100644 --- a/test-tool/test_inquiry_supported_vpd.c +++ b/test-tool/test_inquiry_supported_vpd.c @@ -28,7 +28,7 @@ void test_inquiry_supported_vpd(void) { int ret, i; - struct scsi_inquiry_supported_pages *inq; + struct scsi_inquiry_supported_pages *sup_inq; logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test INQUIRY supported VPD pages"); @@ -43,21 +43,21 @@ test_inquiry_supported_vpd(void) CU_ASSERT(task->datain.size >= 4); logging(LOG_VERBOSE, "Verify we can unmarshall the DATA-IN buffer"); - inq = scsi_datain_unmarshall(task); - CU_ASSERT_NOT_EQUAL(inq, NULL); - if (inq == NULL) { + sup_inq = scsi_datain_unmarshall(task); + CU_ASSERT_NOT_EQUAL(sup_inq, NULL); + if (sup_inq == NULL) { logging(LOG_NORMAL, "[FAILED] Failed to unmarshall DATA-IN " "buffer"); return; } logging(LOG_VERBOSE, "Verify we read all the supported pages"); - for (i = 0; i < inq->num_pages; i++) { + for (i = 0; i < sup_inq->num_pages; i++) { logging(LOG_VERBOSE, "Verify we can read page 0x%02x", - inq->pages[i]); + sup_inq->pages[i]); ret = inquiry(iscsic, tgt_lun, - 1, inq->pages[i], + 1, sup_inq->pages[i], 255, NULL); CU_ASSERT_EQUAL(ret, 0); } diff --git a/test-tool/test_nomedia_sbc.c b/test-tool/test_nomedia_sbc.c index 42ac02a..3290341 100644 --- a/test-tool/test_nomedia_sbc.c +++ b/test-tool/test_nomedia_sbc.c @@ -36,7 +36,7 @@ test_nomedia_sbc(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test that Medium commands fail when medium is ejected on SBC devices"); - if (!removable) { + if (!inq->rmb) { logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. " "Skipping test."); return; diff --git a/test-tool/test_read10_flags.c b/test-tool/test_read10_flags.c index 86c46ab..c303db7 100644 --- a/test-tool/test_read10_flags.c +++ b/test-tool/test_read10_flags.c @@ -33,12 +33,7 @@ test_read10_flags(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ10 flags"); - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - CU_PASS("[SKIPPED] LUN is not SBC device. Skipping test"); - return; - } - + CHECK_FOR_SBC; logging(LOG_VERBOSE, "Test READ10 with DPO==1"); ret = read10(iscsic, tgt_lun, 0, diff --git a/test-tool/test_read10_rdprotect.c b/test-tool/test_read10_rdprotect.c index 070938c..a359c0c 100644 --- a/test-tool/test_read10_rdprotect.c +++ b/test-tool/test_read10_rdprotect.c @@ -31,17 +31,15 @@ test_read10_rdprotect(void) int i, ret; - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - CU_PASS("[SKIPPED] LUN is not SBC device. Skipping test"); - return; - } - /* * Try out different non-zero values for RDPROTECT. * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ10 with non-zero RDPROTECT"); + + CHECK_FOR_SBC; + for (i = 1; i < 8; i++) { ret = read10_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, diff --git a/test-tool/test_read12_flags.c b/test-tool/test_read12_flags.c index cfe5b16..d643f6f 100644 --- a/test-tool/test_read12_flags.c +++ b/test-tool/test_read12_flags.c @@ -33,12 +33,7 @@ test_read12_flags(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ12 flags"); - /* This test is only valid for SBC devices */ - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - CU_PASS("[SKIPPED] LUN is not SBC device. Skipping test"); - return; - } - + CHECK_FOR_SBC; logging(LOG_VERBOSE, "Test READ12 with DPO==1"); ret = read12(iscsic, tgt_lun, 0, diff --git a/test-tool/test_read12_rdprotect.c b/test-tool/test_read12_rdprotect.c index 5ff6db8..8e88f94 100644 --- a/test-tool/test_read12_rdprotect.c +++ b/test-tool/test_read12_rdprotect.c @@ -30,18 +30,15 @@ test_read12_rdprotect(void) { int i, ret; - - if (device_type != SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS) { - CU_PASS("[SKIPPED] LUN is not SBC device. Skipping test"); - return; - } - /* * Try out different non-zero values for RDPROTECT. * They should all fail. */ logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test READ12 with non-zero RDPROTECT"); + + CHECK_FOR_SBC; + for (i = 1; i < 8; i++) { ret = read12_invalidfieldincdb(iscsic, tgt_lun, 0, block_size, block_size, diff --git a/test-tool/test_startstopunit_noloej.c b/test-tool/test_startstopunit_noloej.c index c4bff2c..475e4ce 100644 --- a/test-tool/test_startstopunit_noloej.c +++ b/test-tool/test_startstopunit_noloej.c @@ -32,7 +32,7 @@ test_startstopunit_noloej(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test STARTSTOPUNIT LOEJ==0"); - if (!removable) { + if (!inq->rmb) { logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. " "Skipping test."); return; diff --git a/test-tool/test_startstopunit_pwrcnd.c b/test-tool/test_startstopunit_pwrcnd.c index fffd169..f6a9342 100644 --- a/test-tool/test_startstopunit_pwrcnd.c +++ b/test-tool/test_startstopunit_pwrcnd.c @@ -32,7 +32,7 @@ test_startstopunit_pwrcnd(void) logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, "Test STARTSTOPUNIT PowerCondition"); - if (!removable) { + if (!inq->rmb) { logging(LOG_VERBOSE, "[SKIPPED] LUN is not removable. " "Skipping test."); return; diff --git a/test-tool/test_startstopunit_simple.c b/test-tool/test_startstopunit_simple.c index 7f819dc..75a451b 100644 --- a/test-tool/test_startstopunit_simple.c +++ b/test-tool/test_startstopunit_simple.c @@ -35,7 +35,7 @@ test_startstopunit_simple(void) logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1"); - if (removable) { + if (inq->rmb) { logging(LOG_VERBOSE, "Media is not removable. STARTSTOPUNIT should fail"); } else { logging(LOG_VERBOSE, "Media is removable. STARTSTOPUNIT should work"); @@ -43,7 +43,7 @@ test_startstopunit_simple(void) ret = startstopunit(iscsic, tgt_lun, 1, 0, 0, 0, 1, 0); - if (!removable) { + if (!inq->rmb) { CU_ASSERT_NOT_EQUAL(ret, 0); return; }