Merge pull request #171 from rodrigc/fix2

test_modesense6_control_swp: skip test if target cannot change swp
This commit is contained in:
Ronnie Sahlberg
2015-06-04 00:13:37 -07:00
2 changed files with 13 additions and 1 deletions

View File

@@ -2407,7 +2407,9 @@ int set_swp(struct scsi_device *sdev)
struct scsi_mode_page *mp;
logging(LOG_VERBOSE, "Read CONTROL page");
ret = modesense6(sdev, &sense_task, 1, SCSI_MODESENSE_PC_CURRENT,
/* see if we can even change swp */
ret = modesense6(sdev, &sense_task, 1, SCSI_MODESENSE_PC_CHANGEABLE,
SCSI_MODEPAGE_CONTROL, 0, 255,
EXPECT_STATUS_GOOD);
if (ret) {
@@ -2423,6 +2425,12 @@ int set_swp(struct scsi_device *sdev)
ret = -1;
goto finished;
}
/* if we cannot change swp, we are done here */
if (ms->pages->control.swp == 0) {
logging(LOG_NORMAL, "SWP is not changeable");
ret = -2;
goto finished;
}
mp = scsi_modesense_get_page(ms, SCSI_MODEPAGE_CONTROL, 0);
if (mp == NULL) {
logging(LOG_NORMAL, "failed to read control mode page");

View File

@@ -43,6 +43,10 @@ test_modesense6_control_swp(void)
logging(LOG_VERBOSE, "Set SWP to enable write protect");
ret = set_swp(sd);
if (ret == -2) {
CU_PASS("[SKIPPED] Target does not support changing SWP");
return;
}
CU_ASSERT_EQUAL(ret, 0);
if (ret) {
goto finished;