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:
@@ -20,7 +20,7 @@
|
||||
#include "scsi-lowlevel.h"
|
||||
#include "iscsi-test.h"
|
||||
|
||||
int T0190_writesame16_unmap(const char *initiator, const char *url, int data_loss, int show_info)
|
||||
int T0190_writesame16_unmap(const char *initiator, const char *url)
|
||||
{
|
||||
struct iscsi_context *iscsi;
|
||||
struct scsi_task *task;
|
||||
@@ -28,7 +28,6 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
|
||||
int full_size;
|
||||
struct scsi_inquiry_logical_block_provisioning *inq_lbp;
|
||||
int ret, i, lun;
|
||||
uint32_t num_blocks;
|
||||
int lbppb;
|
||||
int lbpme;
|
||||
int lbpws = 0;
|
||||
@@ -53,6 +52,8 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
/* find the size of the LUN */
|
||||
task = iscsi_readcapacity16_sync(iscsi, lun);
|
||||
if (task == NULL) {
|
||||
@@ -74,7 +75,6 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
|
||||
goto finished;
|
||||
}
|
||||
|
||||
num_blocks = rc16->returned_lba;
|
||||
lbppb = 1 << rc16->lbppbe;
|
||||
lbpme = rc16->lbpme;
|
||||
|
||||
@@ -82,7 +82,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
|
||||
|
||||
if (lbpme == 0) {
|
||||
printf("LBPME not set. Skip test for CPD page 0xB2 (logical block provisioning)\n");
|
||||
goto test2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
/* Check that id we have logical block provisioning we also have the VPD page for it */
|
||||
@@ -94,7 +94,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
|
||||
printf("[FAILED]\n");
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test2;
|
||||
goto finished;
|
||||
}
|
||||
full_size = scsi_datain_getfullsize(task);
|
||||
if (full_size > task->datain.size) {
|
||||
@@ -105,7 +105,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
|
||||
printf("[FAILED]\n");
|
||||
printf("Inquiry command failed : %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test2;
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
|
||||
printf("failed to unmarshall inquiry datain blob\n");
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto test2;
|
||||
goto finished;
|
||||
}
|
||||
|
||||
lbpws = inq_lbp->lbpws;
|
||||
@@ -127,7 +127,6 @@ int T0190_writesame16_unmap(const char *initiator, const char *url, int data_los
|
||||
printf("Device does not support WRITE_SAME16 for UNMAP. All WRITE_SAME16 commands to unmap should fail.\n");
|
||||
}
|
||||
|
||||
test2:
|
||||
|
||||
if (!data_loss) {
|
||||
printf("--dataloss flag is not set. Skipping test\n");
|
||||
@@ -155,7 +154,7 @@ test2:
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test3;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status == SCSI_STATUS_CHECK_CONDITION
|
||||
&& task->sense.key == SCSI_SENSE_ILLEGAL_REQUEST
|
||||
@@ -172,7 +171,7 @@ test2:
|
||||
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto test3;
|
||||
goto finished;
|
||||
}
|
||||
} else {
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
@@ -182,7 +181,7 @@ test2:
|
||||
printf("WRITESAME16 command should fail since LBPWS is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto test3;
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +189,7 @@ test2:
|
||||
}
|
||||
printf("[OK]\n");
|
||||
|
||||
test3:
|
||||
|
||||
/* unmap the last 1 - 256 blocks at the end of the LUN */
|
||||
printf("Unmapping last 1-256 blocks ... ");
|
||||
if (lbpws == 0) {
|
||||
@@ -210,7 +209,7 @@ test3:
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test4;
|
||||
goto finished;
|
||||
}
|
||||
if (lbpws) {
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
@@ -218,7 +217,7 @@ test3:
|
||||
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto test4;
|
||||
goto finished;
|
||||
}
|
||||
} else {
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
@@ -228,15 +227,13 @@ test3:
|
||||
printf("WRITESAME16 command should fail since LBPWS is 0 but failed with wrong sense code %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto test4;
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
}
|
||||
printf("[OK]\n");
|
||||
|
||||
test4:
|
||||
|
||||
|
||||
/* Test that UNMAP=0 and ANCHOR==1 fails with check condition */
|
||||
printf("Try UNMAP==0 and ANCHOR==1 ... ");
|
||||
@@ -247,7 +244,7 @@ test4:
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test5;
|
||||
goto finished;
|
||||
}
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
|| task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST
|
||||
@@ -256,12 +253,11 @@ test4:
|
||||
printf("WRITESAME16 with UNMAP=0 ANCHOR=1 failed with wrong sense code %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto test5;
|
||||
goto finished;
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
test5:
|
||||
|
||||
/* Test UNMAP=1 and ANCHOR==1 */
|
||||
printf("Try UNMAP==1 and ANCHOR==1 ... ");
|
||||
@@ -275,7 +271,7 @@ test5:
|
||||
printf("[FAILED]\n");
|
||||
printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi));
|
||||
ret = -1;
|
||||
goto test5;
|
||||
goto finished;
|
||||
}
|
||||
if (anc_sup == 0) {
|
||||
if (task->status != SCSI_STATUS_CHECK_CONDITION
|
||||
@@ -285,7 +281,7 @@ test5:
|
||||
printf("WRITESAME16 with UNMAP=1 ANCHOR=1 failed with wrong sense code %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto test6;
|
||||
goto finished;
|
||||
}
|
||||
} else {
|
||||
if (task->status != SCSI_STATUS_GOOD) {
|
||||
@@ -293,15 +289,12 @@ test5:
|
||||
printf("WRITESAME16 command: failed with sense. %s\n", iscsi_get_error(iscsi));
|
||||
scsi_free_scsi_task(task);
|
||||
ret = -1;
|
||||
goto test6;
|
||||
goto finished;
|
||||
}
|
||||
}
|
||||
scsi_free_scsi_task(task);
|
||||
printf("[OK]\n");
|
||||
|
||||
test6:
|
||||
|
||||
|
||||
|
||||
finished:
|
||||
iscsi_logout_sync(iscsi);
|
||||
|
||||
Reference in New Issue
Block a user