Validate SCSI error codes (sense key, asc) in unit tests (issue #895) (#950)

This commit is contained in:
Uwe Seimet
2022-10-29 18:16:03 +02:00
committed by GitHub
parent f84a13b3e2
commit 9a4f433baf
10 changed files with 259 additions and 116 deletions
+15 -5
View File
@@ -69,7 +69,9 @@ TEST(HostServicesTest, StartStopUnit)
// START
cmd[4] = 0x01;
EXPECT_THROW(services->Dispatch(scsi_command::eCmdStartStop), scsi_exception);
EXPECT_THAT([&services]() { services->Dispatch(scsi_command::eCmdStartStop); }, Throws<scsi_exception>(AllOf(
Property(&scsi_exception::get_sense_key, sense_key::ILLEGAL_REQUEST),
Property(&scsi_exception::get_asc, asc::INVALID_FIELD_IN_CDB))));
}
TEST(HostServicesTest, ModeSense6)
@@ -79,11 +81,15 @@ TEST(HostServicesTest, ModeSense6)
vector<int>& cmd = controller.GetCmd();
EXPECT_THROW(services->Dispatch(scsi_command::eCmdModeSense6), scsi_exception)
EXPECT_THAT([&services]() { services->Dispatch(scsi_command::eCmdModeSense6); }, Throws<scsi_exception>(AllOf(
Property(&scsi_exception::get_sense_key, sense_key::ILLEGAL_REQUEST),
Property(&scsi_exception::get_asc, asc::INVALID_FIELD_IN_CDB))))
<< "Unsupported mode page was returned";
cmd[2] = 0x20;
EXPECT_THROW(services->Dispatch(scsi_command::eCmdModeSense6), scsi_exception)
EXPECT_THAT([&services]() { services->Dispatch(scsi_command::eCmdModeSense6); }, Throws<scsi_exception>(AllOf(
Property(&scsi_exception::get_sense_key, sense_key::ILLEGAL_REQUEST),
Property(&scsi_exception::get_asc, asc::INVALID_FIELD_IN_CDB))))
<< "Block descriptors are not supported";
cmd[1] = 0x08;
@@ -116,11 +122,15 @@ TEST(HostServicesTest, ModeSense10)
vector<int>& cmd = controller.GetCmd();
EXPECT_THROW(services->Dispatch(scsi_command::eCmdModeSense10), scsi_exception)
EXPECT_THAT([&services]() { services->Dispatch(scsi_command::eCmdModeSense10); }, Throws<scsi_exception>(AllOf(
Property(&scsi_exception::get_sense_key, sense_key::ILLEGAL_REQUEST),
Property(&scsi_exception::get_asc, asc::INVALID_FIELD_IN_CDB))))
<< "Unsupported mode page was returned";
cmd[2] = 0x20;
EXPECT_THROW(services->Dispatch(scsi_command::eCmdModeSense10), scsi_exception)
EXPECT_THAT([&services]() { services->Dispatch(scsi_command::eCmdModeSense10); }, Throws<scsi_exception>(AllOf(
Property(&scsi_exception::get_sense_key, sense_key::ILLEGAL_REQUEST),
Property(&scsi_exception::get_asc, asc::INVALID_FIELD_IN_CDB))))
<< "Block descriptors are not supported";
cmd[1] = 0x08;