2022-10-08 17:26:04 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "mocks.h"
|
2022-10-23 19:51:39 +00:00
|
|
|
#include "rascsi_exceptions.h"
|
2022-10-08 17:26:04 +00:00
|
|
|
|
|
|
|
TEST(ScsiCdTest, Inquiry)
|
|
|
|
{
|
2022-10-23 19:51:39 +00:00
|
|
|
TestInquiry(SCCD, device_type::CD_ROM, scsi_level::SCSI_2, "RaSCSI SCSI CD-ROM ", 0x1f, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ScsiCdTest, Dispatch)
|
|
|
|
{
|
|
|
|
TestDispatch(SCCD);
|
2022-10-08 17:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ScsiCdTest, SetUpModePages)
|
|
|
|
{
|
2022-10-23 19:51:39 +00:00
|
|
|
map<int, vector<byte>> pages;
|
2022-10-08 17:26:04 +00:00
|
|
|
const unordered_set<uint32_t> sector_sizes;
|
|
|
|
MockSCSICD cd(0, sector_sizes);
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
cd.SetUpModePages(pages, 0x3f, false);
|
|
|
|
EXPECT_EQ(7, pages.size()) << "Unexpected number of mode pages";
|
|
|
|
EXPECT_EQ(12, pages[1].size());
|
|
|
|
EXPECT_EQ(24, pages[3].size());
|
|
|
|
EXPECT_EQ(24, pages[4].size());
|
|
|
|
EXPECT_EQ(12, pages[8].size());
|
|
|
|
EXPECT_EQ(8, pages[13].size());
|
|
|
|
EXPECT_EQ(16, pages[14].size());
|
|
|
|
EXPECT_EQ(30, pages[48].size());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ScsiCdTest, ReadToc)
|
|
|
|
{
|
2022-10-25 00:21:40 +00:00
|
|
|
MockAbstractController controller(make_shared<MockBus>(), 0);
|
2022-10-23 19:51:39 +00:00
|
|
|
const unordered_set<uint32_t> sector_sizes;
|
|
|
|
auto cd = make_shared<MockSCSICD>(0, sector_sizes);
|
|
|
|
|
|
|
|
controller.AddDevice(cd);
|
|
|
|
|
|
|
|
EXPECT_THROW(cd->Dispatch(scsi_command::eCmdReadToc), scsi_exception) << "Drive is not ready";
|
|
|
|
|
|
|
|
// Further testing requires filesystem access
|
2022-10-08 17:26:04 +00:00
|
|
|
}
|