2022-08-28 17:25:08 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-08-28 17:25:08 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
2023-10-15 06:38:15 +00:00
|
|
|
// Copyright (C) 2022-2023 Uwe Seimet
|
2022-08-28 17:25:08 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
#include "mocks.h"
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "shared/piscsi_exceptions.h"
|
|
|
|
#include "shared/piscsi_version.h"
|
2022-10-04 15:23:42 +00:00
|
|
|
#include "controllers/controller_manager.h"
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
#include "devices/device.h"
|
|
|
|
#include "devices/device_factory.h"
|
2022-10-01 15:56:06 +00:00
|
|
|
#include <unordered_map>
|
2022-08-28 17:25:08 +00:00
|
|
|
|
|
|
|
TEST(DeviceFactoryTest, GetTypeForFile)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2022-09-08 02:45:00 +00:00
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.hd1"), SCHD);
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.hds"), SCHD);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.HDS"), SCHD);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.hda"), SCHD);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.hdn"), SCHD);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.hdi"), SCHD);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.nhd"), SCHD);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.hdr"), SCRM);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.mos"), SCMO);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.iso"), SCCD);
|
2023-02-27 02:52:19 +00:00
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.is1"), SCCD);
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.suffix.iso"), SCCD);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("bridge"), SCBR);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("daynaport"), SCDP);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("printer"), SCLP);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("services"), SCHS);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("unknown"), UNDEFINED);
|
|
|
|
EXPECT_EQ(device_factory.GetTypeForFile("test.iso.suffix"), UNDEFINED);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceFactoryTest, GetSectorSizes)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
2022-08-28 17:25:08 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
unordered_set<uint32_t> sector_sizes = device_factory.GetSectorSizes(SCHD);
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_EQ(4, sector_sizes.size());
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(sector_sizes.contains(512));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(1024));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(2048));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(4096));
|
2022-08-28 17:25:08 +00:00
|
|
|
|
|
|
|
sector_sizes = device_factory.GetSectorSizes(SCRM);
|
|
|
|
EXPECT_EQ(4, sector_sizes.size());
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(sector_sizes.contains(512));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(1024));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(2048));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(4096));
|
2022-08-28 17:25:08 +00:00
|
|
|
|
|
|
|
sector_sizes = device_factory.GetSectorSizes(SCMO);
|
|
|
|
EXPECT_EQ(4, sector_sizes.size());
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(sector_sizes.contains(512));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(1024));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(2048));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(4096));
|
2022-08-28 17:25:08 +00:00
|
|
|
|
|
|
|
sector_sizes = device_factory.GetSectorSizes(SCCD);
|
|
|
|
EXPECT_EQ(2, sector_sizes.size());
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(sector_sizes.contains(512));
|
|
|
|
EXPECT_TRUE(sector_sizes.contains(2048));
|
2022-08-28 17:25:08 +00:00
|
|
|
}
|
|
|
|
|
2022-10-01 15:56:06 +00:00
|
|
|
TEST(DeviceFactoryTest, GetExtensionMapping)
|
|
|
|
{
|
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
auto mapping = device_factory.GetExtensionMapping();
|
2023-02-27 02:52:19 +00:00
|
|
|
EXPECT_EQ(10, mapping.size());
|
2022-10-01 15:56:06 +00:00
|
|
|
EXPECT_EQ(SCHD, mapping["hd1"]);
|
|
|
|
EXPECT_EQ(SCHD, mapping["hds"]);
|
|
|
|
EXPECT_EQ(SCHD, mapping["hda"]);
|
|
|
|
EXPECT_EQ(SCHD, mapping["hdn"]);
|
|
|
|
EXPECT_EQ(SCHD, mapping["hdi"]);
|
|
|
|
EXPECT_EQ(SCHD, mapping["nhd"]);
|
|
|
|
EXPECT_EQ(SCRM, mapping["hdr"]);
|
|
|
|
EXPECT_EQ(SCMO, mapping["mos"]);
|
|
|
|
EXPECT_EQ(SCCD, mapping["iso"]);
|
2023-02-27 02:52:19 +00:00
|
|
|
EXPECT_EQ(SCCD, mapping["is1"]);
|
2022-10-01 15:56:06 +00:00
|
|
|
}
|
|
|
|
|
2022-08-28 17:25:08 +00:00
|
|
|
TEST(DeviceFactoryTest, UnknownDeviceType)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device1 = device_factory.CreateDevice(UNDEFINED, 0, "test");
|
2022-10-01 15:56:06 +00:00
|
|
|
EXPECT_EQ(nullptr, device1);
|
|
|
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device2 = device_factory.CreateDevice(SAHD, 0, "test");
|
2022-10-01 15:56:06 +00:00
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
EXPECT_EQ(nullptr, device2);
|
2022-08-28 17:25:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceFactoryTest, SCHD_Device_Defaults)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(UNDEFINED, 0, "test.hda");
|
|
|
|
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCHD, device->GetType());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_TRUE(device->SupportsFile());
|
|
|
|
EXPECT_FALSE(device->SupportsParams());
|
|
|
|
EXPECT_TRUE(device->IsProtectable());
|
|
|
|
EXPECT_FALSE(device->IsProtected());
|
|
|
|
EXPECT_FALSE(device->IsReadOnly());
|
|
|
|
EXPECT_FALSE(device->IsRemovable());
|
|
|
|
EXPECT_FALSE(device->IsRemoved());
|
|
|
|
EXPECT_FALSE(device->IsLockable());
|
|
|
|
EXPECT_FALSE(device->IsLocked());
|
|
|
|
EXPECT_TRUE(device->IsStoppable());
|
|
|
|
EXPECT_FALSE(device->IsStopped());
|
|
|
|
|
|
|
|
EXPECT_EQ("QUANTUM", device->GetVendor()) << "Invalid default vendor for Apple drive";
|
|
|
|
EXPECT_EQ("FIREBALL", device->GetProduct()) << "Invalid default vendor for Apple drive";
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ(string(piscsi_get_version_string()).substr(0, 2) + string(piscsi_get_version_string()).substr(3, 2),
|
2022-08-28 17:25:08 +00:00
|
|
|
device->GetRevision());
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
device = device_factory.CreateDevice(UNDEFINED, 0, "test.hds");
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCHD, device->GetType());
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
device = device_factory.CreateDevice(UNDEFINED, 0, "test.hdi");
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCHD, device->GetType());
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
device = device_factory.CreateDevice(UNDEFINED, 0, "test.nhd");
|
SASI code removal, error handling update, bug fixes, code cleanup (#806)
Summary ov most important changes triggered by the SASI code removal:
- Removed the SASI controller code
- New controller management. There is a new controller base class AbstractController and a class ControllerManager managing the controller lifecycle. The lifecycle management was removed from rasci.cpp and is covered by unit tests.
- New device management. The DeviceFactory manages the device lifecycle instead of rascsi.cpp. The new code is covered by unit tests.
- The lifecycle managment uses C++ collections with variable size instead of arrays with hard-coded sizes.
- The ScsiController method contains most of what was previously contained in scsidev_ctrl.cpp plus the code from sasidev_ctrl.cpp that was relevant for SCSI.
- scsi_command_util contains helper methods used for identical SCSI command implementations of more than one device
- Devices know their controllers, so that the controller instance does not need to be passed to each SCSI command. This change helps to decouple the devices from the controller. The phase_handler interface is also part of this decoupling.
- Use scsi_command_exception for propagating SCSI command execution errors, This resolves issues with the previous error handling, which was based on return values and often on magic numbers.
- Removed legacy SCSI error codes, all errors are now encoded by sense_key::, asc:: and status::.
- Fixed various warnings reported with -Wextra, -Weffc++ and -Wpedantic.
- Use constructor member initialization lists (recommended for ISO C++)
- Consistently use new/delete instead of malloc/free (recommended for ISO C++), resulting in better type safety and error handling
- Replaced variable sized arrays on the stack (violates ISO C++ and can cause a stack overflow)
- Replaced NULL by nullptr (recommended for C++), resulting in better type safety
- Use more const member functions in order to avoid side effects
- The format device page can now also be changed for hard disk drives (Fujitsu M2624S supports this, for instance), not just for MOs.
- Better encapsulation, updated access specifiers in many places
- Removed unused methods and method arguments
- Fixed a number of TODOs
- Added/updated unit tests for a lot of non-legacy classes
- Makefile support for creating HTML coverage reports with lcov/genhtml
2022-09-03 14:53:53 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCHD, device->GetType());
|
2022-08-28 17:25:08 +00:00
|
|
|
}
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
void TestRemovableDrive(PbDeviceType type, const string& filename, const string& product)
|
2022-08-28 17:25:08 +00:00
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(UNDEFINED, 0, filename);
|
2022-11-02 14:36:19 +00:00
|
|
|
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_EQ(type, device->GetType());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_TRUE(device->SupportsFile());
|
|
|
|
EXPECT_FALSE(device->SupportsParams());
|
|
|
|
EXPECT_TRUE(device->IsProtectable());
|
|
|
|
EXPECT_FALSE(device->IsProtected());
|
|
|
|
EXPECT_FALSE(device->IsReadOnly());
|
|
|
|
EXPECT_TRUE(device->IsRemovable());
|
|
|
|
EXPECT_FALSE(device->IsRemoved());
|
|
|
|
EXPECT_TRUE(device->IsLockable());
|
|
|
|
EXPECT_FALSE(device->IsLocked());
|
|
|
|
EXPECT_TRUE(device->IsStoppable());
|
|
|
|
EXPECT_FALSE(device->IsStopped());
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ("PiSCSI", device->GetVendor());
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_EQ(product, device->GetProduct());
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ(string(piscsi_get_version_string()).substr(0, 2) + string(piscsi_get_version_string()).substr(3, 2),
|
2022-08-28 17:25:08 +00:00
|
|
|
device->GetRevision());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
TEST(DeviceFactoryTest, SCRM_Device_Defaults)
|
2022-08-28 17:25:08 +00:00
|
|
|
{
|
2022-10-23 19:51:39 +00:00
|
|
|
TestRemovableDrive(SCRM, "test.hdr", "SCSI HD (REM.)");
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
2022-08-28 17:25:08 +00:00
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
TEST(DeviceFactoryTest, SCMO_Device_Defaults)
|
|
|
|
{
|
2022-10-23 19:51:39 +00:00
|
|
|
TestRemovableDrive(SCMO, "test.mos", "SCSI MO");
|
2022-08-28 17:25:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceFactoryTest, SCCD_Device_Defaults)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(UNDEFINED, 0, "test.iso");
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCCD, device->GetType());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_TRUE(device->SupportsFile());
|
|
|
|
EXPECT_FALSE(device->SupportsParams());
|
|
|
|
EXPECT_FALSE(device->IsProtectable());
|
|
|
|
EXPECT_FALSE(device->IsProtected());
|
|
|
|
EXPECT_TRUE(device->IsReadOnly());
|
|
|
|
EXPECT_TRUE(device->IsRemovable());
|
|
|
|
EXPECT_FALSE(device->IsRemoved());
|
|
|
|
EXPECT_TRUE(device->IsLockable());
|
|
|
|
EXPECT_FALSE(device->IsLocked());
|
|
|
|
EXPECT_TRUE(device->IsStoppable());
|
|
|
|
EXPECT_FALSE(device->IsStopped());
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ("PiSCSI", device->GetVendor());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_EQ("SCSI CD-ROM", device->GetProduct());
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ(string(piscsi_get_version_string()).substr(0, 2) + string(piscsi_get_version_string()).substr(3, 2),
|
2022-08-28 17:25:08 +00:00
|
|
|
device->GetRevision());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceFactoryTest, SCBR_Device_Defaults)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(UNDEFINED, 0, "bridge");
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCBR, device->GetType());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_FALSE(device->SupportsFile());
|
|
|
|
EXPECT_TRUE(device->SupportsParams());
|
|
|
|
EXPECT_FALSE(device->IsProtectable());
|
|
|
|
EXPECT_FALSE(device->IsProtected());
|
|
|
|
EXPECT_FALSE(device->IsReadOnly());
|
|
|
|
EXPECT_FALSE(device->IsRemovable());
|
|
|
|
EXPECT_FALSE(device->IsRemoved());
|
|
|
|
EXPECT_FALSE(device->IsLockable());
|
|
|
|
EXPECT_FALSE(device->IsLocked());
|
|
|
|
EXPECT_FALSE(device->IsStoppable());
|
|
|
|
EXPECT_FALSE(device->IsStopped());
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ("PiSCSI", device->GetVendor());
|
2022-09-22 16:03:36 +00:00
|
|
|
EXPECT_EQ("RASCSI BRIDGE", device->GetProduct());
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ(string(piscsi_get_version_string()).substr(0, 2) + string(piscsi_get_version_string()).substr(3, 2),
|
2022-08-28 17:25:08 +00:00
|
|
|
device->GetRevision());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceFactoryTest, SCDP_Device_Defaults)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(UNDEFINED, 0, "daynaport");
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCDP, device->GetType());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_FALSE(device->SupportsFile());
|
|
|
|
EXPECT_TRUE(device->SupportsParams());
|
|
|
|
EXPECT_FALSE(device->IsProtectable());
|
|
|
|
EXPECT_FALSE(device->IsProtected());
|
|
|
|
EXPECT_FALSE(device->IsReadOnly());
|
|
|
|
EXPECT_FALSE(device->IsRemovable());
|
|
|
|
EXPECT_FALSE(device->IsRemoved());
|
|
|
|
EXPECT_FALSE(device->IsLockable());
|
|
|
|
EXPECT_FALSE(device->IsLocked());
|
|
|
|
EXPECT_FALSE(device->IsStoppable());
|
|
|
|
EXPECT_FALSE(device->IsStopped());
|
|
|
|
|
|
|
|
EXPECT_EQ("Dayna", device->GetVendor());
|
|
|
|
EXPECT_EQ("SCSI/Link", device->GetProduct());
|
|
|
|
EXPECT_EQ("1.4a", device->GetRevision());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceFactoryTest, SCHS_Device_Defaults)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(UNDEFINED, 0, "services");
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCHS, device->GetType());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_FALSE(device->SupportsFile());
|
|
|
|
EXPECT_FALSE(device->SupportsParams());
|
|
|
|
EXPECT_FALSE(device->IsProtectable());
|
|
|
|
EXPECT_FALSE(device->IsProtected());
|
|
|
|
EXPECT_FALSE(device->IsReadOnly());
|
|
|
|
EXPECT_FALSE(device->IsRemovable());
|
|
|
|
EXPECT_FALSE(device->IsRemoved());
|
|
|
|
EXPECT_FALSE(device->IsLockable());
|
|
|
|
EXPECT_FALSE(device->IsLocked());
|
|
|
|
EXPECT_FALSE(device->IsStoppable());
|
|
|
|
EXPECT_FALSE(device->IsStopped());
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ("PiSCSI", device->GetVendor());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_EQ("Host Services", device->GetProduct());
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ(string(piscsi_get_version_string()).substr(0, 2) + string(piscsi_get_version_string()).substr(3, 2),
|
2022-08-28 17:25:08 +00:00
|
|
|
device->GetRevision());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(DeviceFactoryTest, SCLP_Device_Defaults)
|
|
|
|
{
|
2022-09-25 21:49:24 +00:00
|
|
|
DeviceFactory device_factory;
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(UNDEFINED, 0, "printer");
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_NE(nullptr, device);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_EQ(SCLP, device->GetType());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_FALSE(device->SupportsFile());
|
|
|
|
EXPECT_TRUE(device->SupportsParams());
|
|
|
|
EXPECT_FALSE(device->IsProtectable());
|
|
|
|
EXPECT_FALSE(device->IsProtected());
|
|
|
|
EXPECT_FALSE(device->IsReadOnly());
|
|
|
|
EXPECT_FALSE(device->IsRemovable());
|
|
|
|
EXPECT_FALSE(device->IsRemoved());
|
|
|
|
EXPECT_FALSE(device->IsLockable());
|
|
|
|
EXPECT_FALSE(device->IsLocked());
|
|
|
|
EXPECT_FALSE(device->IsStoppable());
|
|
|
|
EXPECT_FALSE(device->IsStopped());
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ("PiSCSI", device->GetVendor());
|
2022-08-28 17:25:08 +00:00
|
|
|
EXPECT_EQ("SCSI PRINTER", device->GetProduct());
|
2022-12-05 17:58:23 +00:00
|
|
|
EXPECT_EQ(string(piscsi_get_version_string()).substr(0, 2) + string(piscsi_get_version_string()).substr(3, 2),
|
2022-08-28 17:25:08 +00:00
|
|
|
device->GetRevision());
|
|
|
|
}
|