From cf0ccd839f4c48687099f68a6f7b47402d50c9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20K=C3=A4mpf?= Date: Fri, 5 Jan 2024 20:13:46 +0100 Subject: [PATCH] Test sector size setting via ModeSelect in SCSICD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Klaus Kämpf --- cpp/test/mocks.h | 1 + cpp/test/scsicd_test.cpp | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cpp/test/mocks.h b/cpp/test/mocks.h index 3fefdb40..919afd8d 100644 --- a/cpp/test/mocks.h +++ b/cpp/test/mocks.h @@ -387,6 +387,7 @@ class MockSCSICD : public SCSICD //NOSONAR Ignore inheritance hierarchy depth in FRIEND_TEST(ScsiCdTest, GetSectorSizes); FRIEND_TEST(ScsiCdTest, SetUpModePages); FRIEND_TEST(ScsiCdTest, ReadToc); + FRIEND_TEST(ScsiCdTest, ModeSelect); using SCSICD::SCSICD; }; diff --git a/cpp/test/scsicd_test.cpp b/cpp/test/scsicd_test.cpp index b4c9154f..4ebe3ce2 100644 --- a/cpp/test/scsicd_test.cpp +++ b/cpp/test/scsicd_test.cpp @@ -133,3 +133,26 @@ TEST(ScsiCdTest, ReadToc) // Further testing requires filesystem access } + +TEST(ScsiCdTest, ModeSelect) +{ + MockSCSICD cd(0); + vector cmd(6); + vector 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"; +}