TESTS: Start fixing up the tests so we can test-suite them properly

Dont call READCAPACITY from every single test.
Remove two arguments from the test signatures and turn them into globals.
remove the ret++ silliness.  Tests return 0 : all ok, -2, skipped or -1 : test failed
This commit is contained in:
Ronnie Sahlberg
2012-12-26 18:34:12 -08:00
parent 3c960c1d42
commit 5ad957b873
126 changed files with 1096 additions and 3554 deletions
+14 -45
View File
@@ -20,13 +20,11 @@
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_loss _U_, int show_info)
int T0101_read10_beyond_eol(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity10 *rc10;
int ret, i, lun;
uint32_t block_size, num_blocks;
printf("0101_read10_beyond_eol:\n");
printf("=======================\n");
@@ -47,31 +45,6 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los
return -1;
}
/* find the size of the LUN */
task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0);
if (task == NULL) {
printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("READCAPACITY10 command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc10 = scsi_datain_unmarshall(task);
if (rc10 == NULL) {
printf("failed to unmarshall READCAPACITY10 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
block_size = rc10->block_size;
num_blocks = rc10->lba;
scsi_free_scsi_task(task);
ret = 0;
if (num_blocks >= 0x80000000) {
@@ -89,14 +62,14 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test2;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 beyond end-of-lun did not fail with sense.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -105,13 +78,13 @@ int T0101_read10_beyond_eol(const char *initiator, const char *url, int data_los
printf("READ10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test2;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test2:
/* Reading 1 - 256 blocks at LBA 2^31 */
printf("Reaing 1-256 blocks at LBA 2^31 ... ");
for (i = 1; i <= 256; i++) {
@@ -120,14 +93,14 @@ test2:
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test3;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 command should fail when reading from LBA 2^31\n");
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -136,14 +109,13 @@ test2:
printf("READ10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test3;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test3:
/* read 1 - 256 blocks at LBA -1 */
printf("Read 1-256 blocks at LBA -1 ... ");
for (i = 1; i <= 256; i++) {
@@ -152,14 +124,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test4;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 command should fail when reading at LBA -1\n");
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -168,14 +140,13 @@ test3:
printf("READ10 failed but with the wrong sense code. It should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test4;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test4:
/* read 2-256 blocks, all but one block beyond the eol */
printf("Reading 1-255 blocks beyond eol starting at last block ... ");
for (i=2; i<=256; i++) {
@@ -184,14 +155,14 @@ test3:
printf("[FAILED]\n");
printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto test5;
goto finished;
}
if (task->status == SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("READ10 beyond end-of-lun did not return sense.\n");
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
if (task->status != SCSI_STATUS_CHECK_CONDITION
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
@@ -200,15 +171,13 @@ test3:
printf("READ10 failed but ascq was wrong. Should have failed with ILLEGAL_REQUEST/LBA_OUT_OF_RANGE. Sense:%s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto test5;
goto finished;
}
scsi_free_scsi_task(task);
}
printf("[OK]\n");
test5:
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);