Improve tests for READ10/READ12/READ16

This commit is contained in:
Ronnie Sahlberg
2012-06-24 07:55:49 +10:00
parent 27ea207fd4
commit ecbff226b8
3 changed files with 190 additions and 130 deletions

View File

@@ -36,7 +36,8 @@ int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss _
printf("1, Read at 0 should work.\n");
printf("2, Read at end-of-lun should work.\n");
printf("3, Read beyond end-of-lun should fail.\n");
printf("4, Read at LBA -1 should fail.\n");
printf("4, Read at LBA:2^63 should fail.\n");
printf("5, Read at LBA:-1 should fail.\n");
printf("\n");
return 0;
}
@@ -73,74 +74,103 @@ int T0203_read16_0blocks(const char *initiator, const char *url, int data_loss _
scsi_free_scsi_task(task);
printf("Read16 0blocks at LBA:0 ");
printf("READ16 0blocks at LBA:0 ");
task = iscsi_read16_sync(iscsi, lun, 0, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi));
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
goto test2;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
goto test2;
}
printf("[OK]\n");
printf("Read16 0blocks at LBA:<end-of-disk> ");
test2:
printf("READ16 0blocks at LBA:<end-of-disk> ");
task = iscsi_read16_sync(iscsi, lun, num_blocks, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi));
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
goto test3;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
printf("READ16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
goto test3;
}
printf("[OK]\n");
printf("Read16 0blocks at LBA:<beyond end-of-disk> ");
test3:
printf("READ16 0blocks at LBA:<beyond end-of-disk> ");
task = iscsi_read16_sync(iscsi, lun, num_blocks + 1, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi));
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
goto test4;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read16 command: Should fail when reading 0blocks beyond end\n");
printf("READ16 command: Should fail when reading 0blocks beyond end\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
goto test4;
}
printf("[OK]\n");
printf("Read16 0blocks at LBA:-1 ");
task = iscsi_read16_sync(iscsi, lun, -1, 0, block_size, 0, 0, 0, 0, 0);
test4:
printf("READ16 0blocks at LBA 2^63 ... ");
task = iscsi_read16_sync(iscsi, lun, 0x8000000000000000, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send read16 command: %s\n", iscsi_get_error(iscsi));
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
goto test5;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Read16 command: Should fail when reading 0blocks at LBA -1\n");
printf("READ16 command: Should fail when reading 0blocks at 2^63\n");
ret = -1;
scsi_free_scsi_task(task);
goto finished;
goto test5;
}
printf("[OK]\n");
test5:
printf("READ16 0blocks at LBA -1 ... ");
task = iscsi_read16_sync(iscsi, lun, -1, 0, block_size, 0, 0, 0, 0, 0);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test6;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ16 command: Should fail when reading 0blocks at -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test6;
}
printf("[OK]\n");
test6:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);