TESTS: More tests for invalid DATASN
This commit is contained in:
@@ -155,6 +155,8 @@ int T1000_cmdsn_invalid(const char *initiator, const char *url, int data_loss, i
|
||||
test2:
|
||||
/* in case the previous test failed the session */
|
||||
iscsi_set_noautoreconnect(iscsi, 0);
|
||||
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
|
||||
iscsi->target_max_recv_data_segment_length = 512;
|
||||
|
||||
printf("Write 2 blocks with CMDSN == 0 ... ");fflush(stdout);
|
||||
change_cmdsn = 2;
|
||||
|
||||
@@ -26,11 +26,22 @@ static int clamp_datasn;
|
||||
|
||||
static void my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
|
||||
{
|
||||
if (pdu->outdata.data[0] != ISCSI_PDU_DATA_OUT) {
|
||||
return;
|
||||
}
|
||||
switch (clamp_datasn) {
|
||||
case 1:
|
||||
/* change datasn to 0 */
|
||||
*(uint32_t *)&pdu->outdata.data[36] = 0;
|
||||
break;
|
||||
case 2:
|
||||
/* change datasn to 27 */
|
||||
*(uint32_t *)&pdu->outdata.data[36] = htonl(27);
|
||||
break;
|
||||
case 3:
|
||||
/* change datasn to -1 */
|
||||
*(uint32_t *)&pdu->outdata.data[36] = htonl(-1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +76,8 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss,
|
||||
if (show_info) {
|
||||
printf("Test sending commands with invalid datasn values.\n");
|
||||
printf("1, Test that 2 DATA-IN with DATASN==0 is an error\n");
|
||||
printf("2, Test that 2 DATA-IN with DATASN==27 is an error\n");
|
||||
printf("3, Test that 2 DATA-IN with DATASN==-1 is an error\n");
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -114,7 +127,6 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss,
|
||||
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
||||
|
||||
printf("Write 2 DATA-IN with DATASN == 0 ... ");
|
||||
clamp_datasn = 1;
|
||||
/* we dont want autoreconnect since some targets will drop the
|
||||
* on this condition.
|
||||
*/
|
||||
@@ -129,6 +141,7 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss,
|
||||
ret++;
|
||||
goto test2;
|
||||
}
|
||||
clamp_datasn = 1;
|
||||
test_state.task = task;
|
||||
test_state.finished = 0;
|
||||
test_state.status = 0;
|
||||
@@ -148,6 +161,83 @@ int T1010_datasn_invalid(const char *initiator, const char *url, int data_loss,
|
||||
test2:
|
||||
/* in case the previous test failed the session */
|
||||
iscsi_set_noautoreconnect(iscsi, 0);
|
||||
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
|
||||
iscsi->target_max_recv_data_segment_length = 512;
|
||||
|
||||
printf("Write 2 DATA-IN with DATASN == 27 ... ");
|
||||
/* we dont want autoreconnect since some targets will drop the
|
||||
* on this condition.
|
||||
*/
|
||||
iscsi_set_noautoreconnect(iscsi, 1);
|
||||
|
||||
task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size,
|
||||
0, 0, 0, 0, 0,
|
||||
test_cb, &test_state);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi));
|
||||
ret++;
|
||||
goto test3;
|
||||
}
|
||||
clamp_datasn = 2;
|
||||
test_state.task = task;
|
||||
test_state.finished = 0;
|
||||
test_state.status = 0;
|
||||
wait_until_test_finished(iscsi, &test_state);
|
||||
clamp_datasn = 0;
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("WRITE10 command successful. Should have failed with error\n");
|
||||
ret++;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test3;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
|
||||
test3:
|
||||
/* in case the previous test failed the session */
|
||||
iscsi_set_noautoreconnect(iscsi, 0);
|
||||
iscsi->use_immediate_data = ISCSI_IMMEDIATE_DATA_NO;
|
||||
iscsi->target_max_recv_data_segment_length = 512;
|
||||
|
||||
printf("Write 2 DATA-IN with DATASN == -1 ... ");
|
||||
/* we dont want autoreconnect since some targets will drop the
|
||||
* on this condition.
|
||||
*/
|
||||
iscsi_set_noautoreconnect(iscsi, 1);
|
||||
|
||||
task = iscsi_write10_task(iscsi, lun, 0, data, 2 * block_size, block_size,
|
||||
0, 0, 0, 0, 0,
|
||||
test_cb, &test_state);
|
||||
if (task == NULL) {
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi));
|
||||
ret++;
|
||||
goto test4;
|
||||
}
|
||||
clamp_datasn = 3;
|
||||
test_state.task = task;
|
||||
test_state.finished = 0;
|
||||
test_state.status = 0;
|
||||
wait_until_test_finished(iscsi, &test_state);
|
||||
clamp_datasn = 0;
|
||||
if (task->status == SCSI_STATUS_GOOD) {
|
||||
printf("[FAILED]\n");
|
||||
printf("WRITE10 command successful. Should have failed with error\n");
|
||||
ret++;
|
||||
scsi_free_scsi_task(task);
|
||||
goto test4;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
|
||||
test4:
|
||||
/* in case the previous test failed the session */
|
||||
iscsi_set_noautoreconnect(iscsi, 0);
|
||||
|
||||
|
||||
finished:
|
||||
local_iscsi_queue_pdu = NULL;
|
||||
|
||||
Reference in New Issue
Block a user