Skip to content

Commit

Permalink
Add test for sequential repeated MODE SELECT(6) sector size change
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmark committed Mar 20, 2024
1 parent dd9a329 commit ac4a684
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions cpp/test/scsicd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,53 @@ TEST(ScsiCdTest, ModeSelect)
buf[10] = 0x02;
EXPECT_NO_THROW(cd1.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6), emtpy drive, with sector size 512 is supported";
}

TEST(ScsiCdTest, ModeSelectSequence)
{
MockSCSICD cd(0);
vector<int> cmd(6);
vector<uint8_t> buf(255);

// dummy file for DiskCache resize after sector size change
path filename = CreateTempFile(2* 2048);
cd.SetFilename(string(filename));
cd.Open();
EXPECT_EQ(2, cd.GetBlockCount());

cd.SetSectorSizeInBytes(2048);

// PF
cmd[1] = 0x10;
// Length
buf[3] = 0x08;
// 2048 bytes per sector
buf[10] = 0x08;
// Page 3 (Device Format Page)
buf[12] = 0x01;
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 2048 is supported";

// 512 bytes per sector - ModeSelect6
buf[10] = 0x02;
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 512 is supported";

// 2048 bytes per sector - ModeSelect6
buf[10] = 0x08;
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 2048 is supported";

// 512 bytes per sector - ModeSelect6
buf[10] = 0x02;
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 512 is supported";

// 2048 bytes per sector - ModeSelect6
buf[10] = 0x08;
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 2048 is supported";

// 512 bytes per sector - ModeSelect6
buf[10] = 0x02;
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 512 is supported";

// 2048 bytes per sector - ModeSelect6
buf[10] = 0x08;
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 2048 is supported";

}

0 comments on commit ac4a684

Please sign in to comment.