Merge branch 'sgio'

This commit is contained in:
Ronnie Sahlberg
2014-12-21 15:07:40 -08:00
182 changed files with 3966 additions and 7187 deletions

View File

@@ -89,6 +89,16 @@ if test x"$libiscsi_cv_HAVE_SOCKADDR_IN6" = x"yes"; then
AC_DEFINE(HAVE_SOCKADDR_IN6,1,[Whether we have IPv6 support]) AC_DEFINE(HAVE_SOCKADDR_IN6,1,[Whether we have IPv6 support])
fi fi
AC_CACHE_CHECK([for SG_IO support],libiscsi_cv_HAVE_SG_IO,[
AC_TRY_COMPILE([
#include <unistd.h>
#include <scsi/sg.h>],
[int sgio = SG_IO;],
libiscsi_cv_HAVE_SG_IO=yes,libiscsi_cv_HAVE_SG_IO=no)])
if test x"$libiscsi_cv_HAVE_SG_IO" = x"yes"; then
AC_DEFINE(HAVE_SG_IO,1,[Whether we have SG_IO support])
fi
AC_MSG_CHECKING(whether libcunit is available) AC_MSG_CHECKING(whether libcunit is available)
ac_save_CFLAGS="$CFLAGS" ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"

View File

@@ -159,6 +159,8 @@ EXTERN const char *scsi_sense_key_str(int key);
#define SCSI_SENSE_ASCQ_LOGICAL_UNIT_NOT_SUPPORTED 0x2500 #define SCSI_SENSE_ASCQ_LOGICAL_UNIT_NOT_SUPPORTED 0x2500
#define SCSI_SENSE_ASCQ_INVALID_FIELD_IN_PARAMETER_LIST 0x2600 #define SCSI_SENSE_ASCQ_INVALID_FIELD_IN_PARAMETER_LIST 0x2600
#define SCSI_SENSE_ASCQ_WRITE_PROTECTED 0x2700 #define SCSI_SENSE_ASCQ_WRITE_PROTECTED 0x2700
#define SCSI_SENSE_ASCQ_HARDWARE_WRITE_PROTECTED 0x2701
#define SCSI_SENSE_ASCQ_SOFTWARE_WRITE_PROTECTED 0x2702
#define SCSI_SENSE_ASCQ_BUS_RESET 0x2900 #define SCSI_SENSE_ASCQ_BUS_RESET 0x2900
#define SCSI_SENSE_ASCQ_POWER_ON_OCCURED 0x2901 #define SCSI_SENSE_ASCQ_POWER_ON_OCCURED 0x2901
#define SCSI_SENSE_ASCQ_SCSI_BUS_RESET_OCCURED 0x2902 #define SCSI_SENSE_ASCQ_SCSI_BUS_RESET_OCCURED 0x2902

View File

@@ -155,8 +155,8 @@ iscsi_writesame10_task
iscsi_writesame16_sync iscsi_writesame16_sync
iscsi_writesame16_task iscsi_writesame16_task
scsi_association_to_str scsi_association_to_str
scsi_cdb_inquiry
scsi_cdb_compareandwrite scsi_cdb_compareandwrite
scsi_cdb_inquiry
scsi_cdb_get_lba_status scsi_cdb_get_lba_status
scsi_cdb_modeselect6 scsi_cdb_modeselect6
scsi_cdb_modeselect10 scsi_cdb_modeselect10

View File

@@ -189,6 +189,12 @@ scsi_sense_ascq_str(int ascq)
"INVALID_FIELD_IN_PARAMETER_LIST"}, "INVALID_FIELD_IN_PARAMETER_LIST"},
{SCSI_SENSE_ASCQ_WRITE_PROTECTED, {SCSI_SENSE_ASCQ_WRITE_PROTECTED,
"WRITE_PROTECTED"}, "WRITE_PROTECTED"},
{SCSI_SENSE_ASCQ_WRITE_PROTECTED,
"WRITE_PROTECTED"},
{SCSI_SENSE_ASCQ_HARDWARE_WRITE_PROTECTED,
"HARDWARE_WRITE_PROTECTED"},
{SCSI_SENSE_ASCQ_SOFTWARE_WRITE_PROTECTED,
"SOFTWARE_WRITE_PROTECTED"},
{SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT, {SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT,
"MEDIUM_NOT_PRESENT"}, "MEDIUM_NOT_PRESENT"},
{SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED, {SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED,

File diff suppressed because it is too large Load Diff

View File

@@ -2,6 +2,7 @@
iscsi-test tool support iscsi-test tool support
Copyright (C) 2012 by Lee Duncan <leeman.duncan@gmail.com> Copyright (C) 2012 by Lee Duncan <leeman.duncan@gmail.com>
Copyright (C) 2014 by Ronnie sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -25,9 +26,30 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef discard_const
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
#endif
extern const char *initiatorname1; extern const char *initiatorname1;
extern const char *initiatorname2; extern const char *initiatorname2;
extern const char *tgt_url;
#define EXPECT_STATUS_GOOD SCSI_STATUS_GOOD, SCSI_SENSE_NO_SENSE, NULL, 0
#define EXPECT_NO_MEDIUM SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_NOT_READY, no_medium_ascqs, 3
#define EXPECT_LBA_OOB SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_ILLEGAL_REQUEST, lba_oob_ascqs, 1
#define EXPECT_INVALID_FIELD_IN_CDB SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_ILLEGAL_REQUEST, invalid_cdb_ascqs, 1
#define EXPECT_MISCOMPARE SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_MISCOMPARE, miscompare_ascqs, 1
#define EXPECT_WRITE_PROTECTED SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_DATA_PROTECTION, write_protect_ascqs, 3
#define EXPECT_SANITIZE SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_NOT_READY, sanitize_ascqs, 1
#define EXPECT_REMOVAL_PREVENTED SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_ILLEGAL_REQUEST, removal_ascqs, 1
#define EXPECT_RESERVATION_CONFLICT SCSI_STATUS_RESERVATION_CONFLICT, 0, NULL, 0
int no_medium_ascqs[3];
int lba_oob_ascqs[1];
int invalid_cdb_ascqs[1];
int write_protect_ascqs[3];
int sanitize_ascqs[1];
int removal_ascqs[1];
int miscompare_ascqs[1];
extern int loglevel; extern int loglevel;
#define LOG_SILENT 0 #define LOG_SILENT 0
@@ -166,6 +188,18 @@ extern int readonly;
extern int sbc3_support; extern int sbc3_support;
extern int maximum_transfer_length; extern int maximum_transfer_length;
struct scsi_device {
const char *error_str;
struct iscsi_context *iscsi_ctx;
int iscsi_lun;
const char *iscsi_url;
const char *sgio_dev;
int sgio_fd;
};
extern struct scsi_device *sd;
struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun); struct iscsi_context *iscsi_context_login(const char *initiatorname, const char *url, int *lun);
struct iscsi_async_state { struct iscsi_async_state {
@@ -211,153 +245,70 @@ static inline int pr_type_is_all_registrants(
} }
} }
int prin_task(struct iscsi_context *iscsi, int lun, int service_action, int prin_task(struct scsi_device *sdev, int service_action,
int success_expected); int success_expected);
int prin_read_keys(struct iscsi_context *iscsi, int lun, struct scsi_task **tp, int prin_read_keys(struct scsi_device *sdev, struct scsi_task **tp,
struct scsi_persistent_reserve_in_read_keys **rkp); struct scsi_persistent_reserve_in_read_keys **rkp);
int prout_register_and_ignore(struct iscsi_context *iscsi, int lun, int prout_register_and_ignore(struct scsi_device *sdev,
unsigned long long key); unsigned long long key);
int prout_register_key(struct iscsi_context *iscsi, int lun, int prout_register_key(struct scsi_device *sdev,
unsigned long long sark, unsigned long long rk); unsigned long long sark, unsigned long long rk);
int prin_verify_key_presence(struct iscsi_context *iscsi, int lun, int prin_verify_key_presence(struct scsi_device *sdev,
unsigned long long key, int present); unsigned long long key, int present);
int prout_reregister_key_fails(struct iscsi_context *iscsi, int lun, int prout_reregister_key_fails(struct scsi_device *sdev,
unsigned long long sark); unsigned long long sark);
int prout_reserve(struct iscsi_context *iscsi, int lun, int prout_reserve(struct scsi_device *sdev,
unsigned long long key, enum scsi_persistent_out_type pr_type); unsigned long long key, enum scsi_persistent_out_type pr_type);
int prout_release(struct iscsi_context *iscsi, int lun, int prout_release(struct scsi_device *sdev,
unsigned long long key, enum scsi_persistent_out_type pr_type); unsigned long long key, enum scsi_persistent_out_type pr_type);
int prin_verify_not_reserved(struct iscsi_context *iscsi, int lun); int prin_verify_not_reserved(struct scsi_device *sdev);
int prin_verify_reserved_as(struct iscsi_context *iscsi, int lun, int prin_verify_reserved_as(struct scsi_device *sdev,
unsigned long long key, enum scsi_persistent_out_type pr_type); 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_read_works(struct scsi_device *sdev, unsigned char *buf);
int verify_write_works(struct iscsi_context *iscsi, int lun, unsigned char *buf); int verify_write_works(struct scsi_device *sdev, unsigned char *buf);
int verify_read_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf); int verify_read_fails(struct scsi_device *sdev, unsigned char *buf);
int verify_write_fails(struct iscsi_context *iscsi, int lun, unsigned char *buf); int verify_write_fails(struct scsi_device *sdev, unsigned char *buf);
int inquiry(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize, struct scsi_task **save_task);
int inquiry_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int evpd, int page_code, int maxsize);
struct scsi_task *get_lba_status_task(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
int compareandwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
int compareandwrite_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
int compareandwrite_miscompare(struct iscsi_context *iscsi, int lun, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number);
int get_lba_status(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len, enum scsi_provisioning_type *provisioning0);
int get_lba_status_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
int get_lba_status_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t len);
int orwrite(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int orwrite_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int orwrite_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int orwrite_writeprotected(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int orwrite_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int prefetch10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group);
int prefetch10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group);
int prefetch10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int immed, int group);
int prefetch16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group);
int prefetch16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group);
int prefetch16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int immed, int group);
int preventallow(struct iscsi_context *iscsi, int lun, int prevent);
int read6(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, unsigned char *data);
int read6_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, unsigned char *data);
struct scsi_task *read10_task(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read12(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read12_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read12_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read12_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int read16(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 read16_invalidfieldincdb(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 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 read16_nomedium(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 read16_sanitize(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 readcapacity10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, int pmi);
int readcapacity16(struct iscsi_context *iscsi, int lun, int alloc_len);
int readcapacity16_nomedium(struct iscsi_context *iscsi, int lun, int alloc_len);
int report_supported_opcodes(struct iscsi_context *iscsi, int lun, int rctd, int options, int opcode, int sa, int alloc_len, struct scsi_task **save_task);
int report_supported_opcodes_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int rctd, int options, int opcode, int sa, int alloc_len, struct scsi_task **save_task);
int release6(struct iscsi_context *iscsi, int lun);
int reserve6(struct iscsi_context *iscsi, int lun);
int reserve6_conflict(struct iscsi_context *iscsi, int lun);
int sanitize(struct iscsi_context *iscsi, int lun, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
int sanitize_conflict(struct iscsi_context *iscsi, int lun, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
int sanitize_invalidfieldincdb(struct iscsi_context *iscsi, int lun, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
int sanitize_writeprotected(struct iscsi_context *iscsi, int lun, int immed, int ause, int sa, int param_len, struct iscsi_data *data);
int startstopunit(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start);
int startstopunit_sanitize(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start);
int startstopunit_preventremoval(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start);
int synchronizecache10(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int sync_nv, int immed);
int synchronizecache10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, int num_blocks, int sync_nv, int immed);
int synchronizecache16(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int sync_nv, int immed);
int synchronizecache16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int sync_nv, int immed);
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);
int testunitready_sanitize(struct iscsi_context *iscsi, int lun);
int mode_sense(struct iscsi_context *iscsi, int lun);
int unmap(struct iscsi_context *iscsi, int lun, int anchor, struct unmap_list *list, int list_len);
int unmap_writeprotected(struct iscsi_context *iscsi, int lun, int anchor, struct unmap_list *list, int list_len);
int unmap_nomedium(struct iscsi_context *iscsi, int lun, int anchor, struct unmap_list *list, int list_len);
int verify10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify10_miscompare(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify12(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify12_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify12_miscompare(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify12_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify16_miscompare(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int verify16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data);
int write10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write10_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write12(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write12_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write12_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write12_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write12_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write16_writeprotected(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int write16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data);
int writesame10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame10_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame16_writeprotected(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writesame16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data);
int writeverify10(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify10_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify10_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify10_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify10_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify12(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify12_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify12_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify12_writeprotected(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify12_nomedium(struct iscsi_context *iscsi, int lun, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify16(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify16_invalidfieldincdb(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify16_lbaoutofrange(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify16_writeprotected(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int writeverify16_nomedium(struct iscsi_context *iscsi, int lun, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data);
int set_swp(struct iscsi_context *iscsi, int lun); int compareandwrite(struct scsi_device *sdev, uint64_t lba, unsigned char *data, uint32_t len, int blocksize, int wrprotect, int dpo, int fua, int group_number, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int clear_swp(struct iscsi_context *iscsi, int lun); int get_lba_status(struct scsi_device *sdev, struct scsi_task **task, uint64_t lba, uint32_t len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int inquiry(struct scsi_device *sdev, struct scsi_task **task, int evpd, int page_code, int maxsize, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int modesense6(struct scsi_device *sdev, struct scsi_task **task, int dbd, enum scsi_modesense_page_control pc, enum scsi_modesense_page_code page_code, int sub_page_code, unsigned char alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int modeselect6(struct scsi_device *sdev, int pf, int sp, struct scsi_mode_page *mp, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int orwrite(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int prefetch10(struct scsi_device *sdev, uint32_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int prefetch16(struct scsi_device *sdev, uint64_t lba, int num_blocks, int immed, int group, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int preventallow(struct scsi_device *sdev, int prevent);
int read6(struct scsi_device *sdev, struct scsi_task **task, uint32_t lba, uint32_t datalen, int blocksize, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int read10(struct scsi_device *sdev, struct scsi_task **task, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int read12(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int read16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int readcapacity10(struct scsi_device *sdev, struct scsi_task **task, uint32_t lba, int pmi, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int readcapacity16(struct scsi_device *sdev, struct scsi_task **task, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int report_supported_opcodes(struct scsi_device *sdev, struct scsi_task **save_task, int rctd, int options, int opcode, int sa, int alloc_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int release6(struct scsi_device *sdev);
int reserve6(struct scsi_device *sdev);
int reserve6_conflict(struct scsi_device *sdev);
int sanitize(struct scsi_device *sdev, int immed, int ause, int sa, int param_len, struct iscsi_data *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int startstopunit(struct scsi_device *sdev, int immed, int pcm, int pc, int no_flush, int loej, int start, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int synchronizecache10(struct scsi_device *sdev, uint32_t lba, int num_blocks, int sync_nv, int immed, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int synchronizecache16(struct scsi_device *sdev, uint64_t lba, int num_blocks, int sync_nv, int immed, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int testunitready_clear_ua(struct scsi_device *sdev);
int testunitready(struct scsi_device *sdev, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int unmap(struct scsi_device *sdev, int anchor, struct unmap_list *list, int list_len, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int verify10(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int verify12(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int verify16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int vprotect, int dpo, int bytchk, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int write10(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int write12(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int write16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int writesame10(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int writesame16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int num_blocks, int anchor, int unmap, int wrprotect, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int writeverify10(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int writeverify12(struct scsi_device *sdev, uint32_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int writeverify16(struct scsi_device *sdev, uint64_t lba, uint32_t datalen, int blocksize, int wrprotect, int dpo, int bytchk, int group, unsigned char *data, int status, enum scsi_sense_key key, int *ascq, int num_ascq);
int set_swp(struct scsi_device *sdev);
int clear_swp(struct scsi_device *sdev);
#endif /* _ISCSI_SUPPORT_H_ */ #endif /* _ISCSI_SUPPORT_H_ */

View File

@@ -17,6 +17,8 @@
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "config.h"
#define _GNU_SOURCE #define _GNU_SOURCE
#include <sys/syscall.h> #include <sys/syscall.h>
#include <dlfcn.h> #include <dlfcn.h>
@@ -30,6 +32,12 @@
#include <fnmatch.h> #include <fnmatch.h>
#include <ctype.h> #include <ctype.h>
#ifdef HAVE_SG_IO
#include <fcntl.h>
#include <sys/ioctl.h>
#include <scsi/sg.h>
#endif
#include <CUnit/CUnit.h> #include <CUnit/CUnit.h>
#include <CUnit/Basic.h> #include <CUnit/Basic.h>
#include <CUnit/Automated.h> #include <CUnit/Automated.h>
@@ -40,16 +48,12 @@
#include "iscsi-support.h" #include "iscsi-support.h"
#include "iscsi-test-cu.h" #include "iscsi-test-cu.h"
#include "iscsi-support.h"
#ifndef discard_const
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
#endif
#define PROG "iscsi-test-cu" #define PROG "iscsi-test-cu"
int loglevel = LOG_NORMAL; int loglevel = LOG_NORMAL;
struct scsi_device *sd;
/* /*
* this allows us to redefine how PDU are queued, at times, for * this allows us to redefine how PDU are queued, at times, for
@@ -409,7 +413,6 @@ typedef struct libiscsi_suite_info {
} libiscsi_suite_info; } libiscsi_suite_info;
#define NON_PGR_FUNCS suite_init, suite_cleanup, test_setup, test_teardown #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 */ /* SCSI protocol tests */
static libiscsi_suite_info scsi_suites[] = { static libiscsi_suite_info scsi_suites[] = {
@@ -426,7 +429,7 @@ static libiscsi_suite_info scsi_suites[] = {
{ "PrinReadKeys", NON_PGR_FUNCS, tests_prin_read_keys }, { "PrinReadKeys", NON_PGR_FUNCS, tests_prin_read_keys },
{ "PrinServiceactionRange", NON_PGR_FUNCS, tests_prin_serviceaction_range }, { "PrinServiceactionRange", NON_PGR_FUNCS, tests_prin_serviceaction_range },
{ "ProutRegister", NON_PGR_FUNCS, tests_prout_register }, { "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 }, { "Read6", NON_PGR_FUNCS, tests_read6 },
{ "Read10", NON_PGR_FUNCS, tests_read10 }, { "Read10", NON_PGR_FUNCS, tests_read10 },
{ "Read12", NON_PGR_FUNCS, tests_read12 }, { "Read12", NON_PGR_FUNCS, tests_read12 },
@@ -507,7 +510,7 @@ static libiscsi_suite_info all_suites[] = {
{ "PrinServiceactionRange", NON_PGR_FUNCS, { "PrinServiceactionRange", NON_PGR_FUNCS,
tests_prin_serviceaction_range }, tests_prin_serviceaction_range },
{ "ProutRegister", NON_PGR_FUNCS, tests_prout_register }, { "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 }, { "Read6", NON_PGR_FUNCS, tests_read6 },
{ "Read10", NON_PGR_FUNCS, tests_read10 }, { "Read10", NON_PGR_FUNCS, tests_read10 },
{ "Read12", NON_PGR_FUNCS, tests_read12 }, { "Read12", NON_PGR_FUNCS, tests_read12 },
@@ -539,21 +542,14 @@ static libiscsi_suite_info all_suites[] = {
{ NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL },
}; };
static libiscsi_suite_info scsi_usb_sbc_suites[] = { static libiscsi_suite_info linux_suites[] = {
{ "CompareAndWrite", NON_PGR_FUNCS, tests_compareandwrite }, { "CompareAndWrite", NON_PGR_FUNCS, tests_compareandwrite },
{ "GetLBAStatus", NON_PGR_FUNCS, tests_get_lba_status }, { "GetLBAStatus", NON_PGR_FUNCS, tests_get_lba_status },
{ "Inquiry", NON_PGR_FUNCS, tests_inquiry }, { "Inquiry", NON_PGR_FUNCS, tests_inquiry },
{ "Mandatory", NON_PGR_FUNCS, tests_mandatory }, { "Mandatory", NON_PGR_FUNCS, tests_mandatory },
{ "ModeSense6", NON_PGR_FUNCS, tests_modesense6 },
{ "OrWrite", NON_PGR_FUNCS, tests_orwrite }, { "OrWrite", NON_PGR_FUNCS, tests_orwrite },
{ "Prefetch10", NON_PGR_FUNCS, tests_prefetch10 }, { "Prefetch10", NON_PGR_FUNCS, tests_prefetch10 },
{ "Prefetch16", NON_PGR_FUNCS, tests_prefetch16 }, { "Prefetch16", NON_PGR_FUNCS, tests_prefetch16 },
{ "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 },
{ "Read6", NON_PGR_FUNCS, tests_read6 },
{ "Read10", NON_PGR_FUNCS, tests_read10 }, { "Read10", NON_PGR_FUNCS, tests_read10 },
{ "Read12", NON_PGR_FUNCS, tests_read12 }, { "Read12", NON_PGR_FUNCS, tests_read12 },
{ "Read16", NON_PGR_FUNCS, tests_read16 }, { "Read16", NON_PGR_FUNCS, tests_read16 },
@@ -562,7 +558,6 @@ static libiscsi_suite_info scsi_usb_sbc_suites[] = {
{ "ReadOnly", NON_PGR_FUNCS, tests_readonly }, { "ReadOnly", NON_PGR_FUNCS, tests_readonly },
{ "ReportSupportedOpcodes", NON_PGR_FUNCS, { "ReportSupportedOpcodes", NON_PGR_FUNCS,
tests_report_supported_opcodes }, tests_report_supported_opcodes },
{ "Reserve6", NON_PGR_FUNCS, tests_reserve6 },
{ "TestUnitReady", NON_PGR_FUNCS, tests_testunitready }, { "TestUnitReady", NON_PGR_FUNCS, tests_testunitready },
{ "Unmap", NON_PGR_FUNCS, tests_unmap }, { "Unmap", NON_PGR_FUNCS, tests_unmap },
{ "Verify10", NON_PGR_FUNCS, tests_verify10 }, { "Verify10", NON_PGR_FUNCS, tests_verify10 },
@@ -585,24 +580,19 @@ struct test_family {
}; };
static struct test_family families[] = { static struct test_family families[] = {
{ "ALL", all_suites }, { "ALL", all_suites },
{ "SCSI", scsi_suites }, { "SCSI", scsi_suites },
{ "iSCSI", iscsi_suites }, { "iSCSI", iscsi_suites },
{ "SCSI-USB-SBC", scsi_usb_sbc_suites }, { "LINUX", linux_suites },
{ NULL, NULL} { NULL, NULL}
}; };
/* /*
* globals for test setup and teardown * globals for test setup and teardown
*/ */
int tgt_lun;
struct iscsi_context *iscsic;
struct scsi_task *task; struct scsi_task *task;
int tgt_lun2;
struct iscsi_context *iscsic2;
unsigned char *read_write_buf; unsigned char *read_write_buf;
static void static void
print_usage(void) print_usage(void)
{ {
@@ -683,11 +673,17 @@ test_teardown(void)
int int
suite_init(void) suite_init(void)
{ {
iscsic = iscsi_context_login(initiatorname1, tgt_url, &tgt_lun); if (sd->iscsi_url) {
if (iscsic == NULL) { if (sd->iscsi_ctx) {
fprintf(stderr, iscsi_logout_sync(sd->iscsi_ctx);
"error: Failed to login to target for test set-up\n"); iscsi_destroy_context(sd->iscsi_ctx);
return 1; }
sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
if (sd->iscsi_ctx == NULL) {
fprintf(stderr,
"error: Failed to login to target for test set-up\n");
return 1;
}
} }
#ifndef HAVE_CU_SUITEINFO_PSETUPFUNC #ifndef HAVE_CU_SUITEINFO_PSETUPFUNC
/* libcunit version 1 */ /* libcunit version 1 */
@@ -703,40 +699,16 @@ suite_cleanup(void)
/* libcunit version 1 */ /* libcunit version 1 */
test_teardown(); test_teardown();
#endif #endif
if (iscsic) { if (sd->iscsi_url) {
iscsi_logout_sync(iscsic); if (sd->iscsi_ctx) {
iscsi_destroy_context(iscsic); iscsi_logout_sync(sd->iscsi_ctx);
iscsic = NULL; iscsi_destroy_context(sd->iscsi_ctx);
sd->iscsi_ctx = NULL;
}
} }
return 0; return 0;
} }
int
suite_init_pgr(void)
{
suite_init();
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");
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 static void
list_all_tests(void) list_all_tests(void)
{ {
@@ -893,11 +865,66 @@ static void parse_and_add_tests(char *testname_re)
parse_and_add_test(testname_re); parse_and_add_test(testname_re);
} }
static int connect_scsi_device(struct scsi_device *sdev, const char *initiatorname)
{
if (sdev->iscsi_url) {
sdev->iscsi_ctx = iscsi_context_login(initiatorname, sdev->iscsi_url, &sdev->iscsi_lun);
if (sdev->iscsi_ctx == NULL) {
return -1;
}
return 0;
}
#ifdef HAVE_SG_IO
if (sdev->sgio_dev) {
int version;
if ((sdev->sgio_fd = open(sdev->sgio_dev, O_RDWR)) == -1) {
fprintf(stderr, "Failed to open SG_IO device %s. Error:%s\n", sdev->sgio_dev,
strerror(errno));
return -1;
}
if ((ioctl(sdev->sgio_fd, SG_GET_VERSION_NUM, &version) < 0) || (version < 30000)) {
fprintf(stderr, "%s is not a SCSI device node\n", sdev->sgio_dev);
close(sdev->sgio_fd);
return -1;
}
return 0;
}
#endif
return -1;
}
static void free_scsi_device(struct scsi_device *sdev)
{
if (sdev->error_str) {
free(discard_const(sdev->error_str));
sdev->error_str = NULL;
}
if (sdev->iscsi_url) {
free(discard_const(sdev->iscsi_url));
sdev->iscsi_url = NULL;
}
if (sdev->iscsi_ctx) {
iscsi_logout_sync(sdev->iscsi_ctx);
iscsi_destroy_context(sdev->iscsi_ctx);
sdev->iscsi_ctx = NULL;
}
if (sdev->sgio_dev) {
free(discard_const(sdev->sgio_dev));
sdev->sgio_dev = NULL;
}
if (sdev->sgio_fd != -1) {
close(sdev->sgio_fd);
sdev->sgio_fd = -1;
}
free(sd);
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char *testname_re = NULL; char *testname_re = NULL;
int lun;
CU_BasicRunMode mode = CU_BRM_VERBOSE; CU_BasicRunMode mode = CU_BRM_VERBOSE;
CU_ErrorAction error_action = CUEA_IGNORE; CU_ErrorAction error_action = CUEA_IGNORE;
int res; int res;
@@ -933,6 +960,10 @@ main(int argc, char *argv[])
int i, c; int i, c;
int opt_idx = 0; int opt_idx = 0;
sd = malloc(sizeof(struct scsi_device));
memset(sd, '\0', sizeof(struct scsi_device));
sd->sgio_fd = -1;
while ((c = getopt_long(argc, argv, "?hli:I:t:sdgfAsSnuvxV", long_opts, while ((c = getopt_long(argc, argv, "?hli:I:t:sdgfAsSnuvxV", long_opts,
&opt_idx)) > 0) { &opt_idx)) > 0) {
switch (c) { switch (c) {
@@ -994,7 +1025,13 @@ main(int argc, char *argv[])
} }
if (optind < argc) { if (optind < argc) {
tgt_url = strdup(argv[optind++]); if (!strncmp(argv[optind], "iscsi://", 8)) {
sd->iscsi_url = strdup(argv[optind++]);
#ifdef HAVE_SG_IO
} else if (!strncmp(argv[optind], "/dev/sg", 7)) {
sd->sgio_dev = strdup(argv[optind++]);
#endif
}
} }
if (optind < argc) { if (optind < argc) {
fprintf(stderr, "error: too many arguments\n"); fprintf(stderr, "error: too many arguments\n");
@@ -1005,17 +1042,21 @@ main(int argc, char *argv[])
/* XXX why is this done? */ /* XXX why is this done? */
real_iscsi_queue_pdu = dlsym(RTLD_NEXT, "iscsi_queue_pdu"); real_iscsi_queue_pdu = dlsym(RTLD_NEXT, "iscsi_queue_pdu");
if (tgt_url == NULL) { if (sd->iscsi_url == NULL && sd->sgio_dev== NULL ) {
fprintf(stderr, "You must specify the URL\n"); #ifdef HAVE_SG_IO
fprintf(stderr, "You must specify either an iSCSI URL or a /dev/sg device\n");
#else
fprintf(stderr, "You must specify either an iSCSI URL\n");
#endif
print_usage(); print_usage();
if (testname_re) if (testname_re)
free(testname_re); free(testname_re);
return 10; return 10;
} }
iscsic = iscsi_context_login(initiatorname1, tgt_url, &lun); if (connect_scsi_device(sd, initiatorname1)) {
if (iscsic == NULL) { fprintf(stderr, "Failed to connect to SCSI device\n");
printf("Failed to login to target\n"); free_scsi_device(sd);
return -1; return -1;
} }
@@ -1024,46 +1065,43 @@ main(int argc, char *argv[])
* All devices support readcapacity10 but only some support * All devices support readcapacity10 but only some support
* readcapacity16 * readcapacity16
*/ */
task = iscsi_readcapacity10_sync(iscsic, lun, 0, 0); task = NULL;
readcapacity10(sd, &task, 0, 0, EXPECT_STATUS_GOOD);
if (task == NULL) { if (task == NULL) {
printf("Failed to send READCAPACITY10 command: %s\n", printf("Failed to send READCAPACITY10 command: %s\n", sd->error_str);
iscsi_get_error(iscsic)); free_scsi_device(sd);
iscsi_destroy_context(iscsic);
return -1; return -1;
} }
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY10 command: failed with sense. %s\n", printf("READCAPACITY10 command: failed with sense. %s\n", sd->error_str);
iscsi_get_error(iscsic));
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
iscsi_destroy_context(iscsic); free_scsi_device(sd);
return -1; return -1;
} }
rc10 = scsi_datain_unmarshall(task); rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) { if (rc10 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", printf("failed to unmarshall READCAPACITY10 data.\n");
iscsi_get_error(iscsic));
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
iscsi_destroy_context(iscsic); free_scsi_device(sd);
return -1; return -1;
} }
block_size = rc10->block_size; block_size = rc10->block_size;
num_blocks = rc10->lba + 1; num_blocks = rc10->lba + 1;
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
rc16_task = iscsi_readcapacity16_sync(iscsic, lun); rc16_task = NULL;
readcapacity16(sd, &rc16_task, 96, EXPECT_STATUS_GOOD);
if (rc16_task == NULL) { if (rc16_task == NULL) {
printf("Failed to send READCAPACITY16 command: %s\n", printf("Failed to send READCAPACITY16 command: %s\n", sd->error_str);
iscsi_get_error(iscsic)); free_scsi_device(sd);
iscsi_destroy_context(iscsic);
return -1; return -1;
} }
if (rc16_task->status == SCSI_STATUS_GOOD) { if (rc16_task->status == SCSI_STATUS_GOOD) {
rc16 = scsi_datain_unmarshall(rc16_task); rc16 = scsi_datain_unmarshall(rc16_task);
if (rc16 == NULL) { if (rc16 == NULL) {
printf("failed to unmarshall READCAPACITY16 data. %s\n", printf("failed to unmarshall READCAPACITY16 data. %s\n", sd->error_str);
iscsi_get_error(iscsic));
scsi_free_scsi_task(rc16_task); scsi_free_scsi_task(rc16_task);
iscsi_destroy_context(iscsic); free_scsi_device(sd);
return -1; return -1;
} }
block_size = rc16->block_length; block_size = rc16->block_length;
@@ -1071,9 +1109,10 @@ main(int argc, char *argv[])
lbppb = 1 << rc16->lbppbe; lbppb = 1 << rc16->lbppbe;
} }
inq_task = iscsi_inquiry_sync(iscsic, lun, 0, 0, 64); inq_task = NULL;
inquiry(sd, &inq_task, 0, 0, 64, EXPECT_STATUS_GOOD);
if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) { if (inq_task == NULL || inq_task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsic)); printf("Inquiry command failed : %s\n", sd->error_str);
return -1; return -1;
} }
full_size = scsi_datain_getfullsize(inq_task); full_size = scsi_datain_getfullsize(inq_task);
@@ -1081,10 +1120,10 @@ main(int argc, char *argv[])
scsi_free_scsi_task(inq_task); scsi_free_scsi_task(inq_task);
/* we need more data for the full list */ /* we need more data for the full list */
inq_task = iscsi_inquiry_sync(iscsic, lun, 0, 0, full_size); inq_task = NULL;
inquiry(sd, &inq_task, 0, 0, full_size, EXPECT_STATUS_GOOD);
if (inq_task == NULL) { if (inq_task == NULL) {
printf("Inquiry command failed : %s\n", printf("Inquiry command failed : %s\n", sd->error_str);
iscsi_get_error(iscsic));
return -1; return -1;
} }
} }
@@ -1103,7 +1142,8 @@ main(int argc, char *argv[])
} }
/* try reading block limits vpd */ /* try reading block limits vpd */
inq_bl_task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 64); inq_bl_task = NULL;
inquiry(sd, &inq_bl_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 64, EXPECT_STATUS_GOOD);
if (inq_bl_task && inq_bl_task->status != SCSI_STATUS_GOOD) { if (inq_bl_task && inq_bl_task->status != SCSI_STATUS_GOOD) {
scsi_free_scsi_task(inq_bl_task); scsi_free_scsi_task(inq_bl_task);
inq_bl_task = NULL; inq_bl_task = NULL;
@@ -1113,8 +1153,11 @@ main(int argc, char *argv[])
if (full_size > inq_bl_task->datain.size) { if (full_size > inq_bl_task->datain.size) {
scsi_free_scsi_task(inq_bl_task); scsi_free_scsi_task(inq_bl_task);
if ((inq_bl_task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, full_size)) == NULL) { inq_bl_task = NULL;
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsic)); inquiry(sd, &inq_bl_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, full_size,
EXPECT_STATUS_GOOD);
if (inq_bl_task == NULL) {
printf("Inquiry command failed : %s\n", sd->error_str);
return -1; return -1;
} }
} }
@@ -1127,7 +1170,9 @@ main(int argc, char *argv[])
} }
/* try reading block device characteristics vpd */ /* try reading block device characteristics vpd */
inq_bdc_task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_BLOCK_DEVICE_CHARACTERISTICS, 255); inq_bdc_task = NULL;
inquiry(sd, &inq_bdc_task, 1, SCSI_INQUIRY_PAGECODE_BLOCK_DEVICE_CHARACTERISTICS, 255,
EXPECT_STATUS_GOOD);
if (inq_bdc_task == NULL) { if (inq_bdc_task == NULL) {
printf("Failed to read Block Device Characteristics page\n"); printf("Failed to read Block Device Characteristics page\n");
} }
@@ -1141,9 +1186,11 @@ main(int argc, char *argv[])
/* if thin provisioned we also need to read the VPD page for it */ /* if thin provisioned we also need to read the VPD page for it */
if (rc16 && rc16->lbpme != 0){ if (rc16 && rc16->lbpme != 0){
inq_lbp_task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64); inq_lbp_task = NULL;
inquiry(sd, &inq_lbp_task, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 64,
EXPECT_STATUS_GOOD);
if (inq_lbp_task == NULL || inq_lbp_task->status != SCSI_STATUS_GOOD) { if (inq_lbp_task == NULL || inq_lbp_task->status != SCSI_STATUS_GOOD) {
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsic)); printf("Inquiry command failed : %s\n", sd->error_str);
return -1; return -1;
} }
full_size = scsi_datain_getfullsize(inq_lbp_task); full_size = scsi_datain_getfullsize(inq_lbp_task);
@@ -1151,8 +1198,11 @@ main(int argc, char *argv[])
scsi_free_scsi_task(inq_lbp_task); scsi_free_scsi_task(inq_lbp_task);
/* we need more data for the full list */ /* we need more data for the full list */
if ((inq_lbp_task = iscsi_inquiry_sync(iscsic, lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, full_size)) == NULL) { inq_lbp_task = NULL;
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsic)); inquiry(sd, &inq_lbp_task, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING,
full_size, EXPECT_STATUS_GOOD);
if (inq_lbp_task == NULL) {
printf("Inquiry command failed : %s\n", sd->error_str);
return -1; return -1;
} }
} }
@@ -1164,32 +1214,29 @@ main(int argc, char *argv[])
} }
} }
rsop_task = iscsi_report_supported_opcodes_sync(iscsic, lun, rsop_task = NULL;
1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 65535); report_supported_opcodes(sd, &rsop_task, 1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 65535,
EXPECT_STATUS_GOOD);
if (rsop_task == NULL) { if (rsop_task == NULL) {
printf("Failed to send REPORT_SUPPORTED_OPCODES command: %s\n", printf("Failed to send REPORT_SUPPORTED_OPCODES command: %s\n", sd->error_str);
iscsi_get_error(iscsic)); free_scsi_device(sd);
iscsi_destroy_context(iscsic);
return -1; return -1;
} }
if (rsop_task->status == SCSI_STATUS_GOOD) { if (rsop_task->status == SCSI_STATUS_GOOD) {
rsop = scsi_datain_unmarshall(rsop_task); rsop = scsi_datain_unmarshall(rsop_task);
if (rsop == NULL) { if (rsop == NULL) {
printf("failed to unmarshall REPORT_SUPPORTED_OPCODES " printf("failed to unmarshall REPORT_SUPPORTED_OPCODES data.\n");
"data. %s\n",
iscsi_get_error(iscsic));
scsi_free_scsi_task(rsop_task); scsi_free_scsi_task(rsop_task);
} }
} }
/* check if the device is write protected or not */ /* check if the device is write protected or not */
task = iscsi_modesense6_sync(iscsic, lun, 0, SCSI_MODESENSE_PC_CURRENT, task = NULL;
SCSI_MODEPAGE_RETURN_ALL_PAGES, modesense6(sd, &task, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
0, 255); EXPECT_STATUS_GOOD);
if (task == NULL) { if (task == NULL) {
printf("Failed to send MODE_SENSE6 command: %s\n", printf("Failed to send MODE_SENSE6 command: %s\n", sd->error_str);
iscsi_get_error(iscsic)); free_scsi_device(sd);
iscsi_destroy_context(iscsic);
return -1; return -1;
} }
if (task->status == SCSI_STATUS_GOOD) { if (task->status == SCSI_STATUS_GOOD) {
@@ -1205,9 +1252,6 @@ main(int argc, char *argv[])
} }
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
iscsi_logout_sync(iscsic);
iscsi_destroy_context(iscsic);
if (is_usb) { if (is_usb) {
printf("USB device. Clamping maximum transfer length to 120k\n"); printf("USB device. Clamping maximum transfer length to 120k\n");
maximum_transfer_length = 120 *1024 / block_size; maximum_transfer_length = 120 *1024 / block_size;
@@ -1243,7 +1287,6 @@ main(int argc, char *argv[])
} }
CU_cleanup_registry(); CU_cleanup_registry();
free(discard_const(tgt_url));
if (inq_task != NULL) { if (inq_task != NULL) {
scsi_free_scsi_task(inq_task); scsi_free_scsi_task(inq_task);
@@ -1263,6 +1306,7 @@ main(int argc, char *argv[])
if (rsop_task != NULL) { if (rsop_task != NULL) {
scsi_free_scsi_task(rsop_task); scsi_free_scsi_task(rsop_task);
} }
free_scsi_device(sd);
return 0; return 0;
} }

View File

@@ -32,11 +32,7 @@
#include "iscsi-support.h" #include "iscsi-support.h"
/* globals between setup, tests, and teardown */ /* globals between setup, tests, and teardown */
extern struct iscsi_context *iscsic;
extern int tgt_lun;
extern struct scsi_task *task; extern struct scsi_task *task;
extern struct iscsi_context *iscsic2;
extern int tgt_lun2;
extern unsigned char *read_write_buf; extern unsigned char *read_write_buf;
#ifndef HAVE_CU_SUITEINFO_PSETUPFUNC #ifndef HAVE_CU_SUITEINFO_PSETUPFUNC

View File

@@ -53,8 +53,9 @@ test_compareandwrite_miscompare(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = write16(iscsic, tgt_lun, 0, i * block_size, ret = write16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
CU_PASS("WRITE16 is not implemented."); CU_PASS("WRITE16 is not implemented.");
@@ -71,9 +72,10 @@ test_compareandwrite_miscompare(void)
"BlockLimits.MaximumCompareAndWriteLength(%d). " "BlockLimits.MaximumCompareAndWriteLength(%d). "
"Command should fail with INVALID_FIELD_IN_CDB", "Command should fail with INVALID_FIELD_IN_CDB",
i, maxbl); i, maxbl);
ret = compareandwrite_invalidfieldincdb(iscsic, tgt_lun, 0, ret = compareandwrite(sd, 0,
buf, 2 * i * block_size, block_size, buf, 2 * i * block_size,
0, 0, 0, 0); block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support " CU_PASS("[SKIPPED] Target does not support "
"COMPARE_AND_WRITE. Skipping test"); "COMPARE_AND_WRITE. Skipping test");
@@ -88,8 +90,10 @@ test_compareandwrite_miscompare(void)
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' " logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:0 (if they all contain 'A')", i); "at LBA:0 (if they all contain 'A')", i);
ret = compareandwrite_miscompare(iscsic, tgt_lun, 0, ret = compareandwrite(sd, 0,
buf, 2 * i * block_size, block_size, 0, 0, 0, 0); buf, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_MISCOMPARE);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support " CU_PASS("[SKIPPED] Target does not support "
"COMPARE_AND_WRITE. Skipping test"); "COMPARE_AND_WRITE. Skipping test");
@@ -99,8 +103,9 @@ test_compareandwrite_miscompare(void)
logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify " logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
"they are still unchanged as 'A'", i); "they are still unchanged as 'A'", i);
ret = read16(iscsic, tgt_lun, 0, i * block_size, ret = read16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) { for (j = 0; j < i * block_size; j++) {
@@ -123,8 +128,9 @@ test_compareandwrite_miscompare(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = write16(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = write16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match."); logging(LOG_VERBOSE, "Change byte 27 from the end to 'C' so that it does not match.");
@@ -136,9 +142,10 @@ test_compareandwrite_miscompare(void)
"BlockLimits.MaximumCompareAndWriteLength(%d). " "BlockLimits.MaximumCompareAndWriteLength(%d). "
"Command should fail with INVALID_FIELD_IN_CDB", "Command should fail with INVALID_FIELD_IN_CDB",
i, maxbl); i, maxbl);
ret = compareandwrite_invalidfieldincdb(iscsic, tgt_lun, 0, ret = compareandwrite(sd, 0,
buf, 2 * i * block_size, block_size, buf, 2 * i * block_size,
0, 0, 0, 0); block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
continue; continue;
@@ -148,16 +155,18 @@ test_compareandwrite_miscompare(void)
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' " logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:%" PRIu64 " (if they all contain 'A')", "at LBA:%" PRIu64 " (if they all contain 'A')",
i, num_blocks - i); i, num_blocks - i);
ret = compareandwrite_miscompare(iscsic, tgt_lun, ret = compareandwrite(sd, num_blocks - i,
num_blocks - i, buf, 2 * i * block_size, block_size,
buf, 2 * i * block_size, block_size, 0, 0, 0, 0); 0, 0, 0, 0,
EXPECT_MISCOMPARE);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64 logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
"they are still unchanged as 'A'", "they are still unchanged as 'A'",
i, num_blocks - i); i, num_blocks - i);
ret = read16(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = read16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) { for (j = 0; j < i * block_size; j++) {

View File

@@ -54,8 +54,9 @@ test_compareandwrite_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = write16(iscsic, tgt_lun, 0, i * block_size, ret = write16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] WRITE16 is not implemented.");
CU_PASS("WRITE16 is not implemented."); CU_PASS("WRITE16 is not implemented.");
@@ -68,9 +69,10 @@ test_compareandwrite_simple(void)
"BlockLimits.MaximumCompareAndWriteLength(%d). " "BlockLimits.MaximumCompareAndWriteLength(%d). "
"Command should fail with INVALID_FIELD_IN_CDB", "Command should fail with INVALID_FIELD_IN_CDB",
i, maxbl); i, maxbl);
ret = compareandwrite_invalidfieldincdb(iscsic, tgt_lun, 0, ret = compareandwrite(sd, 0,
buf, 2 * i * block_size, block_size, buf, 2 * i * block_size,
0, 0, 0, 0); block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support " CU_PASS("[SKIPPED] Target does not support "
"COMPARE_AND_WRITE. Skipping test"); "COMPARE_AND_WRITE. Skipping test");
@@ -85,9 +87,10 @@ test_compareandwrite_simple(void)
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' " logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:0 (if they all contain 'A')", i); "at LBA:0 (if they all contain 'A')", i);
ret = compareandwrite(iscsic, tgt_lun, 0, ret = compareandwrite(sd, 0,
buf, 2 * i * block_size, block_size, buf, 2 * i * block_size, block_size,
0, 0, 0, 0); 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support " CU_PASS("[SKIPPED] Target does not support "
"COMPARE_AND_WRITE. Skipping test"); "COMPARE_AND_WRITE. Skipping test");
@@ -97,8 +100,9 @@ test_compareandwrite_simple(void)
logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify " logging(LOG_VERBOSE, "Read %d blocks at LBA:0 and verify "
"they are all 'B'", i); "they are all 'B'", i);
ret = read16(iscsic, tgt_lun, 0, i * block_size, ret = read16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) { for (j = 0; j < i * block_size; j++) {
@@ -122,8 +126,9 @@ test_compareandwrite_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = write16(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = write16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (i > maxbl) { if (i > maxbl) {
@@ -131,9 +136,10 @@ test_compareandwrite_simple(void)
"BlockLimits.MaximumCompareAndWriteLength(%d). " "BlockLimits.MaximumCompareAndWriteLength(%d). "
"Command should fail with INVALID_FIELD_IN_CDB", "Command should fail with INVALID_FIELD_IN_CDB",
i, maxbl); i, maxbl);
ret = compareandwrite_invalidfieldincdb(iscsic, tgt_lun, 0, ret = compareandwrite(sd, 0,
buf, 2 * i * block_size, block_size, buf, 2 * i * block_size,
0, 0, 0, 0); block_size, 0, 0, 0, 0,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
continue; continue;
@@ -143,15 +149,18 @@ test_compareandwrite_simple(void)
logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' " logging(LOG_VERBOSE, "Overwrite %d blocks with 'B' "
"at LBA:%" PRIu64 " (if they all contain 'A')", "at LBA:%" PRIu64 " (if they all contain 'A')",
i, num_blocks - i); i, num_blocks - i);
ret = compareandwrite(iscsic, tgt_lun, num_blocks - i, ret = compareandwrite(sd, num_blocks - i,
buf, 2 * i * block_size, block_size, 0, 0, 0, 0); buf, 2 * i * block_size, block_size,
0, 0, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64 logging(LOG_VERBOSE, "Read %d blocks at LBA:%" PRIu64
" and verify they are all 'B'", " and verify they are all 'B'",
i, num_blocks - i); i, num_blocks - i);
ret = read16(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = read16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
for (j = 0; j < i * block_size; j++) { for (j = 0; j < i * block_size; j++) {

View File

@@ -33,7 +33,8 @@ test_get_lba_status_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test GET_LBA_STATUS one block beyond the end of the LUN"); logging(LOG_VERBOSE, "Test GET_LBA_STATUS one block beyond the end of the LUN");
ret = get_lba_status_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 24); ret = get_lba_status(sd, NULL, num_blocks + 1, 24,
EXPECT_LBA_OOB);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test"); CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test");
return; return;
@@ -42,11 +43,13 @@ test_get_lba_status_beyond_eol(void)
logging(LOG_VERBOSE, "Test GET_LBA_STATUS at LBA 2^63"); logging(LOG_VERBOSE, "Test GET_LBA_STATUS at LBA 2^63");
ret = get_lba_status_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000ULL, 24); ret = get_lba_status(sd, NULL, 0x8000000000000000ULL, 24,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test GET_LBA_STATUS at LBA -1"); logging(LOG_VERBOSE, "Test GET_LBA_STATUS at LBA -1");
ret = get_lba_status_lbaoutofrange(iscsic, tgt_lun, 0xffffffffffffffffULL, 24); ret = get_lba_status(sd, NULL, 0xffffffffffffffffULL, 24,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -33,7 +33,8 @@ test_get_lba_status_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test GET_LBA_STATUS of 1-256 blocks at the start of the LUN"); logging(LOG_VERBOSE, "Test GET_LBA_STATUS of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = get_lba_status(iscsic, tgt_lun, 0, 24, NULL); ret = get_lba_status(sd, NULL,0, 24,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test"); CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test");
return; return;
@@ -47,7 +48,8 @@ test_get_lba_status_simple(void)
logging(LOG_VERBOSE, "Test GET_LBA_STATUS of 1-256 blocks at the end of the LUN"); logging(LOG_VERBOSE, "Test GET_LBA_STATUS of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = get_lba_status(iscsic, tgt_lun, num_blocks - i, 24, NULL); ret = get_lba_status(sd, NULL, num_blocks - i, 24,
EXPECT_STATUS_GOOD);
if (ret != 0) { if (ret != 0) {
CU_FAIL("[FAILED] GET_LBA_STATUS command failed"); CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
return; return;

View File

@@ -25,7 +25,6 @@
#include "iscsi-support.h" #include "iscsi-support.h"
#include "iscsi-test-cu.h" #include "iscsi-test-cu.h"
void void
test_get_lba_status_unmap_single(void) test_get_lba_status_unmap_single(void)
{ {
@@ -33,7 +32,9 @@ test_get_lba_status_unmap_single(void)
uint64_t i; uint64_t i;
unsigned char *buf = alloca(257 * block_size); unsigned char *buf = alloca(257 * block_size);
struct unmap_list list[1]; struct unmap_list list[1];
enum scsi_provisioning_type provisioning; struct scsi_task *t = NULL;
struct scsi_get_lba_status *lbas = NULL;
struct scsi_lba_status_descriptor *lbasd = NULL;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
CHECK_FOR_THIN_PROVISIONING; CHECK_FOR_THIN_PROVISIONING;
@@ -49,8 +50,9 @@ test_get_lba_status_unmap_single(void)
logging(LOG_VERBOSE, "Write the first %i blocks with a known " logging(LOG_VERBOSE, "Write the first %i blocks with a known "
"pattern and thus map the blocks", 256 + lbppb); "pattern and thus map the blocks", 256 + lbppb);
ret = write10(iscsic, tgt_lun, 0, (256 + lbppb) * block_size, ret = write10(sd, 0, (256 + lbppb) * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
for (i = 0; i + lbppb <= 256; i += lbppb) { for (i = 0; i + lbppb <= 256; i += lbppb) {
@@ -58,12 +60,14 @@ test_get_lba_status_unmap_single(void)
PRIu64 " (number of logical blocks: %d)", i, lbppb); PRIu64 " (number of logical blocks: %d)", i, lbppb);
list[0].lba = i; list[0].lba = i;
list[0].num = lbppb; list[0].num = lbppb;
ret = unmap(iscsic, tgt_lun, 0, list, 1); ret = unmap(sd, 0, list, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read the status of the block at LBA:%" logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
PRIu64, i); PRIu64, i);
ret = get_lba_status(iscsic, tgt_lun, i, 24, NULL); ret = get_lba_status(sd, NULL, i, 24,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test"); CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test");
return; return;
@@ -74,15 +78,36 @@ test_get_lba_status_unmap_single(void)
} }
logging(LOG_VERBOSE, "Read the status of the block at LBA:%" logging(LOG_VERBOSE, "Read the status of the block at LBA:%"
PRIu64, i + lbppb); PRIu64, i + lbppb);
ret = get_lba_status(iscsic, tgt_lun, i + lbppb, 24, &provisioning); ret = get_lba_status(sd, &t, i + lbppb, 24,
EXPECT_STATUS_GOOD);
if (ret != 0) { if (ret != 0) {
CU_FAIL("[FAILED] GET_LBA_STATUS command failed"); CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
return; return;
} }
if (provisioning != SCSI_PROVISIONING_TYPE_MAPPED) { if (t == NULL) {
CU_FAIL("[FAILED] GET_LBA_STATUS task is NULL");
return;
}
lbas = scsi_datain_unmarshall(t);
if (lbas == NULL) {
CU_FAIL("[FAILED] GET_LBA_STATUS command: failed "
"to unmarshall data.");
scsi_free_scsi_task(t);
return;
}
lbasd = &lbas->descriptors[0];
if (lbasd->lba != i + lbppb) {
CU_FAIL("[FAILED] GET_LBA_STATUS command: "
"lba offset in first descriptor does not "
"match request.");
scsi_free_scsi_task(t);
return;
}
if (lbasd->provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
CU_FAIL("[FAILED] LBA should be mapped but isn't"); CU_FAIL("[FAILED] LBA should be mapped but isn't");
return; return;
} }
scsi_free_scsi_task(t);
} }
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
@@ -91,18 +116,21 @@ test_get_lba_status_unmap_single(void)
for (i = lbppb; i + lbppb <= 256; i += lbppb) { for (i = lbppb; i + lbppb <= 256; i += lbppb) {
logging(LOG_VERBOSE, "Write the first %i blocks with a known " logging(LOG_VERBOSE, "Write the first %i blocks with a known "
"pattern and thus map the blocks", (256 + lbppb)); "pattern and thus map the blocks", (256 + lbppb));
ret = write10(iscsic, tgt_lun, 0, (256 + lbppb) * block_size, ret = write10(sd, 0, (256 + lbppb) * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmap %" PRIu64 " blocks at LBA 0", i); logging(LOG_VERBOSE, "Unmap %" PRIu64 " blocks at LBA 0", i);
list[0].lba = 0; list[0].lba = 0;
list[0].num = i; list[0].num = i;
ret = unmap(iscsic, tgt_lun, 0, list, 1); ret = unmap(sd, 0, list, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read the status of the block at LBA:0"); logging(LOG_VERBOSE, "Read the status of the block at LBA:0");
ret = get_lba_status(iscsic, tgt_lun, 0, 24, NULL); ret = get_lba_status(sd, NULL, 0, 24,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test"); CU_PASS("[SKIPPED] Target does not support GET_LBA_STATUS. Skipping test");
return; return;
@@ -112,14 +140,35 @@ test_get_lba_status_unmap_single(void)
return; return;
} }
logging(LOG_VERBOSE, "Read the status of the block at LBA:%" PRIu64, i + 1); logging(LOG_VERBOSE, "Read the status of the block at LBA:%" PRIu64, i + 1);
ret = get_lba_status(iscsic, tgt_lun, i + 1, 24, &provisioning); ret = get_lba_status(sd, &t, i + 1, 24,
EXPECT_STATUS_GOOD);
if (ret != 0) { if (ret != 0) {
CU_FAIL("[FAILED] GET_LBA_STATUS command failed"); CU_FAIL("[FAILED] GET_LBA_STATUS command failed");
return; return;
} }
if (provisioning != SCSI_PROVISIONING_TYPE_MAPPED) { if (t == NULL) {
CU_FAIL("[FAILED] GET_LBA_STATUS task is NULL");
return;
}
lbas = scsi_datain_unmarshall(t);
if (lbas == NULL) {
CU_FAIL("[FAILED] GET_LBA_STATUS command: failed "
"to unmarshall data.");
scsi_free_scsi_task(t);
return;
}
lbasd = &lbas->descriptors[0];
if (lbasd->lba != i + lbppb) {
CU_FAIL("[FAILED] GET_LBA_STATUS command: "
"lba offset in first descriptor does not "
"match request.");
scsi_free_scsi_task(t);
return;
}
if (lbasd->provisioning != SCSI_PROVISIONING_TYPE_MAPPED) {
CU_FAIL("[FAILED] LBA should be mapped but isn't"); CU_FAIL("[FAILED] LBA should be mapped but isn't");
return; return;
} }
scsi_free_scsi_task(t);
} }
} }

View File

@@ -34,14 +34,14 @@ test_inquiry_alloc_length(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test of the INQUIRY allocation length"); logging(LOG_VERBOSE, "Test of the INQUIRY allocation length");
logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page with alloc length from 5-255"); logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page with alloc length from 5-255");
for (i = 5; i < 256 ; i++) { for (i = 5; i < 256 ; i++) {
if (task != NULL) { if (task != NULL) {
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
task = NULL; task = NULL;
} }
ret = inquiry(iscsic, tgt_lun, 0, 0, i, &task); ret = inquiry(sd, &task, 0, 0, i,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data when reading with alloc length 255"); logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data when reading with alloc length 255");
@@ -83,11 +83,13 @@ test_inquiry_alloc_length(void)
logging(LOG_VERBOSE, "Version is SPC-3 or later. Read INQUIRY data using 16-bit allocation length"); logging(LOG_VERBOSE, "Version is SPC-3 or later. Read INQUIRY data using 16-bit allocation length");
logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 511 (low order byte is 0xff)"); logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 511 (low order byte is 0xff)");
ret = inquiry(iscsic, tgt_lun, 0, 0, 511, &task); ret = inquiry(sd, &task, 0, 0, 511,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 512 (low order byte is 0x00)"); logging(LOG_VERBOSE, "Read INQUIRY data with allocation length 512 (low order byte is 0x00)");
ret = inquiry(iscsic, tgt_lun, 0, 0, 512, &task2); ret = inquiry(sd, &task2, 0, 0, 512,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "INQUIRY data should be the same when allocation length is 511 and 512 bytes"); logging(LOG_VERBOSE, "INQUIRY data should be the same when allocation length is 511 and 512 bytes");

View File

@@ -24,10 +24,19 @@
#include "iscsi-support.h" #include "iscsi-support.h"
#include "iscsi-test-cu.h" #include "iscsi-test-cu.h"
static void check_lbp(int *supports_lbp)
{
*supports_lbp = 0;
CHECK_FOR_THIN_PROVISIONING;
*supports_lbp = 1;
}
void void
test_inquiry_block_limits(void) test_inquiry_block_limits(void)
{ {
int ret; int supports_lbp, ret;
struct scsi_inquiry_block_limits *bl; struct scsi_inquiry_block_limits *bl;
struct scsi_task *bl_task = NULL; struct scsi_task *bl_task = NULL;
struct scsi_inquiry_logical_block_provisioning *lbp = NULL; struct scsi_inquiry_logical_block_provisioning *lbp = NULL;
@@ -38,10 +47,11 @@ test_inquiry_block_limits(void)
CHECK_FOR_SBC; CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Block device. Verify that we can read Block Limits VPD"); logging(LOG_VERBOSE, "Block device. Verify that we can read Block "
ret = inquiry(iscsic, tgt_lun, "Limits VPD");
1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, ret = inquiry(sd, &bl_task,
64, &bl_task); 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, 255,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) { if (ret != 0) {
logging(LOG_NORMAL, "[FAILURE] failed to send inquiry."); logging(LOG_NORMAL, "[FAILURE] failed to send inquiry.");
@@ -57,59 +67,63 @@ test_inquiry_block_limits(void)
goto finished; goto finished;
} }
logging(LOG_VERBOSE, "Verify that the PageLength matches up with the size of the DATA-IN buffer."); logging(LOG_VERBOSE, "Verify that the PageLength matches up with the "
"size of the DATA-IN buffer.");
CU_ASSERT_EQUAL(bl_task->datain.size, bl_task->datain.data[3] + 4); CU_ASSERT_EQUAL(bl_task->datain.size, bl_task->datain.data[3] + 4);
if (bl_task->datain.size != bl_task->datain.data[3] + 4) { if (bl_task->datain.size != bl_task->datain.data[3] + 4) {
logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned. " logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned. "
"Was %d but expected %d", "Was %d but expected %d",
bl_task->datain.data[3], bl_task->datain.size - 4); bl_task->datain.data[3], bl_task->datain.size - 4);
} else { } else {
logging(LOG_VERBOSE, "[SUCCESS] PageLength matches DataIn buffer size"); logging(LOG_VERBOSE, "[SUCCESS] PageLength matches DataIn "
"buffer size");
} }
logging(LOG_VERBOSE, "Verify that the PageLength matches SCSI-level."); logging(LOG_VERBOSE, "Verify that the PageLength matches SCSI-level.");
/* if it is not SBC3 then we assume it must be SBC2 */ /* if it is not SBC3 then we assume it must be SBC2 */
if (sbc3_support) { if (sbc3_support) {
logging(LOG_VERBOSE, "Device claims SBC-3. Verify that " "PageLength == 0x3C"); logging(LOG_VERBOSE, "Device claims SBC-3. Verify that " "page size is >= 60");
} else { } else {
logging(LOG_VERBOSE, "Device is not SBC-3. Verify that " logging(LOG_VERBOSE, "Device is not SBC-3. Verify that "
"PageLength == 0x0C (but allow 0x3C too. Some SBC-2 " "PageLength == 8 (but allow >= 60 too. Some SBC-2 "
"devices support some SBC-3 features."); "devices support some SBC-3 features.");
} }
switch (bl_task->datain.data[3]) {
case 0x3c:
/* accept 0x3c (==SBC-3) for all levels */
if (!sbc3_support) {
logging(LOG_NORMAL, "[WARNING] SBC-3 pagelength (0x3C) "
"returned but SBC-3 support was not claimed "
"in the standard inquiry page.");
}
break;
case 0x0c:
/* only accept 0x0c for levels < SBC-3 */
if (!sbc3_support) {
break;
}
/* fallthrough */
default:
CU_FAIL("[FAILED] Invalid pagelength returned");
logging(LOG_NORMAL, "[FAILURE] Invalid PageLength returned.");
}
if (bl_task->datain.data[3] == 8) {
if (sbc3_support) {
logging(LOG_NORMAL, "[FAILURE] Invalid PageLength "
"returned. SBC3 claimed but page length "
"is 8.");
CU_FAIL("[FAILED] Invalid pagelength returned. "
"SBC3 claimed but page length is 8.");
}
} else if (bl_task->datain.size >= 60) {
if (!sbc3_support) {
logging(LOG_NORMAL, "[WARNING] SBC-3 pagelength "
"(>=60) returned but SBC-3 support was not "
"claimed in the standard inquiry page.");
CU_FAIL("[WARNING] SBC-3 pagelength "
"(>=60) returned but SBC-3 support was not "
"claimed in the standard inquiry page.");
}
}
if (bl_task->datain.data[3] != 0x3c) { if (bl_task->datain.data[3] != 0x3c) {
goto finished; goto finished;
} }
check_lbp(&supports_lbp);
if (!supports_lbp)
goto finished;
/* /*
* MAXIMUM UNMAP LBA COUNT * MAXIMUM UNMAP LBA COUNT
* MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT * MAXIMUM UNMAP BLOCK DESCRIPTOR COUNT
*/ */
logging(LOG_VERBOSE, "Try reading the logical block provisioning VPD"); logging(LOG_VERBOSE, "Try reading the logical block provisioning VPD");
ret = inquiry(iscsic, tgt_lun, ret = inquiry(sd, &lbp_task,
1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, 255,
64, &lbp_task); EXPECT_STATUS_GOOD);
if (ret == 0) { if (ret == 0) {
lbp = scsi_datain_unmarshall(lbp_task); lbp = scsi_datain_unmarshall(lbp_task);
if (lbp == NULL) { if (lbp == NULL) {

View File

@@ -33,6 +33,7 @@ test_inquiry_evpd(void)
logging(LOG_VERBOSE, "Test of the INQUIRY EVPD bit"); logging(LOG_VERBOSE, "Test of the INQUIRY EVPD bit");
logging(LOG_VERBOSE, "Verify that INQUIRY with EVPD==0 and PC!=0 is an error"); logging(LOG_VERBOSE, "Verify that INQUIRY with EVPD==0 and PC!=0 is an error");
ret = inquiry_invalidfieldincdb(iscsic, tgt_lun, 0, 1, 256); ret = inquiry(sd, NULL, 0, 1, 256,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -36,14 +36,14 @@ test_inquiry_mandatory_vpd_sbc(void)
logging(LOG_VERBOSE, "SUPPORTED_VPD_PAGES is mandatory for SBC devices. Verify we can read it."); logging(LOG_VERBOSE, "SUPPORTED_VPD_PAGES is mandatory for SBC devices. Verify we can read it.");
ret = inquiry(iscsic, tgt_lun, ret = inquiry(sd, NULL,
1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
255, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "DEVICE_IDENTIFICATION is mandatory for SBC devices. Verify we can read it."); logging(LOG_VERBOSE, "DEVICE_IDENTIFICATION is mandatory for SBC devices. Verify we can read it.");
ret = inquiry(iscsic, tgt_lun, ret = inquiry(sd, NULL,
1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION, 1, SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION, 255,
255, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -35,7 +35,8 @@ test_inquiry_standard(void)
logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page"); logging(LOG_VERBOSE, "Verify we can read standard INQUIRY page");
/* 260 bytes is the maximum possible size of the standard vpd */ /* 260 bytes is the maximum possible size of the standard vpd */
ret = inquiry(iscsic, tgt_lun, 0, 0, 260, &task); ret = inquiry(sd, &task, 0, 0, 260,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data"); logging(LOG_VERBOSE, "Verify we got at least 36 bytes of data");
@@ -82,13 +83,29 @@ test_inquiry_standard(void)
CU_ASSERT_EQUAL(std_inq->response_data_format, 2); CU_ASSERT_EQUAL(std_inq->response_data_format, 2);
logging(LOG_VERBOSE, "Verify additional-length is correct"); logging(LOG_VERBOSE, "Verify additional-length is correct");
if (std_inq->additional_length != task->datain.size - 5) { if (std_inq->additional_length > task->datain.size - 5) {
logging(LOG_NORMAL, "[FAILED] Bad additional length " logging(LOG_NORMAL, "[FAILED] Bad additional length "
"returned. Should be %d but device returned %d.", "returned. Should be %d but device returned %d.",
task->datain.size - 5, task->datain.size - 5,
std_inq->additional_length); std_inq->additional_length);
logging(LOG_NORMAL, "[FAILED] Additional length points "
"beyond end of data");
CU_FAIL("Additional length points beyond end of data");
}
if (std_inq->additional_length < task->datain.size - 5) {
logging(LOG_NORMAL, "[WARNING] Bad additional length "
"returned. Should be %d but device returned %d. ",
task->datain.size - 5,
std_inq->additional_length);
logging(LOG_VERBOSE, "Verify that all padding data is 0");
for (i = std_inq->additional_length + 6; i < task->datain.size; i++) {
if (!task->datain.data[i])
continue;
logging(LOG_NORMAL, "[FAILED] Padding data is not zero."
" Are we leaking data?");
CU_FAIL("Padding data is not zero. Leaking data?");
}
} }
CU_ASSERT_EQUAL(std_inq->additional_length, task->datain.size - 5);
logging(LOG_VERBOSE, "Verify VENDOR_IDENTIFICATION is in ASCII"); logging(LOG_VERBOSE, "Verify VENDOR_IDENTIFICATION is in ASCII");
for (i = 8; i < 16; i++) { for (i = 8; i < 16; i++) {

View File

@@ -34,9 +34,9 @@ test_inquiry_supported_vpd(void)
logging(LOG_VERBOSE, "Test INQUIRY supported VPD pages"); logging(LOG_VERBOSE, "Test INQUIRY supported VPD pages");
logging(LOG_VERBOSE, "Verify we can read the SUPPORTED VPD page"); logging(LOG_VERBOSE, "Verify we can read the SUPPORTED VPD page");
ret = inquiry(iscsic, tgt_lun, ret = inquiry(sd, &task,
1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, 255,
255, &task); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we got at least 4 bytes of data"); logging(LOG_VERBOSE, "Verify we got at least 4 bytes of data");
@@ -56,9 +56,8 @@ test_inquiry_supported_vpd(void)
logging(LOG_VERBOSE, "Verify we can read page 0x%02x", logging(LOG_VERBOSE, "Verify we can read page 0x%02x",
sup_inq->pages[i]); sup_inq->pages[i]);
ret = inquiry(iscsic, tgt_lun, ret = inquiry(sd, NULL, 1, sup_inq->pages[i], 255,
1, sup_inq->pages[i], EXPECT_STATUS_GOOD);
255, NULL);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -51,20 +51,29 @@ void test_iscsi_cmdsn_toohigh(void)
logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN"); logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN");
logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN"); logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN > MAXCMDSN must be silently ignored by the target"); logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN > MAXCMDSN must be silently ignored by the target");
logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == MAXCMDSN+1. Should be ignored by the target."); logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == MAXCMDSN+1. Should be ignored by the target.");
iscsic->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsic->target_max_recv_data_segment_length = block_size; sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
local_iscsi_queue_pdu = my_iscsi_queue_pdu; local_iscsi_queue_pdu = my_iscsi_queue_pdu;
change_cmdsn = 1; change_cmdsn = 1;
/* we don't want autoreconnect since some targets will incorrectly /* we don't want autoreconnect since some targets will incorrectly
* drop the connection on this condition. * drop the connection on this condition.
*/ */
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(iscsic, 3); iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, -1); CU_ASSERT_EQUAL(ret, -1);
if (ret == -1) { if (ret == -1) {
logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply"); logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply");
@@ -73,9 +82,10 @@ void test_iscsi_cmdsn_toohigh(void)
} }
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again"); logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -51,20 +51,29 @@ void test_iscsi_cmdsn_toolow(void)
logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN"); logging(LOG_VERBOSE, "Test sending invalid iSCSI CMDSN");
logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN"); logging(LOG_VERBOSE, "CMDSN MUST be in the range EXPCMDSN and MAXCMDSN");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN < EXPCMDSN must be silently ignored by the target"); logging(LOG_VERBOSE, "RFC3720:3.2.2.1 CMDSN < EXPCMDSN must be silently ignored by the target");
logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN-1. Should be ignored by the target."); logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN-1. Should be ignored by the target.");
iscsic->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsic->target_max_recv_data_segment_length = block_size; sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
local_iscsi_queue_pdu = my_iscsi_queue_pdu; local_iscsi_queue_pdu = my_iscsi_queue_pdu;
change_cmdsn = 1; change_cmdsn = 1;
/* we don't want autoreconnect since some targets will incorrectly /* we don't want autoreconnect since some targets will incorrectly
* drop the connection on this condition. * drop the connection on this condition.
*/ */
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(iscsic, 3); iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, -1); CU_ASSERT_EQUAL(ret, -1);
if (ret == -1) { if (ret == -1) {
logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply"); logging(LOG_VERBOSE, "[SUCCESS] We did not receive a reply");
@@ -74,9 +83,10 @@ void test_iscsi_cmdsn_toolow(void)
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again"); logging(LOG_VERBOSE, "Send a TESTUNITREADY with CMDSN == EXPCMDSN. should work again");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -35,19 +35,19 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu
} }
switch (change_datasn) { switch (change_datasn) {
case 1: case 1:
/* change datasn to 0 */ /* change DataSN to 0 */
scsi_set_uint32(&pdu->outdata.data[36], 0); scsi_set_uint32(&pdu->outdata.data[36], 0);
break; break;
case 2: case 2:
/* change datasn to 27 */ /* change DataSN to 27 */
scsi_set_uint32(&pdu->outdata.data[36], 27); scsi_set_uint32(&pdu->outdata.data[36], 27);
break; break;
case 3: case 3:
/* change datasn to -1 */ /* change DataSN to -1 */
scsi_set_uint32(&pdu->outdata.data[36], -1); scsi_set_uint32(&pdu->outdata.data[36], -1);
break; break;
case 4: case 4:
/* change datasn from (0,1) to (1,0) */ /* change DataSN from (0,1) to (1,0) */
datasn = scsi_get_uint32(&pdu->outdata.data[36]); datasn = scsi_get_uint32(&pdu->outdata.data[36]);
scsi_set_uint32(&pdu->outdata.data[36], 1 - datasn); scsi_set_uint32(&pdu->outdata.data[36], 1 - datasn);
break; break;
@@ -63,20 +63,28 @@ void test_iscsi_datasn_invalid(void)
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test sending invalid iSCSI DATASN"); logging(LOG_VERBOSE, "Test sending invalid iSCSI DataSN");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Send 2 DATAIN with DATASN==0. Should fail."); logging(LOG_VERBOSE, "Send two Data-Out PDU's with DataSN==0. Should fail.");
change_datasn = 1; change_datasn = 1;
iscsic->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsic->target_max_recv_data_segment_length = block_size; sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
local_iscsi_queue_pdu = my_iscsi_queue_pdu; local_iscsi_queue_pdu = my_iscsi_queue_pdu;
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(iscsic, 3); iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = write10(iscsic, tgt_lun, 100, 2 * block_size, ret = write10(sd, 100, 2 * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
CU_PASS("WRITE10 is not implemented."); CU_PASS("WRITE10 is not implemented.");
@@ -85,20 +93,21 @@ void test_iscsi_datasn_invalid(void)
} }
CU_ASSERT_NOT_EQUAL(ret, 0); CU_ASSERT_NOT_EQUAL(ret, 0);
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Send DATAIN with DATASN==27. Should fail"); logging(LOG_VERBOSE, "Send Data-Out PDU with DataSN==27. Should fail");
change_datasn = 2; change_datasn = 2;
iscsic->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsic->target_max_recv_data_segment_length = block_size; sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
local_iscsi_queue_pdu = my_iscsi_queue_pdu; local_iscsi_queue_pdu = my_iscsi_queue_pdu;
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(iscsic, 3); iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = write10(iscsic, tgt_lun, 100, block_size, ret = write10(sd, 100, block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
CU_PASS("WRITE10 is not implemented."); CU_PASS("WRITE10 is not implemented.");
@@ -107,20 +116,21 @@ void test_iscsi_datasn_invalid(void)
} }
CU_ASSERT_NOT_EQUAL(ret, 0); CU_ASSERT_NOT_EQUAL(ret, 0);
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Send DATAIN with DATASN==-1. Should fail"); logging(LOG_VERBOSE, "Send Data-Out PDU with DataSN==-1. Should fail");
change_datasn = 3; change_datasn = 3;
iscsic->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsic->target_max_recv_data_segment_length = block_size; sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
local_iscsi_queue_pdu = my_iscsi_queue_pdu; local_iscsi_queue_pdu = my_iscsi_queue_pdu;
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(iscsic, 3); iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = write10(iscsic, tgt_lun, 100, block_size, ret = write10(sd, 100, block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
CU_PASS("WRITE10 is not implemented."); CU_PASS("WRITE10 is not implemented.");
@@ -129,21 +139,22 @@ void test_iscsi_datasn_invalid(void)
} }
CU_ASSERT_NOT_EQUAL(ret, 0); CU_ASSERT_NOT_EQUAL(ret, 0);
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Send DATAIN in reverse order (datasn == 1,0). Should fail"); logging(LOG_VERBOSE, "Send Data-Out PDU's in reverse order (DataSN == 1,0). Should fail");
change_datasn = 4; change_datasn = 4;
iscsic->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO; sd->iscsi_ctx->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
iscsic->target_max_recv_data_segment_length = block_size; sd->iscsi_ctx->target_max_recv_data_segment_length = block_size;
local_iscsi_queue_pdu = my_iscsi_queue_pdu; local_iscsi_queue_pdu = my_iscsi_queue_pdu;
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(iscsic, 3); iscsi_set_timeout(sd->iscsi_ctx, 3);
ret = write10(iscsic, tgt_lun, 100, 2 * block_size, ret = write10(sd, 100, 2 * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] WRITE10 is not implemented.");
CU_PASS("WRITE10 is not implemented."); CU_PASS("WRITE10 is not implemented.");
@@ -153,5 +164,5 @@ void test_iscsi_datasn_invalid(void)
CU_ASSERT_NOT_EQUAL(ret, 0); CU_ASSERT_NOT_EQUAL(ret, 0);
local_iscsi_queue_pdu = NULL; local_iscsi_queue_pdu = NULL;
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
} }

View File

@@ -37,32 +37,38 @@ test_mandatory_sbc(void)
CHECK_FOR_SBC; CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Test INQUIRY."); logging(LOG_VERBOSE, "Test INQUIRY.");
ret = inquiry(iscsic, tgt_lun, 0, 0, 255, NULL); ret = inquiry(sd, NULL, 0, 0, 255,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READCAPACITY10."); logging(LOG_VERBOSE, "Test READCAPACITY10.");
ret = readcapacity10(iscsic, tgt_lun, 0, 0); ret = readcapacity10(sd, NULL, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (sbc3_support) { if (sbc3_support) {
logging(LOG_VERBOSE, "Test READCAPACITY16. The device claims SBC-3 support."); logging(LOG_VERBOSE, "Test READCAPACITY16. The device claims SBC-3 support.");
ret = readcapacity16(iscsic, tgt_lun, 15); ret = readcapacity16(sd, NULL, 15,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test READ10."); logging(LOG_VERBOSE, "Test READ10.");
ret = read10(iscsic, tgt_lun, 0, block_size, block_size, ret = read10(sd, NULL, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (sbc3_support) { if (sbc3_support) {
logging(LOG_VERBOSE, "Test READ16. the device claims SBC-3 support."); logging(LOG_VERBOSE, "Test READ16. the device claims SBC-3 support.");
ret = read16(iscsic, tgt_lun, 0, block_size, block_size, ret = read16(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test TESTUNITREADY."); logging(LOG_VERBOSE, "Test TESTUNITREADY.");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -28,39 +28,28 @@ void
test_modesense6_all_pages(void) test_modesense6_all_pages(void)
{ {
struct scsi_mode_sense *ms; struct scsi_mode_sense *ms;
struct scsi_task *ms_task = NULL;
int ret;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test of MODESENSE6 AllPages"); logging(LOG_VERBOSE, "Test of MODESENSE6 AllPages");
if (task != NULL) {
scsi_free_scsi_task(task);
task = NULL;
}
logging(LOG_VERBOSE, "Send MODESENSE6 command to fetch AllPages"); logging(LOG_VERBOSE, "Send MODESENSE6 command to fetch AllPages");
task = iscsi_modesense6_sync(iscsic, tgt_lun, 0, ret = modesense6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
SCSI_MODEPAGE_RETURN_ALL_PAGES, EXPECT_STATUS_GOOD);
0, 255); CU_ASSERT_EQUAL(ret, 0);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Failed to send MODE_SENSE6 "
"command:%s",
iscsi_get_error(iscsic));
CU_FAIL("[FAILED] Failed to fetch the All Pages page.");
return;
}
logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched."); logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer."); logging(LOG_VERBOSE, "Try to unmarshall the DATA-IN buffer.");
ms = scsi_datain_unmarshall(task); ms = scsi_datain_unmarshall(ms_task);
if (ms == NULL) { if (ms == NULL) {
logging(LOG_VERBOSE, "[FAILED] failed to unmarshall mode sense " logging(LOG_VERBOSE, "[FAILED] failed to unmarshall mode sense "
"datain buffer"); "datain buffer");
CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer."); CU_FAIL("[FAILED] Failed to unmarshall the data-in buffer.");
scsi_free_scsi_task(task); scsi_free_scsi_task(ms_task);
task = NULL;
return; return;
} }
logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful."); logging(LOG_VERBOSE, "[SUCCESS] Unmarshalling successful.");
@@ -75,8 +64,5 @@ test_modesense6_all_pages(void)
CU_ASSERT_TRUE(ms->mode_data_length >= 3); CU_ASSERT_TRUE(ms->mode_data_length >= 3);
if (task != NULL) { scsi_free_scsi_task(ms_task);
scsi_free_scsi_task(task);
task = NULL;
}
} }

View File

@@ -27,6 +27,9 @@
void void
test_modesense6_residuals(void) test_modesense6_residuals(void)
{ {
struct scsi_task *ms_task = NULL;
int ret;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test of MODESENSE6 Residuals"); logging(LOG_VERBOSE, "Test of MODESENSE6 Residuals");
@@ -36,95 +39,69 @@ test_modesense6_residuals(void)
logging(LOG_VERBOSE, "Try a MODESENSE6 command with 4 bytes of " logging(LOG_VERBOSE, "Try a MODESENSE6 command with 4 bytes of "
"transfer length and verify that we don't get residuals."); "transfer length and verify that we don't get residuals.");
if (task != NULL) { ret = modesense6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
scsi_free_scsi_task(task); SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 4,
task = NULL; EXPECT_STATUS_GOOD);
} CU_ASSERT_EQUAL(ret, 0);
task = iscsi_modesense6_sync(iscsic, tgt_lun, 0,
SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES,
0, 4);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Failed to send MODE_SENSE6 "
"command:%s",
iscsi_get_error(iscsic));
CU_FAIL("[FAILED] Failed to fetch the All Pages page.");
return;
}
logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched."); logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
logging(LOG_VERBOSE, "Verify that we got at most 4 bytes of DATA-IN"); logging(LOG_VERBOSE, "Verify that we got at most 4 bytes of DATA-IN");
if (task->datain.size > 4) { if (ms_task->datain.size > 4) {
logging(LOG_NORMAL, "[FAILED] got more than 4 bytes of " logging(LOG_NORMAL, "[FAILED] got more than 4 bytes of "
"DATA-IN."); "DATA-IN.");
} else { } else {
logging(LOG_VERBOSE, "[SUCCESS] <= 4 bytes of DATA-IN " logging(LOG_VERBOSE, "[SUCCESS] <= 4 bytes of DATA-IN "
"received."); "received.");
} }
CU_ASSERT_TRUE(task->datain.size <= 4); CU_ASSERT_TRUE(ms_task->datain.size <= 4);
logging(LOG_VERBOSE, "Verify residual overflow flag not set"); logging(LOG_VERBOSE, "Verify residual overflow flag not set");
if (task->residual_status == SCSI_RESIDUAL_OVERFLOW) { if (ms_task->residual_status == SCSI_RESIDUAL_OVERFLOW) {
logging(LOG_VERBOSE, "[FAILED] Target set residual " logging(LOG_VERBOSE, "[FAILED] Target set residual "
"overflow flag"); "overflow flag");
} }
CU_ASSERT_NOT_EQUAL(task->residual_status, SCSI_RESIDUAL_OVERFLOW); CU_ASSERT_NOT_EQUAL(ms_task->residual_status, SCSI_RESIDUAL_OVERFLOW);
logging(LOG_VERBOSE, "Try a MODESENSE6 command with 255 bytes of " logging(LOG_VERBOSE, "Try a MODESENSE6 command with 255 bytes of "
"transfer length and verify that we get residuals if the target returns less than the requested amount of data."); "transfer length and verify that we get residuals if the target returns less than the requested amount of data.");
if (task != NULL) { scsi_free_scsi_task(ms_task);
scsi_free_scsi_task(task); ret = modesense6(sd, &ms_task, 0, SCSI_MODESENSE_PC_CURRENT,
task = NULL; SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
} EXPECT_STATUS_GOOD);
task = iscsi_modesense6_sync(iscsic, tgt_lun, 0, CU_ASSERT_EQUAL(ret, 0);
SCSI_MODESENSE_PC_CURRENT,
SCSI_MODEPAGE_RETURN_ALL_PAGES,
0, 255);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Failed to send MODE_SENSE6 "
"command:%s",
iscsi_get_error(iscsic));
CU_FAIL("[FAILED] Failed to fetch the All Pages page.");
return;
}
logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched."); logging(LOG_VERBOSE, "[SUCCESS] All Pages fetched.");
if (ms_task->datain.size == 255) {
if (task->datain.size == 255) {
logging(LOG_VERBOSE, "We got all 255 bytes of data back " logging(LOG_VERBOSE, "We got all 255 bytes of data back "
"from the target. Verify that underflow is not set."); "from the target. Verify that underflow is not set.");
if (task->residual_status == SCSI_RESIDUAL_UNDERFLOW) { if (ms_task->residual_status == SCSI_RESIDUAL_UNDERFLOW) {
logging(LOG_VERBOSE, "[FAILED] Target set residual " logging(LOG_VERBOSE, "[FAILED] Target set residual "
"underflow flag"); "underflow flag");
} else { } else {
logging(LOG_VERBOSE, "[SUCCESS] Residual underflow " logging(LOG_VERBOSE, "[SUCCESS] Residual underflow "
"is not set"); "is not set");
} }
CU_ASSERT_NOT_EQUAL(task->residual_status, CU_ASSERT_NOT_EQUAL(ms_task->residual_status,
SCSI_RESIDUAL_UNDERFLOW); SCSI_RESIDUAL_UNDERFLOW);
} else { } else {
logging(LOG_VERBOSE, "We got less than the requested 255 bytes " logging(LOG_VERBOSE, "We got less than the requested 255 bytes "
"from the target. Verify that underflow is set."); "from the target. Verify that underflow is set.");
if (task->residual_status != SCSI_RESIDUAL_UNDERFLOW) { if (ms_task->residual_status != SCSI_RESIDUAL_UNDERFLOW) {
logging(LOG_VERBOSE, "[FAILED] Target did not set " logging(LOG_VERBOSE, "[FAILED] Target did not set "
"residual underflow flag"); "residual underflow flag");
} else { } else {
logging(LOG_VERBOSE, "[SUCCESS] Residual underflow " logging(LOG_VERBOSE, "[SUCCESS] Residual underflow "
"is set"); "is set");
} }
CU_ASSERT_EQUAL(task->residual_status, CU_ASSERT_EQUAL(ms_task->residual_status,
SCSI_RESIDUAL_UNDERFLOW); SCSI_RESIDUAL_UNDERFLOW);
} }
scsi_free_scsi_task(ms_task);
if (task != NULL) {
scsi_free_scsi_task(task);
task = NULL;
}
} }

View File

@@ -43,15 +43,18 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Eject the medium."); logging(LOG_VERBOSE, "Eject the medium.");
ret = startstopunit(iscsic, tgt_lun, 1, 0, 0, 0, 1, 0); ret = startstopunit(sd, 1, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY when medium is ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY when medium is ejected.");
ret = testunitready_nomedium(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test SYNCHRONIZECACHE10 when medium is ejected."); logging(LOG_VERBOSE, "Test SYNCHRONIZECACHE10 when medium is ejected.");
ret = synchronizecache10_nomedium(iscsic, tgt_lun, 0, 1, 1, 1); ret = synchronizecache10(sd, 0, 1, 1, 1,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"SYNCHRONIZECACHE10"); "SYNCHRONIZECACHE10");
@@ -60,7 +63,8 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test SYNCHRONIZECACHE16 when medium is ejected."); logging(LOG_VERBOSE, "Test SYNCHRONIZECACHE16 when medium is ejected.");
ret = synchronizecache16_nomedium(iscsic, tgt_lun, 0, 1, 1, 1); ret = synchronizecache16(sd, 0, 1, 1, 1,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"SYNCHRONIZECACHE16"); "SYNCHRONIZECACHE16");
@@ -69,26 +73,31 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test READ10 when medium is ejected."); logging(LOG_VERBOSE, "Test READ10 when medium is ejected.");
ret = read10_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = read10(sd, NULL, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ12 when medium is ejected."); logging(LOG_VERBOSE, "Test READ12 when medium is ejected.");
ret = read12_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = read12(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ16 when medium is ejected."); logging(LOG_VERBOSE, "Test READ16 when medium is ejected.");
ret = read16_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = read16(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READCAPACITY10 when medium is ejected."); logging(LOG_VERBOSE, "Test READCAPACITY10 when medium is ejected.");
ret = readcapacity10_nomedium(iscsic, tgt_lun, 0, 0); ret = readcapacity10(sd, NULL, 0, 0,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READCAPACITY16 when medium is ejected."); logging(LOG_VERBOSE, "Test READCAPACITY16 when medium is ejected.");
ret = readcapacity16_nomedium(iscsic, tgt_lun, 15); ret = readcapacity16(sd, NULL, 15,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
if (sbc3_support) { if (sbc3_support) {
logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support."); logging(LOG_NORMAL, "[FAILED] READCAPACITY16 is not available but the device claims SBC-3 support.");
@@ -101,7 +110,8 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test GET_LBA_STATUS when medium is ejected."); logging(LOG_VERBOSE, "Test GET_LBA_STATUS when medium is ejected.");
ret = get_lba_status_nomedium(iscsic, tgt_lun, 0, 24); ret = get_lba_status(sd, NULL, 0, 24,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"GET_LBA_STATUS"); "GET_LBA_STATUS");
@@ -110,7 +120,8 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test PREFETCH10 when medium is ejected."); logging(LOG_VERBOSE, "Test PREFETCH10 when medium is ejected.");
ret = prefetch10_nomedium(iscsic, tgt_lun, 0, 1, 1, 0); ret = prefetch10(sd, 0, 1, 1, 0, EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"PREFETCH10"); "PREFETCH10");
@@ -119,7 +130,7 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test PREFETCH16 when medium is ejected."); logging(LOG_VERBOSE, "Test PREFETCH16 when medium is ejected.");
ret = prefetch16_nomedium(iscsic, tgt_lun, 0, 1, 1, 0); ret = prefetch16(sd, 0, 1, 1, 0, EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"PREFETCH16"); "PREFETCH16");
@@ -128,8 +139,9 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test VERIFY10 when medium is ejected."); logging(LOG_VERBOSE, "Test VERIFY10 when medium is ejected.");
ret = verify10_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = verify10(sd, 0, block_size, block_size,
0, 0, 1, buf); 0, 0, 1, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"VERIFY10"); "VERIFY10");
@@ -138,8 +150,9 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test VERIFY12 when medium is ejected."); logging(LOG_VERBOSE, "Test VERIFY12 when medium is ejected.");
ret = verify12_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = verify12(sd, 0, block_size, block_size,
0, 0, 1, buf); 0, 0, 1, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"VERIFY102"); "VERIFY102");
@@ -148,8 +161,9 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test VERIFY16 when medium is ejected."); logging(LOG_VERBOSE, "Test VERIFY16 when medium is ejected.");
ret = verify16_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = verify16(sd, 0, block_size, block_size,
0, 0, 1, buf); 0, 0, 1, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"VERIFY16"); "VERIFY16");
@@ -163,23 +177,27 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test WRITE10 when medium is ejected."); logging(LOG_VERBOSE, "Test WRITE10 when medium is ejected.");
ret = write10_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = write10(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, buf); 0, 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITE12 when medium is ejected."); logging(LOG_VERBOSE, "Test WRITE12 when medium is ejected.");
ret = write12_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = write12(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, buf); 0, 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITE16 when medium is ejected."); logging(LOG_VERBOSE, "Test WRITE16 when medium is ejected.");
ret = write16_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = write16(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, buf); 0, 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 when medium is ejected."); logging(LOG_VERBOSE, "Test WRITEVERIFY10 when medium is ejected.");
ret = writeverify10_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = writeverify10(sd, 0, block_size, block_size,
0, 0, 0, 0, buf); 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"WRITEVERIFY10"); "WRITEVERIFY10");
@@ -188,8 +206,9 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY12 when medium is ejected."); logging(LOG_VERBOSE, "Test WRITEVERIFY12 when medium is ejected.");
ret = writeverify12_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = writeverify12(sd, 0, block_size, block_size,
0, 0, 0, 0, buf); 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"WRITEVERIFY12"); "WRITEVERIFY12");
@@ -198,8 +217,9 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test WRITEVERIFY16 when medium is ejected."); logging(LOG_VERBOSE, "Test WRITEVERIFY16 when medium is ejected.");
ret = writeverify16_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = writeverify16(sd, 0, block_size, block_size,
0, 0, 0, 0, buf); 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"WRITEVERIFY16"); "WRITEVERIFY16");
@@ -208,8 +228,9 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test ORWRITE when medium is ejected."); logging(LOG_VERBOSE, "Test ORWRITE when medium is ejected.");
ret = orwrite_nomedium(iscsic, tgt_lun, 0, block_size, block_size, ret = orwrite(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, buf); 0, 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"ORWRITE"); "ORWRITE");
@@ -221,8 +242,9 @@ test_nomedia_sbc(void)
logging(LOG_VERBOSE, "[SKIPPED] Test not implemented yet"); logging(LOG_VERBOSE, "[SKIPPED] Test not implemented yet");
logging(LOG_VERBOSE, "Test WRITESAME10 when medium is ejected."); logging(LOG_VERBOSE, "Test WRITESAME10 when medium is ejected.");
ret = writesame10_nomedium(iscsic, tgt_lun, 0, block_size, ret = writesame10(sd, 0, block_size,
1, 0, 0, 0, 0, buf); 1, 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"WRITESAME10"); "WRITESAME10");
@@ -231,8 +253,9 @@ test_nomedia_sbc(void)
} }
logging(LOG_VERBOSE, "Test WRITESAME16 when medium is ejected."); logging(LOG_VERBOSE, "Test WRITESAME16 when medium is ejected.");
ret = writesame16_nomedium(iscsic, tgt_lun, 0, block_size, ret = writesame16(sd, 0, block_size,
1, 0, 0, 0, 0, buf); 1, 0, 0, 0, 0, buf,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"WRITESAME16"); "WRITESAME16");
@@ -243,7 +266,8 @@ test_nomedia_sbc(void)
logging(LOG_VERBOSE, "Test UNMAP when medium is ejected."); logging(LOG_VERBOSE, "Test UNMAP when medium is ejected.");
list[0].lba = 0; list[0].lba = 0;
list[0].num = lbppb; list[0].num = lbppb;
ret = unmap_nomedium(iscsic, tgt_lun, 0, list, 1); ret = unmap(sd, 0, list, 1,
EXPECT_NO_MEDIUM);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] target does not support " logging(LOG_NORMAL, "[SKIPPED] target does not support "
"UNMAP"); "UNMAP");
@@ -254,6 +278,7 @@ test_nomedia_sbc(void)
finished: finished:
logging(LOG_VERBOSE, "Load the medium again."); logging(LOG_VERBOSE, "Load the medium again.");
ret = startstopunit(iscsic, tgt_lun, 1, 0, 0, 0, 1, 1); ret = startstopunit(sd, 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -33,9 +33,9 @@ test_orwrite_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==0");
ret = orwrite(iscsic, tgt_lun, 0, ret = orwrite(sd, 0,
0, block_size, 0, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented."); CU_PASS("ORWRITE is not implemented.");
@@ -44,22 +44,22 @@ test_orwrite_0blocks(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks one block past end-of-LUN");
ret = orwrite_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, ret = orwrite(sd, num_blocks + 1,
0, block_size, 0, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==2^63"); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==2^63");
ret = orwrite_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000ULL, ret = orwrite(sd, 0x8000000000000000ULL,
0, block_size, 0, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test ORWRITE 0-blocks at LBA==-1");
ret = orwrite_lbaoutofrange(iscsic, tgt_lun, -1, ret = orwrite(sd, -1,
0, block_size, 0, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,10 +40,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite_lbaoutofrange(iscsic, tgt_lun, ret = orwrite(sd, num_blocks + 1 - i,
num_blocks + 1 - i, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, EXPECT_LBA_OOB);
0, 0, 0, 0, 0, buf);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented."); CU_PASS("ORWRITE is not implemented.");
@@ -58,10 +57,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite_lbaoutofrange(iscsic, tgt_lun, ret = orwrite(sd, 0x8000000000000000ULL,
0x8000000000000000ULL, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, EXPECT_LBA_OOB);
0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -71,10 +69,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite_lbaoutofrange(iscsic, tgt_lun, ret = orwrite(sd, -1,
-1, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, EXPECT_LBA_OOB);
0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -84,10 +81,9 @@ test_orwrite_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite_lbaoutofrange(iscsic, tgt_lun, ret = orwrite(sd, num_blocks - 1,
num_blocks - 1, i * block_size, block_size, 0, 0, 0, 0, 0, buf,
i * block_size, block_size, EXPECT_LBA_OOB);
0, 0, 0, 0, 0, buf);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -39,9 +39,9 @@ test_orwrite_flags(void)
logging(LOG_VERBOSE, "Test ORWRITE flags"); logging(LOG_VERBOSE, "Test ORWRITE flags");
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1"); logging(LOG_VERBOSE, "Test ORWRITE with DPO==1");
ret = orwrite(iscsic, tgt_lun, 0, ret = orwrite(sd, 0,
block_size, block_size, block_size, block_size, 0, 1, 0, 0, 0, buf,
0, 1, 0, 0, 0, buf); EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test"); CU_PASS("[SKIPPED] Target does not support VERIFY16. Skipping test");
return; return;
@@ -50,29 +50,29 @@ test_orwrite_flags(void)
logging(LOG_VERBOSE, "Test ORWRITE with FUA==1 FUA_NV==0"); logging(LOG_VERBOSE, "Test ORWRITE with FUA==1 FUA_NV==0");
ret = orwrite(iscsic, tgt_lun, 0, ret = orwrite(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 1, 0, 0, buf,
0, 0, 1, 0, 0, buf); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE with FUA==1 FUA_NV==1"); logging(LOG_VERBOSE, "Test ORWRITE with FUA==1 FUA_NV==1");
ret = orwrite(iscsic, tgt_lun, 0, ret = orwrite(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 1, 1, 0, buf,
0, 0, 1, 1, 0, buf); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE with FUA==0 FUA_NV==1"); logging(LOG_VERBOSE, "Test ORWRITE with FUA==0 FUA_NV==1");
ret = orwrite(iscsic, tgt_lun, 0, ret = orwrite(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 0, 1, 0, buf,
0, 0, 0, 1, 0, buf); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1 FUA_NV==1"); logging(LOG_VERBOSE, "Test ORWRITE with DPO==1 FUA==1 FUA_NV==1");
ret = orwrite(iscsic, tgt_lun, 0, ret = orwrite(sd, 0,
block_size, block_size, block_size, block_size, 0, 1, 1, 1, 0, buf,
0, 1, 1, 1, 0, buf); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -42,8 +42,9 @@ test_orwrite_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite(iscsic, tgt_lun, 0, i * block_size, ret = orwrite(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented."); CU_PASS("ORWRITE is not implemented.");
@@ -57,8 +58,9 @@ test_orwrite_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = orwrite(iscsic, tgt_lun, num_blocks - i, ret = orwrite(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, buf); i * block_size, block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -47,14 +47,16 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "Write %d blocks of all-zero", i); logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
memset(buf, 0, block_size * i); memset(buf, 0, block_size * i);
ret = write10(iscsic, tgt_lun, 0, i * block_size, ret = write10(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i); logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
memset(buf, 0xa5, block_size * i); memset(buf, 0xa5, block_size * i);
ret = orwrite(iscsic, tgt_lun, 0, i * block_size, ret = orwrite(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented."); CU_PASS("ORWRITE is not implemented.");
@@ -63,8 +65,9 @@ test_orwrite_verify(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i); logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read10(iscsic, tgt_lun, 0, i * block_size, ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf); block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify that the blocks are all 0xa5"); logging(LOG_VERBOSE, "Verify that the blocks are all 0xa5");
@@ -73,13 +76,15 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i); logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i);
memset(buf, 0x5a, block_size * i); memset(buf, 0x5a, block_size * i);
ret = orwrite(iscsic, tgt_lun, 0, i * block_size, ret = orwrite(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i); logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read10(iscsic, tgt_lun, 0, i * block_size, ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf); block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify that the blocks are all 0xff"); logging(LOG_VERBOSE, "Verify that the blocks are all 0xff");
@@ -96,19 +101,22 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "Write %d blocks of all-zero", i); logging(LOG_VERBOSE, "Write %d blocks of all-zero", i);
memset(buf, 0, block_size * i); memset(buf, 0, block_size * i);
ret = write16(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = write16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i); logging(LOG_VERBOSE, "OrWrite %d blocks with 0xa5", i);
memset(buf, 0xa5, block_size * i); memset(buf, 0xa5, block_size * i);
ret = orwrite(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = orwrite(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i); logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read16(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = read16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf); block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify that the blocks are all 0xa5"); logging(LOG_VERBOSE, "Verify that the blocks are all 0xa5");
@@ -117,13 +125,15 @@ test_orwrite_verify(void)
logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i); logging(LOG_VERBOSE, "OrWrite %d blocks with 0x5a", i);
memset(buf, 0x5a, block_size * i); memset(buf, 0x5a, block_size * i);
ret = orwrite(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = orwrite(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Read %d blocks back", i); logging(LOG_VERBOSE, "Read %d blocks back", i);
ret = read16(iscsic, tgt_lun, num_blocks - i, i * block_size, ret = read16(sd, num_blocks - i, i * block_size,
block_size, 0, 0, 0, 0, 0, readbuf); block_size, 0, 0, 0, 0, 0, readbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify that the blocks are all 0xff"); logging(LOG_VERBOSE, "Verify that the blocks are all 0xff");

View File

@@ -44,9 +44,10 @@ test_orwrite_wrprotect(void)
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) { for (i = 1; i < 8; i++) {
ret = orwrite_invalidfieldincdb(iscsic, tgt_lun, 0, ret = orwrite(sd, 0, block_size,
block_size, block_size, block_size, i, 0, 0, 0, 0, buf,
i, 0, 0, 0, 0, buf); EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented."); logging(LOG_NORMAL, "[SKIPPED] ORWRITE is not implemented.");
CU_PASS("ORWRITE is not implemented."); CU_PASS("ORWRITE is not implemented.");

View File

@@ -30,8 +30,8 @@ test_prefetch10_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==0");
ret = prefetch10(iscsic, tgt_lun, 0, ret = prefetch10(sd, 0, 0, 0, 0,
0, 0, 0); EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented.");
CU_PASS("PREFETCH10 is not implemented."); CU_PASS("PREFETCH10 is not implemented.");
@@ -45,19 +45,19 @@ test_prefetch10_0blocks(void)
} }
logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks one block past end-of-LUN");
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, ret = prefetch10(sd, num_blocks + 1, 0, 0, 0,
0, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==2^31");
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, 0x80000000, ret = prefetch10(sd, 0x80000000, 0, 0, 0,
0, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test PREFETCH10 0-blocks at LBA==-1");
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, -1, ret = prefetch10(sd, -1, 0, 0, 0,
0, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -37,8 +37,8 @@ test_prefetch10_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks one block beyond the end"); logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i, ret = prefetch10(sd, num_blocks + 1 - i, i, 0, 0,
i, 0, 0); EXPECT_LBA_OOB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented.");
CU_PASS("PREFETCH10 is not implemented."); CU_PASS("PREFETCH10 is not implemented.");
@@ -50,24 +50,24 @@ test_prefetch10_beyond_eol(void)
logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, 0x80000000, ret = prefetch10(sd, 0x80000000, i, 0, 0,
i, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==-1"); logging(LOG_VERBOSE, "Test PREFETCH10 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, -1, ret = prefetch10(sd, -1, i, 0, 0,
i, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test PREFETCH10 2-256 blocks all but one block beyond the end"); logging(LOG_VERBOSE, "Test PREFETCH10 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) { for (i = 2; i <= 256; i++) {
ret = prefetch10_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1, ret = prefetch10(sd, num_blocks - 1, i, 0, 0,
i, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -34,8 +34,8 @@ test_prefetch10_flags(void)
logging(LOG_VERBOSE, "Test PREFETCH10 flags"); logging(LOG_VERBOSE, "Test PREFETCH10 flags");
logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED==1"); logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED==1");
ret = prefetch10(iscsic, tgt_lun, 0, ret = prefetch10(sd, 0, 1, 1, 0,
1, 1, 0); EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented.");
CU_PASS("PREFETCH10 is not implemented."); CU_PASS("PREFETCH10 is not implemented.");
@@ -44,12 +44,12 @@ test_prefetch10_flags(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH10 with GROUP==3"); logging(LOG_VERBOSE, "Test PREFETCH10 with GROUP==3");
ret = prefetch10(iscsic, tgt_lun, 0, ret = prefetch10(sd, 0, 1, 0, 3,
1, 0, 3); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED=1 and GROUP==3"); logging(LOG_VERBOSE, "Test PREFETCH10 with IMMED=1 and GROUP==3");
ret = prefetch10(iscsic, tgt_lun, 0, ret = prefetch10(sd, 0, 1, 1, 3,
1, 1, 3); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -33,7 +33,8 @@ test_prefetch10_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the start of the LUN"); logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch10(iscsic, tgt_lun, 0, i, 0, 0); ret = prefetch10(sd, 0, i, 0, 0,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PREFETCH10 is not implemented.");
CU_PASS("PREFETCH10 is not implemented."); CU_PASS("PREFETCH10 is not implemented.");
@@ -45,7 +46,8 @@ test_prefetch10_simple(void)
logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the end of the LUN"); logging(LOG_VERBOSE, "Test PREFETCH10 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch10(iscsic, tgt_lun, num_blocks - i, i, 0, 0); ret = prefetch10(sd, num_blocks - i, i, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -30,8 +30,8 @@ test_prefetch16_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==0");
ret = prefetch16(iscsic, tgt_lun, 0, ret = prefetch16(sd, 0, 0, 0, 0,
0, 0, 0); EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented.");
CU_PASS("PREFETCH16 is not implemented."); CU_PASS("PREFETCH16 is not implemented.");
@@ -40,19 +40,19 @@ test_prefetch16_0blocks(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks one block past end-of-LUN");
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, ret = prefetch16(sd, num_blocks + 1, 0, 0, 0,
0, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==2^63"); logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==2^63");
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000ULL, ret = prefetch16(sd, 0x8000000000000000ULL, 0, 0, 0,
0, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test PREFETCH16 0-blocks at LBA==-1");
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, -1, ret = prefetch16(sd, -1, 0, 0, 0,
0, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -32,8 +32,8 @@ test_prefetch16_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks one block beyond the end"); logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks one block beyond the end");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i, ret = prefetch16(sd, num_blocks + 1 - i, i, 0, 0,
i, 0, 0); EXPECT_LBA_OOB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented.");
CU_PASS("PREFETCH16 is not implemented."); CU_PASS("PREFETCH16 is not implemented.");
@@ -45,24 +45,25 @@ test_prefetch16_beyond_eol(void)
logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==2^63"); logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000ULL, ret = prefetch16(sd, 0x8000000000000000ULL,
i, 0, 0); i, 0, 0,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==-1"); logging(LOG_VERBOSE, "Test PREFETCH16 1-256 blocks at LBA==-1");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, -1, ret = prefetch16(sd, -1, i, 0, 0,
i, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test PREFETCH16 2-256 blocks all but one block beyond the end"); logging(LOG_VERBOSE, "Test PREFETCH16 2-256 blocks all but one block beyond the end");
for (i = 2; i <= 256; i++) { for (i = 2; i <= 256; i++) {
ret = prefetch16_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1, ret = prefetch16(sd, num_blocks - 1, i, 0, 0,
i, 0, 0); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -34,8 +34,8 @@ test_prefetch16_flags(void)
logging(LOG_VERBOSE, "Test PREFETCH16 flags"); logging(LOG_VERBOSE, "Test PREFETCH16 flags");
logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED==1"); logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED==1");
ret = prefetch16(iscsic, tgt_lun, 0, ret = prefetch16(sd, 0, 1, 1, 0,
1, 1, 0); EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented.");
CU_PASS("PREFETCH16 is not implemented."); CU_PASS("PREFETCH16 is not implemented.");
@@ -44,12 +44,12 @@ test_prefetch16_flags(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 with GROUP==3"); logging(LOG_VERBOSE, "Test PREFETCH16 with GROUP==3");
ret = prefetch16(iscsic, tgt_lun, 0, ret = prefetch16(sd, 0, 1, 0, 3,
1, 0, 3); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED=1 and GROUP==3"); logging(LOG_VERBOSE, "Test PREFETCH16 with IMMED=1 and GROUP==3");
ret = prefetch16(iscsic, tgt_lun, 0, ret = prefetch16(sd, 0, 1, 1, 3,
1, 1, 3); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -33,7 +33,8 @@ test_prefetch16_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the start of the LUN"); logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the start of the LUN");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch16(iscsic, tgt_lun, 0, i, 0, 0); ret = prefetch16(sd, 0, i, 0, 0,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PREFETCH16 is not implemented.");
CU_PASS("PREFETCH16 is not implemented."); CU_PASS("PREFETCH16 is not implemented.");
@@ -45,7 +46,8 @@ test_prefetch16_simple(void)
logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the end of the LUN"); logging(LOG_VERBOSE, "Test PREFETCH16 of 1-256 blocks at the end of the LUN");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
ret = prefetch16(iscsic, tgt_lun, num_blocks - i, i, 0, 0); ret = prefetch16(sd, num_blocks - i, i, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -28,6 +28,7 @@ void
test_preventallow_2_itnexuses(void) test_preventallow_2_itnexuses(void)
{ {
int ret; int ret;
struct scsi_device sd2;
CHECK_FOR_SBC; CHECK_FOR_SBC;
CHECK_FOR_REMOVABLE; CHECK_FOR_REMOVABLE;
@@ -35,43 +36,55 @@ test_preventallow_2_itnexuses(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that PREVENT MEDIUM REMOVAL are seen on other nexuses as well"); logging(LOG_VERBOSE, "Test that PREVENT MEDIUM REMOVAL are seen on other nexuses as well");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PREVENTALLOW test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit_preventremoval(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd->iscsi_lun);
if (iscsic2 == NULL) { if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_VERBOSE, "Try to eject the medium on the second connection"); logging(LOG_VERBOSE, "Try to eject the medium on the second connection");
ret = startstopunit_preventremoval(iscsic2, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(&sd2, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Logout the second connection from target"); logging(LOG_VERBOSE, "Logout the second connection from target");
iscsi_logout_sync(iscsic2); iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(iscsic2); iscsi_destroy_context(sd2.iscsi_ctx);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1); ret = startstopunit(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -35,46 +35,60 @@ test_preventallow_cold_reset(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL"); logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PREVENTALLOW test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit_preventremoval(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Perform cold reset on target"); logging(LOG_VERBOSE, "Perform cold reset on target");
ret = iscsi_task_mgmt_target_cold_reset_sync(iscsic); ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
logging(LOG_VERBOSE, "Wait until all unit attentions clear"); logging(LOG_VERBOSE, "Wait until all unit attentions clear");
while (testunitready(iscsic, tgt_lun) != 0); while (testunitready(sd, EXPECT_STATUS_GOOD) != 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready_nomedium(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1); ret = startstopunit(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -36,43 +36,49 @@ test_preventallow_eject(void)
logging(LOG_VERBOSE, "Test that we can not eject medium when PREVENT is active"); logging(LOG_VERBOSE, "Test that we can not eject medium when PREVENT is active");
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit_preventremoval(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready_nomedium(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to load the medium"); logging(LOG_VERBOSE, "Try to load the medium");
ret = startstopunit_preventremoval(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1); ret = startstopunit(sd, 0, 0, 0, 0, 1, 1,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT flag"); logging(LOG_VERBOSE, "Clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium again"); logging(LOG_VERBOSE, "Load the medium again");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1); ret = startstopunit(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -35,49 +35,63 @@ test_preventallow_itnexus_loss(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that IT-Nexus loss clears PREVENT MEDIUM REMOVAL"); logging(LOG_VERBOSE, "Test that IT-Nexus loss clears PREVENT MEDIUM REMOVAL");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PREVENTALLOW test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit_preventremoval(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Disconnect from the target."); logging(LOG_VERBOSE, "Disconnect from the target.");
iscsi_destroy_context(iscsic); iscsi_destroy_context(sd->iscsi_ctx);
logging(LOG_VERBOSE, "Reconnect to target"); logging(LOG_VERBOSE, "Reconnect to target");
iscsic = iscsi_context_login(initiatorname1, tgt_url, &tgt_lun); sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
if (iscsic == NULL) { if (sd->iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready_nomedium(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1); ret = startstopunit(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -35,50 +35,64 @@ test_preventallow_logout(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that Logout loss clears PREVENT MEDIUM REMOVAL"); logging(LOG_VERBOSE, "Test that Logout loss clears PREVENT MEDIUM REMOVAL");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PREVENTALLOW test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit_preventremoval(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Logout from target"); logging(LOG_VERBOSE, "Logout from target");
iscsi_logout_sync(iscsic); iscsi_logout_sync(sd->iscsi_ctx);
iscsi_destroy_context(iscsic); iscsi_destroy_context(sd->iscsi_ctx);
logging(LOG_VERBOSE, "Relogin to target"); logging(LOG_VERBOSE, "Relogin to target");
iscsic = iscsi_context_login(initiatorname1, tgt_url, &tgt_lun); sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
if (iscsic == NULL) { if (sd->iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready_nomedium(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1); ret = startstopunit(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -35,46 +35,59 @@ test_preventallow_lun_reset(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL"); logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PREVENTALLOW test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit_preventremoval(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Perform LUN reset on target"); logging(LOG_VERBOSE, "Perform LUN reset on target");
ret = iscsi_task_mgmt_lun_reset_sync(iscsic, tgt_lun); ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Wait until all unit attentions clear"); logging(LOG_VERBOSE, "Wait until all unit attentions clear");
while (testunitready(iscsic, tgt_lun) != 0); while (testunitready(sd, EXPECT_STATUS_GOOD) != 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready_nomedium(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1); ret = startstopunit(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -36,10 +36,10 @@ test_preventallow_simple(void)
logging(LOG_VERBOSE, "Test PREVENTALLOW basics"); logging(LOG_VERBOSE, "Test PREVENTALLOW basics");
logging(LOG_VERBOSE, "Test we can set PREVENT flag"); logging(LOG_VERBOSE, "Test we can set PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -35,46 +35,60 @@ test_preventallow_warm_reset(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL"); logging(LOG_VERBOSE, "Test that Target Warm Reset clears PREVENT MEDIUM REMOVAL");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PREVENTALLOW test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 1); ret = preventallow(sd, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit_preventremoval(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Perform warm reset on target"); logging(LOG_VERBOSE, "Perform warm reset on target");
ret = iscsi_task_mgmt_target_warm_reset_sync(iscsic); ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Wait until all unit attentions clear"); logging(LOG_VERBOSE, "Wait until all unit attentions clear");
while (testunitready(iscsic, tgt_lun) != 0); while (testunitready(sd, EXPECT_STATUS_GOOD) != 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready_nomedium(iscsic, tgt_lun); ret = testunitready(sd,
EXPECT_NO_MEDIUM);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0); ret = startstopunit(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(iscsic, tgt_lun, 0); ret = preventallow(sd, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1); ret = startstopunit(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -36,7 +36,7 @@ test_prin_read_keys_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test Persistent Reserve IN READ_KEYS works."); logging(LOG_VERBOSE, "Test Persistent Reserve IN READ_KEYS works.");
ret = prin_read_keys(iscsic, tgt_lun, &task, NULL); ret = prin_read_keys(sd, &task, NULL);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE IN is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE IN is not implemented.");
CU_PASS("PERSISTENT RESERVE IN is not implemented."); CU_PASS("PERSISTENT RESERVE IN is not implemented.");

View File

@@ -37,7 +37,7 @@ test_prin_serviceaction_range(void)
logging(LOG_VERBOSE, "Test Persistent Reserve IN Serviceaction range."); logging(LOG_VERBOSE, "Test Persistent Reserve IN Serviceaction range.");
/* verify PRIN/READ_KEYS works -- XXX redundant -- remove this? */ /* verify PRIN/READ_KEYS works -- XXX redundant -- remove this? */
ret = prin_read_keys(iscsic, tgt_lun, &task, NULL); ret = prin_read_keys(sd, &task, NULL);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE IN is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE IN is not implemented.");
CU_PASS("PERSISTENT RESERVE IN is not implemented."); CU_PASS("PERSISTENT RESERVE IN is not implemented.");
@@ -47,13 +47,13 @@ test_prin_serviceaction_range(void)
/* verify that PRIN/SA={0,1,2,3} works ... */ /* verify that PRIN/SA={0,1,2,3} works ... */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
ret = prin_task(iscsic, tgt_lun, i, 1); ret = prin_task(sd, i, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
/* verify that PRIN/SA={4..0x20} fails ... */ /* verify that PRIN/SA={4..0x20} fails ... */
for (i = 4; i < 0x20; i++) { for (i = 4; i < 0x20; i++) {
ret = prin_task(iscsic, tgt_lun, i, 0); ret = prin_task(sd, i, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -37,7 +37,7 @@ test_prout_register_simple(void)
logging(LOG_VERBOSE, "Test Persistent Reserve IN REGISTER works."); logging(LOG_VERBOSE, "Test Persistent Reserve IN REGISTER works.");
/* register our reservation key with the target */ /* register our reservation key with the target */
ret = prout_register_and_ignore(iscsic, tgt_lun, key); ret = prout_register_and_ignore(sd, key);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
CU_PASS("PERSISTENT RESERVE OUT is not implemented."); CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
@@ -46,18 +46,18 @@ test_prout_register_simple(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
/* verify we can read the registration */ /* verify we can read the registration */
ret = prin_verify_key_presence(iscsic, tgt_lun, key, 1); ret = prin_verify_key_presence(sd, key, 1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
/* try to reregister, which should fail */ /* try to reregister, which should fail */
ret = prout_reregister_key_fails(iscsic, tgt_lun, key+1); ret = prout_reregister_key_fails(sd, key+1);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
/* release from the target */ /* release from the target */
ret = prout_register_key(iscsic, tgt_lun, 0, key); ret = prout_register_key(sd, 0, key);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
/* Verify the registration is gone */ /* Verify the registration is gone */
ret = prin_verify_key_presence(iscsic, tgt_lun, key, 0); ret = prin_verify_key_presence(sd, key, 0);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -25,8 +25,7 @@
static void static void
verify_persistent_reserve_access(struct iscsi_context *iscsi1, int lun1, verify_persistent_reserve_access(struct scsi_device *sd1, struct scsi_device *sd2,
struct iscsi_context *iscsi2, int lun2,
const enum scsi_persistent_out_type pr_type, const enum scsi_persistent_out_type pr_type,
int reg_i2_can_read, int reg_i2_can_read,
int reg_i2_can_write, int reg_i2_can_write,
@@ -44,26 +43,26 @@ verify_persistent_reserve_access(struct iscsi_context *iscsi1, int lun1,
scsi_pr_type_str(pr_type)); scsi_pr_type_str(pr_type));
/* send TURs to clear possible check conditions */ /* send TURs to clear possible check conditions */
(void) testunitready_clear_ua(iscsi1, lun1); (void) testunitready_clear_ua(sd1);
(void) testunitready_clear_ua(iscsi2, lun2); (void) testunitready_clear_ua(sd2);
/* register our reservation key with the target */ /* register our reservation key with the target */
ret = prout_register_and_ignore(iscsi1, lun1, key); ret = prout_register_and_ignore(sd1, key);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
CU_PASS("PERSISTENT RESERVE OUT is not implemented."); CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
return; return;
} }
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
ret = prout_register_and_ignore(iscsi2, lun2, key2); ret = prout_register_and_ignore(sd2, key2);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* reserve the target through initiator 1 */ /* reserve the target through initiator 1 */
ret = prout_reserve(iscsi1, lun1, key, pr_type); ret = prout_reserve(sd1, key, pr_type);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* verify target reservation */ /* verify target reservation */
ret = prin_verify_reserved_as(iscsi1, lun1, ret = prin_verify_reserved_as(sd1,
pr_type_is_all_registrants(pr_type) ? 0 : key, pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type); pr_type);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
@@ -72,98 +71,212 @@ verify_persistent_reserve_access(struct iscsi_context *iscsi1, int lun1,
CU_ASSERT_PTR_NOT_NULL(read_write_buf); CU_ASSERT_PTR_NOT_NULL(read_write_buf);
/* make sure init1 can read */ /* make sure init1 can read */
ret = verify_read_works(iscsi1, lun1, read_write_buf); ret = verify_read_works(sd1, read_write_buf);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* make sure init1 can write */ /* make sure init1 can write */
ret = verify_write_works(iscsi1, lun1, read_write_buf); ret = verify_write_works(sd1, read_write_buf);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* verify registered init2 read access */ /* verify registered init2 read access */
if (reg_i2_can_read) if (reg_i2_can_read)
ret = verify_read_works(iscsi2, lun2, read_write_buf); ret = verify_read_works(sd2, read_write_buf);
else else
ret = verify_read_fails(iscsi2, lun2, read_write_buf); ret = verify_read_fails(sd2, read_write_buf);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* verify registered init2 write access */ /* verify registered init2 write access */
if (reg_i2_can_write) if (reg_i2_can_write)
ret = verify_write_works(iscsi2, lun2, read_write_buf); ret = verify_write_works(sd2, read_write_buf);
else else
ret = verify_write_fails(iscsi2, lun2, read_write_buf); ret = verify_write_fails(sd2, read_write_buf);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* unregister init2 */ /* unregister init2 */
ret = prout_register_key(iscsi2, lun2, 0, key); ret = prout_register_key(sd2, 0, key);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* verify unregistered init2 read access */ /* verify unregistered init2 read access */
if (unreg_i2_can_read) if (unreg_i2_can_read)
ret = verify_read_works(iscsi2, lun2, read_write_buf); ret = verify_read_works(sd2, read_write_buf);
else else
ret = verify_read_fails(iscsi2, lun2, read_write_buf); ret = verify_read_fails(sd2, read_write_buf);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* verify unregistered init2 write access */ /* verify unregistered init2 write access */
if (unreg_i2_can_write) if (unreg_i2_can_write)
ret = verify_write_works(iscsi2, lun2, read_write_buf); ret = verify_write_works(sd2, read_write_buf);
else else
ret = verify_write_fails(iscsi2, lun2, read_write_buf); ret = verify_write_fails(sd2, read_write_buf);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* release our reservation */ /* release our reservation */
ret = prout_release(iscsi1, lun1, key, pr_type); ret = prout_release(sd1, key, pr_type);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* remove our key from the target */ /* remove our key from the target */
ret = prout_register_key(iscsi1, lun1, 0, key); ret = prout_register_key(sd1, 0, key);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
} }
void void
test_prout_reserve_access_ea(void) test_prout_reserve_access_ea(void)
{ {
verify_persistent_reserve_access(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS,
0, 0, 0, 0); 0, 0, 0, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_access_we(void) test_prout_reserve_access_we(void)
{ {
verify_persistent_reserve_access(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE,
1, 0, 1, 0); 1, 0, 1, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_access_earo(void) test_prout_reserve_access_earo(void)
{ {
verify_persistent_reserve_access(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY,
1, 1, 0, 0); 1, 1, 0, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_access_wero(void) test_prout_reserve_access_wero(void)
{ {
verify_persistent_reserve_access(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY,
1, 1, 1, 0); 1, 1, 1, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_access_eaar(void) test_prout_reserve_access_eaar(void)
{ {
verify_persistent_reserve_access(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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, SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS,
1, 1, 0, 0); 1, 1, 0, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_access_wear(void) test_prout_reserve_access_wear(void)
{ {
verify_persistent_reserve_access(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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, SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS,
1, 1, 1, 0); 1, 1, 1, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }

View File

@@ -25,8 +25,7 @@
static void static void
verify_persistent_reserve_ownership(struct iscsi_context *iscsi1, int lun1, verify_persistent_reserve_ownership(struct scsi_device *sd1, struct scsi_device *sd2,
struct iscsi_context *iscsi2, int lun2,
const enum scsi_persistent_out_type pr_type, const enum scsi_persistent_out_type pr_type,
int resvn_is_shared) int resvn_is_shared)
{ {
@@ -41,97 +40,211 @@ verify_persistent_reserve_ownership(struct iscsi_context *iscsi1, int lun1,
scsi_pr_type_str(pr_type)); scsi_pr_type_str(pr_type));
/* send TURs to clear possible check conditions */ /* send TURs to clear possible check conditions */
(void) testunitready_clear_ua(iscsi1, lun1); (void) testunitready_clear_ua(sd1);
(void) testunitready_clear_ua(iscsi2, lun2); (void) testunitready_clear_ua(sd2);
/* register our reservation key with the target */ /* register our reservation key with the target */
ret = prout_register_and_ignore(iscsi1, lun1, key1); ret = prout_register_and_ignore(sd1, key1);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
CU_PASS("PERSISTENT RESERVE OUT is not implemented."); CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
return; return;
} }
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
ret = prout_register_and_ignore(iscsi2, lun2, key2); ret = prout_register_and_ignore(sd2, key2);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* reserve the target through initiator 1 */ /* reserve the target through initiator 1 */
ret = prout_reserve(iscsi1, lun1, key1, pr_type); ret = prout_reserve(sd1, key1, pr_type);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* verify target reservation */ /* verify target reservation */
ret = prin_verify_reserved_as(iscsi1, lun1, ret = prin_verify_reserved_as(sd1,
pr_type_is_all_registrants(pr_type) ? 0 : key1, pr_type_is_all_registrants(pr_type) ? 0 : key1,
pr_type); pr_type);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* unregister init1 */ /* unregister init1 */
ret = prout_register_key(iscsi1, lun1, 0, key1); ret = prout_register_key(sd1, 0, key1);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* verify if reservation is still present */ /* verify if reservation is still present */
if (resvn_is_shared) { if (resvn_is_shared) {
/* verify target reservation */ /* verify target reservation */
ret = prin_verify_reserved_as(iscsi1, lun1, ret = prin_verify_reserved_as(sd1,
pr_type_is_all_registrants(pr_type) ? 0 : key1, pr_type_is_all_registrants(pr_type) ? 0 : key1,
pr_type); pr_type);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* release our reservation */ /* release our reservation */
ret = prout_release(iscsi2, lun2, key2, pr_type); ret = prout_release(sd2, key2, pr_type);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
} else { } else {
/* verify target is not reserved now */ /* verify target is not reserved now */
ret = prin_verify_not_reserved(iscsi1, lun1); ret = prin_verify_not_reserved(sd1);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
/* send TUR to clear possible check condition */ /* send TUR to clear possible check condition */
(void) testunitready_clear_ua(iscsi2, lun2); (void) testunitready_clear_ua(sd2);
} }
/* remove our remaining key from the target */ /* remove our remaining key from the target */
ret = prout_register_key(iscsi2, lun2, 0, key2); ret = prout_register_key(sd2, 0, key2);
CU_ASSERT_EQUAL(0, ret); CU_ASSERT_EQUAL(0, ret);
} }
void void
test_prout_reserve_ownership_ea(void) test_prout_reserve_ownership_ea(void)
{ {
verify_persistent_reserve_ownership(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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); SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_ownership_we(void) test_prout_reserve_ownership_we(void)
{ {
verify_persistent_reserve_ownership(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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); SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_ownership_earo(void) test_prout_reserve_ownership_earo(void)
{ {
verify_persistent_reserve_ownership(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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); SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_ownership_wero(void) test_prout_reserve_ownership_wero(void)
{ {
verify_persistent_reserve_ownership(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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); SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_REGISTRANTS_ONLY, 0);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_ownership_eaar(void) test_prout_reserve_ownership_eaar(void)
{ {
verify_persistent_reserve_ownership(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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); SCSI_PERSISTENT_RESERVE_TYPE_EXCLUSIVE_ACCESS_ALL_REGISTRANTS, 1);
iscsi_destroy_context(sd2.iscsi_ctx);
} }
void void
test_prout_reserve_ownership_wear(void) test_prout_reserve_ownership_wear(void)
{ {
verify_persistent_reserve_ownership(iscsic, tgt_lun, iscsic2, tgt_lun2, struct scsi_device sd2;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This PERSISTENT RESERVE test is "
"only supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
memset(&sd2, 0, sizeof(sd2));
sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.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); SCSI_PERSISTENT_RESERVE_TYPE_WRITE_EXCLUSIVE_ALL_REGISTRANTS, 1);
iscsi_destroy_context(sd2.iscsi_ctx);
} }

View File

@@ -52,7 +52,7 @@ test_prout_reserve_simple(void)
logging(LOG_VERBOSE, "Test Persistent Reserve IN RESERVE works."); logging(LOG_VERBOSE, "Test Persistent Reserve IN RESERVE works.");
/* register our reservation key with the target */ /* register our reservation key with the target */
ret = prout_register_and_ignore(iscsic, tgt_lun, key); ret = prout_register_and_ignore(sd, key);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented."); logging(LOG_NORMAL, "[SKIPPED] PERSISTEN RESERVE OUT is not implemented.");
CU_PASS("PERSISTENT RESERVE OUT is not implemented."); CU_PASS("PERSISTENT RESERVE OUT is not implemented.");
@@ -65,22 +65,22 @@ test_prout_reserve_simple(void)
enum scsi_persistent_out_type pr_type = pr_types_to_test[i]; enum scsi_persistent_out_type pr_type = pr_types_to_test[i];
/* reserve the target */ /* reserve the target */
ret = prout_reserve(iscsic, tgt_lun, key, pr_type); ret = prout_reserve(sd, key, pr_type);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
/* verify target reservation */ /* verify target reservation */
ret = prin_verify_reserved_as(iscsic, tgt_lun, ret = prin_verify_reserved_as(sd,
pr_type_is_all_registrants(pr_type) ? 0 : key, pr_type_is_all_registrants(pr_type) ? 0 : key,
pr_type); pr_type);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
/* release our reservation */ /* release our reservation */
ret = prout_release(iscsic, tgt_lun, key, pr_type); ret = prout_release(sd, key, pr_type);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
/* remove our key from the target */ /* remove our key from the target */
ret = prout_register_key(iscsic, tgt_lun, 0, key); ret = prout_register_key(sd, 0, key);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -30,8 +30,9 @@ test_read10_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==0");
ret = read10(iscsic, tgt_lun, 0, 0, block_size, ret = read10(sd, NULL, 0, 0, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (num_blocks > 0x80000000) { if (num_blocks > 0x80000000) {
@@ -40,19 +41,22 @@ test_read10_0blocks(void)
} }
logging(LOG_VERBOSE, "Test READ10 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test READ10 0-blocks one block past end-of-LUN");
ret = read10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 0, ret = read10(sd, NULL, num_blocks + 1, 0,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==2^31");
ret = read10_lbaoutofrange(iscsic, tgt_lun, 0x80000000, 0, block_size, ret = read10(sd, NULL, 0x80000000, 0, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test READ10 0-blocks at LBA==-1");
ret = read10_lbaoutofrange(iscsic, tgt_lun, -1, 0, block_size, ret = read10(sd, NULL, -1, 0, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,21 +40,20 @@ test_read10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read10_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i, ret = read10(sd, NULL, num_blocks + 1 - i,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test READ10 1-256 blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test READ10 1-256 blocks at LBA==2^31");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read10_lbaoutofrange(iscsic, tgt_lun, 0x80000000, ret = read10(sd, NULL, 0x80000000,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -64,8 +63,9 @@ test_read10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read10_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size, ret = read10(sd, NULL, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -75,9 +75,9 @@ test_read10_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read10_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1, ret = read10(sd, NULL, num_blocks - 1,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -36,36 +36,36 @@ test_read10_flags(void)
CHECK_FOR_SBC; CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Test READ10 with DPO==1"); logging(LOG_VERBOSE, "Test READ10 with DPO==1");
ret = read10(iscsic, tgt_lun, 0, ret = read10(sd, NULL, 0,
block_size, block_size, block_size, block_size, 0, 1, 0, 0, 0, NULL,
0, 1, 0, 0, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 with FUA==1 FUA_NV==0"); logging(LOG_VERBOSE, "Test READ10 with FUA==1 FUA_NV==0");
ret = read10(iscsic, tgt_lun, 0, ret = read10(sd, NULL, 0,
block_size, block_size, block_size, block_size, 0, 0, 1, 0, 0, NULL,
0, 0, 1, 0, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 with FUA==1 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ10 with FUA==1 FUA_NV==1");
ret = read10(iscsic, tgt_lun, 0, ret = read10(sd, NULL, 0,
block_size, block_size, block_size, block_size, 0, 0, 1, 1, 0, NULL,
0, 0, 1, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 with FUA==0 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ10 with FUA==0 FUA_NV==1");
ret = read10(iscsic, tgt_lun, 0, ret = read10(sd, NULL, 0,
block_size, block_size, block_size, block_size, 0, 0, 0, 1, 0, NULL,
0, 0, 0, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ10 with DPO==1 FUA==1 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ10 with DPO==1 FUA==1 FUA_NV==1");
ret = read10(iscsic, tgt_lun, 0, ret = read10(sd, NULL, 0,
block_size, block_size, block_size, block_size, 0, 1, 1, 1, 0, NULL,
0, 1, 1, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -39,6 +39,14 @@ test_read10_invalid(void)
logging(LOG_VERBOSE, "Test invalid READ10 commands"); logging(LOG_VERBOSE, "Test invalid READ10 commands");
logging(LOG_VERBOSE, "Block size is %zu", block_size); logging(LOG_VERBOSE, "Block size is %zu", block_size);
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This READ10 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
/* Try a read10 of 1 block but xferlength == 0 */ /* Try a read10 of 1 block but xferlength == 0 */
task = malloc(sizeof(struct scsi_task)); task = malloc(sizeof(struct scsi_task));
CU_ASSERT_PTR_NOT_NULL(task); CU_ASSERT_PTR_NOT_NULL(task);
@@ -54,19 +62,19 @@ test_read10_invalid(void)
* we don't want autoreconnect since some targets will drop the session * we don't want autoreconnect since some targets will drop the session
* on this condition. * on this condition.
*/ */
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0"); logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -89,7 +97,7 @@ test_read10_invalid(void)
task = NULL; task = NULL;
/* in case the previous test failed the session */ /* in case the previous test failed the session */
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000"); logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
@@ -103,13 +111,13 @@ test_read10_invalid(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 10000; task->expxferlen = 10000;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -147,13 +155,13 @@ test_read10_invalid(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 200; task->expxferlen = 200;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -193,13 +201,13 @@ test_read10_invalid(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = block_size; task->expxferlen = block_size;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -240,16 +248,16 @@ test_read10_invalid(void)
data.size = block_size; data.size = block_size;
data.data = (unsigned char *)buf; data.data = (unsigned char *)buf;
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
iscsi_set_timeout(iscsic, 3); iscsi_set_timeout(sd->iscsi_ctx, 3);
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, &data); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, &data);
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
scsi_free_scsi_task(task); scsi_free_scsi_task(task);

View File

@@ -42,9 +42,10 @@ test_read10_rdprotect(void)
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) { for (i = 1; i < 8; i++) {
ret = read10_invalidfieldincdb(iscsic, tgt_lun, 0, ret = read10(sd, NULL, 0,
block_size, block_size, block_size, block_size,
i, 0, 0, 0, 0, NULL); i, 0, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
return; return;

View File

@@ -40,6 +40,14 @@ test_read10_residuals(void)
logging(LOG_VERBOSE, "Test READ10 commands with residuals"); logging(LOG_VERBOSE, "Test READ10 commands with residuals");
logging(LOG_VERBOSE, "Block size is %zu", block_size); logging(LOG_VERBOSE, "Block size is %zu", block_size);
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This READ10 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
/* Try a read10 of 1 block but xferlength == 0 */ /* Try a read10 of 1 block but xferlength == 0 */
task = malloc(sizeof(struct scsi_task)); task = malloc(sizeof(struct scsi_task));
CU_ASSERT_PTR_NOT_NULL(task); CU_ASSERT_PTR_NOT_NULL(task);
@@ -55,19 +63,19 @@ test_read10_residuals(void)
* we don't want autoreconnect since some targets will drop the session * we don't want autoreconnect since some targets will drop the session
* on this condition. * on this condition.
*/ */
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0"); logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -90,7 +98,7 @@ test_read10_residuals(void)
task = NULL; task = NULL;
/* in case the previous test failed the session */ /* in case the previous test failed the session */
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000"); logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
@@ -104,13 +112,13 @@ test_read10_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 10000; task->expxferlen = 10000;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -152,13 +160,13 @@ test_read10_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 200; task->expxferlen = 200;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -198,13 +206,13 @@ test_read10_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = block_size; task->expxferlen = block_size;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);

View File

@@ -37,8 +37,9 @@ test_read10_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read10(iscsic, tgt_lun, 0, i * block_size, ret = read10(sd, NULL, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -48,8 +49,9 @@ test_read10_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read10(iscsic, tgt_lun, num_blocks - i, ret = read10(sd, NULL, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL); i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -30,8 +30,9 @@ test_read12_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==0");
ret = read12(iscsic, tgt_lun, 0, 0, block_size, ret = read12(sd, 0, 0, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented."); CU_PASS("READ12 is not implemented.");
@@ -45,19 +46,22 @@ test_read12_0blocks(void)
} }
logging(LOG_VERBOSE, "Test READ12 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test READ12 0-blocks one block past end-of-LUN");
ret = read12_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 0, ret = read12(sd, num_blocks + 1, 0,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==2^31"); logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==2^31");
ret = read12_lbaoutofrange(iscsic, tgt_lun, 0x80000000, 0, block_size, ret = read12(sd, 0x80000000, 0, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test READ12 0-blocks at LBA==-1");
ret = read12_lbaoutofrange(iscsic, tgt_lun, -1, 0, block_size, ret = read12(sd, -1, 0, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,9 +40,9 @@ test_read12_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read12_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i, ret = read12(sd, num_blocks + 1 - i,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented."); CU_PASS("READ12 is not implemented.");
@@ -57,9 +57,9 @@ test_read12_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read12_lbaoutofrange(iscsic, tgt_lun, 0x80000000, ret = read12(sd, 0x80000000,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -69,8 +69,9 @@ test_read12_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read12_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size, ret = read12(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -80,9 +81,9 @@ test_read12_beyond_eol(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read12_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1, ret = read12(sd, num_blocks - 1,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -36,9 +36,9 @@ test_read12_flags(void)
CHECK_FOR_SBC; CHECK_FOR_SBC;
logging(LOG_VERBOSE, "Test READ12 with DPO==1"); logging(LOG_VERBOSE, "Test READ12 with DPO==1");
ret = read12(iscsic, tgt_lun, 0, ret = read12(sd, 0,
block_size, block_size, block_size, block_size, 0, 1, 0, 0, 0, NULL,
0, 1, 0, 0, 0, NULL); EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented."); CU_PASS("READ12 is not implemented.");
@@ -48,29 +48,29 @@ test_read12_flags(void)
logging(LOG_VERBOSE, "Test READ12 with FUA==1 FUA_NV==0"); logging(LOG_VERBOSE, "Test READ12 with FUA==1 FUA_NV==0");
ret = read12(iscsic, tgt_lun, 0, ret = read12(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 1, 0, 0, NULL,
0, 0, 1, 0, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ12 with FUA==1 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ12 with FUA==1 FUA_NV==1");
ret = read12(iscsic, tgt_lun, 0, ret = read12(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 1, 1, 0, NULL,
0, 0, 1, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ12 with FUA==0 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ12 with FUA==0 FUA_NV==1");
ret = read12(iscsic, tgt_lun, 0, ret = read12(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 0, 1, 0, NULL,
0, 0, 0, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ12 with DPO==1 FUA==1 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ12 with DPO==1 FUA==1 FUA_NV==1");
ret = read12(iscsic, tgt_lun, 0, ret = read12(sd, 0,
block_size, block_size, block_size, block_size, 0, 1, 1, 1, 0, NULL,
0, 1, 1, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -41,9 +41,10 @@ test_read12_rdprotect(void)
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) { for (i = 1; i < 8; i++) {
ret = read12_invalidfieldincdb(iscsic, tgt_lun, 0, ret = read12(sd, 0,
block_size, block_size, block_size, block_size,
i, 0, 0, 0, 0, NULL); i, 0, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented."); CU_PASS("READ12 is not implemented.");

View File

@@ -36,6 +36,14 @@ test_read12_residuals(void)
logging(LOG_VERBOSE, "Test READ12 commands with residuals"); logging(LOG_VERBOSE, "Test READ12 commands with residuals");
logging(LOG_VERBOSE, "Block size is %zu", block_size); logging(LOG_VERBOSE, "Block size is %zu", block_size);
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This READ12 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
task = malloc(sizeof(struct scsi_task)); task = malloc(sizeof(struct scsi_task));
CU_ASSERT_PTR_NOT_NULL(task); CU_ASSERT_PTR_NOT_NULL(task);
@@ -50,12 +58,12 @@ test_read12_residuals(void)
* we don't want autoreconnect since some targets will drop the session * we don't want autoreconnect since some targets will drop the session
* on this condition. * on this condition.
*/ */
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0"); logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
@@ -69,7 +77,7 @@ test_read12_residuals(void)
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -92,7 +100,7 @@ test_read12_residuals(void)
task = NULL; task = NULL;
/* in case the previous test failed the session */ /* in case the previous test failed the session */
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000"); logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
@@ -106,13 +114,13 @@ test_read12_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 10000; task->expxferlen = 10000;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -154,13 +162,13 @@ test_read12_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 200; task->expxferlen = 200;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -200,13 +208,13 @@ test_read12_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = block_size; task->expxferlen = block_size;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);

View File

@@ -37,8 +37,9 @@ test_read12_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read12(iscsic, tgt_lun, 0, i * block_size, ret = read12(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] READ12 is not implemented.");
CU_PASS("READ12 is not implemented."); CU_PASS("READ12 is not implemented.");
@@ -53,8 +54,9 @@ test_read12_simple(void)
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read12(iscsic, tgt_lun, num_blocks - i, ret = read12(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL); i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -32,8 +32,9 @@ test_read16_0blocks(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==0"); logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==0");
ret = read16(iscsic, tgt_lun, 0, 0, block_size, ret = read16(sd, 0, 0, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support."); logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
CU_PASS("READ16 is not implemented and no SBC-3 support claimed."); CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
@@ -42,19 +43,22 @@ test_read16_0blocks(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ16 0-blocks one block past end-of-LUN"); logging(LOG_VERBOSE, "Test READ16 0-blocks one block past end-of-LUN");
ret = read16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1, 0, ret = read16(sd, num_blocks + 1, 0,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==2^63"); logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==2^63");
ret = read16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000ULL, 0, ret = read16(sd, 0x8000000000000000ULL, 0,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==-1"); logging(LOG_VERBOSE, "Test READ16 0-blocks at LBA==-1");
ret = read16_lbaoutofrange(iscsic, tgt_lun, -1, 0, block_size, ret = read16(sd, -1, 0, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -49,9 +49,9 @@ test_read16_beyond_eol(void)
break; break;
} }
ret = read16_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i, ret = read16(sd, num_blocks + 1 - i,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support."); logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
CU_PASS("READ16 is not implemented and no SBC-3 support claimed."); CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
@@ -60,16 +60,15 @@ test_read16_beyond_eol(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^63"); logging(LOG_VERBOSE, "Test READ16 1-256 blocks at LBA==2^63");
for (i = 1; i <= 256; i++) { for (i = 1; i <= 256; i++) {
if (maximum_transfer_length && maximum_transfer_length < i) { if (maximum_transfer_length && maximum_transfer_length < i) {
break; break;
} }
ret = read16_lbaoutofrange(iscsic, tgt_lun, 0x8000000000000000ULL, ret = read16(sd, 0x8000000000000000ULL,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -81,10 +80,10 @@ test_read16_beyond_eol(void)
break; break;
} }
ret = read16_lbaoutofrange(iscsic, tgt_lun, ret = read16(sd,
1ULL << (64 - ilog2(block_size)), 1ULL << (64 - ilog2(block_size)),
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -96,10 +95,10 @@ test_read16_beyond_eol(void)
break; break;
} }
ret = read16_lbaoutofrange(iscsic, tgt_lun, ret = read16(sd,
1ULL << (63 - ilog2(block_size)), 1ULL << (63 - ilog2(block_size)),
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -110,8 +109,9 @@ test_read16_beyond_eol(void)
break; break;
} }
ret = read16_lbaoutofrange(iscsic, tgt_lun, -1, i * block_size, ret = read16(sd, -1, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -122,9 +122,9 @@ test_read16_beyond_eol(void)
break; break;
} }
ret = read16_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1, ret = read16(sd, num_blocks - 1,
i * block_size, block_size, i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
0, 0, 0, 0, 0, NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -36,9 +36,9 @@ test_read16_flags(void)
logging(LOG_VERBOSE, "Test READ16 flags"); logging(LOG_VERBOSE, "Test READ16 flags");
logging(LOG_VERBOSE, "Test READ16 with DPO==1"); logging(LOG_VERBOSE, "Test READ16 with DPO==1");
ret = read16(iscsic, tgt_lun, 0, ret = read16(sd, 0,
block_size, block_size, block_size, block_size, 0, 1, 0, 0, 0, NULL,
0, 1, 0, 0, 0, NULL); EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support."); logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
CU_PASS("READ16 is not implemented and no SBC-3 support claimed."); CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
@@ -48,29 +48,29 @@ test_read16_flags(void)
logging(LOG_VERBOSE, "Test READ16 with FUA==1 FUA_NV==0"); logging(LOG_VERBOSE, "Test READ16 with FUA==1 FUA_NV==0");
ret = read16(iscsic, tgt_lun, 0, ret = read16(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 1, 0, 0, NULL,
0, 0, 1, 0, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ16 with FUA==1 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ16 with FUA==1 FUA_NV==1");
ret = read16(iscsic, tgt_lun, 0, ret = read16(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 1, 1, 0, NULL,
0, 0, 1, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ16 with FUA==0 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ16 with FUA==0 FUA_NV==1");
ret = read16(iscsic, tgt_lun, 0, ret = read16(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 0, 1, 0, NULL,
0, 0, 0, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test READ16 with DPO==1 FUA==1 FUA_NV==1"); logging(LOG_VERBOSE, "Test READ16 with DPO==1 FUA==1 FUA_NV==1");
ret = read16(iscsic, tgt_lun, 0, ret = read16(sd, 0,
block_size, block_size, block_size, block_size, 0, 1, 1, 1, 0, NULL,
0, 1, 1, 1, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -41,9 +41,10 @@ test_read16_rdprotect(void)
if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) { if (!inq->protect || (rc16 != NULL && !rc16->prot_en)) {
logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail."); logging(LOG_VERBOSE, "Device does not support/use protection information. All commands should fail.");
for (i = 1; i < 8; i++) { for (i = 1; i < 8; i++) {
ret = read16_invalidfieldincdb(iscsic, tgt_lun, 0, ret = read16(sd, 0,
block_size, block_size, block_size, block_size,
i, 0, 0, 0, 0, NULL); i, 0, 0, 0, 0, NULL,
EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ16 is not im lemented on this target and it does not claim SBC-3 support."); logging(LOG_NORMAL, "[SKIPPED] READ16 is not im lemented on this target and it does not claim SBC-3 support.");
CU_PASS("READ16 is not implemented and no SBC-3 support claimed."); CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");

View File

@@ -36,6 +36,14 @@ test_read16_residuals(void)
logging(LOG_VERBOSE, "Test READ16 commands with residuals"); logging(LOG_VERBOSE, "Test READ16 commands with residuals");
logging(LOG_VERBOSE, "Block size is %zu", block_size); logging(LOG_VERBOSE, "Block size is %zu", block_size);
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This READ16 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
task = malloc(sizeof(struct scsi_task)); task = malloc(sizeof(struct scsi_task));
CU_ASSERT_PTR_NOT_NULL(task); CU_ASSERT_PTR_NOT_NULL(task);
@@ -50,12 +58,12 @@ test_read16_residuals(void)
* we don't want autoreconnect since some targets will drop the session * we don't want autoreconnect since some targets will drop the session
* on this condition. * on this condition.
*/ */
iscsi_set_noautoreconnect(iscsic, 1); iscsi_set_noautoreconnect(sd->iscsi_ctx, 1);
logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0"); logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==0");
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */ CU_ASSERT_NOT_EQUAL(task->status, SCSI_STATUS_CANCELLED); /* XXX redundant? */
@@ -69,7 +77,7 @@ test_read16_residuals(void)
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -92,7 +100,7 @@ test_read16_residuals(void)
task = NULL; task = NULL;
/* in case the previous test failed the session */ /* in case the previous test failed the session */
iscsi_set_noautoreconnect(iscsic, 0); iscsi_set_noautoreconnect(sd->iscsi_ctx, 0);
logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000"); logging(LOG_VERBOSE, "Try reading one block but with iSCSI expected transfer length==10000");
@@ -106,13 +114,13 @@ test_read16_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 10000; task->expxferlen = 10000;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -154,13 +162,13 @@ test_read16_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = 200; task->expxferlen = 200;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);
@@ -200,13 +208,13 @@ test_read16_residuals(void)
task->xfer_dir = SCSI_XFER_READ; task->xfer_dir = SCSI_XFER_READ;
task->expxferlen = block_size; task->expxferlen = block_size;
task_ret = iscsi_scsi_command_sync(iscsic, tgt_lun, task, NULL); task_ret = iscsi_scsi_command_sync(sd->iscsi_ctx, sd->iscsi_lun, task, NULL);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
logging(LOG_VERBOSE, "Verify that the target returned SUCCESS"); logging(LOG_VERBOSE, "Verify that the target returned SUCCESS");
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Target returned error %s", logging(LOG_VERBOSE, "[FAILED] Target returned error %s",
iscsi_get_error(iscsic)); iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);

View File

@@ -39,8 +39,9 @@ test_read16_simple(void)
break; break;
} }
ret = read16(iscsic, tgt_lun, 0, i * block_size, ret = read16(sd, 0, i * block_size,
block_size, 0, 0, 0, 0, 0, NULL); block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support."); logging(LOG_NORMAL, "[SKIPPED] READ16 is not implemented on this target and it does not claim SBC-3 support.");
CU_PASS("READ16 is not implemented and no SBC-3 support claimed."); CU_PASS("READ16 is not implemented and no SBC-3 support claimed.");
@@ -56,9 +57,9 @@ test_read16_simple(void)
break; break;
} }
ret = read16(iscsic, tgt_lun, num_blocks - i, ret = read16(sd, num_blocks - i,
i * block_size, block_size, 0, 0, 0, 0, 0, NULL); i * block_size, block_size, 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -38,9 +38,9 @@ test_read6_beyond_eol(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end"); logging(LOG_VERBOSE, "Test READ6 1-255 blocks one block beyond the end");
for (i = 1; i <= 255; i++) { for (i = 1; i <= 255; i++) {
ret = read6_lbaoutofrange(iscsic, tgt_lun, num_blocks + 1 - i, ret = read6(sd, NULL, num_blocks + 1 - i,
i * block_size, block_size, i * block_size, block_size, NULL,
NULL); EXPECT_LBA_OOB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented.");
CU_PASS("READ6 is not implemented."); CU_PASS("READ6 is not implemented.");
@@ -52,18 +52,18 @@ test_read6_beyond_eol(void)
logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff"); logging(LOG_VERBOSE, "Test READ6 1-255 blocks at LBA==0x1fffff");
for (i = 1; i <= 255; i++) { for (i = 1; i <= 255; i++) {
ret = read6_lbaoutofrange(iscsic, tgt_lun, 0x1fffff, ret = read6(sd, NULL, 0x1fffff,
i * block_size, block_size, i * block_size, block_size, NULL,
NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end"); logging(LOG_VERBOSE, "Test READ6 2-255 blocks all but one block beyond the end");
for (i = 2; i <= 255; i++) { for (i = 2; i <= 255; i++) {
ret = read6_lbaoutofrange(iscsic, tgt_lun, num_blocks - 1, ret = read6(sd, NULL, num_blocks - 1,
i * block_size, block_size, i * block_size, block_size, NULL,
NULL); EXPECT_LBA_OOB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -34,8 +34,9 @@ test_read6_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN"); logging(LOG_VERBOSE, "Test READ6 of 1-255 blocks at the start of the LUN");
for (i = 1; i <= 255; i++) { for (i = 1; i <= 255; i++) {
ret = read6(iscsic, tgt_lun, 0, i * block_size, ret = read6(sd, NULL, 0, i * block_size,
block_size, NULL); block_size, NULL,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented."); logging(LOG_NORMAL, "[SKIPPED] READ6 is not implemented.");
CU_PASS("READ6 is not implemented."); CU_PASS("READ6 is not implemented.");
@@ -50,8 +51,9 @@ test_read6_simple(void)
CU_PASS("LUN is too big for read-at-eol tests with READ6. Skipping test.\n"); CU_PASS("LUN is too big for read-at-eol tests with READ6. Skipping test.\n");
} else { } else {
for (i = 1; i <= 255; i++) { for (i = 1; i <= 255; i++) {
ret = read6(iscsic, tgt_lun, num_blocks - i, ret = read6(sd, NULL, num_blocks - i,
i * block_size, block_size, NULL); i * block_size, block_size, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }
@@ -62,11 +64,12 @@ test_read6_simple(void)
logging(LOG_VERBOSE, "Test sending a READ6 with transfer length == 0 " logging(LOG_VERBOSE, "Test sending a READ6 with transfer length == 0 "
"(meaning 256 blocks)"); "(meaning 256 blocks)");
/* 256 is converted to 0 when the CDB is marshalled by the helper */ /* 256 is converted to 0 when the CDB is marshalled by the helper */
task = iscsi_read6_sync(iscsic, tgt_lun, 0, ret = read6(sd, &task, 0,
256 * block_size, block_size); 256 * block_size, block_size, NULL,
EXPECT_STATUS_GOOD);
if (task->status != SCSI_STATUS_GOOD) { if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL, "[FAILED] READ6 command: " logging(LOG_NORMAL, "[FAILED] READ6 command: "
"failed with sense. %s", iscsi_get_error(iscsic)); "failed with sense. %s", sd->error_str );
} }
CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD); CU_ASSERT_EQUAL(task->status, SCSI_STATUS_GOOD);

View File

@@ -1,4 +1,3 @@
/* /*
Copyright (C) 2013 by Ronnie Sahlberg <ronniesahlberg@gmail.com> Copyright (C) 2013 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
@@ -35,6 +34,7 @@ test_readcapacity10_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test basic READCAPACITY10"); logging(LOG_VERBOSE, "Test basic READCAPACITY10");
ret = readcapacity10(iscsic, tgt_lun, 0, 0); ret = readcapacity10(sd, NULL, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -35,7 +35,8 @@ test_readcapacity16_alloclen(void)
logging(LOG_VERBOSE, "Test that READCAPACITY16 with alloc_len 0-15 is not an error"); logging(LOG_VERBOSE, "Test that READCAPACITY16 with alloc_len 0-15 is not an error");
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
ret = readcapacity16(iscsic, tgt_lun, i); ret = readcapacity16(sd, NULL, i,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim SBC-3 support."); logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim SBC-3 support.");
CU_PASS("READCAPACITY16 is not implemented and no SBC-3 support claimed."); CU_PASS("READCAPACITY16 is not implemented and no SBC-3 support claimed.");

View File

@@ -34,7 +34,8 @@ test_readcapacity16_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that READCAPACITY16 works"); logging(LOG_VERBOSE, "Test that READCAPACITY16 works");
ret = readcapacity16(iscsic, tgt_lun, 16); ret = readcapacity16(sd, NULL, 16,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim support."); logging(LOG_NORMAL, "[SKIPPED] READCAPACITY16 is not implemented on this target and it does not claim support.");
CU_PASS("READCAPACITY16 is not implemented and no SBC-3 support claimed."); CU_PASS("READCAPACITY16 is not implemented and no SBC-3 support claimed.");

View File

@@ -41,49 +41,54 @@ test_readonly_sbc(void)
logging(LOG_VERBOSE, "Test WRITE10 fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITE10 fails with WRITE_PROTECTED");
ret = write10_writeprotected(iscsic, tgt_lun, 0, block_size, block_size, ret = write10(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, buf); 0, 0, 0, 0, 0, buf,
EXPECT_WRITE_PROTECTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITE12 fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITE12 fails with WRITE_PROTECTED");
ret = write12_writeprotected(iscsic, tgt_lun, 0, block_size, block_size, ret = write12(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, buf); 0, 0, 0, 0, 0, buf,
EXPECT_WRITE_PROTECTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITE16 fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITE16 fails with WRITE_PROTECTED");
ret = write16_writeprotected(iscsic, tgt_lun, 0, block_size, block_size, ret = write16(sd, 0, block_size, block_size,
0, 0, 0, 0, 0, buf); 0, 0, 0, 0, 0, buf,
EXPECT_WRITE_PROTECTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test WRITE_SAME10 fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITE_SAME10 fails with WRITE_PROTECTED");
ret = writesame10_writeprotected(iscsic, tgt_lun, 0, block_size, 1, ret = writesame10(sd, 0, block_size, 1,
0, 0, 0, 0, buf); 0, 0, 0, 0, buf,
EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "WRITE_SAME10 not supported on target. Skipped."); logging(LOG_VERBOSE, "WRITE_SAME10 not supported on target. Skipped.");
} }
CU_ASSERT_NOT_EQUAL(ret, -1); CU_ASSERT_NOT_EQUAL(ret, -1);
logging(LOG_VERBOSE, "Test WRITE_SAME16 fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITE_SAME16 fails with WRITE_PROTECTED");
ret = writesame16_writeprotected(iscsic, tgt_lun, 0, block_size, 1, ret = writesame16(sd, 0, block_size, 1,
0, 0, 0, 0, buf); 0, 0, 0, 0, buf,
EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "WRITE_SAME16 not supported on target. Skipped."); logging(LOG_VERBOSE, "WRITE_SAME16 not supported on target. Skipped.");
} }
CU_ASSERT_NOT_EQUAL(ret, -1); CU_ASSERT_NOT_EQUAL(ret, -1);
logging(LOG_VERBOSE, "Test WRITE_SAME10 UNMAP fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITE_SAME10 UNMAP fails with WRITE_PROTECTED");
ret = writesame10_writeprotected(iscsic, tgt_lun, 0, ret = writesame10(sd, 0,
block_size, 1, block_size, 1, 0, 1, 0, 0, NULL,
0, 1, 0, 0, NULL); EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "WRITE_SAME10 not supported on target. Skipped."); logging(LOG_VERBOSE, "WRITE_SAME10 not supported on target. Skipped.");
} }
CU_ASSERT_NOT_EQUAL(ret, -1); CU_ASSERT_NOT_EQUAL(ret, -1);
logging(LOG_VERBOSE, "Test WRITE_SAME16 UNMAP fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITE_SAME16 UNMAP fails with WRITE_PROTECTED");
ret = writesame16_writeprotected(iscsic, tgt_lun, 0, ret = writesame16(sd, 0,
block_size, 1, block_size, 1, 0, 1, 0, 0, NULL,
0, 1, 0, 0, NULL); EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "WRITE_SAME16 not supported on target. Skipped."); logging(LOG_VERBOSE, "WRITE_SAME16 not supported on target. Skipped.");
} }
@@ -92,7 +97,8 @@ test_readonly_sbc(void)
logging(LOG_VERBOSE, "Test UNMAP of one physical block fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test UNMAP of one physical block fails with WRITE_PROTECTED");
list[0].lba = 0; list[0].lba = 0;
list[0].num = lbppb; list[0].num = lbppb;
ret = unmap_writeprotected(iscsic, tgt_lun, 0, list, 1); ret = unmap(sd, 0, list, 1,
EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "UNMAP not supported on target. Skipped."); logging(LOG_VERBOSE, "UNMAP not supported on target. Skipped.");
} }
@@ -101,43 +107,44 @@ test_readonly_sbc(void)
logging(LOG_VERBOSE, "Test UNMAP of one logical block fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test UNMAP of one logical block fails with WRITE_PROTECTED");
list[0].lba = 0; list[0].lba = 0;
list[0].num = 1; list[0].num = 1;
ret = unmap_writeprotected(iscsic, tgt_lun, 0, list, 1); ret = unmap(sd, 0, list, 1,
EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "UNMAP not supported on target. Skipped."); logging(LOG_VERBOSE, "UNMAP not supported on target. Skipped.");
} }
CU_ASSERT_NOT_EQUAL(ret, -1); CU_ASSERT_NOT_EQUAL(ret, -1);
logging(LOG_VERBOSE, "Test WRITEVERIFY10 fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITEVERIFY10 fails with WRITE_PROTECTED");
ret = writeverify10_writeprotected(iscsic, tgt_lun, 0, ret = writeverify10(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 0, 0, buf,
0, 0, 0, 0, buf); EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "WRITEVERIFY10 not supported on target. Skipped."); logging(LOG_VERBOSE, "WRITEVERIFY10 not supported on target. Skipped.");
} }
CU_ASSERT_NOT_EQUAL(ret, -1); CU_ASSERT_NOT_EQUAL(ret, -1);
logging(LOG_VERBOSE, "Test WRITEVERIFY12 fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITEVERIFY12 fails with WRITE_PROTECTED");
ret = writeverify12_writeprotected(iscsic, tgt_lun, 0, ret = writeverify12(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 0, 0, buf,
0, 0, 0, 0, buf); EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "WRITEVERIFY12 not supported on target. Skipped."); logging(LOG_VERBOSE, "WRITEVERIFY12 not supported on target. Skipped.");
} }
CU_ASSERT_NOT_EQUAL(ret, -1); CU_ASSERT_NOT_EQUAL(ret, -1);
logging(LOG_VERBOSE, "Test WRITEVERIFY16 fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test WRITEVERIFY16 fails with WRITE_PROTECTED");
ret = writeverify16_writeprotected(iscsic, tgt_lun, 0, ret = writeverify16(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 0, 0, buf,
0, 0, 0, 0, buf); EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "WRITEVERIFY16 not supported on target. Skipped."); logging(LOG_VERBOSE, "WRITEVERIFY16 not supported on target. Skipped.");
} }
CU_ASSERT_NOT_EQUAL(ret, -1); CU_ASSERT_NOT_EQUAL(ret, -1);
logging(LOG_VERBOSE, "Test ORWRITE fails with WRITE_PROTECTED"); logging(LOG_VERBOSE, "Test ORWRITE fails with WRITE_PROTECTED");
ret = orwrite_writeprotected(iscsic, tgt_lun, 0, ret = orwrite(sd, 0,
block_size, block_size, block_size, block_size, 0, 0, 0, 0, 0, buf,
0, 0, 0, 0, 0, buf); EXPECT_WRITE_PROTECTED);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "ORWRITE not supported on target. Skipped."); logging(LOG_VERBOSE, "ORWRITE not supported on target. Skipped.");
} }

View File

@@ -39,17 +39,20 @@ test_report_supported_opcodes_one_command(void)
logging(LOG_VERBOSE, "Fetch list of all supported opcodes"); logging(LOG_VERBOSE, "Fetch list of all supported opcodes");
ret = report_supported_opcodes(iscsic, tgt_lun, ret = report_supported_opcodes(sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 0, SCSI_REPORT_SUPPORTING_OPS_ALL,
65535, &rso_task); 0, 0, 65535,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented."); "implemented.");
CU_PASS("READ_SUPPORTED_OPCODES is not implemented."); CU_PASS("READ_SUPPORTED_OPCODES is not implemented.");
scsi_free_scsi_task(rso_task);
return; return;
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) { if (ret != 0) {
scsi_free_scsi_task(rso_task);
return; return;
} }
@@ -67,22 +70,23 @@ test_report_supported_opcodes_one_command(void)
if (rsoc->descriptors[i].servactv) { if (rsoc->descriptors[i].servactv) {
logging(LOG_VERBOSE, "This opcode has service actions. " logging(LOG_VERBOSE, "This opcode has service actions. "
"Reporting Options 001b should fail"); "Reporting Options 001b should fail");
ret = report_supported_opcodes_invalidfieldincdb( ret = report_supported_opcodes(sd, NULL,
iscsic, tgt_lun,
0, SCSI_REPORT_SUPPORTING_OPCODE, 0, SCSI_REPORT_SUPPORTING_OPCODE,
rsoc->descriptors[i].opcode, rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa, rsoc->descriptors[i].sa,
65535, NULL); 65535,
EXPECT_INVALID_FIELD_IN_CDB);
} else { } else {
logging(LOG_VERBOSE, "This opcode does not have " logging(LOG_VERBOSE, "This opcode does not have "
"service actions. Reporting Options 001b " "service actions. Reporting Options 001b "
"should work"); "should work");
ret = report_supported_opcodes( ret = report_supported_opcodes(
iscsic, tgt_lun, sd, NULL,
0, SCSI_REPORT_SUPPORTING_OPCODE, 0, SCSI_REPORT_SUPPORTING_OPCODE,
rsoc->descriptors[i].opcode, rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa, rsoc->descriptors[i].sa,
65535, NULL); 65535,
EXPECT_STATUS_GOOD);
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -90,21 +94,23 @@ test_report_supported_opcodes_one_command(void)
logging(LOG_VERBOSE, "This opcode has service actions. " logging(LOG_VERBOSE, "This opcode has service actions. "
"Reporting Options 002b should work"); "Reporting Options 002b should work");
ret = report_supported_opcodes( ret = report_supported_opcodes(
iscsic, tgt_lun, sd, NULL,
0, SCSI_REPORT_SUPPORTING_SERVICEACTION, 0, SCSI_REPORT_SUPPORTING_SERVICEACTION,
rsoc->descriptors[i].opcode, rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa, rsoc->descriptors[i].sa,
65535, NULL); 65535,
EXPECT_STATUS_GOOD);
} else { } else {
logging(LOG_VERBOSE, "This opcode does not have " logging(LOG_VERBOSE, "This opcode does not have "
"service actions. Reporting Options 002b " "service actions. Reporting Options 002b "
"should fail"); "should fail");
ret = report_supported_opcodes_invalidfieldincdb( ret = report_supported_opcodes(
iscsic, tgt_lun, sd, NULL,
0, SCSI_REPORT_SUPPORTING_SERVICEACTION, 0, SCSI_REPORT_SUPPORTING_SERVICEACTION,
rsoc->descriptors[i].opcode, rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa, rsoc->descriptors[i].sa,
65535, NULL); 65535,
EXPECT_INVALID_FIELD_IN_CDB);
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -117,14 +123,14 @@ test_report_supported_opcodes_one_command(void)
rsoc->descriptors[i].opcode, rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa); rsoc->descriptors[i].sa);
ret = report_supported_opcodes( ret = report_supported_opcodes(
iscsic, tgt_lun, sd, &one_task, 0,
0,
rsoc->descriptors[i].servactv ? rsoc->descriptors[i].servactv ?
SCSI_REPORT_SUPPORTING_SERVICEACTION : SCSI_REPORT_SUPPORTING_SERVICEACTION :
SCSI_REPORT_SUPPORTING_OPCODE, SCSI_REPORT_SUPPORTING_OPCODE,
rsoc->descriptors[i].opcode, rsoc->descriptors[i].opcode,
rsoc->descriptors[i].sa, rsoc->descriptors[i].sa,
65535, &one_task); 65535,
EXPECT_STATUS_GOOD);
logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer"); logging(LOG_VERBOSE, "Unmarshall the DATA-IN buffer");
rsoc_one = scsi_datain_unmarshall(one_task); rsoc_one = scsi_datain_unmarshall(one_task);

View File

@@ -38,17 +38,21 @@ test_report_supported_opcodes_rctd(void)
logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes " logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes "
"without timeout descriptors"); "without timeout descriptors");
ret = report_supported_opcodes(iscsic, tgt_lun, ret = report_supported_opcodes(
sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535, &rso_task); 65535,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented."); "implemented.");
CU_PASS("READ_SUPPORTED_OPCODES is not implemented."); CU_PASS("READ_SUPPORTED_OPCODES is not implemented.");
scsi_free_scsi_task(rso_task);
return; return;
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) { if (ret != 0) {
scsi_free_scsi_task(rso_task);
return; return;
} }
@@ -73,9 +77,11 @@ test_report_supported_opcodes_rctd(void)
logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes " logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES report ALL opcodes "
"with timeout descriptors"); "with timeout descriptors");
ret = report_supported_opcodes(iscsic, tgt_lun, ret = report_supported_opcodes(
sd, &rso_task,
1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 1, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535, &rso_task); 65535,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) { if (ret != 0) {
return; return;

View File

@@ -36,17 +36,21 @@ test_report_supported_opcodes_servactv(void)
logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES SERVACTV flag"); logging(LOG_VERBOSE, "Test READ_SUPPORTED_OPCODES SERVACTV flag");
ret = report_supported_opcodes(iscsic, tgt_lun, ret = report_supported_opcodes(
sd, &rso_task,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
65535, &rso_task); 65535,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented."); "implemented.");
CU_PASS("READ_SUPPORTED_OPCODES is not implemented."); CU_PASS("READ_SUPPORTED_OPCODES is not implemented.");
scsi_free_scsi_task(rso_task);
return; return;
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) { if (ret != 0) {
scsi_free_scsi_task(rso_task);
return; return;
} }

View File

@@ -33,9 +33,11 @@ test_report_supported_opcodes_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test basic READ_SUPPORTED_OPCODES"); logging(LOG_VERBOSE, "Test basic READ_SUPPORTED_OPCODES");
ret = report_supported_opcodes(iscsic, tgt_lun, ret = report_supported_opcodes(
sd, NULL,
0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0, 0, SCSI_REPORT_SUPPORTING_OPS_ALL, 0, 0,
1024, NULL); 1024,
EXPECT_STATUS_GOOD);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not " logging(LOG_NORMAL, "[SKIPPED] READ_SUPPORTED_OPCODES is not "
"implemented."); "implemented.");

View File

@@ -29,14 +29,21 @@ void
test_reserve6_2initiators(void) test_reserve6_2initiators(void)
{ {
int ret; int ret;
struct scsi_device sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test RESERVE6/RELEASE6 across two initiators"); logging(LOG_VERBOSE, "Test RESERVE6/RELEASE6 across two initiators");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This RESERVE6 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
ret = reserve6(iscsic, tgt_lun); ret = reserve6(sd);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test");
CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test");
@@ -46,53 +53,54 @@ test_reserve6_2initiators(void)
logging(LOG_NORMAL, "Verify that the first initiator can re-RESERVE6 the same reservation"); logging(LOG_NORMAL, "Verify that the first initiator can re-RESERVE6 the same reservation");
ret = reserve6(iscsic, tgt_lun); ret = reserve6(sd);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun);
if (iscsic2 == NULL) { if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator"); logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
ret = reserve6_conflict(iscsic2, tgt_lun); ret = reserve6_conflict(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "Try to RELEASE from the second initiator. Should be a nop"); logging(LOG_NORMAL, "Try to RELEASE from the second initiator. Should be a nop");
ret = release6(iscsic2, tgt_lun); ret = release6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "Test we can still send MODE SENSE from the first initiator"); logging(LOG_NORMAL, "Test we can still send MODE SENSE from the first initiator");
ret = mode_sense(iscsic, tgt_lun); ret = modesense6(sd, NULL, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "MODE SENSE should fail from the second initiator"); logging(LOG_NORMAL, "MODE SENSE should fail from the second initiator");
ret = mode_sense(iscsic2, tgt_lun); ret = modesense6(&sd2, NULL, 0, SCSI_MODESENSE_PC_CURRENT, SCSI_MODEPAGE_RETURN_ALL_PAGES, 0, 255,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, SCSI_STATUS_RESERVATION_CONFLICT); CU_ASSERT_EQUAL(ret, SCSI_STATUS_RESERVATION_CONFLICT);
logging(LOG_NORMAL, "RESERVE6 from the second initiator should still fail"); logging(LOG_NORMAL, "RESERVE6 from the second initiator should still fail");
ret = reserve6_conflict(iscsic2, tgt_lun); ret = reserve6_conflict(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "RELEASE6 from the first initiator"); logging(LOG_NORMAL, "RELEASE6 from the first initiator");
ret = release6(iscsic, tgt_lun); ret = release6(sd);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now"); logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
ret = reserve6(iscsic2, tgt_lun); ret = reserve6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "RELEASE6 from the second initiator"); logging(LOG_NORMAL, "RELEASE6 from the second initiator");
ret = release6(iscsic2, tgt_lun); ret = release6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
iscsi_logout_sync(iscsic2); iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(iscsic2); iscsi_destroy_context(sd2.iscsi_ctx);
iscsic2 = NULL;
} }

View File

@@ -29,14 +29,21 @@ void
test_reserve6_itnexus_loss(void) test_reserve6_itnexus_loss(void)
{ {
int ret; int ret;
struct scsi_device sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that RESERVE6 is released on it-nexus loss"); logging(LOG_VERBOSE, "Test that RESERVE6 is released on it-nexus loss");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This RESERVE6 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
ret = reserve6(iscsic, tgt_lun); ret = reserve6(sd);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test");
CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test");
@@ -46,39 +53,38 @@ test_reserve6_itnexus_loss(void)
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun);
if (iscsic2 == NULL) { if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator"); logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
ret = reserve6_conflict(iscsic2, tgt_lun); ret = reserve6_conflict(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Disconnect from the target."); logging(LOG_VERBOSE, "Disconnect from the target.");
iscsi_destroy_context(iscsic); iscsi_destroy_context(sd->iscsi_ctx);
logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset"); logging(LOG_VERBOSE, "Sleep for three seconds incase the target is slow to reset");
sleep(3); sleep(3);
logging(LOG_VERBOSE, "Reconnect to target"); logging(LOG_VERBOSE, "Reconnect to target");
iscsic = iscsi_context_login(initiatorname1, tgt_url, &tgt_lun); sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
if (iscsic == NULL) { if (sd->iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
goto finished; goto finished;
} }
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now"); logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
ret = reserve6(iscsic2, tgt_lun); ret = reserve6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "RELEASE6 from the second initiator"); logging(LOG_NORMAL, "RELEASE6 from the second initiator");
ret = release6(iscsic2, tgt_lun); ret = release6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
finished: finished:
iscsi_logout_sync(iscsic2); iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(iscsic2); iscsi_destroy_context(sd2.iscsi_ctx);
iscsic2 = NULL;
} }

View File

@@ -29,14 +29,21 @@ void
test_reserve6_logout(void) test_reserve6_logout(void)
{ {
int ret; int ret;
struct scsi_device sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that RESERVE6 is released on logout"); logging(LOG_VERBOSE, "Test that RESERVE6 is released on logout");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This RESERVE6 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator"); logging(LOG_NORMAL, "Take out a RESERVE6 from the first initiator");
ret = reserve6(iscsic, tgt_lun); ret = reserve6(sd);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test");
CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test");
@@ -46,36 +53,35 @@ test_reserve6_logout(void)
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun);
if (iscsic2 == NULL) { if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator"); logging(LOG_NORMAL, "Try to take out a RESERVE6 from the second initiator");
ret = reserve6_conflict(iscsic2, tgt_lun); ret = reserve6_conflict(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Logout from target"); logging(LOG_VERBOSE, "Logout from target");
iscsi_logout_sync(iscsic); iscsi_logout_sync(sd->iscsi_ctx);
iscsi_destroy_context(iscsic); iscsi_destroy_context(sd->iscsi_ctx);
logging(LOG_VERBOSE, "Relogin to target"); logging(LOG_VERBOSE, "Relogin to target");
iscsic = iscsi_context_login(initiatorname1, tgt_url, &tgt_lun); sd->iscsi_ctx = iscsi_context_login(initiatorname1, sd->iscsi_url, &sd->iscsi_lun);
if (iscsic == NULL) { if (sd->iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now"); logging(LOG_NORMAL, "RESERVE6 from the second initiator should work now");
ret = reserve6(iscsic2, tgt_lun); ret = reserve6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_NORMAL, "RELEASE6 from the second initiator"); logging(LOG_NORMAL, "RELEASE6 from the second initiator");
ret = release6(iscsic2, tgt_lun); ret = release6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
iscsi_logout_sync(iscsic2); iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(iscsic2); iscsi_destroy_context(sd2.iscsi_ctx);
iscsic2 = NULL;
} }

View File

@@ -29,14 +29,21 @@ void
test_reserve6_lun_reset(void) test_reserve6_lun_reset(void)
{ {
int ret; int ret;
struct scsi_device sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that RESERVE6 is released on lun reset"); logging(LOG_VERBOSE, "Test that RESERVE6 is released on lun reset");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This RESERVE6 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
ret = reserve6(iscsic, tgt_lun); ret = reserve6(sd);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test");
CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test");
@@ -46,9 +53,9 @@ test_reserve6_lun_reset(void)
logging(LOG_VERBOSE, "Send a LUN Reset"); logging(LOG_VERBOSE, "Send a LUN Reset");
ret = iscsi_task_mgmt_lun_reset_sync(iscsic, tgt_lun); ret = iscsi_task_mgmt_lun_reset_sync(sd->iscsi_ctx, sd->iscsi_lun);
if (ret != 0) { if (ret != 0) {
logging(LOG_NORMAL, "LUN reset failed. %s", iscsi_get_error(iscsic)); logging(LOG_NORMAL, "LUN reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -57,21 +64,20 @@ test_reserve6_lun_reset(void)
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun);
if (iscsic2 == NULL) { if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now"); logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
ret = reserve6(iscsic2, tgt_lun); ret = reserve6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "RELEASE6 from the second initiator"); logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
ret = release6(iscsic2, tgt_lun); ret = release6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
iscsi_logout_sync(iscsic2); iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(iscsic2); iscsi_destroy_context(sd2.iscsi_ctx);
iscsic2 = NULL;
} }

View File

@@ -34,7 +34,7 @@ test_reserve6_simple(void)
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test basic RESERVE6/RELEASE6 commands if supported"); logging(LOG_VERBOSE, "Test basic RESERVE6/RELEASE6 commands if supported");
ret = reserve6(iscsic, tgt_lun); ret = reserve6(sd);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test");
CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test");
@@ -42,6 +42,6 @@ test_reserve6_simple(void)
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
ret = release6(iscsic, tgt_lun); ret = release6(sd);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -29,14 +29,21 @@ void
test_reserve6_target_cold_reset(void) test_reserve6_target_cold_reset(void)
{ {
int ret; int ret;
struct scsi_device sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that RESERVE6 is released on target cold reset"); logging(LOG_VERBOSE, "Test that RESERVE6 is released on target cold reset");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This RESERVE6 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
ret = reserve6(iscsic, tgt_lun); ret = reserve6(sd);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test");
CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test");
@@ -46,9 +53,9 @@ test_reserve6_target_cold_reset(void)
logging(LOG_VERBOSE, "Send a Cold Reset to the target"); logging(LOG_VERBOSE, "Send a Cold Reset to the target");
ret = iscsi_task_mgmt_target_cold_reset_sync(iscsic); ret = iscsi_task_mgmt_target_cold_reset_sync(sd->iscsi_ctx);
if (ret != 0) { if (ret != 0) {
logging(LOG_NORMAL, "Cold reset failed. %s", iscsi_get_error(iscsic)); logging(LOG_NORMAL, "Cold reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -56,21 +63,20 @@ test_reserve6_target_cold_reset(void)
sleep(3); sleep(3);
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun);
if (iscsic2 == NULL) { if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now"); logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
ret = reserve6(iscsic2, tgt_lun); ret = reserve6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "RELEASE6 from the second initiator"); logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
ret = release6(iscsic2, tgt_lun); ret = release6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
iscsi_logout_sync(iscsic2); iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(iscsic2); iscsi_destroy_context(sd2.iscsi_ctx);
iscsic2 = NULL;
} }

View File

@@ -29,14 +29,21 @@ void
test_reserve6_target_warm_reset(void) test_reserve6_target_warm_reset(void)
{ {
int ret; int ret;
struct scsi_device sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test that RESERVE6 is released on target warm reset"); logging(LOG_VERBOSE, "Test that RESERVE6 is released on target warm reset");
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This RESERVE6 test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator"); logging(LOG_VERBOSE, "Take out a RESERVE6 from the first initiator");
ret = reserve6(iscsic, tgt_lun); ret = reserve6(sd);
if (ret == -2) { if (ret == -2) {
logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test"); logging(LOG_VERBOSE, "[SKIPPED] Target does not support RESERVE6. Skipping test");
CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test"); CU_PASS("[SKIPPED] Target does not support RESERVE6. Skipping test");
@@ -46,9 +53,9 @@ test_reserve6_target_warm_reset(void)
logging(LOG_VERBOSE, "Send a Warm Reset to the target"); logging(LOG_VERBOSE, "Send a Warm Reset to the target");
ret = iscsi_task_mgmt_target_warm_reset_sync(iscsic); ret = iscsi_task_mgmt_target_warm_reset_sync(sd->iscsi_ctx);
if (ret != 0) { if (ret != 0) {
logging(LOG_NORMAL, "Warm reset failed. %s", iscsi_get_error(iscsic)); logging(LOG_NORMAL, "Warm reset failed. %s", iscsi_get_error(sd->iscsi_ctx));
} }
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -57,22 +64,21 @@ test_reserve6_target_warm_reset(void)
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun);
if (iscsic2 == NULL) { if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now"); logging(LOG_VERBOSE, "RESERVE6 from the second initiator should work now");
ret = reserve6(iscsic2, tgt_lun); ret = reserve6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "RELEASE6 from the second initiator"); logging(LOG_VERBOSE, "RELEASE6 from the second initiator");
ret = release6(iscsic2, tgt_lun); ret = release6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
iscsi_logout_sync(iscsic2); iscsi_logout_sync(sd2.iscsi_ctx);
iscsi_destroy_context(iscsic2); iscsi_destroy_context(sd2.iscsi_ctx);
iscsic2 = NULL;
} }

View File

@@ -30,11 +30,12 @@
static void static void
check_wabereq(void) check_wabereq(void)
{ {
struct scsi_task *task_ret; struct scsi_task *task_ret = NULL;
logging(LOG_VERBOSE, "Read one block from LBA 0"); logging(LOG_VERBOSE, "Read one block from LBA 0");
task_ret = read10_task(iscsic, tgt_lun, 0, block_size, block_size, read10(sd, &task_ret, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED); CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED);
@@ -103,12 +104,13 @@ static void
check_unmap(void) check_unmap(void)
{ {
int i; int i;
struct scsi_task *task_ret; struct scsi_task *task_ret = NULL;
struct scsi_get_lba_status *lbas; struct scsi_get_lba_status *lbas;
uint64_t lba; uint64_t lba;
logging(LOG_VERBOSE, "Read LBA mapping from the target"); logging(LOG_VERBOSE, "Read LBA mapping from the target");
task_ret = get_lba_status_task(iscsic, tgt_lun, 0, 256); get_lba_status(sd, &task_ret, 0, 256,
EXPECT_STATUS_GOOD);
if (task_ret == NULL) { if (task_ret == NULL) {
logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping " logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping "
"from the target."); "from the target.");
@@ -119,7 +121,7 @@ check_unmap(void)
if (task_ret->status != SCSI_STATUS_GOOD) { if (task_ret->status != SCSI_STATUS_GOOD) {
logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping " logging(LOG_VERBOSE, "[FAILED] Failed to read LBA mapping "
"from the target. Sense: %s", "from the target. Sense: %s",
iscsi_get_error(iscsic)); sd->error_str);
CU_FAIL("[FAILED] Failed to read LBA mapping " CU_FAIL("[FAILED] Failed to read LBA mapping "
"from the target."); "from the target.");
scsi_free_scsi_task(task_ret); scsi_free_scsi_task(task_ret);
@@ -195,8 +197,9 @@ init_lun_with_data(unsigned char *buf, uint64_t lba)
int ret; int ret;
memset(buf, 'a', 256 * block_size); memset(buf, 'a', 256 * block_size);
ret = write16(iscsic, tgt_lun, lba, 256 * block_size, ret = write16(sd, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -206,8 +209,9 @@ check_lun_is_wiped(unsigned char *buf, uint64_t lba)
int ret; int ret;
unsigned char *rbuf = alloca(256 * block_size); unsigned char *rbuf = alloca(256 * block_size);
ret = read16(iscsic, tgt_lun, lba, 256 * block_size, ret = read16(sd, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, rbuf); block_size, 0, 0, 0, 0, 0, rbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (rc16 == NULL) { if (rc16 == NULL) {
@@ -321,8 +325,8 @@ test_sanitize_block_erase(void)
logging(LOG_VERBOSE, "Test we can perform basic BLOCK ERASE SANITIZE"); logging(LOG_VERBOSE, "Test we can perform basic BLOCK ERASE SANITIZE");
ret = sanitize(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped."); logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
@@ -337,8 +341,8 @@ test_sanitize_block_erase(void)
logging(LOG_VERBOSE, "BLOCK_ERASE parameter list length must be 0"); logging(LOG_VERBOSE, "BLOCK_ERASE parameter list length must be 0");
logging(LOG_VERBOSE, "Test that non-zero param length is an error for " logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
"BLOCK ERASE"); "BLOCK ERASE");
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 8, &data,
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 8, &data); EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (inq_bdc) { if (inq_bdc) {

View File

@@ -63,8 +63,8 @@ void test_sanitize_block_erase_reserved(void)
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved " logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
"bit in byte 1 set to 1"); "bit in byte 1 set to 1");
change_num = 1; change_num = 1;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL); EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not " logging(LOG_NORMAL, "[SKIPPED] SANITIZE BLOCK_ERASE is not "
"implemented on target."); "implemented on target.");
@@ -79,8 +79,8 @@ void test_sanitize_block_erase_reserved(void)
"byte %d set to non-zero", i); "byte %d set to non-zero", i);
change_num = i; change_num = i;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL); EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -30,11 +30,12 @@
static void static void
check_wacereq(void) check_wacereq(void)
{ {
struct scsi_task *task_ret; struct scsi_task *task_ret = NULL;
logging(LOG_VERBOSE, "Read one block from LBA 0"); logging(LOG_VERBOSE, "Read one block from LBA 0");
task_ret = read10_task(iscsic, tgt_lun, 0, block_size, block_size, read10(sd, &task_ret, 0, block_size, block_size,
0, 0, 0, 0, 0, NULL); 0, 0, 0, 0, 0, NULL,
EXPECT_STATUS_GOOD);
CU_ASSERT_PTR_NOT_NULL(task_ret); CU_ASSERT_PTR_NOT_NULL(task_ret);
CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED); CU_ASSERT_NOT_EQUAL(task_ret->status, SCSI_STATUS_CANCELLED);
@@ -105,8 +106,9 @@ init_lun_with_data(unsigned char *buf, uint64_t lba)
int ret; int ret;
memset(buf, 'a', 256 * block_size); memset(buf, 'a', 256 * block_size);
ret = write16(iscsic, tgt_lun, lba, 256 * block_size, ret = write16(sd, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -116,8 +118,9 @@ check_lun_is_wiped(unsigned char *buf, uint64_t lba)
int ret; int ret;
unsigned char *rbuf = alloca(256 * block_size); unsigned char *rbuf = alloca(256 * block_size);
ret = read16(iscsic, tgt_lun, lba, 256 * block_size, ret = read16(sd, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, rbuf); block_size, 0, 0, 0, 0, 0, rbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (!memcmp(buf, rbuf, 256 * block_size)) { if (!memcmp(buf, rbuf, 256 * block_size)) {
@@ -181,8 +184,8 @@ test_sanitize_crypto_erase(void)
logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE"); logging(LOG_VERBOSE, "Test we can perform basic CRYPTO ERASE SANITIZE");
ret = sanitize(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped."); logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
@@ -199,8 +202,8 @@ return;
logging(LOG_VERBOSE, "CRYPTO_ERASE parameter list length must be 0"); logging(LOG_VERBOSE, "CRYPTO_ERASE parameter list length must be 0");
logging(LOG_VERBOSE, "Test that non-zero param length is an error for " logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
"CRYPTO ERASE"); "CRYPTO ERASE");
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 8, &data,
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 8, &data); EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (inq_bdc) { if (inq_bdc) {

View File

@@ -63,8 +63,8 @@ void test_sanitize_crypto_erase_reserved(void)
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved " logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
"bit in byte 1 set to 1"); "bit in byte 1 set to 1");
change_num = 1; change_num = 1;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL); EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not " logging(LOG_NORMAL, "[SKIPPED] SANITIZE CRYPTO_ERASE is not "
"implemented on target."); "implemented on target.");
@@ -79,8 +79,8 @@ void test_sanitize_crypto_erase_reserved(void)
"byte %d set to non-zero", i); "byte %d set to non-zero", i);
change_num = i; change_num = i;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL); EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -60,7 +60,7 @@ test_sanitize_exit_failure_mode(void)
"be 0"); "be 0");
logging(LOG_VERBOSE, "Test that non-zero param length is an error for " logging(LOG_VERBOSE, "Test that non-zero param length is an error for "
"EXIT_FAILURE_MODE"); "EXIT_FAILURE_MODE");
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_EXIT_FAILURE_MODE, 8, &data,
0, 0, SCSI_SANITIZE_EXIT_FAILURE_MODE, 8, &data); EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -51,8 +51,8 @@ test_sanitize_invalid_serviceaction(void)
logging(LOG_VERBOSE, "Verify that ServiceAction:0x%02d is " logging(LOG_VERBOSE, "Verify that ServiceAction:0x%02d is "
"an error.", i); "an error.", i);
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, i, 0, NULL,
0, 0, i, 0, NULL); EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not " logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
"implemented."); "implemented.");

View File

@@ -33,8 +33,9 @@ init_lun_with_data(uint64_t lba)
unsigned char *buf = alloca(256 * block_size); unsigned char *buf = alloca(256 * block_size);
memset(buf, 'a', 256 * block_size); memset(buf, 'a', 256 * block_size);
ret = write16(iscsic, tgt_lun, lba, 256 * block_size, ret = write16(sd, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, buf); block_size, 0, 0, 0, 0, 0, buf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -45,8 +46,9 @@ check_lun_is_wiped(uint64_t lba, char c)
unsigned char *rbuf = alloca(256 * block_size); unsigned char *rbuf = alloca(256 * block_size);
unsigned char *zbuf = alloca(256 * block_size); unsigned char *zbuf = alloca(256 * block_size);
ret = read16(iscsic, tgt_lun, lba, 256 * block_size, ret = read16(sd, lba, 256 * block_size,
block_size, 0, 0, 0, 0, 0, rbuf); block_size, 0, 0, 0, 0, 0, rbuf,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
memset(zbuf, c, 256 * block_size); memset(zbuf, c, 256 * block_size);
@@ -122,8 +124,8 @@ test_sanitize_overwrite(void)
data.data[1] = 0x00; data.data[1] = 0x00;
data.data[2] = block_size >> 8; data.data[2] = block_size >> 8;
data.data[3] = block_size & 0xff; data.data[3] = block_size & 0xff;
ret = sanitize(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped."); logging(LOG_VERBOSE, "Check that the first 256 LBAs are wiped.");
@@ -138,8 +140,8 @@ test_sanitize_overwrite(void)
data.data[2] = (block_size / 2) >> 8; data.data[2] = (block_size / 2) >> 8;
data.data[3] = (block_size / 2 ) & 0xff; data.data[3] = (block_size / 2 ) & 0xff;
ret = sanitize(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -149,8 +151,8 @@ test_sanitize_overwrite(void)
data.data[2] = 0; data.data[2] = 0;
data.data[3] = 4; data.data[3] = 4;
ret = sanitize(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "OVERWRITE parameter list length must " logging(LOG_VERBOSE, "OVERWRITE parameter list length must "
@@ -159,8 +161,8 @@ test_sanitize_overwrite(void)
logging(LOG_VERBOSE, "Test OVERWRITE with ParamLen:%d is an " logging(LOG_VERBOSE, "Test OVERWRITE with ParamLen:%d is an "
"error.", i); "error.", i);
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, i, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, i, &data); EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not " logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
"implemented."); "implemented.");
@@ -178,8 +180,9 @@ test_sanitize_overwrite(void)
data.size = block_size + 8; data.size = block_size + 8;
data.data = alloca(block_size + 8); /* so we can send IP > blocksize */ data.data = alloca(block_size + 8); /* so we can send IP > blocksize */
memset(data.data, 0, data.size); memset(data.data, 0, data.size);
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, block_size + 5, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, block_size + 5, &data); EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not " logging(LOG_NORMAL, "[SKIPPED] SANITIZE is not "
"implemented."); "implemented.");
@@ -197,8 +200,8 @@ test_sanitize_overwrite(void)
data.data[1] = 0x00; data.data[1] = 0x00;
data.data[2] = block_size >> 8; data.data[2] = block_size >> 8;
data.data[3] = block_size & 0xff; data.data[3] = block_size & 0xff;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -210,8 +213,8 @@ test_sanitize_overwrite(void)
data.data[1] = 0x00; data.data[1] = 0x00;
data.data[2] = 0x00; data.data[2] = 0x00;
data.data[3] = 0x00; data.data[3] = 0x00;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -224,7 +227,7 @@ test_sanitize_overwrite(void)
data.data[1] = 0x00; data.data[1] = 0x00;
data.data[2] = (block_size + 4) >> 8; data.data[2] = (block_size + 4) >> 8;
data.data[3] = (block_size + 4) & 0xff; data.data[3] = (block_size + 4) & 0xff;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -73,8 +73,8 @@ void test_sanitize_overwrite_reserved(void)
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved " logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
"bit in byte 1 set to 1"); "bit in byte 1 set to 1");
change_num = 1; change_num = 1;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); EXPECT_INVALID_FIELD_IN_CDB);
if (ret == -2) { if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not " logging(LOG_NORMAL, "[SKIPPED] SANITIZE OVERWRITE is not "
"implemented on target."); "implemented on target.");
@@ -89,8 +89,9 @@ void test_sanitize_overwrite_reserved(void)
"byte %d set to non-zero", i); "byte %d set to non-zero", i);
change_num = i; change_num = i;
ret = sanitize_invalidfieldincdb(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); &data,
EXPECT_INVALID_FIELD_IN_CDB);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
} }

View File

@@ -32,6 +32,7 @@ test_sanitize_readonly(void)
int ret; int ret;
struct iscsi_data data; struct iscsi_data data;
struct scsi_command_descriptor *cd; struct scsi_command_descriptor *cd;
struct scsi_device sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test SANITIZE with READONLY devices"); logging(LOG_VERBOSE, "Test SANITIZE with READONLY devices");
@@ -39,15 +40,26 @@ test_sanitize_readonly(void)
CHECK_FOR_SANITIZE; CHECK_FOR_SANITIZE;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This SANITIZE test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); memset(&sd2, 0, sizeof(sd2));
if (iscsic2 == NULL) { sd2.iscsi_url = sd->iscsi_url;
sd2.iscsi_lun = sd->iscsi_lun;
sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd2.iscsi_url, &sd2.iscsi_lun);
if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_VERBOSE, "Set Software Write Protect on the second connection"); logging(LOG_VERBOSE, "Set Software Write Protect on the second connection");
ret = set_swp(iscsic2, tgt_lun); ret = set_swp(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
if (ret != 0) { if (ret != 0) {
return; return;
@@ -55,7 +67,7 @@ test_sanitize_readonly(void)
logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on " logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on "
"first connection"); "first connection");
while (testunitready_clear_ua(iscsic, tgt_lun)) { while (testunitready_clear_ua(sd)) {
sleep(1); sleep(1);
} }
@@ -77,8 +89,9 @@ test_sanitize_readonly(void)
data.data[1] = 0x00; data.data[1] = 0x00;
data.data[2] = block_size >> 8; data.data[2] = block_size >> 8;
data.data[3] = block_size & 0xff; data.data[3] = block_size & 0xff;
ret = sanitize_writeprotected(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); &data,
EXPECT_WRITE_PROTECTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -92,8 +105,8 @@ test_sanitize_readonly(void)
"implemented according to REPORT_SUPPORTED_OPCODES."); "implemented according to REPORT_SUPPORTED_OPCODES.");
} else { } else {
logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE"); logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE");
ret = sanitize_writeprotected(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL); EXPECT_WRITE_PROTECTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -106,21 +119,20 @@ test_sanitize_readonly(void)
"implemented according to REPORT_SUPPORTED_OPCODES."); "implemented according to REPORT_SUPPORTED_OPCODES.");
} else { } else {
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE"); logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE");
ret = sanitize_writeprotected(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL); EXPECT_WRITE_PROTECTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
logging(LOG_VERBOSE, "Clear Software Write Protect on the second connection"); logging(LOG_VERBOSE, "Clear Software Write Protect on the second connection");
ret = clear_swp(iscsic2, tgt_lun); ret = clear_swp(&sd2);
logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on " logging(LOG_VERBOSE, "Use TESTUNITREADY to clear unit attention on "
"first connection"); "first connection");
while (testunitready_clear_ua(iscsic, tgt_lun)) { while (testunitready_clear_ua(sd)) {
sleep(1); sleep(1);
} }
iscsi_destroy_context(iscsic2); iscsi_destroy_context(sd2.iscsi_ctx);
iscsic2 = NULL;
} }

View File

@@ -32,6 +32,7 @@ test_sanitize_reservations(void)
int ret; int ret;
struct iscsi_data data; struct iscsi_data data;
struct scsi_command_descriptor *cd; struct scsi_command_descriptor *cd;
struct scsi_device sd2;
logging(LOG_VERBOSE, LOG_BLANK_LINE); logging(LOG_VERBOSE, LOG_BLANK_LINE);
logging(LOG_VERBOSE, "Test SANITIZE with RESERVATIONS"); logging(LOG_VERBOSE, "Test SANITIZE with RESERVATIONS");
@@ -39,16 +40,24 @@ test_sanitize_reservations(void)
CHECK_FOR_SANITIZE; CHECK_FOR_SANITIZE;
CHECK_FOR_DATALOSS; CHECK_FOR_DATALOSS;
if (sd->iscsi_ctx == NULL) {
const char *err = "[SKIPPED] This SANITIZE test is only "
"supported for iSCSI backends";
logging(LOG_NORMAL, "%s", err);
CU_PASS(err);
return;
}
logging(LOG_VERBOSE, "Create a second connection to the target"); logging(LOG_VERBOSE, "Create a second connection to the target");
iscsic2 = iscsi_context_login(initiatorname2, tgt_url, &tgt_lun); sd2.iscsi_ctx = iscsi_context_login(initiatorname2, sd->iscsi_url, &sd2.iscsi_lun);
if (iscsic2 == NULL) { if (sd2.iscsi_ctx == NULL) {
logging(LOG_VERBOSE, "Failed to login to target"); logging(LOG_VERBOSE, "Failed to login to target");
return; return;
} }
logging(LOG_VERBOSE, "Take out a RESERVE6 from the second " logging(LOG_VERBOSE, "Take out a RESERVE6 from the second "
"initiator"); "initiator");
ret = reserve6(iscsic2, tgt_lun); ret = reserve6(&sd2);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -70,8 +79,9 @@ test_sanitize_reservations(void)
data.data[1] = 0x00; data.data[1] = 0x00;
data.data[2] = block_size >> 8; data.data[2] = block_size >> 8;
data.data[3] = block_size & 0xff; data.data[3] = block_size & 0xff;
ret = sanitize_conflict(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size,
0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data); &data,
EXPECT_RESERVATION_CONFLICT);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -85,8 +95,8 @@ test_sanitize_reservations(void)
"implemented according to REPORT_SUPPORTED_OPCODES."); "implemented according to REPORT_SUPPORTED_OPCODES.");
} else { } else {
logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE"); logging(LOG_VERBOSE, "Test SANITIZE BLOCK_ERASE");
ret = sanitize_conflict(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_BLOCK_ERASE, 0, NULL); EXPECT_RESERVATION_CONFLICT);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
@@ -99,12 +109,10 @@ test_sanitize_reservations(void)
"implemented according to REPORT_SUPPORTED_OPCODES."); "implemented according to REPORT_SUPPORTED_OPCODES.");
} else { } else {
logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE"); logging(LOG_VERBOSE, "Test SANITIZE CRYPTO_ERASE");
ret = sanitize_conflict(iscsic, tgt_lun, ret = sanitize(sd, 0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL,
0, 0, SCSI_SANITIZE_CRYPTO_ERASE, 0, NULL); EXPECT_RESERVATION_CONFLICT);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }
iscsi_destroy_context(sd2.iscsi_ctx);
iscsi_destroy_context(iscsic2);
iscsic2 = NULL;
} }

Some files were not shown because too many files have changed in this diff Show More