mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 08:29:59 +00:00
Don't ResizeCache on sector change if no filename is defined (#1438)
* Add tests for issue#1426 Signed-off-by: Klaus Kämpf <kkaempf@gmail.com> * add test without medium Signed-off-by: Klaus Kämpf <kkaempf@gmail.com> * Don't resize DiskCache without a file DiskCache computes its size from a file. Skip ResizeCache Without file (i.e. 'empty' CD) Fixes #1426 Signed-off-by: Klaus Kämpf <kkaempf@gmail.com>
This commit is contained in:
parent
24372ba939
commit
dd9a3296d4
@ -179,7 +179,11 @@ void SCSICD::ModeSelect(scsi_command cmd, cdb_t cdb, span<const uint8_t> buf, in
|
||||
ClearTrack();
|
||||
CreateDataTrack();
|
||||
FlushCache();
|
||||
ResizeCache(GetFilename(), GetRawMode());
|
||||
string filename;
|
||||
if ((filename = GetFilename()) != "") {
|
||||
// DiskCache fails without a file to compute the cache size
|
||||
ResizeCache(filename, GetRawMode());
|
||||
}
|
||||
}
|
||||
|
||||
if (const string result = scsi_command_util::ModeSelect(cmd, cdb, buf, length, sector_size);
|
||||
|
@ -137,9 +137,11 @@ TEST(ScsiCdTest, ReadToc)
|
||||
TEST(ScsiCdTest, ModeSelect)
|
||||
{
|
||||
MockSCSICD cd(0);
|
||||
MockSCSICD cd1(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();
|
||||
@ -157,7 +159,30 @@ TEST(ScsiCdTest, ModeSelect)
|
||||
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
|
||||
// 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 - ModeSelect10
|
||||
buf[10] = 0x02;
|
||||
EXPECT_NO_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect10, cmd, buf, 255)) << "MODE SELECT(10) with sector size 512 is supported";
|
||||
|
||||
// unsupported sector size - ModeSelect6
|
||||
buf[10] = 0x04;
|
||||
EXPECT_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255), io_exception) << "MODE SELECT(6) with sector size 1024 is unsupported";
|
||||
|
||||
// sector size not multiple of 512 - ModeSelect6
|
||||
buf[10] = 0x03;
|
||||
EXPECT_THROW(cd.ModeSelect(scsi_command::eCmdModeSelect6, cmd, buf, 255), io_exception) << "MODE SELECT(6) with sector size 768 is unsupported";
|
||||
|
||||
// cd1 has no dummy file attached, simulating an empty CD drive
|
||||
cd1.SetSectorSizeInBytes(2048);
|
||||
|
||||
// 512 bytes per sector - ModeSelect6
|
||||
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";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user