2022-10-04 15:23:42 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-10-04 15:23:42 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
2023-10-15 06:38:15 +00:00
|
|
|
// Copyright (C) 2022-2023 Uwe Seimet
|
2022-10-04 15:23:42 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "mocks.h"
|
2022-11-10 06:44:06 +00:00
|
|
|
#include "shared/protobuf_util.h"
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "shared/piscsi_exceptions.h"
|
2022-10-04 15:23:42 +00:00
|
|
|
#include "controllers/controller_manager.h"
|
|
|
|
#include "devices/device_factory.h"
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "generated/piscsi_interface.pb.h"
|
|
|
|
#include "piscsi/command_context.h"
|
|
|
|
#include "piscsi/piscsi_response.h"
|
|
|
|
#include "piscsi/piscsi_executor.h"
|
2022-10-25 08:29:57 +00:00
|
|
|
#include <filesystem>
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-10-25 08:29:57 +00:00
|
|
|
using namespace filesystem;
|
2022-12-05 17:58:23 +00:00
|
|
|
using namespace piscsi_interface;
|
2022-10-08 17:26:04 +00:00
|
|
|
using namespace protobuf_util;
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, ProcessDeviceCmd)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
|
|
|
const int ID = 3;
|
|
|
|
const int LUN = 0;
|
|
|
|
|
2022-10-29 16:10:00 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
|
|
|
MockAbstractController controller(bus, ID);
|
2023-10-30 12:57:46 +00:00
|
|
|
auto executor = make_shared<MockPiscsiExecutor>(*bus, controller_manager);
|
2022-10-04 15:23:42 +00:00
|
|
|
PbDeviceDefinition definition;
|
|
|
|
PbCommand command;
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
definition.set_id(8);
|
|
|
|
definition.set_unit(32);
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context, definition, true)) << "Invalid ID and LUN must fail";
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
definition.set_unit(LUN);
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context, definition, true)) << "Invalid ID must fail";
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
definition.set_id(ID);
|
2022-10-23 19:51:39 +00:00
|
|
|
definition.set_unit(32);
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context, definition, true)) << "Invalid LUN must fail";
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
definition.set_unit(LUN);
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context, definition, true)) << "Unknown operation must fail";
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
command.set_operation(ATTACH);
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_attach(command, "", "");
|
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context_attach, definition, true)) << "Operation for unknown device type must fail";
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
auto device1 = make_shared<MockPrimaryDevice>(LUN);
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller_manager.AttachToController(*bus, ID, device1));
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
definition.set_type(SCHS);
|
|
|
|
command.set_operation(INSERT);
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_insert1(command, "", "");
|
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context_insert1, definition, true)) << "Operation unsupported by device must fail";
|
|
|
|
controller_manager.DeleteAllControllers();
|
2022-10-23 19:51:39 +00:00
|
|
|
definition.set_type(SCRM);
|
|
|
|
|
|
|
|
auto device2 = make_shared<MockSCSIHD_NEC>(LUN);
|
|
|
|
device2->SetRemovable(true);
|
|
|
|
device2->SetProtectable(true);
|
|
|
|
device2->SetReady(true);
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller_manager.AttachToController(*bus, ID, device2));
|
2022-10-23 19:51:39 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context_attach, definition, true)) << "ID and LUN already exist";
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
command.set_operation(START);
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_start(command, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_start, definition, true));
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_start, definition, false));
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
command.set_operation(PROTECT);
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_protect(command, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_protect, definition, true));
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_protect, definition, false));
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
command.set_operation(UNPROTECT);
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_unprotect(command, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_unprotect, definition, true));
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_unprotect, definition, false));
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
command.set_operation(STOP);
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_stop(command, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_stop, definition, true));
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_stop, definition, false));
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
command.set_operation(EJECT);
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_eject(command, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_eject, definition, true));
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_eject, definition, false));
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
command.set_operation(INSERT);
|
|
|
|
SetParam(definition, "file", "filename");
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_insert2(command, "", "");
|
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context_insert2, definition, true)) << "Non-existing file";
|
|
|
|
EXPECT_FALSE(executor->ProcessDeviceCmd(context_insert2, definition, false)) << "Non-existing file";
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
command.set_operation(DETACH);
|
2023-10-15 06:38:15 +00:00
|
|
|
CommandContext context_detach(command, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_detach, definition, true));
|
|
|
|
EXPECT_TRUE(executor->ProcessDeviceCmd(context_detach, definition, false));
|
2022-10-23 19:51:39 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, ProcessCmd)
|
2022-10-23 19:51:39 +00:00
|
|
|
{
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
|
|
|
MockAbstractController controller(bus, 0);
|
2023-10-30 12:57:46 +00:00
|
|
|
auto executor = make_shared<MockPiscsiExecutor>(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
|
|
|
|
PbCommand command_detach_all;
|
|
|
|
command_detach_all.set_operation(DETACH_ALL);
|
|
|
|
CommandContext context_detach_all(command_detach_all, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessCmd(context_detach_all));
|
|
|
|
|
|
|
|
PbCommand command_reserve_ids1;
|
|
|
|
command_reserve_ids1.set_operation(RESERVE_IDS);
|
|
|
|
SetParam(command_reserve_ids1, "ids", "2,3");
|
|
|
|
CommandContext context_reserve_ids1(command_reserve_ids1, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessCmd(context_reserve_ids1));
|
2022-10-23 19:51:39 +00:00
|
|
|
const unordered_set<int> ids = executor->GetReservedIds();
|
|
|
|
EXPECT_EQ(2, ids.size());
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(ids.contains(2));
|
|
|
|
EXPECT_TRUE(ids.contains(3));
|
2022-10-23 19:51:39 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command_reserve_ids2;
|
|
|
|
command_reserve_ids2.set_operation(RESERVE_IDS);
|
|
|
|
CommandContext context_reserve_ids2(command_reserve_ids2, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessCmd(context_reserve_ids2));
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_TRUE(executor->GetReservedIds().empty());
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command_reserve_ids3;
|
|
|
|
command_reserve_ids3.set_operation(RESERVE_IDS);
|
|
|
|
SetParam(command_reserve_ids3, "ids", "-1");
|
|
|
|
CommandContext context_reserve_ids3(command_reserve_ids3, "", "");
|
|
|
|
EXPECT_FALSE(executor->ProcessCmd(context_reserve_ids3));
|
|
|
|
EXPECT_TRUE(executor->GetReservedIds().empty());
|
2022-10-23 19:51:39 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command_no_operation;
|
|
|
|
command_no_operation.set_operation(NO_OPERATION);
|
|
|
|
CommandContext context_no_operation(command_no_operation, "", "");
|
|
|
|
EXPECT_TRUE(executor->ProcessCmd(context_no_operation));
|
|
|
|
|
|
|
|
PbCommand command_attach1;
|
|
|
|
command_attach1.set_operation(ATTACH);
|
|
|
|
auto device1 = command_attach1.add_devices();
|
|
|
|
device1->set_type(SCHS);
|
|
|
|
device1->set_id(-1);
|
|
|
|
CommandContext context_attach1(command_attach1, "", "");
|
|
|
|
EXPECT_FALSE(executor->ProcessCmd(context_attach1));
|
|
|
|
|
|
|
|
PbCommand command_attach2;
|
|
|
|
command_attach2.set_operation(ATTACH);
|
|
|
|
auto device2 = command_attach2.add_devices();
|
|
|
|
device2->set_type(SCHS);
|
|
|
|
device2->set_id(0);
|
|
|
|
device2->set_unit(1);
|
|
|
|
CommandContext context_attach2(command_attach2, "", "");
|
|
|
|
EXPECT_FALSE(executor->ProcessCmd(context_attach2)) << "LUN 0 is missing";
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, Attach)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
|
|
|
const int ID = 3;
|
|
|
|
const int LUN = 0;
|
|
|
|
|
|
|
|
DeviceFactory device_factory;
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2022-10-04 15:23:42 +00:00
|
|
|
PbDeviceDefinition definition;
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
definition.set_unit(32);
|
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false));
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(SCHD, LUN, "");
|
2022-10-04 15:23:42 +00:00
|
|
|
definition.set_id(ID);
|
|
|
|
definition.set_unit(LUN);
|
|
|
|
|
|
|
|
executor.SetReservedIds(to_string(ID));
|
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false)) << "Reserved ID not rejected";
|
|
|
|
|
|
|
|
executor.SetReservedIds("");
|
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false)) << "Unknown device type not rejected";
|
|
|
|
|
|
|
|
definition.set_type(PbDeviceType::SCHS);
|
|
|
|
EXPECT_TRUE(executor.Attach(context, definition, false));
|
2023-10-15 06:38:15 +00:00
|
|
|
controller_manager.DeleteAllControllers();
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
definition.set_type(PbDeviceType::SCHD);
|
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false)) << "Drive without sectors not rejected";
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
definition.set_revision("invalid revision");
|
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false)) << "Drive with invalid revision not rejected";
|
|
|
|
definition.set_revision("1234");
|
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
definition.set_block_size(1);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false)) << "Drive with invalid sector size not rejected";
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
definition.set_block_size(512);
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false)) << "Drive without image file not rejected";
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
SetParam(definition, "file", "/non_existing_file");
|
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false)) << "Drive with non-existing image file not rejected";
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-10-25 08:29:57 +00:00
|
|
|
path filename = CreateTempFile(1);
|
2023-10-15 06:38:15 +00:00
|
|
|
SetParam(definition, "file", filename.string());
|
2023-01-28 16:28:21 +00:00
|
|
|
EXPECT_FALSE(executor.Attach(context, definition, false)) << "Too small image file not rejected";
|
2022-10-25 08:29:57 +00:00
|
|
|
remove(filename);
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
filename = CreateTempFile(512);
|
2023-10-15 06:38:15 +00:00
|
|
|
SetParam(definition, "file", filename.string());
|
2022-10-23 19:51:39 +00:00
|
|
|
bool result = executor.Attach(context, definition, false);
|
2022-10-25 08:29:57 +00:00
|
|
|
remove(filename);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_TRUE(result);
|
2023-10-15 06:38:15 +00:00
|
|
|
controller_manager.DeleteAllControllers();
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
filename = CreateTempFile(513);
|
2023-10-15 06:38:15 +00:00
|
|
|
SetParam(definition, "file", filename.string());
|
2022-10-23 19:51:39 +00:00
|
|
|
result = executor.Attach(context, definition, false);
|
2022-10-25 08:29:57 +00:00
|
|
|
remove(filename);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_TRUE(result);
|
|
|
|
|
|
|
|
definition.set_type(PbDeviceType::SCCD);
|
|
|
|
definition.set_unit(LUN + 1);
|
|
|
|
filename = CreateTempFile(2048);
|
2023-10-15 06:38:15 +00:00
|
|
|
SetParam(definition, "file", filename.string());
|
2022-10-23 19:51:39 +00:00
|
|
|
result = executor.Attach(context, definition, false);
|
2022-10-25 08:29:57 +00:00
|
|
|
remove(filename);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_TRUE(result);
|
|
|
|
|
|
|
|
definition.set_type(PbDeviceType::SCMO);
|
|
|
|
definition.set_unit(LUN + 2);
|
|
|
|
SetParam(definition, "read_only", "true");
|
|
|
|
filename = CreateTempFile(4096);
|
2023-10-15 06:38:15 +00:00
|
|
|
SetParam(definition, "file", filename.string());
|
2022-10-23 19:51:39 +00:00
|
|
|
result = executor.Attach(context, definition, false);
|
2022-10-25 08:29:57 +00:00
|
|
|
remove(filename);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_TRUE(result);
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
controller_manager.DeleteAllControllers();
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, Insert)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
|
|
|
auto [controller, device] = CreateDevice(SCHD);
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2022-10-04 15:23:42 +00:00
|
|
|
PbDeviceDefinition definition;
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
device->SetRemoved(false);
|
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false)) << "Medium is not removed";
|
|
|
|
|
|
|
|
device->SetRemoved(true);
|
|
|
|
definition.set_vendor("v");
|
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false)) << "Product data must not be set";
|
|
|
|
definition.set_vendor("");
|
|
|
|
|
|
|
|
definition.set_product("p");
|
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false)) << "Product data must not be set";
|
|
|
|
definition.set_product("");
|
|
|
|
|
|
|
|
definition.set_revision("r");
|
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false)) << "Product data must not be set";
|
|
|
|
definition.set_revision("");
|
|
|
|
|
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false)) << "Filename is missing";
|
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
SetParam(definition, "file", "filename");
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_TRUE(executor.Insert(context, definition, device, true)) << "Dry-run must not fail";
|
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false));
|
|
|
|
|
|
|
|
definition.set_block_size(1);
|
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false));
|
|
|
|
|
|
|
|
definition.set_block_size(0);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false)) << "Image file validation must fail";
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-10-23 19:51:39 +00:00
|
|
|
SetParam(definition, "file", "/non_existing_file");
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false));
|
|
|
|
|
2022-10-25 08:29:57 +00:00
|
|
|
path filename = CreateTempFile(1);
|
2023-10-15 06:38:15 +00:00
|
|
|
SetParam(definition, "file", filename.string());
|
2023-01-28 16:28:21 +00:00
|
|
|
EXPECT_FALSE(executor.Insert(context, definition, device, false)) << "Too small image file not rejected";
|
2022-10-25 08:29:57 +00:00
|
|
|
remove(filename);
|
2022-10-23 19:51:39 +00:00
|
|
|
|
|
|
|
filename = CreateTempFile(512);
|
2023-10-15 06:38:15 +00:00
|
|
|
SetParam(definition, "file", filename.string());
|
2022-10-23 19:51:39 +00:00
|
|
|
const bool result = executor.Insert(context, definition, device, false);
|
2022-10-25 08:29:57 +00:00
|
|
|
remove(filename);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_TRUE(result);
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, Detach)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
|
|
|
const int ID = 3;
|
|
|
|
const int LUN1 = 0;
|
|
|
|
const int LUN2 = 1;
|
|
|
|
|
|
|
|
DeviceFactory device_factory;
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device1 = device_factory.CreateDevice(SCHS, LUN1, "");
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller_manager.AttachToController(*bus, ID, device1));
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device2 = device_factory.CreateDevice(SCHS, LUN2, "");
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller_manager.AttachToController(*bus, ID, device2));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
auto d1 = controller_manager.GetDeviceForIdAndLun(ID, LUN1);
|
|
|
|
EXPECT_FALSE(executor.Detach(context, *d1, false)) << "LUNs > 0 have to be detached first";
|
|
|
|
auto d2 = controller_manager.GetDeviceForIdAndLun(ID, LUN2);
|
|
|
|
EXPECT_TRUE(executor.Detach(context, *d2, false));
|
|
|
|
EXPECT_TRUE(executor.Detach(context, *d1, false));
|
|
|
|
EXPECT_TRUE(controller_manager.GetAllDevices().empty());
|
2022-10-23 19:51:39 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(executor.Detach(context, *d1, false));
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, DetachAll)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
|
|
|
const int ID = 4;
|
|
|
|
|
|
|
|
DeviceFactory device_factory;
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(SCHS, 0, "");
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller_manager.AttachToController(*bus, ID, device));
|
|
|
|
EXPECT_TRUE(controller_manager.HasController(ID));
|
|
|
|
EXPECT_FALSE(controller_manager.GetAllDevices().empty());
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
executor.DetachAll();
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_EQ(nullptr, controller_manager.FindController(ID));
|
|
|
|
EXPECT_TRUE(controller_manager.GetAllDevices().empty());
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, SetReservedIds)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
|
|
|
DeviceFactory device_factory;
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
string error = executor.SetReservedIds("xyz");
|
|
|
|
EXPECT_FALSE(error.empty());
|
|
|
|
EXPECT_TRUE(executor.GetReservedIds().empty());
|
|
|
|
|
|
|
|
error = executor.SetReservedIds("8");
|
|
|
|
EXPECT_FALSE(error.empty());
|
|
|
|
EXPECT_TRUE(executor.GetReservedIds().empty());
|
|
|
|
|
|
|
|
error = executor.SetReservedIds("-1");
|
|
|
|
EXPECT_FALSE(error.empty());
|
|
|
|
EXPECT_TRUE(executor.GetReservedIds().empty());
|
|
|
|
|
|
|
|
error = executor.SetReservedIds("");
|
|
|
|
EXPECT_TRUE(error.empty());
|
|
|
|
EXPECT_TRUE(executor.GetReservedIds().empty());
|
|
|
|
|
|
|
|
error = executor.SetReservedIds("7,1,2,3,5");
|
|
|
|
EXPECT_TRUE(error.empty());
|
|
|
|
unordered_set<int> reserved_ids = executor.GetReservedIds();
|
|
|
|
EXPECT_EQ(5, reserved_ids.size());
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(reserved_ids.contains(1));
|
|
|
|
EXPECT_TRUE(reserved_ids.contains(2));
|
|
|
|
EXPECT_TRUE(reserved_ids.contains(3));
|
|
|
|
EXPECT_TRUE(reserved_ids.contains(5));
|
|
|
|
EXPECT_TRUE(reserved_ids.contains(7));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(SCHS, 0, "");
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller_manager.AttachToController(*bus, 5, device));
|
2022-10-04 15:23:42 +00:00
|
|
|
error = executor.SetReservedIds("5");
|
|
|
|
EXPECT_FALSE(error.empty());
|
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, ValidateImageFile)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
|
|
|
DeviceFactory device_factory;
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = dynamic_pointer_cast<StorageDevice>(device_factory.CreateDevice(SCHD, 0, "test"));
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(executor.ValidateImageFile(context, *device, ""));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_FALSE(executor.ValidateImageFile(context, *device, "/non_existing_file"));
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, PrintCommand)
|
|
|
|
{
|
|
|
|
auto bus = make_shared<MockBus>();
|
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbDeviceDefinition definition;
|
|
|
|
|
|
|
|
PbCommand command;
|
|
|
|
string s = executor.PrintCommand(command, definition);
|
|
|
|
EXPECT_NE(s.find("operation="), string::npos);
|
|
|
|
EXPECT_EQ(s.find("key1=value1"), string::npos);
|
|
|
|
EXPECT_EQ(s.find("key2=value2"), string::npos);
|
|
|
|
|
|
|
|
SetParam(command, "key1", "value1");
|
|
|
|
s = executor.PrintCommand(command, definition);
|
|
|
|
EXPECT_NE(s.find("operation="), string::npos);
|
|
|
|
EXPECT_NE(s.find("key1=value1"), string::npos);
|
|
|
|
|
|
|
|
SetParam(command, "key2", "value2");
|
|
|
|
s = executor.PrintCommand(command, definition);
|
|
|
|
EXPECT_NE(s.find("operation="), string::npos);
|
|
|
|
EXPECT_NE(s.find("key1=value1"), string::npos);
|
|
|
|
EXPECT_NE(s.find("key2=value2"), string::npos);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(PiscsiExecutorTest, EnsureLun0)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
|
|
|
DeviceFactory device_factory;
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2022-10-04 15:23:42 +00:00
|
|
|
PbCommand command;
|
|
|
|
|
|
|
|
auto device1 = command.add_devices();
|
|
|
|
device1->set_unit(0);
|
2023-10-15 06:38:15 +00:00
|
|
|
string error = executor.EnsureLun0(command);
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_TRUE(error.empty());
|
|
|
|
|
|
|
|
device1->set_unit(1);
|
2023-10-15 06:38:15 +00:00
|
|
|
error = executor.EnsureLun0(command);
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_FALSE(error.empty());
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device2 = device_factory.CreateDevice(SCHS, 0, "");
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller_manager.AttachToController(*bus, 0, device2));
|
|
|
|
error = executor.EnsureLun0(command);
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_TRUE(error.empty());
|
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, VerifyExistingIdAndLun)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
|
|
|
const int ID = 1;
|
2022-10-23 19:51:39 +00:00
|
|
|
const int LUN1 = 0;
|
2022-10-04 15:23:42 +00:00
|
|
|
const int LUN2 = 3;
|
|
|
|
|
|
|
|
DeviceFactory device_factory;
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
EXPECT_FALSE(executor.VerifyExistingIdAndLun(context, ID, LUN1));
|
2022-11-04 07:22:32 +00:00
|
|
|
auto device = device_factory.CreateDevice(SCHS, LUN1, "");
|
2023-10-15 06:38:15 +00:00
|
|
|
EXPECT_TRUE(controller_manager.AttachToController(*bus, ID, device));
|
2022-10-04 15:23:42 +00:00
|
|
|
EXPECT_TRUE(executor.VerifyExistingIdAndLun(context, ID, LUN1));
|
|
|
|
EXPECT_FALSE(executor.VerifyExistingIdAndLun(context, ID, LUN2));
|
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, CreateDevice)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
EXPECT_EQ(nullptr, executor.CreateDevice(context, UNDEFINED, 0, ""));
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
EXPECT_EQ(nullptr, executor.CreateDevice(context, SAHD, 0, ""));
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
EXPECT_NE(nullptr, executor.CreateDevice(context, UNDEFINED, 0, "services"));
|
|
|
|
EXPECT_NE(nullptr, executor.CreateDevice(context, SCHS, 0, ""));
|
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, SetSectorSize)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
unordered_set<uint32_t> sizes;
|
2023-11-14 14:32:46 +00:00
|
|
|
auto hd = make_shared<MockSCSIHD>(sizes);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_FALSE(executor.SetSectorSize(context, hd, 512));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
sizes.insert(512);
|
2023-11-14 14:32:46 +00:00
|
|
|
hd = make_shared<MockSCSIHD>(sizes);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_TRUE(executor.SetSectorSize(context, hd, 0));
|
|
|
|
EXPECT_FALSE(executor.SetSectorSize(context, hd, 1));
|
2023-11-14 14:32:46 +00:00
|
|
|
EXPECT_FALSE(executor.SetSectorSize(context, hd, 512));
|
|
|
|
|
|
|
|
sizes.insert(1024);
|
|
|
|
hd = make_shared<MockSCSIHD>(sizes);
|
2022-10-23 19:51:39 +00:00
|
|
|
EXPECT_TRUE(executor.SetSectorSize(context, hd, 512));
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, ValidateOperationAgainstDevice)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
auto device = make_shared<MockPrimaryDevice>(0);
|
|
|
|
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, ATTACH));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, DETACH));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, START));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, STOP));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, INSERT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, EJECT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, PROTECT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, UNPROTECT));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
device->SetStoppable(true);
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, START));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, STOP));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, INSERT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, EJECT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, PROTECT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, UNPROTECT));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
device->SetRemovable(true);
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, START));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, STOP));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, INSERT));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, EJECT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, PROTECT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, UNPROTECT));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
device->SetProtectable(true);
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, START));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, STOP));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, INSERT));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, EJECT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, PROTECT));
|
|
|
|
EXPECT_FALSE(executor.ValidateOperationAgainstDevice(context, *device, UNPROTECT));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
device->SetReady(true);
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, START));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, STOP));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, INSERT));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, EJECT));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, PROTECT));
|
|
|
|
EXPECT_TRUE(executor.ValidateOperationAgainstDevice(context, *device, UNPROTECT));
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, ValidateIdAndLun)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
EXPECT_FALSE(executor.ValidateIdAndLun(context, -1, 0));
|
|
|
|
EXPECT_FALSE(executor.ValidateIdAndLun(context, 8, 0));
|
|
|
|
EXPECT_FALSE(executor.ValidateIdAndLun(context, 7, -1));
|
|
|
|
EXPECT_FALSE(executor.ValidateIdAndLun(context, 7, 32));
|
|
|
|
EXPECT_TRUE(executor.ValidateIdAndLun(context, 7, 0));
|
|
|
|
EXPECT_TRUE(executor.ValidateIdAndLun(context, 7, 31));
|
|
|
|
}
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
TEST(PiscsiExecutorTest, SetProductData)
|
2022-10-04 15:23:42 +00:00
|
|
|
{
|
2022-11-04 07:22:32 +00:00
|
|
|
auto bus = make_shared<MockBus>();
|
2023-10-15 06:38:15 +00:00
|
|
|
ControllerManager controller_manager;
|
2023-10-30 12:57:46 +00:00
|
|
|
PiscsiExecutor executor(*bus, controller_manager);
|
2023-10-15 06:38:15 +00:00
|
|
|
PbCommand command;
|
|
|
|
CommandContext context(command, "", "");
|
2022-10-04 15:23:42 +00:00
|
|
|
PbDeviceDefinition definition;
|
|
|
|
|
|
|
|
auto device = make_shared<MockPrimaryDevice>(0);
|
|
|
|
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
definition.set_vendor("123456789");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_FALSE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
definition.set_vendor("1");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
definition.set_vendor("12345678");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
definition.set_product("12345678901234567");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_FALSE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
definition.set_product("1");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
definition.set_product("1234567890123456");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
definition.set_revision("12345");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_FALSE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
definition.set_revision("1");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
definition.set_revision("1234");
|
2022-11-02 06:36:25 +00:00
|
|
|
EXPECT_TRUE(executor.SetProductData(context, definition, *device));
|
2022-10-04 15:23:42 +00:00
|
|
|
}
|