Skip to content

Commit

Permalink
Test sector size setting via ModeSelect in SCSICD
Browse files Browse the repository at this point in the history
Signed-off-by: Klaus Kämpf <[email protected]>
  • Loading branch information
kkaempf committed Jan 5, 2024
1 parent a60d040 commit ecb45d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions cpp/test/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ class MockSCSICD : public SCSICD //NOSONAR Ignore inheritance hierarchy depth in
{
FRIEND_TEST(ScsiCdTest, SetUpModePages);
FRIEND_TEST(ScsiCdTest, ReadToc);
FRIEND_TEST(ScsiCdTest, ModeSelect);

using SCSICD::SCSICD;
};
Expand Down
23 changes: 23 additions & 0 deletions cpp/test/scsicd_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,26 @@ TEST(ScsiCdTest, ReadToc)

// Further testing requires filesystem access
}

TEST(ScsiCdTest, ModeSelect)
{
MockSCSICD cd(0, { 512, 2048 });
vector<int> cmd(6);
vector<uint8_t> buf(255);

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
buf[10] = 0x02;
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255)) << "MODE SELECT(6) with sector size 512 is supported";
}

0 comments on commit ecb45d3

Please sign in to comment.