Skip to content

Commit

Permalink
Eliminate method
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Oct 19, 2024
1 parent 23ec9fa commit 795e672
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 24 deletions.
7 changes: 0 additions & 7 deletions cpp/base/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ Device::Device(PbDeviceType type, int lun) : type(type), lun(lun)
revision = fmt::format("{0:02}{1:1}{2:1}", s2p_major_version, s2p_minor_version, s2p_revision);
}

void Device::Reset()
{
locked = false;
attn = false;
reset = false;
}

void Device::SetProtected(bool b)
{
if (protectable && !read_only) {
Expand Down
1 change: 0 additions & 1 deletion cpp/base/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Device // NOSONAR The number of fields and methods is justified, the compl
{
return ready;
}
virtual void Reset();

void SetReset(bool b)
{
Expand Down
4 changes: 3 additions & 1 deletion cpp/base/primary_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ void PrimaryDevice::Reset()
{
DiscardReservation();

Device::Reset();
SetReset(false);
SetAttn(false);
SetLocked(false);
}

int PrimaryDevice::GetId() const
Expand Down
2 changes: 1 addition & 1 deletion cpp/base/primary_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PrimaryDevice : public ScsiPrimaryCommands, public Device
bool CheckReservation(int) const;
void DiscardReservation();

void Reset() override;
void Reset();

virtual int ReadData(span<uint8_t>)
{
Expand Down
13 changes: 0 additions & 13 deletions cpp/test/device_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,6 @@ TEST(DeviceTest, GetPaddedName)
EXPECT_EQ("V P R ", device.GetPaddedName());
}

TEST(DeviceTest, Reset)
{
MockDevice device(0);

device.SetLocked(true);
device.SetAttn(true);
device.SetReset(true);
device.Reset();
EXPECT_FALSE(device.IsLocked());
EXPECT_FALSE(device.IsAttn());
EXPECT_FALSE(device.IsReset());
}

TEST(DeviceTest, Start)
{
MockDevice device(0);
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/mocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ class MockDevice : public Device
FRIEND_TEST(DeviceTest, Properties);
FRIEND_TEST(DeviceTest, Params);
FRIEND_TEST(DeviceTest, StatusCode);
FRIEND_TEST(DeviceTest, Reset);
FRIEND_TEST(DeviceTest, Start);
FRIEND_TEST(DeviceTest, Stop);
FRIEND_TEST(DeviceTest, Eject);
Expand All @@ -250,6 +249,7 @@ class MockDevice : public Device

class MockPrimaryDevice : public PrimaryDevice
{
FRIEND_TEST(PrimaryDeviceTest, Reset);
FRIEND_TEST(PrimaryDeviceTest, StatusPhase);
FRIEND_TEST(PrimaryDeviceTest, DataInPhase);
FRIEND_TEST(PrimaryDeviceTest, DataOutPhase);
Expand Down
6 changes: 6 additions & 0 deletions cpp/test/primary_device_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,15 @@ TEST(PrimaryDeviceTest, Reset)
{
auto [controller, device] = CreatePrimaryDevice();

device->SetLocked(true);
device->SetAttn(true);
device->SetReset(true);
EXPECT_NO_THROW(device->Dispatch(scsi_command::cmd_reserve6));
EXPECT_FALSE(device->CheckReservation(1)) << "Device must be reserved for initiator ID 1";
device->Reset();
EXPECT_FALSE(device->IsLocked());
EXPECT_FALSE(device->IsAttn());
EXPECT_FALSE(device->IsReset());
EXPECT_TRUE(device->CheckReservation(1)) << "Device must not be reserved anymore for initiator ID 1";
}

Expand Down

0 comments on commit 795e672

Please sign in to comment.