diff --git a/test-tool/0370_nomedia.c b/test-tool/0370_nomedia.c index 5cb1e26..b401949 100644 --- a/test-tool/0370_nomedia.c +++ b/test-tool/0370_nomedia.c @@ -140,81 +140,38 @@ int T0370_nomedia(const char *initiator, const char *url, int data_loss, int sho if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } scsi_free_scsi_task(task); - - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; - } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_NOT_READY - || (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT - && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN - && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { - printf("[FAILED]\n"); - printf("TESTUNITREADY after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; - scsi_free_scsi_task(task); - goto test2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - /* * TESTS THAT READ FROM THE MEDIUM */ - -test2: - - printf("Test TESTUNITREADY ... "); - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + printf("Test TESTUNITREADY.\n"); + ret = testunitready_nomedium(iscsi, lun); + if (ret != 0) { + goto finished; } - if (task->status != SCSI_STATUS_CHECK_CONDITION - || task->sense.key != SCSI_SENSE_NOT_READY - || (task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT - && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_OPEN - && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { - printf("[FAILED]\n"); - printf("TESTUNITREADY after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; - scsi_free_scsi_task(task); - goto test3; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - -test3: printf("Test SYNCHRONIZECACHE10 ... "); task = iscsi_synchronizecache10_sync(iscsi, lun, 0, 1, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send SYNCHRONIZECACHE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test4; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -223,23 +180,21 @@ test3: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("SYNCHRONIZECACHE10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test4; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test4: printf("Test SYNCHRONIZECACHE16 ... "); task = iscsi_synchronizecache16_sync(iscsi, lun, 0, 1, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send SYNCHRONIZECACHE16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -248,23 +203,21 @@ test4: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("SYNCHRONIZECACHE16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test5: printf("Test READ10 ... "); task = iscsi_read10_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test6; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -273,23 +226,21 @@ test5: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("READ10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test6; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test6: printf("Test READ12 ... "); task = iscsi_read12_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test7; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -298,24 +249,21 @@ test6: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("READ12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test7: - printf("Test READ16 ... "); task = iscsi_read16_sync(iscsi, lun, 0, block_size, block_size, 0, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READ16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test8; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -324,23 +272,21 @@ test7: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("READ16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test8; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test8: printf("Test READCAPACITY10 ... "); task = iscsi_readcapacity10_sync(iscsi, lun, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READCAPACITY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test9; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -349,23 +295,21 @@ test8: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("READCAPACITY10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test9; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test9: printf("Test READCAPACITY16 ... "); task = iscsi_readcapacity16_sync(iscsi, lun); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send READCAPACITY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test10; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -374,23 +318,21 @@ test9: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("READCAPACITY16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test10; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test10: printf("Test GETLBASTATUS ... "); task = iscsi_get_lba_status_sync(iscsi, lun, 0, 64); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send GETLBASTATUS command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test11; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -399,23 +341,21 @@ test10: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("GETLBASTATUS after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test11; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test11: printf("Test PREFETCH10 ... "); task = iscsi_prefetch10_sync(iscsi, lun, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREFETCH10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test12; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -424,24 +364,21 @@ test11: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("PREFETCH10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test12; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test12: - printf("Test PREFETCH16 ... "); task = iscsi_prefetch16_sync(iscsi, lun, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREFETCH16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test13; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -450,23 +387,21 @@ test12: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("PREFETCH16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test13; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test13: printf("Test VERIFY10 ... "); task = iscsi_verify10_sync(iscsi, lun, buf, block_size, 0, 0, 0, 1, block_size); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send VERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test14; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -475,23 +410,21 @@ test13: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("VERIFY10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test14; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test14: printf("Test VERIFY12 ... "); task = iscsi_verify12_sync(iscsi, lun, buf, block_size, 0, 0, 0, 1, block_size); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send VERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test15; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -500,23 +433,21 @@ test14: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("VERIFY12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test15; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test15: printf("Test VERIFY16 ... "); task = iscsi_verify16_sync(iscsi, lun, buf, block_size, 0, 0, 0, 1, block_size); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send VERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test16; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -525,20 +456,18 @@ test15: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("VERIFY16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test16; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test16: if (!data_loss) { printf("--dataloss flag is not set. Skipping all WRITE tests\n"); ret = -2; - goto cleanup; + goto finished; } @@ -551,8 +480,8 @@ test16: if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test17; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -561,23 +490,21 @@ test16: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("WRITE10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test17; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test17: printf("Test WRITE12 ... "); task = iscsi_write12_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test18; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -586,23 +513,21 @@ test17: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("WRITE12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test18; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test18: printf("Test WRITE16 ... "); task = iscsi_write16_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITE16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test19; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -611,23 +536,21 @@ test18: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("WRITE16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test19; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test19: printf("Test WRITEVERIFY10 ... "); task = iscsi_writeverify10_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test20; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -636,23 +559,21 @@ test19: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("WRITEVERIFY10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test20; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test20: printf("Test WRITEVERIFY12 ... "); task = iscsi_writeverify12_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY12 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test21; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -661,23 +582,21 @@ test20: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("WRITEVERIFY12 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test21; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test21: printf("Test WRITEVERIFY16 ... "); task = iscsi_writeverify16_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITEVERIFY16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test22; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -686,22 +605,21 @@ test21: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("WRITEVERIFY16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test22; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test22: + printf("Test ORWRITE ... "); task = iscsi_orwrite_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send ORWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test23; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -710,22 +628,21 @@ test22: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("ORWRITE after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test23; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test23: + printf("Test COMPAREWRITE ... "); task = iscsi_compareandwrite_sync(iscsi, lun, 0, buf, block_size, block_size, 0, 0, 1, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send COMPAREWRITE command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test24; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -734,23 +651,21 @@ test23: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("COMPAREWRITE after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test24; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test24: printf("Test WRITESAME10 ... "); task = iscsi_writesame10_sync(iscsi, lun, buf, block_size, 0, 1, 0, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITESAME10 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test25; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -759,22 +674,21 @@ test24: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("WRITESAME10 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test25; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test25: + printf("Test WRITESAME16 ... "); task = iscsi_writesame16_sync(iscsi, lun, buf, block_size, 0, 1, 0, 0, 0, 0, 0, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send WRITESAME16 command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test26; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -783,23 +697,21 @@ test25: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("WRITESAME16 after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test26; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test26: printf("Test UNMAP ... "); task = iscsi_unmap_sync(iscsi, lun, 0, 0, NULL, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send UNMAP command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test27; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_NOT_READY @@ -808,54 +720,51 @@ test26: && task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_NOT_PRESENT_TRAY_CLOSED)) { printf("[FAILED]\n"); printf("UNMAP after eject failed with the wrong sense code. Should fail with NOT_READY/MEDIUM_NOT_PRESENT*\n"); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test27; + goto finished; } scsi_free_scsi_task(task); - printf("[OK]\n"); -test27: -cleanup: printf("Try to mount the media again ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command: failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); goto finished; } scsi_free_scsi_task(task); - - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TESTUNITREADY command: failed with sense after STARTSTOPUNIT %s\n", iscsi_get_error(iscsi)); - ret++; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); + printf("Check with TESTUNITREADY that the medium is present again.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { + goto finished; + } + + finished: + printf("Make sure the media is mounted again before the next test ... "); + task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); + return -1; + } + scsi_free_scsi_task(task); + printf("[OK]\n"); + iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); return ret; diff --git a/test-tool/0383_preventallow_target_warm_reset.c b/test-tool/0383_preventallow_target_warm_reset.c index 2118ed1..876121b 100644 --- a/test-tool/0383_preventallow_target_warm_reset.c +++ b/test-tool/0383_preventallow_target_warm_reset.c @@ -114,8 +114,8 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url, if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW @@ -125,37 +125,36 @@ int T0383_preventallow_target_warm_reset(const char *initiator, const char *url, if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test2: + printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("Eject failed. [OK]\n"); -test3: + printf("Send a Warm Reset to the target ... "); iscsi_task_mgmt_target_warm_reset_async(iscsi, mgmt_cb, &mgmt_task); while (mgmt_task.finished == 0) { @@ -164,7 +163,7 @@ test3: if (poll(&pfd, 1, -1) < 0) { printf("Poll failed"); - goto test4; + goto finished; } if (iscsi_service(iscsi, pfd.revents) < 0) { printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); @@ -174,54 +173,43 @@ test3: if (mgmt_task.status != 0) { printf("[FAILED]\n"); printf("Failed to reset the target\n"); - goto test4; + goto finished; } printf("[OK]\n"); again: - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - scsi_free_scsi_task(task); + printf("Use TESTUNITREADY and clear any unit attentions.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { goto again; } - scsi_free_scsi_task(task); - -test4: printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have worked but it failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - printf("Load the media again in case it was ejected ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test6; + ret = -1; + goto finished; } /* SBC doesnt really say anything about whether we can LOAD media when the prevent * flag is set @@ -229,16 +217,14 @@ test5: scsi_free_scsi_task(task); printf("[OK]\n"); -test6: - printf("Clear the PREVENTALLOW again ... "); task = iscsi_preventallow_sync(iscsi, lun, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test7; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. @@ -247,16 +233,14 @@ test6: if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test7: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0384_preventallow_target_cold_reset.c b/test-tool/0384_preventallow_target_cold_reset.c index e0d20eb..2db377e 100644 --- a/test-tool/0384_preventallow_target_cold_reset.c +++ b/test-tool/0384_preventallow_target_cold_reset.c @@ -114,8 +114,8 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url, if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW @@ -125,37 +125,36 @@ int T0384_preventallow_target_cold_reset(const char *initiator, const char *url, if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test2: + printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("Eject failed. [OK]\n"); -test3: + printf("Send a Cold Reset to the target ... "); iscsi_task_mgmt_target_cold_reset_async(iscsi, mgmt_cb, &mgmt_task); while (mgmt_task.finished == 0) { @@ -164,7 +163,7 @@ test3: if (poll(&pfd, 1, -1) < 0) { printf("Poll failed"); - goto test4; + goto finished; } if (iscsi_service(iscsi, pfd.revents) < 0) { printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); @@ -174,54 +173,44 @@ test3: if (mgmt_task.status != 0) { printf("[FAILED]\n"); printf("Failed to reset the target\n"); - goto test4; + goto finished; } printf("[OK]\n"); again: - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - scsi_free_scsi_task(task); + printf("Use TESTUNITREADY and clear any unit attentions.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { goto again; } - scsi_free_scsi_task(task); -test4: printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have worked but it failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - printf("Load the media again in case it was ejected ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test6; + ret = -1; + goto finished; } /* SBC doesnt really say anything about whether we can LOAD media when the prevent * flag is set @@ -229,16 +218,14 @@ test5: scsi_free_scsi_task(task); printf("[OK]\n"); -test6: - printf("Clear the PREVENTALLOW again ... "); task = iscsi_preventallow_sync(iscsi, lun, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test7; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. @@ -247,16 +234,14 @@ test6: if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test7: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0385_preventallow_lun_reset.c b/test-tool/0385_preventallow_lun_reset.c index b77e9ab..569f046 100644 --- a/test-tool/0385_preventallow_lun_reset.c +++ b/test-tool/0385_preventallow_lun_reset.c @@ -114,8 +114,8 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url, int dat if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW @@ -125,37 +125,36 @@ int T0385_preventallow_lun_reset(const char *initiator, const char *url, int dat if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test2; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test2: + printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test3; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_CHECK_CONDITION || task->sense.key != SCSI_SENSE_ILLEGAL_REQUEST || task->sense.ascq != SCSI_SENSE_ASCQ_MEDIUM_REMOVAL_PREVENTED) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have failed with ILLEGAL_REQUEST/MEDIUM_REMOVAL_PREVENTED with : failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test3; + goto finished; } scsi_free_scsi_task(task); printf("Eject failed. [OK]\n"); -test3: + printf("Send a LUN Reset to the target ... "); iscsi_task_mgmt_lun_reset_async(iscsi, lun, mgmt_cb, &mgmt_task); while (mgmt_task.finished == 0) { @@ -164,7 +163,7 @@ test3: if (poll(&pfd, 1, -1) < 0) { printf("Poll failed"); - goto test4; + goto finished; } if (iscsi_service(iscsi, pfd.revents) < 0) { printf("iscsi_service failed with : %s\n", iscsi_get_error(iscsi)); @@ -174,54 +173,44 @@ test3: if (mgmt_task.status != 0) { printf("[FAILED]\n"); printf("Failed to reset the LUN\n"); - goto test4; + goto finished; } printf("[OK]\n"); again: - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TESTUNITREADY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - scsi_free_scsi_task(task); + printf("Use TESTUNITREADY and clear any unit attentions.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { goto again; } - scsi_free_scsi_task(task); -test4: printf("Try to eject the media ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test5; + ret = -1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("STARTSTOPUNIT command should have worked but it failed with sense. %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test5; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test5: - printf("Load the media again in case it was ejected ... "); task = iscsi_startstopunit_sync(iscsi, lun, 1, 0, 0, 0, 1, 1); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send STARTSTOPUNIT command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test6; + ret = -1; + goto finished; } /* SBC doesnt really say anything about whether we can LOAD media when the prevent * flag is set @@ -229,16 +218,14 @@ test5: scsi_free_scsi_task(task); printf("[OK]\n"); -test6: - printf("Clear the PREVENTALLOW again ... "); task = iscsi_preventallow_sync(iscsi, lun, 0); if (task == NULL) { printf("[FAILED]\n"); printf("Failed to send PREVENTALLOW command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test7; + ret = -1; + goto finished; } /* SPC doesnt really say anything about what should happen if using PREVENTALLOW * on a device that does not support medium removals. @@ -247,16 +234,14 @@ test6: if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("PREVENTALLOW command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; + ret = -1; scsi_free_scsi_task(task); - goto test7; + goto finished; } } scsi_free_scsi_task(task); - printf("[OK]\n"); -test7: finished: iscsi_logout_sync(iscsi); diff --git a/test-tool/0390_mandatory_opcodes_sbc.c b/test-tool/0390_mandatory_opcodes_sbc.c index d7c85dc..b3e3357 100644 --- a/test-tool/0390_mandatory_opcodes_sbc.c +++ b/test-tool/0390_mandatory_opcodes_sbc.c @@ -295,26 +295,13 @@ test14: goto test15; test15: - printf("Test TEST UNIT READY ... "); - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test11; + printf("Test TEST UNIT READY.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { + goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; - scsi_free_scsi_task(task); - goto test16; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); -test16: printf("Test UNMAP ... "); if (lbpme == 0) { printf("[LBPME == 0, SKIPPING TEST]\n"); diff --git a/test-tool/0420_reserve6_simple.c b/test-tool/0420_reserve6_simple.c index e6f2300..2a60077 100644 --- a/test-tool/0420_reserve6_simple.c +++ b/test-tool/0420_reserve6_simple.c @@ -25,7 +25,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss _U_, int show_info) { - struct iscsi_context *iscsi, *iscsi2; + struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; int ret, lun; @@ -56,7 +56,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss if (iscsi2 == NULL) { printf("Failed to login to target\n"); ret = 1; - goto out_login1; + goto finished; } ret = 0; @@ -68,7 +68,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss printf("Failed to send RESERVE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { if (task->status == SCSI_STATUS_CHECK_CONDITION @@ -76,7 +76,8 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss && task->sense.ascq == SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE) { printf("[OK]\n"); printf("RESERVE6 Not Supported\n"); - goto finished2; + scsi_free_scsi_task(task); + goto finished; } else { printf("[FAILED]\n"); printf("RESERVE6 failed but ascq was wrong. Should " @@ -84,7 +85,8 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss "INVALID OPERATOR. Sense:%s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished2; + scsi_free_scsi_task(task); + goto finished; } } scsi_free_scsi_task(task); @@ -97,14 +99,15 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss printf("Failed to send RELEASE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("RELEASE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished2; + scsi_free_scsi_task(task); + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -117,32 +120,15 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss printf("Failed to send RESERVE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("RESERVE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - task = iscsi_reserve6_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send RESERVE6 command : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished1; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("RESERVE6 command failed : %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished2; + scsi_free_scsi_task(task); + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -154,14 +140,15 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss printf("Failed to send RESERVE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished1; + goto finished; } /* We expect this command to fail for the test to pass. */ if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { printf("[FAILED]\n"); printf("Expected RESERVATION CONFLICT\n"); ret = -1; - goto finished2; + scsi_free_scsi_task(task); + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -173,7 +160,7 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss printf("Failed to send RELEASE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished1; + goto finished; } /* We expect this command to pass. */ if (task->status != SCSI_STATUS_GOOD) { @@ -183,48 +170,22 @@ int T0420_reserve6_simple(const char *initiator, const char *url, int data_loss ret = -1; /* Treat as non-fatal failure for now. STGT is broken.*/ scsi_free_scsi_task(task); - goto test4; + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); -test4: - printf("Send TESTUNITREADY from Initiator 1 ... "); - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished1; + printf("Send TESTUNITREADY from Initiator 1\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { + goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - printf("Send TESTUNITREADY from Initiator 2. Expect conflict. ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; - goto finished1; + printf("Send TESTUNITREADY from Initiator 2. Expect conflict.\n"); + ret = testunitready_conflict(iscsi2, lun); + if (ret != 0) { + goto finished; } - if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { - printf("[FAILED]\n"); - printf("Expected RESERVATION CONFLICT\n"); - ret = -1; - goto finished2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); printf("Test that release actually works\n"); printf("Send RELEASE6 from Initiator 1 ... "); @@ -234,14 +195,15 @@ test4: printf("Failed to send RELEASE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("RELEASE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished2; + scsi_free_scsi_task(task); + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -253,14 +215,15 @@ test4: printf("Failed to send RESERVE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("RESERVE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished2; + scsi_free_scsi_task(task); + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); @@ -272,27 +235,29 @@ test4: printf("Failed to send RELEASE6 command : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished1; + goto finished; } if (task->status != SCSI_STATUS_GOOD) { printf("[FAILED]\n"); printf("RELEASE6 command failed : %s\n", iscsi_get_error(iscsi)); ret = -1; - goto finished2; + scsi_free_scsi_task(task); + goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); - goto finished1; + goto finished; -finished2: - scsi_free_scsi_task(task); -finished1: - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); -out_login1: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); +finished: + if (iscsi2 != NULL) { + iscsi_logout_sync(iscsi2); + iscsi_destroy_context(iscsi2); + } + if (iscsi != NULL) { + iscsi_logout_sync(iscsi); + iscsi_destroy_context(iscsi); + } return ret; } diff --git a/test-tool/0421_reserve6_lun_reset.c b/test-tool/0421_reserve6_lun_reset.c index 69321ee..34839c9 100644 --- a/test-tool/0421_reserve6_lun_reset.c +++ b/test-tool/0421_reserve6_lun_reset.c @@ -40,7 +40,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, int T0421_reserve6_lun_reset(const char *initiator, const char *url, int data_loss _U_, int show_info) { - struct iscsi_context *iscsi, *iscsi2; + struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; int ret, lun; struct mgmt_task mgmt_task = {0, 0}; @@ -101,54 +101,25 @@ int T0421_reserve6_lun_reset(const char *initiator, const char *url, iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -test2: - printf("Verify we can access the LUN from the first initiator ... "); - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test3; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -test3: - printf("Verify we can NOT access the LUN from the second initiator ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { - printf("[FAILED]\n"); - printf("Expected RESERVATION CONFLICT\n"); - ret = -1; - scsi_free_scsi_task(task); goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); + + printf("Verify we can access the LUN from the first initiator.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { + goto finished; + } + + + printf("Verify we can NOT access the LUN from the second initiator.\n"); + ret = testunitready_conflict(iscsi2, lun); + if (ret != 0) { + goto finished; + } + printf("Send a LUN Reset to the target ... "); iscsi_task_mgmt_lun_reset_async(iscsi, lun, mgmt_cb, &mgmt_task); while (mgmt_task.finished == 0) { @@ -171,42 +142,33 @@ test3: } printf("[OK]\n"); -test5: + /* We might be getting UNIT_ATTENTION/BUS_RESET after the lun-reset above. If so just loop and try the TESTUNITREADY again until it clears */ - printf("Verify we can access the LUN from the second initiator ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; + printf("Use TESTUNITREADY and clear any unit attentions on the second initiator.\n"); +again: + ret = testunitready(iscsi2, lun); + if (ret != 0) { + goto again; + } + + + printf("Verify we can access the LUN from the second initiator.\n"); + ret = testunitready(iscsi2, lun); + if (ret != 0) { goto finished; } - if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_UNIT_ATTENTION - && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) { - printf("Got BUS RESET. Retry accessing the LUN\n"); - goto test5; - - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi2)); - ret = -1; - scsi_free_scsi_task(task); - goto test3; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); + if (iscsi2 != NULL) { + iscsi_logout_sync(iscsi2); + iscsi_destroy_context(iscsi2); + } + if (iscsi != NULL) { + iscsi_logout_sync(iscsi); + iscsi_destroy_context(iscsi); + } return ret; } diff --git a/test-tool/0422_reserve6_logout.c b/test-tool/0422_reserve6_logout.c index 102ccd4..bf0d72f 100644 --- a/test-tool/0422_reserve6_logout.c +++ b/test-tool/0422_reserve6_logout.c @@ -25,7 +25,7 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss _U_, int show_info) { - struct iscsi_context *iscsi, *iscsi2; + struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; int ret, lun; @@ -84,82 +84,46 @@ int T0422_reserve6_logout(const char *initiator, const char *url, int data_loss iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -test2: - printf("Verify we can access the LUN from the first initiator ... "); - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test3; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -test3: - printf("Verify we can NOT access the LUN from the second initiator ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { - printf("[FAILED]\n"); - printf("Expected RESERVATION CONFLICT\n"); - ret = -1; - scsi_free_scsi_task(task); goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); + + printf("Verify we can access the LUN from the first initiator.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { + goto finished; + } + + + printf("Verify we can NOT access the LUN from the second initiator.\n"); + ret = testunitready_conflict(iscsi2, lun); + if (ret != 0) { + goto finished; + } + printf("Logout the first initiator ... "); iscsi_logout_sync(iscsi); iscsi_destroy_context(iscsi); + iscsi = NULL; printf("[OK]\n"); - printf("Verify we can access the LUN from the second initiator ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; + printf("Verify we can access the LUN from the second initiator.\n"); + ret = testunitready(iscsi2, lun); + if (ret != 0) { goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi2)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); finished: - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); + if (iscsi2 != NULL) { + iscsi_logout_sync(iscsi2); + iscsi_destroy_context(iscsi2); + } + if (iscsi != NULL) { + iscsi_logout_sync(iscsi); + iscsi_destroy_context(iscsi); + } return ret; } diff --git a/test-tool/0423_reserve6_sessionloss.c b/test-tool/0423_reserve6_sessionloss.c index c2683c5..b5f8aa3 100644 --- a/test-tool/0423_reserve6_sessionloss.c +++ b/test-tool/0423_reserve6_sessionloss.c @@ -25,7 +25,7 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, int data_loss _U_, int show_info) { - struct iscsi_context *iscsi, *iscsi2; + struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; int ret, lun; @@ -84,81 +84,46 @@ int T0423_reserve6_sessionloss(const char *initiator, const char *url, iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -test2: - printf("Verify we can access the LUN from the first initiator ... "); - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test3; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - - -test3: - printf("Verify we can NOT access the LUN from the second initiator ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; - goto finished; - } - if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { - printf("[FAILED]\n"); - printf("Expected RESERVATION CONFLICT\n"); - ret = -1; - scsi_free_scsi_task(task); goto finished; } scsi_free_scsi_task(task); printf("[OK]\n"); + + printf("Verify we can access the LUN from the first initiator.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { + goto finished; + } + + + printf("Verify we can NOT access the LUN from the second initiator.\n"); + ret = testunitready_conflict(iscsi2, lun); + if (ret != 0) { + goto finished; + } + + printf("Drop the session to the first initiator ... "); iscsi_destroy_context(iscsi); + iscsi = NULL; printf("[OK]\n"); - printf("Verify we can access the LUN from the second initiator ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; + printf("Verify we can access the LUN from the second initiator.\n"); + ret = testunitready(iscsi2, lun); + if (ret != 0) { goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi2)); - ret = -1; - scsi_free_scsi_task(task); - goto finished; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); finished: - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); + if (iscsi2 != NULL) { + iscsi_logout_sync(iscsi2); + iscsi_destroy_context(iscsi2); + } + if (iscsi != NULL) { + iscsi_logout_sync(iscsi); + iscsi_destroy_context(iscsi); + } return ret; } diff --git a/test-tool/0424_reserve6_target_reset.c b/test-tool/0424_reserve6_target_reset.c index ac62ab2..09f7ee7 100644 --- a/test-tool/0424_reserve6_target_reset.c +++ b/test-tool/0424_reserve6_target_reset.c @@ -40,7 +40,7 @@ static void mgmt_cb(struct iscsi_context *iscsi _U_, int status _U_, int T0424_reserve6_target_reset(const char *initiator, const char *url, int data_loss _U_, int show_info) { - struct iscsi_context *iscsi, *iscsi2; + struct iscsi_context *iscsi = NULL, *iscsi2 = NULL; struct scsi_task *task; int ret, lun; struct mgmt_task mgmt_task = {0, 0}; @@ -98,52 +98,24 @@ int T0424_reserve6_target_reset(const char *initiator, const char *url, iscsi_get_error(iscsi)); ret = -1; scsi_free_scsi_task(task); - goto test2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - -test2: - printf("Verify we can access the LUN from the first initiator ... "); - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi)); - ret = -1; goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi)); - ret = -1; - scsi_free_scsi_task(task); - goto test3; - } scsi_free_scsi_task(task); printf("[OK]\n"); -test3: - printf("Verify we can NOT access the LUN from the second initiator ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; + printf("Verify we can access the LUN from the first initiator.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { goto finished; } - if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { - printf("[FAILED]\n"); - printf("Expected RESERVATION CONFLICT\n"); - ret = -1; - scsi_free_scsi_task(task); + + + printf("Verify we can NOT access the LUN from the second initiator.\n"); + ret = testunitready_conflict(iscsi2, lun); + if (ret != 0) { goto finished; } - scsi_free_scsi_task(task); - printf("[OK]\n"); printf("Send a Target Cold-Reset ... "); iscsi_task_mgmt_target_cold_reset_async(iscsi, mgmt_cb, &mgmt_task); @@ -167,42 +139,33 @@ test3: } printf("[OK]\n"); -test5: + /* We might be getting UNIT_ATTENTION/BUS_RESET after the lun-reset above. If so just loop and try the TESTUNITREADY again until it clears */ + printf("Use TESTUNITREADY and clear any unit attentions on the second initiator.\n"); +again: + ret = testunitready(iscsi2, lun); + if (ret != 0) { + goto again; + } + + printf("Verify we can access the LUN from the second initiator ... "); - task = iscsi_testunitready_sync(iscsi2, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", - iscsi_get_error(iscsi2)); - ret = -1; + ret = testunitready(iscsi2, lun); + if (ret != 0) { goto finished; } - if (task->status == SCSI_STATUS_CHECK_CONDITION - && task->sense.key == SCSI_SENSE_UNIT_ATTENTION - && task->sense.ascq == SCSI_SENSE_ASCQ_BUS_RESET) { - printf("Got BUS RESET. Retry accessing the LUN\n"); - goto test5; - - } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", - iscsi_get_error(iscsi2)); - ret = -1; - scsi_free_scsi_task(task); - goto test3; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); finished: - iscsi_logout_sync(iscsi); - iscsi_destroy_context(iscsi); - iscsi_logout_sync(iscsi2); - iscsi_destroy_context(iscsi2); + if (iscsi2 != NULL) { + iscsi_logout_sync(iscsi2); + iscsi_destroy_context(iscsi2); + } + if (iscsi != NULL) { + iscsi_logout_sync(iscsi); + iscsi_destroy_context(iscsi); + } return ret; } diff --git a/test-tool/1031_unsolicited_data_out.c b/test-tool/1031_unsolicited_data_out.c index 7c823ae..986276a 100644 --- a/test-tool/1031_unsolicited_data_out.c +++ b/test-tool/1031_unsolicited_data_out.c @@ -230,30 +230,18 @@ int T1031_unsolicited_data_out(const char *initiator, const char *url, goto finished; } } + printf("[OK]\n"); /* Send a TUR to drive the eventsystem and make sure the * DATA-OUT PDUs are flushed */ - task = iscsi_testunitready_sync(iscsi, lun); - if (task == NULL) { - printf("[FAILED]\n"); - printf("Failed to send TEST UNIT READY command: %s\n", iscsi_get_error(iscsi)); - ret++; - goto test2; + printf("Send a TESTUNITREADY and flush tx queue.\n"); + ret = testunitready(iscsi, lun); + if (ret != 0) { + goto finished; } - if (task->status != SCSI_STATUS_GOOD) { - printf("[FAILED]\n"); - printf("TEST UNIT READY command: failed with sense %s\n", iscsi_get_error(iscsi)); - ret++; - scsi_free_scsi_task(task); - goto test2; - } - scsi_free_scsi_task(task); - printf("[OK]\n"); - -test2: printf("Verify the target is still alive ... "); iscsi2 = iscsi_context_login(initiator, url, &lun); if (iscsi2 == NULL) { diff --git a/test-tool/iscsi-test.c b/test-tool/iscsi-test.c index ddf686b..6ee9c63 100644 --- a/test-tool/iscsi-test.c +++ b/test-tool/iscsi-test.c @@ -772,6 +772,28 @@ int testunitready_nomedium(struct iscsi_context *iscsi, int lun) return 0; } +int testunitready_conflict(struct iscsi_context *iscsi, int lun) +{ + struct scsi_task *task; + + printf("Send TESTUNITREADY expecting it to fail with RESERVATION_CONFLICT ... "); + task = iscsi_testunitready_sync(iscsi, lun); + if (task == NULL) { + printf("[FAILED]\n"); + printf("Failed to send TESTUNITREADY command: %s\n", + iscsi_get_error(iscsi)); + return -1; + } + if (task->status != SCSI_STATUS_RESERVATION_CONFLICT) { + printf("[FAILED]\n"); + printf("Expected RESERVATION CONFLICT\n"); + return -1; + } + scsi_free_scsi_task(task); + printf("[OK]\n"); + return 0; +} + int main(int argc, const char *argv[]) { poptContext pc; diff --git a/test-tool/iscsi-test.h b/test-tool/iscsi-test.h index 7ec134f..786adb6 100644 --- a/test-tool/iscsi-test.h +++ b/test-tool/iscsi-test.h @@ -254,5 +254,6 @@ int verify_reserved_as(struct iscsi_context *iscsi, int lun, unsigned long long key, struct resvn_type_info *rtip); int testunitready(struct iscsi_context *iscsi, int lun); int testunitready_nomedium(struct iscsi_context *iscsi, int lun); +int testunitready_conflict(struct iscsi_context *iscsi, int lun); #endif /* _ISCSI_TEST_H_ */