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 16:53:53 +02:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gmock/gmock.h>
|
|
|
|
|
|
|
|
#include "controllers/controller_manager.h"
|
|
|
|
#include "devices/device_factory.h"
|
|
|
|
#include "devices/primary_device.h"
|
|
|
|
#include "devices/scsihd.h"
|
|
|
|
#include "devices/scsihd_nec.h"
|
|
|
|
#include "devices/scsicd.h"
|
|
|
|
#include "devices/scsimo.h"
|
|
|
|
#include "devices/host_services.h"
|
|
|
|
|
|
|
|
// Note that these global variables are convenient,
|
|
|
|
// but might cause issues because they are reused by all tests
|
|
|
|
extern DeviceFactory& device_factory;
|
|
|
|
extern ControllerManager& controller_manager;
|
|
|
|
|
|
|
|
class MockAbstractController : public AbstractController
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
MOCK_METHOD(BUS::phase_t, Process, (int), (override));
|
|
|
|
MOCK_METHOD(int, GetEffectiveLun, (), (const override));
|
|
|
|
MOCK_METHOD(void, Error, (scsi_defs::sense_key, scsi_defs::asc, scsi_defs::status), (override));
|
|
|
|
MOCK_METHOD(int, GetInitiatorId, (), (const override));
|
|
|
|
MOCK_METHOD(void, SetUnit, (int), ());
|
|
|
|
MOCK_METHOD(void, Connect, (int, BUS *), ());
|
|
|
|
MOCK_METHOD(void, Status, (), ());
|
|
|
|
MOCK_METHOD(void, DataIn, (), ());
|
|
|
|
MOCK_METHOD(void, DataOut, (), ());
|
|
|
|
MOCK_METHOD(void, BusFree, (), ());
|
|
|
|
MOCK_METHOD(void, Selection, (), ());
|
|
|
|
MOCK_METHOD(void, Command, (), ());
|
|
|
|
MOCK_METHOD(void, MsgIn, (), ());
|
|
|
|
MOCK_METHOD(void, MsgOut, (), ());
|
|
|
|
MOCK_METHOD(void, Send, (), ());
|
|
|
|
MOCK_METHOD(bool, XferMsg, (int), ());
|
|
|
|
MOCK_METHOD(bool, XferIn, (BYTE *), ());
|
|
|
|
MOCK_METHOD(bool, XferOut, (bool), ());
|
|
|
|
MOCK_METHOD(void, ReceiveBytes, (), ());
|
|
|
|
MOCK_METHOD(void, Execute, (), ());
|
|
|
|
MOCK_METHOD(void, FlushUnit, (), ());
|
|
|
|
MOCK_METHOD(void, Receive, (), ());
|
|
|
|
MOCK_METHOD(bool, HasUnit, (), (const override));
|
|
|
|
MOCK_METHOD(int, GetMaxLuns, (), (const override));
|
|
|
|
MOCK_METHOD(void, SetByteTransfer, (bool), (override));
|
|
|
|
MOCK_METHOD(void, ScheduleShutdown, (rascsi_shutdown_mode), (override));
|
|
|
|
MOCK_METHOD(void, SetPhase, (BUS::phase_t), (override));
|
|
|
|
MOCK_METHOD(void, Reset, (), (override));
|
|
|
|
|
2022-09-07 16:38:42 +02:00
|
|
|
explicit MockAbstractController(int target_id) : AbstractController(nullptr, target_id) {}
|
2022-09-10 07:59:41 +02:00
|
|
|
~MockAbstractController() final = default;
|
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 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MockScsiController : public ScsiController
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
MOCK_METHOD(BUS::phase_t, Process, (int), (override));
|
|
|
|
MOCK_METHOD(void, Error, (scsi_defs::sense_key, scsi_defs::asc, scsi_defs::status), (override));
|
|
|
|
MOCK_METHOD(int, GetInitiatorId, (), (const override));
|
|
|
|
MOCK_METHOD(void, SetUnit, (int), ());
|
|
|
|
MOCK_METHOD(void, Connect, (int, BUS *), ());
|
|
|
|
MOCK_METHOD(void, Status, (), ());
|
|
|
|
MOCK_METHOD(void, DataIn, (), ());
|
|
|
|
MOCK_METHOD(void, DataOut, (), ());
|
|
|
|
MOCK_METHOD(void, BusFree, (), ());
|
|
|
|
MOCK_METHOD(void, Selection, (), ());
|
|
|
|
MOCK_METHOD(void, Command, (), ());
|
|
|
|
MOCK_METHOD(void, MsgIn, (), ());
|
|
|
|
MOCK_METHOD(void, MsgOut, (), ());
|
|
|
|
MOCK_METHOD(void, Send, (), ());
|
|
|
|
MOCK_METHOD(bool, XferMsg, (int), ());
|
|
|
|
MOCK_METHOD(bool, XferIn, (BYTE *), ());
|
|
|
|
MOCK_METHOD(bool, XferOut, (bool), ());
|
|
|
|
MOCK_METHOD(void, ReceiveBytes, (), ());
|
|
|
|
MOCK_METHOD(void, Execute, (), ());
|
|
|
|
MOCK_METHOD(void, FlushUnit, (), ());
|
|
|
|
MOCK_METHOD(void, Receive, (), ());
|
|
|
|
MOCK_METHOD(bool, HasUnit, (), (const override));
|
|
|
|
MOCK_METHOD(void, SetPhase, (BUS::phase_t), (override));
|
|
|
|
MOCK_METHOD(void, Sleep, (), ());
|
|
|
|
|
|
|
|
FRIEND_TEST(PrimaryDeviceTest, UnitReady);
|
|
|
|
FRIEND_TEST(PrimaryDeviceTest, Inquiry);
|
|
|
|
FRIEND_TEST(PrimaryDeviceTest, RequestSense);
|
|
|
|
FRIEND_TEST(PrimaryDeviceTest, ReportLuns);
|
|
|
|
FRIEND_TEST(PrimaryDeviceTest, UnknownCommand);
|
|
|
|
|
2022-09-10 07:59:41 +02:00
|
|
|
using ScsiController::ScsiController;
|
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 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MockPrimaryDevice : public PrimaryDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
MOCK_METHOD(vector<BYTE>, InquiryInternal, (), (const));
|
|
|
|
|
|
|
|
MockPrimaryDevice() : PrimaryDevice("test") {}
|
2022-09-10 07:59:41 +02:00
|
|
|
~MockPrimaryDevice() final = default;
|
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 16:53:53 +02:00
|
|
|
|
|
|
|
// Make protected methods visible for testing
|
|
|
|
|
|
|
|
void SetReady(bool ready) { PrimaryDevice::SetReady(ready); }
|
|
|
|
void SetReset(bool reset) { PrimaryDevice::SetReset(reset); }
|
|
|
|
void SetAttn(bool attn) { PrimaryDevice::SetAttn(attn); }
|
|
|
|
vector<BYTE> HandleInquiry(device_type type, scsi_level level, bool is_removable) const {
|
|
|
|
return PrimaryDevice::HandleInquiry(type, level, is_removable);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class MockModePageDevice : public ModePageDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2022-09-07 16:38:42 +02:00
|
|
|
MockModePageDevice() : ModePageDevice("test") {}
|
2022-09-10 07:59:41 +02:00
|
|
|
~MockModePageDevice() final = default;
|
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 16:53:53 +02:00
|
|
|
|
|
|
|
MOCK_METHOD(vector<BYTE>, InquiryInternal, (), (const));
|
|
|
|
MOCK_METHOD(int, ModeSense6, (const DWORD *, BYTE *, int), ());
|
|
|
|
MOCK_METHOD(int, ModeSense10, (const DWORD *, BYTE *, int), ());
|
|
|
|
|
|
|
|
void AddModePages(map<int, vector<BYTE>>& pages, int page, bool) const override {
|
|
|
|
// Return dummy data for other pages than page 0
|
|
|
|
if (page) {
|
|
|
|
vector<BYTE> buf(255);
|
|
|
|
pages[page] = buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make protected methods visible for testing
|
|
|
|
// TODO Why does FRIEND_TEST not work for this method?
|
|
|
|
|
2022-09-15 23:01:10 +02:00
|
|
|
int AddModePages(const DWORD *cdb, BYTE *buf, int max_length) const {
|
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 16:53:53 +02:00
|
|
|
return ModePageDevice::AddModePages(cdb, buf, max_length);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class MockSCSIHD : public SCSIHD
|
|
|
|
{
|
|
|
|
FRIEND_TEST(ModePagesTest, SCSIHD_AddModePages);
|
|
|
|
|
2022-09-07 16:38:42 +02:00
|
|
|
explicit MockSCSIHD(const unordered_set<uint32_t>& sector_sizes) : SCSIHD(sector_sizes, false) {}
|
2022-09-10 07:59:41 +02:00
|
|
|
~MockSCSIHD() final = default;
|
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 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MockSCSIHD_NEC : public SCSIHD_NEC
|
|
|
|
{
|
|
|
|
FRIEND_TEST(ModePagesTest, SCSIHD_NEC_AddModePages);
|
|
|
|
|
2022-09-07 16:38:42 +02:00
|
|
|
MockSCSIHD_NEC() = default;
|
2022-09-10 07:59:41 +02:00
|
|
|
~MockSCSIHD_NEC() final = default;
|
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 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MockSCSICD : public SCSICD
|
|
|
|
{
|
|
|
|
FRIEND_TEST(ModePagesTest, SCSICD_AddModePages);
|
|
|
|
|
2022-09-07 16:38:42 +02:00
|
|
|
explicit MockSCSICD(const unordered_set<uint32_t>& sector_sizes) : SCSICD(sector_sizes) {}
|
2022-09-10 07:59:41 +02:00
|
|
|
~MockSCSICD() final = default;
|
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 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MockSCSIMO : public SCSIMO
|
|
|
|
{
|
|
|
|
FRIEND_TEST(ModePagesTest, SCSIMO_AddModePages);
|
|
|
|
|
|
|
|
MockSCSIMO(const unordered_set<uint32_t>& sector_sizes, const unordered_map<uint64_t, Geometry>& geometries)
|
2022-09-07 16:38:42 +02:00
|
|
|
: SCSIMO(sector_sizes, geometries) {}
|
2022-09-10 07:59:41 +02:00
|
|
|
~MockSCSIMO() final = default;
|
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 16:53:53 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class MockHostServices : public HostServices
|
|
|
|
{
|
|
|
|
FRIEND_TEST(ModePagesTest, HostServices_AddModePages);
|
|
|
|
|
2022-09-07 16:38:42 +02:00
|
|
|
MockHostServices() = default;
|
2022-09-10 07:59:41 +02:00
|
|
|
~MockHostServices() final = default;
|
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 16:53:53 +02:00
|
|
|
};
|