TESTS: update startstopunit to use new api

Signed-off-by: Ronnie Sahlberg <sahlberg@localhost>
This commit is contained in:
Ronnie Sahlberg
2014-09-17 13:41:59 -07:00
committed by Ronnie Sahlberg
parent 28b0a0ab11
commit f1d198c684
14 changed files with 108 additions and 135 deletions

View File

@@ -65,6 +65,9 @@ int write_protect_ascqs[1] = {
int sanitize_ascqs[1] = { int sanitize_ascqs[1] = {
SCSI_SENSE_ASCQ_SANITIZE_IN_PROGRESS SCSI_SENSE_ASCQ_SANITIZE_IN_PROGRESS
}; };
int removal_ascqs[1] = {
SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED
};
struct scsi_inquiry_standard *inq; struct scsi_inquiry_standard *inq;
struct scsi_inquiry_logical_block_provisioning *inq_lbp; struct scsi_inquiry_logical_block_provisioning *inq_lbp;
@@ -1347,101 +1350,27 @@ int sanitize_writeprotected(struct iscsi_context *iscsi, int lun, int immed, int
return 0; return 0;
} }
int startstopunit(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start) int startstopunit(struct iscsi_context *iscsi, int lun, 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)
{ {
struct scsi_task *task; struct scsi_task *task;
int ret;
logging(LOG_VERBOSE, "Send STARTSTOPUNIT IMMED:%d PCM:%d PC:%d NO_FLUSH:%d LOEJ:%d START:%d", immed, pcm, pc, no_flush, loej, start); logging(LOG_VERBOSE, "Send STARTSTOPUNIT (Expecting %s) IMMED:%d "
task = iscsi_startstopunit_sync(iscsi, lun, immed, pcm, pc, no_flush, "PCM:%d PC:%d NO_FLUSH:%d LOEJ:%d START:%d",
loej, start); scsi_status_str(status),
if (task == NULL) {
logging(LOG_NORMAL,
"[FAILED] Failed to send STARTSTOPUNIT command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status != SCSI_STATUS_GOOD) {
logging(LOG_NORMAL,
"[FAILED] STARTSTOPUNIT command: failed with sense. %s",
iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] STARTSTOPUNIT returned SUCCESS.");
return 0;
}
int startstopunit_preventremoval(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start)
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send STARTSTOPUNIT (Expecting MEDIUM_REMOVAL_PREVENTED) "
"IMMED:%d PCM:%d PC:%d NO_FLUSH:%d LOEJ:%d START:%d",
immed, pcm, pc, no_flush, loej, start); immed, pcm, pc, no_flush, loej, start);
task = iscsi_startstopunit_sync(iscsi, lun, immed, pcm, pc, no_flush, task = scsi_cdb_startstopunit(immed, pcm, pc, no_flush, loej, start);
loej, start); assert(task != NULL);
if (task == NULL) {
logging(LOG_NORMAL,
"[FAILED] Failed to send STARTSTOPUNIT command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL,
"[FAILED] STARTSTOPUNIT successful but should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED");
scsi_free_scsi_task(task);
return -1;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|| task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) {
logging(LOG_NORMAL, "[FAILED] STARTSTOPUNIT Should have failed "
"with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED But failed "
"with %s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] STARTSTOPUNIT returned MEDIUM_REMOVAL_PREVENTED.");
return 0;
}
int startstopunit_sanitize(struct iscsi_context *iscsi, int lun, int immed, int pcm, int pc, int no_flush, int loej, int start) task = iscsi_scsi_command_sync(iscsi, lun, task, NULL);
{
struct scsi_task *task;
logging(LOG_VERBOSE, "Send STARTSTOPUNIT (Expecting SANITIZE_IN_PROGRESS) " ret = check_result("STARTSTOPUNIT", iscsi, task, status, key, ascq,
"IMMED:%d PCM:%d PC:%d NO_FLUSH:%d LOEJ:%d START:%d", num_ascq);
immed, pcm, pc, no_flush, loej, start); if (task) {
task = iscsi_startstopunit_sync(iscsi, lun, immed, pcm, pc, no_flush,
loej, start);
if (task == NULL) {
logging(LOG_NORMAL,
"[FAILED] Failed to send STARTSTOPUNIT command: %s",
iscsi_get_error(iscsi));
return -1;
}
if (task->status == SCSI_STATUS_GOOD) {
logging(LOG_NORMAL,
"[FAILED] STARTSTOPUNIT successful but should have failed with NOT_READY/SANITIZE_IN_PROGRESS");
scsi_free_scsi_task(task); scsi_free_scsi_task(task);
return -1;
} }
if (task->status != SCSI_STATUS_CHECK_CONDITION return ret;
|| task->sense.key != SCSI_SENSE_NOT_READY
|| task->sense.ascq != SCSI_SENSE_ASCQ_SANITIZE_IN_PROGRESS) {
logging(LOG_NORMAL, "[FAILED] STARTSTOPUNIT Should have failed "
"with NOT_READY/SANITIZE_IN_PROGRESS But failed "
"with %s", iscsi_get_error(iscsi));
scsi_free_scsi_task(task);
return -1;
}
scsi_free_scsi_task(task);
logging(LOG_VERBOSE, "[OK] STARTSTOPUNIT returned SANITIZE_IN_PROGRESS.");
return 0;
} }
int int

View File

@@ -36,12 +36,14 @@ extern const char *tgt_url;
#define EXPECT_MISCOMPARE SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_MISCOMPARE, 0, 0 #define EXPECT_MISCOMPARE SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_MISCOMPARE, 0, 0
#define EXPECT_WRITE_PROTECTED SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_DATA_PROTECTION, write_protect_ascqs, 1 #define EXPECT_WRITE_PROTECTED SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_DATA_PROTECTION, write_protect_ascqs, 1
#define EXPECT_SANITIZE SCSI_STATUS_CHECK_CONDITION, SCSI_SENSE_NOT_READY, sanitize_ascqs, 1 #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
int no_medium_ascqs[3]; int no_medium_ascqs[3];
int lba_oob_ascqs[1]; int lba_oob_ascqs[1];
int invalid_cdb_ascqs[1]; int invalid_cdb_ascqs[1];
int write_protect_ascqs[1]; int write_protect_ascqs[1];
int sanitize_ascqs[1]; int sanitize_ascqs[1];
int removal_ascqs[1];
extern int loglevel; extern int loglevel;
#define LOG_SILENT 0 #define LOG_SILENT 0
@@ -280,9 +282,7 @@ int sanitize(struct iscsi_context *iscsi, int lun, int immed, int ause, int sa,
int sanitize_conflict(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_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 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(struct iscsi_context *iscsi, int lun, 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 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(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 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(struct iscsi_context *iscsi, int lun, uint64_t lba, int num_blocks, int sync_nv, int immed);

View File

@@ -43,7 +43,8 @@ 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(iscsic, tgt_lun, 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.");
@@ -270,6 +271,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(iscsic, tgt_lun, 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,7 +40,8 @@ test_preventallow_2_itnexuses(void)
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(iscsic, tgt_lun, 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.");
@@ -55,7 +56,8 @@ test_preventallow_2_itnexuses(void)
} }
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(iscsic2, tgt_lun, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -71,7 +73,8 @@ test_preventallow_2_itnexuses(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,7 +40,8 @@ test_preventallow_cold_reset(void)
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(iscsic, tgt_lun, 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.");
@@ -56,7 +57,8 @@ test_preventallow_cold_reset(void)
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(iscsic, tgt_lun, 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.");
@@ -64,7 +66,8 @@ test_preventallow_cold_reset(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -74,7 +77,8 @@ test_preventallow_cold_reset(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,7 +40,8 @@ test_preventallow_eject(void)
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(iscsic, tgt_lun, 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.");
@@ -52,7 +53,8 @@ test_preventallow_eject(void)
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(iscsic, tgt_lun, 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.");
@@ -64,7 +66,8 @@ test_preventallow_eject(void)
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(iscsic, tgt_lun, 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");
@@ -72,7 +75,8 @@ test_preventallow_eject(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,7 +40,8 @@ test_preventallow_itnexus_loss(void)
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(iscsic, tgt_lun, 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.");
@@ -59,7 +60,8 @@ test_preventallow_itnexus_loss(void)
} }
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(iscsic, tgt_lun, 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.");
@@ -67,7 +69,8 @@ test_preventallow_itnexus_loss(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -77,7 +80,8 @@ test_preventallow_itnexus_loss(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,7 +40,8 @@ test_preventallow_logout(void)
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(iscsic, tgt_lun, 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.");
@@ -60,7 +61,8 @@ test_preventallow_logout(void)
} }
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(iscsic, tgt_lun, 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.");
@@ -68,7 +70,8 @@ test_preventallow_logout(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -78,7 +81,8 @@ test_preventallow_logout(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,7 +40,8 @@ test_preventallow_lun_reset(void)
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(iscsic, tgt_lun, 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.");
@@ -56,7 +57,8 @@ test_preventallow_lun_reset(void)
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(iscsic, tgt_lun, 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.");
@@ -64,7 +66,8 @@ test_preventallow_lun_reset(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -74,7 +77,7 @@ test_preventallow_lun_reset(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -40,7 +40,8 @@ test_preventallow_warm_reset(void)
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(iscsic, tgt_lun, 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.");
@@ -56,7 +57,8 @@ test_preventallow_warm_reset(void)
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(iscsic, tgt_lun, 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.");
@@ -64,7 +66,8 @@ test_preventallow_warm_reset(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -74,7 +77,8 @@ test_preventallow_warm_reset(void)
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(iscsic, tgt_lun, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
} }

View File

@@ -91,7 +91,8 @@ test_sanitize_reset(void)
logging(LOG_VERBOSE, "Verify that STARTSTOPUNIT fails with " logging(LOG_VERBOSE, "Verify that STARTSTOPUNIT fails with "
"SANITIZE_IN_PROGRESS"); "SANITIZE_IN_PROGRESS");
ret = startstopunit_sanitize(iscsic, tgt_lun, 1, 0, 1, 0, 1, 0); ret = startstopunit(iscsic, tgt_lun, 1, 0, 1, 0, 1, 0,
EXPECT_SANITIZE);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify that READ16 fails with " logging(LOG_VERBOSE, "Verify that READ16 fails with "

View File

@@ -40,7 +40,8 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==0"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==0");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
0, 0, 0, 0, 0, 0); 0, 0, 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -49,7 +50,8 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==1"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==1");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
0, 0, 0, 0, 0, 1); 0, 0, 0, 0, 0, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -58,7 +60,8 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==0"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==0");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
1, 0, 0, 0, 0, 0); 1, 0, 0, 0, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -67,7 +70,8 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==1"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==1");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
1, 0, 0, 0, 0, 1); 1, 0, 0, 0, 0, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -76,7 +80,8 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==0"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==0");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
0, 0, 0, 1, 0, 0); 0, 0, 0, 1, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -85,7 +90,8 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==1"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==1");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
0, 0, 0, 1, 0, 1); 0, 0, 0, 1, 0, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -94,7 +100,8 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==0"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==0");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
1, 0, 0, 1, 0, 0); 1, 0, 0, 1, 0, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -103,7 +110,8 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==1"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==1");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
1, 0, 0, 1, 0, 1); 1, 0, 0, 1, 0, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -112,5 +120,6 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "In case the target did eject the medium, load it again."); logging(LOG_VERBOSE, "In case the target did eject the medium, load it again.");
startstopunit(iscsic, tgt_lun, 1, 0, 0, 0, 1, 1); startstopunit(iscsic, tgt_lun, 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
} }

View File

@@ -41,7 +41,8 @@ test_startstopunit_pwrcnd(void)
logging(LOG_VERBOSE, "Test that media is not ejected when PC!=0"); logging(LOG_VERBOSE, "Test that media is not ejected when PC!=0");
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
1, 0, i, 0, 1, 0); 1, 0, i, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
@@ -50,5 +51,6 @@ test_startstopunit_pwrcnd(void)
} }
logging(LOG_VERBOSE, "In case the target did eject the medium, load it again."); logging(LOG_VERBOSE, "In case the target did eject the medium, load it again.");
startstopunit(iscsic, tgt_lun, 1, 0, 0, 0, 1, 1); startstopunit(iscsic, tgt_lun, 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
} }

View File

@@ -42,7 +42,8 @@ test_startstopunit_simple(void)
} }
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
1, 0, 0, 0, 1, 0); 1, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
if (!inq->rmb) { if (!inq->rmb) {
CU_ASSERT_NOT_EQUAL(ret, 0); CU_ASSERT_NOT_EQUAL(ret, 0);
return; return;
@@ -57,7 +58,8 @@ test_startstopunit_simple(void)
logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1"); logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
1, 0, 0, 0, 1, 1); 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can read from the media."); logging(LOG_VERBOSE, "Verify we can read from the media.");
@@ -68,7 +70,8 @@ test_startstopunit_simple(void)
logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1"); logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
0, 0, 0, 0, 1, 0); 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
@@ -79,7 +82,8 @@ test_startstopunit_simple(void)
logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1"); logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1");
ret = startstopunit(iscsic, tgt_lun, ret = startstopunit(iscsic, tgt_lun,
0, 0, 0, 0, 1, 1); 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can access the media again."); logging(LOG_VERBOSE, "Verify we can access the media again.");