Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 8, 2024
1 parent 67d053a commit 6934560
Show file tree
Hide file tree
Showing 13 changed files with 329 additions and 329 deletions.
2 changes: 1 addition & 1 deletion cpp/test/controller_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ TEST(ControllerTest, RequestSense)

device->SetReady(true);
EXPECT_CALL(controller, Status);
EXPECT_NO_THROW(Dispatch(*device, scsi_command::request_sense));
EXPECT_NO_THROW(Dispatch(device, scsi_command::request_sense));
EXPECT_EQ(status_code::good, controller.GetStatus()) << "Wrong CHECK CONDITION for non-existing LUN";
}

Expand Down
38 changes: 19 additions & 19 deletions cpp/test/daynaport_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TEST(DaynaportTest, TestUnitReady)
auto [controller, daynaport] = CreateDevice(SCDP);

EXPECT_CALL(*controller, Status);
EXPECT_NO_THROW(Dispatch(*daynaport, scsi_command::test_unit_ready));
EXPECT_NO_THROW(Dispatch(daynaport, scsi_command::test_unit_ready));
EXPECT_EQ(status_code::good, controller->GetStatus());
}

Expand All @@ -75,17 +75,17 @@ TEST(DaynaportTest, GetMessage6)
controller->SetCdbByte(4, 0x01);
controller->SetCdbByte(5, 0xc0);
controller->GetBuffer()[0] = 0x12;
EXPECT_NO_THROW(Dispatch(*daynaport, scsi_command::get_message_6));
EXPECT_NO_THROW(Dispatch(daynaport, scsi_command::get_message_6));
EXPECT_EQ(0x12, controller->GetBuffer()[0]) << "No data must be returned when trying to read the root sector";

controller->SetCdbByte(4, 0x01);
controller->SetCdbByte(5, 0x80);
EXPECT_NO_THROW(Dispatch(*daynaport, scsi_command::get_message_6));
EXPECT_NO_THROW(Dispatch(daynaport, scsi_command::get_message_6));
EXPECT_EQ(0x12, controller->GetBuffer()[0]) << "No data must be returned when trying to read the root sector";

controller->SetCdbByte(4, 0x00);
controller->SetCdbByte(5, 0xff);
Dispatch(*daynaport, scsi_command::get_message_6, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::get_message_6, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Invalid data format");
}

Expand All @@ -94,24 +94,24 @@ TEST(DaynaportTest, SendMessage6)
auto [controller, daynaport] = CreateDevice(SCDP);

controller->SetCdbByte(5, 0x00);
Dispatch(*daynaport, scsi_command::send_message_6, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::send_message_6, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Invalid transfer length");

controller->SetCdbByte(3, -1);
controller->SetCdbByte(4, -8);
controller->SetCdbByte(5, 0x08);
Dispatch(*daynaport, scsi_command::send_message_6, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::send_message_6, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Invalid transfer length");

controller->SetCdbByte(3, 0);
controller->SetCdbByte(4, 0);
controller->SetCdbByte(5, 0xff);
Dispatch(*daynaport, scsi_command::send_message_6, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::send_message_6, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Invalid transfer length");

controller->SetCdbByte(5, 0x80);
EXPECT_CALL(*controller, DataOut);
EXPECT_NO_THROW(Dispatch(*daynaport, scsi_command::send_message_6));
EXPECT_NO_THROW(Dispatch(daynaport, scsi_command::send_message_6));
}

TEST(DaynaportTest, TestRetrieveStats)
Expand All @@ -121,49 +121,49 @@ TEST(DaynaportTest, TestRetrieveStats)
// ALLOCATION LENGTH
controller->SetCdbByte(4, 255);
EXPECT_CALL(*controller, DataIn);
EXPECT_NO_THROW(Dispatch(*daynaport, scsi_command::retrieve_stats));
EXPECT_NO_THROW(Dispatch(daynaport, scsi_command::retrieve_stats));
}

TEST(DaynaportTest, SetInterfaceMode)
{
auto [controller, daynaport] = CreateDevice(SCDP);

Dispatch(*daynaport, scsi_command::set_iface_mode, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::set_iface_mode, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Unknown interface command");

// Not implemented, do nothing
controller->SetCdbByte(5, DaynaPort::CMD_SCSILINK_SETMODE);
EXPECT_CALL(*controller, Status);
EXPECT_NO_THROW(Dispatch(*daynaport, scsi_command::set_iface_mode));
EXPECT_NO_THROW(Dispatch(daynaport, scsi_command::set_iface_mode));
EXPECT_EQ(status_code::good, controller->GetStatus());

controller->SetCdbByte(5, DaynaPort::CMD_SCSILINK_SETMAC);
EXPECT_CALL(*controller, DataOut);
EXPECT_NO_THROW(Dispatch(*daynaport, scsi_command::set_iface_mode));
EXPECT_NO_THROW(Dispatch(daynaport, scsi_command::set_iface_mode));

controller->SetCdbByte(5, DaynaPort::CMD_SCSILINK_STATS);
Dispatch(*daynaport, scsi_command::set_iface_mode, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::set_iface_mode, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Not implemented");

controller->SetCdbByte(5, DaynaPort::CMD_SCSILINK_ENABLE);
Dispatch(*daynaport, scsi_command::set_iface_mode, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::set_iface_mode, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Not implemented");

controller->SetCdbByte(5, DaynaPort::CMD_SCSILINK_SET);
Dispatch(*daynaport, scsi_command::set_iface_mode, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::set_iface_mode, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Not implemented");
}

TEST(DaynaportTest, SetMcastAddr)
{
auto [controller, daynaport] = CreateDevice(SCDP);

Dispatch(*daynaport, scsi_command::set_mcast_addr, sense_key::illegal_request, asc::invalid_field_in_cdb,
Dispatch(daynaport, scsi_command::set_mcast_addr, sense_key::illegal_request, asc::invalid_field_in_cdb,
"Length of 0 is not supported");

controller->SetCdbByte(4, 1);
EXPECT_CALL(*controller, DataOut);
EXPECT_NO_THROW(Dispatch(*daynaport, scsi_command::set_mcast_addr));
EXPECT_NO_THROW(Dispatch(daynaport, scsi_command::set_mcast_addr));
}

TEST(DaynaportTest, EnableInterface)
Expand All @@ -172,11 +172,11 @@ TEST(DaynaportTest, EnableInterface)

// Enable
controller->SetCdbByte(5, 0x80);
Dispatch(*daynaport, scsi_command::enable_interface, sense_key::aborted_command, asc::daynaport_enable_interface);
Dispatch(daynaport, scsi_command::enable_interface, sense_key::aborted_command, asc::daynaport_enable_interface);

// Disable
controller->SetCdbByte(5, 0x00);
Dispatch(*daynaport, scsi_command::enable_interface, sense_key::aborted_command, asc::daynaport_disable_interface);
Dispatch(daynaport, scsi_command::enable_interface, sense_key::aborted_command, asc::daynaport_disable_interface);
}

TEST(DaynaportTest, GetDelayAfterBytes)
Expand Down
Loading

0 comments on commit 6934560

Please sign in to comment.