Remove the abstraction for generating error response packets.

After the MCTP refactoring, the abstract API to generate error packets is not called by any code.  It no longer belongs as part of the command interface API, so it has been removed.
This commit is contained in:
Christopher Weimer 2024-07-09 20:16:43 +00:00
Родитель 001c5da1e4
Коммит be0dc616f0
39 изменённых файлов: 20 добавлений и 1160 удалений

Просмотреть файл

@ -353,52 +353,3 @@ int cmd_interface_prepare_response (const struct cmd_interface *intf,
return status;
}
/**
* Generate a packet containing error message.
*
* TODO: Deprecate use of this function and remove it. Use cerberus_protocol_build_error_response
* instead.
*
* @param intf The command interface to utilize.
* @param request The request container to utilize.
* @param error_code Identifier for the error.
* @param error_data Data for the error condition.
* @param cmd_set Command set to respond on.
*
* @return 0 if the error was successfully generated or an error code.
*/
int cmd_interface_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
struct cerberus_protocol_error *error_msg;
if ((intf == NULL) || (request == NULL)) {
return CMD_HANDLER_INVALID_ARGUMENT;
}
error_msg = (struct cerberus_protocol_error*) request->data;
memset (error_msg, 0, sizeof (struct cerberus_protocol_error));
error_msg->header.rq = cmd_set;
error_msg->header.msg_type = MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF;
error_msg->header.pci_vendor_id = CERBERUS_PROTOCOL_MSFT_PCI_VID;
error_msg->header.command = CERBERUS_PROTOCOL_ERROR;
error_msg->error_code = error_code;
error_msg->error_data = error_data;
request->length = sizeof (struct cerberus_protocol_error);
#ifdef CMD_SUPPORT_ENCRYPTED_SESSIONS
if (request->is_encrypted) {
int status = intf->session->encrypt_message (intf->session, request);
if (status != 0) {
return status;
}
}
#endif
return 0;
}

Просмотреть файл

@ -146,29 +146,6 @@ struct cmd_interface {
int (*process_response) (const struct cmd_interface *intf, struct cmd_interface_msg *response);
#endif
/**
* Generate a message to indicate an error condition.
*
* TODO: Revisit the need for this function and how it gets used. Generally, individual
* protocols will generate their own error responses (e.g. SPDM). This is really only used for
* transport layer errors (e.g. MCTP) when there is no other associated protocol known (or no
* protocol handling of the error), so perhaps it doesn't belong here. Maybe it belongs in
* cmd_interface_protocol? Maybe this function should be removed entirely and it should be up
* to the transport to internally figure out what to do? Does it really make sense to always
* return Cerberus error messages for MCTP layer errors?
*
* @param intf The command interface to utilize.
* @param request The request container to utilize.
* @param error_code Identifier for the error.
* @param error_data Data for the error condition.
* @param cmd_set Command set to respond on.
*
* @return 0 if the packet was generated successfully or an error code.
*/
int (*generate_error_packet) (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data,
uint8_t cmd_set);
/* TODO: Now that the cmd_interface is used for more than Cerberus messages, this should get
* refactored out of the base interface and into some Cerberus specific handling, like the
* protocol handlers. */
@ -262,8 +239,6 @@ int cmd_interface_process_cerberus_protocol_message (const struct cmd_interface
bool rsvd_zero);
int cmd_interface_prepare_response (const struct cmd_interface *intf,
struct cmd_interface_msg *response);
int cmd_interface_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set);
#define CMD_HANDLER_ERROR(code) ROT_ERROR (ROT_MODULE_CMD_HANDLER, code)

Просмотреть файл

@ -152,7 +152,6 @@ int cmd_interface_ac_rot_init (struct cmd_interface_ac_rot *intf,
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_ac_rot_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_generate_error_packet;
#ifdef CMD_SUPPORT_ENCRYPTED_SESSIONS
intf->base.session = session;

Просмотреть файл

@ -32,7 +32,6 @@ int cmd_interface_ac_rot_process_response (const struct cmd_interface *intf,
#define CMD_INTERFACE_AC_ROT_API_INIT(session_ptr) { \
.process_request = cmd_interface_ac_rot_process_request, \
CMD_INTERFACE_AC_ROT_RESPONSE_API \
.generate_error_packet = cmd_interface_generate_error_packet, \
.session = session_ptr, \
}

Просмотреть файл

@ -56,26 +56,6 @@ int cmd_interface_dual_cmd_set_process_response (const struct cmd_interface *int
}
#endif
int cmd_interface_dual_cmd_set_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
const struct cmd_interface_dual_cmd_set *interface =
(const struct cmd_interface_dual_cmd_set*) intf;
if (interface == NULL) {
return CMD_HANDLER_INVALID_ARGUMENT;
}
if (cmd_set == 0) {
return interface->intf_0->generate_error_packet (interface->intf_0, request, error_code,
error_data, cmd_set);
}
else {
return interface->intf_1->generate_error_packet (interface->intf_1, request, error_code,
error_data, cmd_set);
}
}
/**
* Initialize a command interface instance with two command sets supported. Requests from each
* command set get routed to the appropiate command interface. Issuing requests from this interface
@ -103,7 +83,6 @@ int cmd_interface_dual_cmd_set_init (struct cmd_interface_dual_cmd_set *intf,
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_dual_cmd_set_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_dual_cmd_set_generate_error_packet;
return 0;
}

Просмотреть файл

@ -12,8 +12,6 @@ int cmd_interface_dual_cmd_set_process_request (const struct cmd_interface *intf
struct cmd_interface_msg *request);
int cmd_interface_dual_cmd_set_process_response (const struct cmd_interface *intf,
struct cmd_interface_msg *response);
int cmd_interface_dual_cmd_set_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set);
/**
@ -32,7 +30,6 @@ int cmd_interface_dual_cmd_set_generate_error_packet (const struct cmd_interface
#define CMD_INTERFACE_DUAL_CMD_SET_API_INIT { \
.process_request = cmd_interface_dual_cmd_set_process_request, \
CMD_INTERFACE_DUAL_CMD_SET_RESPONSE_API \
.generate_error_packet = cmd_interface_dual_cmd_set_generate_error_packet, \
.session = NULL, \
}

Просмотреть файл

@ -82,20 +82,6 @@ int cmd_interface_multi_handler_process_response (const struct cmd_interface *in
return CMD_HANDLER_UNSUPPORTED_OPERATION;
}
int cmd_interface_multi_handler_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
UNUSED (intf);
UNUSED (request);
UNUSED (error_code);
UNUSED (error_data);
UNUSED (cmd_set);
/* TODO: Perhaps add an API to the protocol handler to generate an error message? But really,
* this API should probably be removed from the command handler interface. */
return CMD_HANDLER_UNSUPPORTED_OPERATION;
}
int cmd_interface_multi_handler_is_message_type_supported (
const struct cmd_interface_multi_handler *intf, uint32_t message_type)
{
@ -162,7 +148,6 @@ int cmd_interface_multi_handler_init (struct cmd_interface_multi_handler *intf,
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_multi_handler_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_multi_handler_generate_error_packet;
intf->is_message_type_supported = cmd_interface_multi_handler_is_message_type_supported;

Просмотреть файл

@ -12,8 +12,6 @@ int cmd_interface_multi_handler_process_request (const struct cmd_interface *int
struct cmd_interface_msg *request);
int cmd_interface_multi_handler_process_response (const struct cmd_interface *intf,
struct cmd_interface_msg *response);
int cmd_interface_multi_handler_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set);
int cmd_interface_multi_handler_is_message_type_supported (
const struct cmd_interface_multi_handler *intf, uint32_t message_type);
@ -35,7 +33,6 @@ int cmd_interface_multi_handler_is_message_type_supported (
#define CMD_INTERFACE_MULTI_HANDLER_API_INIT { \
.process_request = cmd_interface_multi_handler_process_request, \
CMD_INTERFACE_MULTI_HANDLER_RESPONSE_API \
.generate_error_packet = cmd_interface_multi_handler_generate_error_packet, \
.session = NULL, \
}

Просмотреть файл

@ -50,7 +50,6 @@ int cmd_interface_null_init (struct cmd_interface_null *intf)
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_null_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_generate_error_packet;
return 0;
}

Просмотреть файл

@ -30,7 +30,6 @@ int cmd_interface_null_process_response (const struct cmd_interface *intf,
#define CMD_INTERFACE_NULL_API_INIT { \
.process_request = cmd_interface_null_process_request, \
CMD_INTERFACE_NULL_RESPONSE_API \
.generate_error_packet = cmd_interface_generate_error_packet, \
.session = NULL, \
}

Просмотреть файл

@ -454,7 +454,6 @@ int cmd_interface_system_init (struct cmd_interface_system *intf,
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_system_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_generate_error_packet;
#if CMD_SUPPORT_ENCRYPTED_SESSIONS
intf->base.session = session;

Просмотреть файл

@ -186,18 +186,6 @@ static int cmd_interface_mctp_control_process_response (const struct cmd_interfa
}
#endif
static int cmd_interface_mctp_control_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
UNUSED (intf);
UNUSED (request);
UNUSED (error_code);
UNUSED (error_data);
UNUSED (cmd_set);
return CMD_HANDLER_MCTP_CTRL_UNSUPPORTED_OPERATION;
}
/**
* Initialize MCTP control command interface instance
*
@ -233,7 +221,6 @@ int cmd_interface_mctp_control_init (struct cmd_interface_mctp_control *intf,
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_mctp_control_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_mctp_control_generate_error_packet;
return 0;
}

Просмотреть файл

@ -65,18 +65,6 @@ int cmd_interface_ide_responder_process_response (const struct cmd_interface *in
}
#endif
int cmd_interface_ide_responder_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
UNUSED (intf);
UNUSED (request);
UNUSED (error_code);
UNUSED (error_data);
UNUSED (cmd_set);
return CMD_INTERFACE_IDE_RESPONDER_UNSUPPORTED_OPERATION;
}
/**
* Initialize the IDE responder instance.
*
@ -100,8 +88,6 @@ int cmd_interface_ide_responder_init (struct cmd_interface_ide_responder *ide_re
ide_responder->base.process_request = cmd_interface_ide_responder_process_request;
ide_responder->base.process_response = cmd_interface_ide_responder_process_response;
ide_responder->base.generate_error_packet =
cmd_interface_ide_responder_generate_error_packet;
exit:

Просмотреть файл

@ -10,12 +10,9 @@
/* Internal function declared to allow for static initialization. */
int cmd_interface_ide_responder_process_request (const struct cmd_interface *intf,
struct cmd_interface_msg *request);
int cmd_interface_ide_responder_process_response (const struct cmd_interface *intf,
struct cmd_interface_msg *response);
int cmd_interface_ide_responder_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set);
/**
* Constant initializer for response handling.
@ -30,12 +27,12 @@ int cmd_interface_ide_responder_generate_error_packet (const struct cmd_interfac
/**
* Constant initializer for the IDE Responder API.
*/
#define CMD_INTERFACE_IDE_RESPONDER_API_INIT { \
.process_request = cmd_interface_ide_responder_process_request, \
CMD_INTERFACE_IDE_RESPONDER_RESPONSE_API \
.generate_error_packet = cmd_interface_ide_responder_generate_error_packet \
#define CMD_INTERFACE_IDE_RESPONDER_API_INIT { \
.process_request = cmd_interface_ide_responder_process_request, \
CMD_INTERFACE_IDE_RESPONDER_RESPONSE_API \
}
/**
* IDE responder static initialization
*

Просмотреть файл

@ -85,18 +85,6 @@ int cmd_interface_tdisp_responder_process_response (const struct cmd_interface *
}
#endif
int cmd_interface_tdisp_responder_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
UNUSED (intf);
UNUSED (request);
UNUSED (error_code);
UNUSED (error_data);
UNUSED (cmd_set);
return CMD_INTERFACE_TDISP_RESPONDER_UNSUPPORTED_OPERATION;
}
/**
* Initialize the TDISP responder instance.
*
@ -132,8 +120,6 @@ int cmd_interface_tdisp_responder_init (struct cmd_interface_tdisp_responder *td
#ifdef CMD_ENABLE_ISSUE_REQUEST
tdisp_responder->base.process_response = cmd_interface_tdisp_responder_process_response;
#endif
tdisp_responder->base.generate_error_packet =
cmd_interface_tdisp_responder_generate_error_packet;
/* Initialize the state. */
status = cmd_interface_tdisp_responder_init_state (tdisp_responder);

Просмотреть файл

@ -10,12 +10,9 @@
/* Internal function declared to allow for static initialization. */
int cmd_interface_tdisp_responder_process_request (const struct cmd_interface *intf,
struct cmd_interface_msg *request);
int cmd_interface_tdisp_responder_process_response (const struct cmd_interface *intf,
struct cmd_interface_msg *response);
int cmd_interface_tdisp_responder_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set);
/**
* Constant initializer for response handling.
@ -30,12 +27,12 @@ int cmd_interface_tdisp_responder_generate_error_packet (const struct cmd_interf
/**
* Constant initializer for the TDISP Responder API.
*/
#define CMD_INTERFACE_TDISP_RESPONDER_API_INIT { \
.process_request = cmd_interface_tdisp_responder_process_request, \
CMD_INTERFACE_TDISP_RESPONDER_RESPONSE_API \
.generate_error_packet = cmd_interface_tdisp_responder_generate_error_packet \
#define CMD_INTERFACE_TDISP_RESPONDER_API_INIT { \
.process_request = cmd_interface_tdisp_responder_process_request, \
CMD_INTERFACE_TDISP_RESPONDER_RESPONSE_API \
}
/**
* TDISP responder static initialization.
*

Просмотреть файл

@ -119,7 +119,6 @@ int cmd_interface_recovery_init (struct cmd_interface_recovery *intf,
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_recovery_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_generate_error_packet;
return 0;
}

Просмотреть файл

@ -13,6 +13,7 @@ int cmd_interface_recovery_process_request (const struct cmd_interface *intf,
int cmd_interface_recovery_process_response (const struct cmd_interface *intf,
struct cmd_interface_msg *response);
/**
* Constant initializer for response handling.
*/
@ -29,7 +30,6 @@ int cmd_interface_recovery_process_response (const struct cmd_interface *intf,
#define CMD_INTERFACE_RECOVERY_API_INIT { \
.process_request = cmd_interface_recovery_process_request, \
CMD_INTERFACE_RECOVERY_RESPONSE_API \
.generate_error_packet = cmd_interface_generate_error_packet, \
}
@ -40,7 +40,8 @@ int cmd_interface_recovery_process_response (const struct cmd_interface *intf,
*
* @param device_manager_ptr Manager for known devices.
*/
#define cmd_interface_recovery_static_init(device_manager_ptr, firmware_update_control_ptr, fw_version_ptr) { \
#define cmd_interface_recovery_static_init(device_manager_ptr, firmware_update_control_ptr, \
fw_version_ptr) { \
.base = CMD_INTERFACE_RECOVERY_API_INIT, \
.device_manager = device_manager_ptr, \
.control = firmware_update_control_ptr, \

Просмотреть файл

@ -67,7 +67,6 @@ int cmd_interface_rma_init (struct cmd_interface_rma *intf, struct device_manage
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_rma_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_generate_error_packet;
intf->device_manager = device_manager;

Просмотреть файл

@ -30,7 +30,6 @@ int cmd_interface_rma_process_response (const struct cmd_interface *intf,
#define CMD_INTERFACE_RMA_API_INIT { \
.process_request = cmd_interface_rma_process_request, \
CMD_INTERFACE_RMA_RESPONSE_API \
.generate_error_packet = cmd_interface_generate_error_packet, \
.session = NULL, \
}

Просмотреть файл

@ -142,18 +142,6 @@ static int cmd_interface_spdm_process_response (const struct cmd_interface *intf
}
#endif
static int cmd_interface_spdm_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
UNUSED (intf);
UNUSED (request);
UNUSED (error_code);
UNUSED (error_data);
UNUSED (cmd_set);
return CMD_HANDLER_SPDM_UNSUPPORTED_OPERATION;
}
/**
* Initialize SPDM command interface instance
*
@ -180,7 +168,6 @@ int cmd_interface_spdm_init (struct cmd_interface_spdm *intf)
#ifdef CMD_ENABLE_ISSUE_REQUEST
intf->base.process_response = cmd_interface_spdm_process_response;
#endif
intf->base.generate_error_packet = cmd_interface_spdm_generate_error_packet;
return 0;
}

Просмотреть файл

@ -146,29 +146,6 @@ int cmd_interface_spdm_process_response (const struct cmd_interface *intf,
}
#endif
/**
* Generate an SPDM error packet.
*
* @param intf SPDM command responder interface.
* @param request SPDM request message.
* @param error_code SPDM error code.
* @param error_data SPDM error data.
* @param cmd_set SPDM command set.
*
* @return 0 if the packet was generated successfully or an error code.
*/
int cmd_interface_spdm_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
UNUSED (intf);
UNUSED (request);
UNUSED (error_code);
UNUSED (error_data);
UNUSED (cmd_set);
return CMD_HANDLER_SPDM_RESPONDER_UNSUPPORTED_OPERATION;
}
/**
* Initialize the SPDM responder instance.
*
@ -231,7 +208,6 @@ int cmd_interface_spdm_responder_init (struct cmd_interface_spdm_responder *spdm
#ifdef CMD_ENABLE_ISSUE_REQUEST
spdm_responder->base.process_response = cmd_interface_spdm_process_response;
#endif
spdm_responder->base.generate_error_packet = cmd_interface_spdm_generate_error_packet;
status = cmd_interface_spdm_responder_init_state (spdm_responder);
if (status != 0) {

Просмотреть файл

@ -10,12 +10,9 @@
/* Internal function declarations to allow for static initialization. */
int cmd_interface_spdm_process_request (const struct cmd_interface *intf,
struct cmd_interface_msg *request);
int cmd_interface_spdm_process_response (const struct cmd_interface *intf,
struct cmd_interface_msg *response);
int cmd_interface_spdm_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set);
/**
* Constant initializer for response handling.
@ -30,12 +27,12 @@ int cmd_interface_spdm_generate_error_packet (const struct cmd_interface *intf,
/**
* Constant initializer for the SPDM Responder API.
*/
#define CMD_INTERFACE_SPDM_RESPONDER_API_INIT { \
#define CMD_INTERFACE_SPDM_RESPONDER_API_INIT { \
.process_request = cmd_interface_spdm_process_request, \
CMD_INTERFACE_SPDM_RESPONDER_RESPONSE_API \
.generate_error_packet = cmd_interface_spdm_generate_error_packet \
}
/**
* SPDM Responder Static Initialization.
*
@ -57,11 +54,11 @@ int cmd_interface_spdm_generate_error_packet (const struct cmd_interface *intf,
* @param rng_engine_ptr RNG Engine instance pointer.
* @param session_manager_ptr Secure Session Manager instance pointer.
*/
#define cmd_interface_spdm_responder_static_init(state_ptr, transcript_manager_ptr, hash_engine_ptr, \
hash_engine_count_arg, version_num_ptr, version_num_count_arg, \
secured_message_version_num_ptr, secured_message_version_num_count_arg, local_capabilities_ptr, \
local_algorithms_ptr, key_manager_ptr, measurements_ptr, ecc_engine_ptr, rng_engine_ptr, \
session_manager_ptr) { \
#define cmd_interface_spdm_responder_static_init(state_ptr, transcript_manager_ptr, \
hash_engine_ptr, hash_engine_count_arg, version_num_ptr, version_num_count_arg, \
secured_message_version_num_ptr, secured_message_version_num_count_arg, \
local_capabilities_ptr, local_algorithms_ptr, key_manager_ptr, measurements_ptr, \
ecc_engine_ptr, rng_engine_ptr, session_manager_ptr) { \
.base = CMD_INTERFACE_SPDM_RESPONDER_API_INIT, \
.state = state_ptr, \
.transcript_manager = transcript_manager_ptr, \

Просмотреть файл

@ -41,16 +41,10 @@ void cerberus_protocol_required_commands_testing_supports_all_required_commands
cerberus_protocol_required_commands_testing_process_get_device_id (test, cmd, vendor_id,
device_id, subsystem_vid, subsystem_id);
cerberus_protocol_required_commands_testing_process_reset_counter (test, cmd, cmd_device);
cerberus_protocol_required_commands_testing_generate_error_packet (test, cmd);
cerberus_protocol_required_commands_testing_generate_error_packet_invalid_arg (test, cmd);
if (session) {
cerberus_protocol_required_commands_testing_process_get_challenge_response (test, cmd,
attestation, session);
cerberus_protocol_required_commands_testing_generate_error_packet_encrypted (test, cmd,
session);
cerberus_protocol_required_commands_testing_generate_error_packet_encrypted_fail (test, cmd,
session);
}
else {
cerberus_protocol_required_commands_testing_process_get_challenge_response_no_session_mgr (
@ -3491,174 +3485,6 @@ void cerberus_protocol_master_commands_testing_process_error_response_invalid_le
CuAssertIntEquals (test, CMD_HANDLER_INVALID_ERROR_MSG, status);
}
void cerberus_protocol_required_commands_testing_generate_error_packet (CuTest *test,
struct cmd_interface *cmd)
{
uint8_t data[MCTP_BASE_PROTOCOL_MAX_MESSAGE_BODY];
struct cmd_interface_msg error_packet;
struct cerberus_protocol_error *error = (struct cerberus_protocol_error*) data;
int status;
memset (&error_packet, 0, sizeof (error_packet));
memset (data, 0, sizeof (data));
error_packet.data = data;
status = cmd->generate_error_packet (cmd, &error_packet, CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, 0, status);
CuAssertIntEquals (test, sizeof (struct cerberus_protocol_error), error_packet.length);
CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF, error->header.msg_type);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_MSFT_PCI_VID, error->header.pci_vendor_id);
CuAssertIntEquals (test, 0, error->header.crypt);
CuAssertIntEquals (test, 0, error->header.reserved2);
CuAssertIntEquals (test, 0, error->header.integrity_check);
CuAssertIntEquals (test, 0, error->header.reserved1);
CuAssertIntEquals (test, 0, error->header.rq);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_ERROR, error->header.command);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_NO_ERROR, error->error_code);
CuAssertIntEquals (test, 0, error->error_data);
}
void cerberus_protocol_required_commands_testing_generate_error_packet_encrypted (CuTest *test,
struct cmd_interface *cmd, struct session_manager_mock *session)
{
uint8_t error_data[MCTP_BASE_PROTOCOL_MAX_MESSAGE_BODY];
struct cmd_interface_msg error_packet;
uint8_t encrypted_error_data[MCTP_BASE_PROTOCOL_MAX_MESSAGE_BODY];
struct cmd_interface_msg encrypted_error_packet;
struct cerberus_protocol_error *error = (struct cerberus_protocol_error*) error_data;
int status;
memset (&error_packet, 0, sizeof (error_packet));
memset (error_data, 0, sizeof (error_data));
error_packet.data = error_data;
memset (&encrypted_error_packet, 0, sizeof (encrypted_error_packet));
memset (encrypted_error_data, 0, sizeof (encrypted_error_data));
encrypted_error_packet.data = encrypted_error_data;
error->header.msg_type = 0x7E;
error->header.pci_vendor_id = 0x1414;
error->header.crypt = 0;
error->header.reserved2 = 0;
error->header.integrity_check = 0;
error->header.reserved1 = 0;
error->header.rq = 0;
error->header.command = 0x7F;
error->error_code = CERBERUS_PROTOCOL_NO_ERROR;
error->error_data = 0;
error_packet.length = sizeof (struct cerberus_protocol_error);
error_packet.payload = error_packet.data;
error_packet.payload_length = error_packet.length;
error_packet.max_response = MCTP_BASE_PROTOCOL_MIN_TRANSMISSION_UNIT;
error_packet.source_eid = MCTP_BASE_PROTOCOL_BMC_EID;
error_packet.target_eid = MCTP_BASE_PROTOCOL_PA_ROT_CTRL_EID;
error_packet.is_encrypted = true;
error = (struct cerberus_protocol_error*) encrypted_error_packet.data;
error->header.msg_type = 0x7E;
error->header.pci_vendor_id = 0x1414;
error->header.crypt = 1;
error->header.reserved2 = 0;
error->header.integrity_check = 0;
error->header.reserved1 = 0;
error->header.rq = 0;
error->header.command = 0x7F;
error->error_code = 0xAA;
error->error_data = 0xBB;
encrypted_error_packet.length = sizeof (struct cerberus_protocol_error) +
SESSION_MANAGER_TRAILER_LEN;
encrypted_error_packet.payload = encrypted_error_packet.data;
encrypted_error_packet.payload_length = encrypted_error_packet.length;
encrypted_error_packet.source_eid = MCTP_BASE_PROTOCOL_BMC_EID;
encrypted_error_packet.target_eid = MCTP_BASE_PROTOCOL_PA_ROT_CTRL_EID;
encrypted_error_packet.is_encrypted = true;
status = mock_expect (&session->mock, session->base.encrypt_message, session, 0,
MOCK_ARG_VALIDATOR_DEEP_COPY_TMP (cmd_interface_mock_validate_request, &error_packet,
sizeof (error_packet), cmd_interface_mock_save_request, cmd_interface_mock_free_request,
cmd_interface_mock_duplicate_request));
status |= mock_expect_output_deep_copy (&session->mock, 0, &encrypted_error_packet,
sizeof (encrypted_error_packet), cmd_interface_mock_copy_request);
CuAssertIntEquals (test, 0, status);
error = (struct cerberus_protocol_error*) error_packet.data;
memset (error_data, 0, sizeof (error_data));
error_packet.length = 0;
error_packet.max_response = MCTP_BASE_PROTOCOL_MIN_TRANSMISSION_UNIT;
status = cmd->generate_error_packet (cmd, &error_packet, CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, 0, status);
CuAssertIntEquals (test, sizeof (struct cerberus_protocol_error) + SESSION_MANAGER_TRAILER_LEN,
error_packet.length);
CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF, error->header.msg_type);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_MSFT_PCI_VID, error->header.pci_vendor_id);
CuAssertIntEquals (test, 1, error->header.crypt);
CuAssertIntEquals (test, 0, error->header.reserved2);
CuAssertIntEquals (test, 0, error->header.integrity_check);
CuAssertIntEquals (test, 0, error->header.reserved1);
CuAssertIntEquals (test, 0, error->header.rq);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_ERROR, error->header.command);
CuAssertIntEquals (test, 0xAA, error->error_code);
CuAssertIntEquals (test, 0xBB, error->error_data);
}
void cerberus_protocol_required_commands_testing_generate_error_packet_encrypted_fail (CuTest *test,
struct cmd_interface *cmd, struct session_manager_mock *session)
{
uint8_t error_data[MCTP_BASE_PROTOCOL_MAX_MESSAGE_BODY];
struct cmd_interface_msg error_packet;
struct cerberus_protocol_error *error = (struct cerberus_protocol_error*) error_data;
int status;
memset (&error_packet, 0, sizeof (error_packet));
memset (error_data, 0, sizeof (error_data));
error_packet.data = error_data;
error->header.msg_type = 0x7E;
error->header.pci_vendor_id = 0x1414;
error->header.crypt = 0;
error->header.reserved2 = 0;
error->header.integrity_check = 0;
error->header.reserved1 = 0;
error->header.rq = 0;
error->header.command = 0x7F;
error->error_code = CERBERUS_PROTOCOL_NO_ERROR;
error->error_data = 0;
error_packet.length = sizeof (struct cerberus_protocol_error);
error_packet.payload = error_packet.data;
error_packet.payload_length = error_packet.length;
error_packet.max_response = MCTP_BASE_PROTOCOL_MIN_TRANSMISSION_UNIT;
error_packet.source_eid = MCTP_BASE_PROTOCOL_BMC_EID;
error_packet.target_eid = MCTP_BASE_PROTOCOL_PA_ROT_CTRL_EID;
error_packet.is_encrypted = true;
status = mock_expect (&session->mock, session->base.encrypt_message, session,
SESSION_MANAGER_NO_MEMORY,
MOCK_ARG_VALIDATOR_DEEP_COPY_TMP (cmd_interface_mock_validate_request, &error_packet,
sizeof (error_packet), cmd_interface_mock_save_request, cmd_interface_mock_free_request,
cmd_interface_mock_duplicate_request));
CuAssertIntEquals (test, 0, status);
status = cmd->generate_error_packet (cmd, &error_packet, CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, SESSION_MANAGER_NO_MEMORY, status);
}
void cerberus_protocol_required_commands_testing_generate_error_packet_invalid_arg (CuTest *test,
struct cmd_interface *cmd)
{
struct cmd_interface_msg error_packet;
int status;
status = cmd->generate_error_packet (NULL, &error_packet, CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, CMD_HANDLER_INVALID_ARGUMENT, status);
status = cmd->generate_error_packet (cmd, NULL, CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, CMD_HANDLER_INVALID_ARGUMENT, status);
}
/*******************
* Test cases

Просмотреть файл

@ -203,14 +203,5 @@ void cerberus_protocol_master_commands_testing_process_error_response (CuTest *t
void cerberus_protocol_master_commands_testing_process_error_response_invalid_len (CuTest *test,
struct cmd_interface *cmd, struct cmd_interface_msg *response);
void cerberus_protocol_required_commands_testing_generate_error_packet (CuTest *test,
struct cmd_interface *cmd);
void cerberus_protocol_required_commands_testing_generate_error_packet_encrypted (CuTest *test,
struct cmd_interface *cmd, struct session_manager_mock *session);
void cerberus_protocol_required_commands_testing_generate_error_packet_encrypted_fail (CuTest *test,
struct cmd_interface *cmd, struct session_manager_mock *session);
void cerberus_protocol_required_commands_testing_generate_error_packet_invalid_arg (CuTest *test,
struct cmd_interface *cmd);
#endif /* CERBERUS_PROTOCOL_REQUIRED_COMMANDS_TESTING_H_ */

Просмотреть файл

@ -252,7 +252,6 @@ static void cmd_interface_ac_rot_test_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.handler.base.process_request);
CuAssertPtrNotNull (test, cmd.handler.base.process_response);
CuAssertPtrNotNull (test, cmd.handler.base.generate_error_packet);
complete_cmd_interface_ac_rot_mock_test (test, &cmd);
}
@ -312,7 +311,6 @@ static void cmd_interface_ac_rot_test_static_init (CuTest *test)
CuAssertPtrNotNull (test, interface.base.process_request);
CuAssertPtrNotNull (test, interface.base.process_response);
CuAssertPtrNotNull (test, interface.base.generate_error_packet);
cmd_interface_ac_rot_testing_init_dependencies (test, &cmd);
@ -2340,82 +2338,6 @@ static void cmd_interface_ac_rot_test_process_response_static_init (CuTest *test
cmd_interface_ac_rot_deinit (&test_static);
}
static void cmd_interface_ac_rot_test_generate_error_packet (CuTest *test)
{
struct cmd_interface_ac_rot_testing cmd;
TEST_START;
setup_cmd_interface_ac_rot_mock_test (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet (test, &cmd.handler.base);
complete_cmd_interface_ac_rot_mock_test (test, &cmd);
}
static void cmd_interface_ac_rot_test_generate_error_packet_encrypted (CuTest *test)
{
struct cmd_interface_ac_rot_testing cmd;
TEST_START;
setup_cmd_interface_ac_rot_mock_test (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet_encrypted (test,
&cmd.handler.base, &cmd.session);
complete_cmd_interface_ac_rot_mock_test (test, &cmd);
}
static void cmd_interface_ac_rot_test_generate_error_packet_static_init (CuTest *test)
{
struct cmd_interface_ac_rot_testing cmd;
struct cmd_interface_ac_rot test_static =
cmd_interface_ac_rot_static_init (&cmd.attestation.base, &cmd.device_manager,
&cmd.background.base, &cmd.fw_version, &cmd.riot, &cmd.cmd_device.base, 0x1234, 20, 0x5678,
40, &cmd.session.base);
TEST_START;
cmd_interface_ac_rot_testing_init_dependencies (test, &cmd);
setup_cmd_interface_ac_rot_mock_test_init_fw_version (&cmd, CERBERUS_FW_VERSION,
RIOT_CORE_VERSION, FW_VERSION_COUNT);
cerberus_protocol_required_commands_testing_generate_error_packet (test, &test_static.base);
cmd_interface_ac_rot_testing_release_dependencies (test, &cmd);
cmd_interface_ac_rot_deinit (&test_static);
}
static void cmd_interface_ac_rot_test_generate_error_packet_encrypted_fail (CuTest *test)
{
struct cmd_interface_ac_rot_testing cmd;
TEST_START;
setup_cmd_interface_ac_rot_mock_test (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet_encrypted_fail (test,
&cmd.handler.base, &cmd.session);
complete_cmd_interface_ac_rot_mock_test (test, &cmd);
}
static void cmd_interface_ac_rot_test_generate_error_packet_invalid_arg (CuTest *test)
{
struct cmd_interface_ac_rot_testing cmd;
TEST_START;
setup_cmd_interface_ac_rot_mock_test (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet_invalid_arg (test,
&cmd.handler.base);
complete_cmd_interface_ac_rot_mock_test (test, &cmd);
}
// *INDENT-OFF*
TEST_SUITE_START (cmd_interface_ac_rot);
@ -2530,11 +2452,6 @@ TEST (cmd_interface_ac_rot_test_process_session_sync_invalid_len);
TEST (cmd_interface_ac_rot_test_supports_all_required_commands);
TEST (cmd_interface_ac_rot_test_process_response);
TEST (cmd_interface_ac_rot_test_process_response_static_init);
TEST (cmd_interface_ac_rot_test_generate_error_packet);
TEST (cmd_interface_ac_rot_test_generate_error_packet_encrypted);
TEST (cmd_interface_ac_rot_test_generate_error_packet_static_init);
TEST (cmd_interface_ac_rot_test_generate_error_packet_encrypted_fail);
TEST (cmd_interface_ac_rot_test_generate_error_packet_invalid_arg);
TEST_SUITE_END;
// *INDENT-ON*

Просмотреть файл

@ -113,7 +113,6 @@ static void cmd_interface_dual_cmd_set_test_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.interface.base.process_request);
CuAssertPtrNotNull (test, cmd.interface.base.process_response);
CuAssertPtrNotNull (test, cmd.interface.base.generate_error_packet);
complete_cmd_interface_dual_cmd_set_test (test, &cmd);
}
@ -149,7 +148,6 @@ static void cmd_interface_dual_cmd_set_test_static_init (CuTest *test)
CuAssertPtrNotNull (test, test_static.base.process_request);
CuAssertPtrNotNull (test, test_static.base.process_response);
CuAssertPtrNotNull (test, test_static.base.generate_error_packet);
cmd_interface_dual_cmd_set_testing_init_dependencies (test, &cmd);
@ -1649,243 +1647,6 @@ static void cmd_interface_dual_cmd_set_test_process_response_cmd_set_1_fail (CuT
complete_cmd_interface_dual_cmd_set_test (test, &cmd);
}
static void cmd_interface_dual_cmd_set_test_generate_error_packet_set_0 (CuTest *test)
{
struct cmd_interface_dual_cmd_set_testing cmd;
uint8_t error_data[sizeof (struct cerberus_protocol_error)];
struct cmd_interface_msg error_packet;
struct cerberus_protocol_error *error = (struct cerberus_protocol_error*) error_data;
int status;
TEST_START;
setup_cmd_interface_dual_cmd_set_test (test, &cmd);
memset (&error_packet, 0, sizeof (error_packet));
memset (error_data, 0, sizeof (error_data));
error_packet.data = error_data;
error->header.msg_type = 0x7E;
error->header.pci_vendor_id = 0x1414;
error->header.crypt = 0;
error->header.reserved2 = 0;
error->header.integrity_check = 0;
error->header.reserved1 = 0;
error->header.rq = 0;
error->header.command = 0x7F;
error->error_code = CERBERUS_PROTOCOL_NO_ERROR;
error->error_data = 0;
error_packet.data = error_data;
error_packet.length = sizeof (error_data);
status = mock_expect (&cmd.primary_handler.mock, cmd.primary_handler.base.generate_error_packet,
&cmd.primary_handler, 0, MOCK_ARG_PTR (&error_packet),
MOCK_ARG (CERBERUS_PROTOCOL_NO_ERROR), MOCK_ARG (0), MOCK_ARG (0));
status |= mock_expect_output_deep_copy (&cmd.primary_handler.mock, 0, &error_packet,
sizeof (error_packet), cmd_interface_mock_copy_request);
CuAssertIntEquals (test, 0, status);
status = cmd.interface.base.generate_error_packet (&cmd.interface.base, &error_packet,
CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, 0, status);
CuAssertIntEquals (test, sizeof (struct cerberus_protocol_error), error_packet.length);
CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF, error->header.msg_type);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_MSFT_PCI_VID, error->header.pci_vendor_id);
CuAssertIntEquals (test, 0, error->header.crypt);
CuAssertIntEquals (test, 0, error->header.reserved2);
CuAssertIntEquals (test, 0, error->header.integrity_check);
CuAssertIntEquals (test, 0, error->header.reserved1);
CuAssertIntEquals (test, 0, error->header.rq);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_ERROR, error->header.command);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_NO_ERROR, error->error_code);
CuAssertIntEquals (test, 0, error->error_data);
complete_cmd_interface_dual_cmd_set_test (test, &cmd);
}
static void cmd_interface_dual_cmd_set_test_generate_error_packet_set_1 (CuTest *test)
{
struct cmd_interface_dual_cmd_set_testing cmd;
uint8_t error_data[sizeof (struct cerberus_protocol_error)];
struct cmd_interface_msg error_packet;
struct cerberus_protocol_error *error = (struct cerberus_protocol_error*) error_data;
int status;
TEST_START;
setup_cmd_interface_dual_cmd_set_test (test, &cmd);
memset (&error_packet, 0, sizeof (error_packet));
memset (error_data, 0, sizeof (error_data));
error_packet.data = error_data;
error->header.msg_type = 0x7E;
error->header.pci_vendor_id = 0x1414;
error->header.crypt = 0;
error->header.reserved2 = 0;
error->header.integrity_check = 0;
error->header.reserved1 = 0;
error->header.rq = 1;
error->header.command = 0x7F;
error->error_code = CERBERUS_PROTOCOL_NO_ERROR;
error->error_data = 0;
error_packet.data = error_data;
error_packet.length = sizeof (error_data);
status = mock_expect (&cmd.secondary_handler.mock,
cmd.secondary_handler.base.generate_error_packet, &cmd.secondary_handler, 0,
MOCK_ARG_PTR (&error_packet), MOCK_ARG (CERBERUS_PROTOCOL_NO_ERROR), MOCK_ARG (0),
MOCK_ARG (1));
status |= mock_expect_output_deep_copy (&cmd.secondary_handler.mock, 0, &error_packet,
sizeof (error_packet), cmd_interface_mock_copy_request);
CuAssertIntEquals (test, 0, status);
status = cmd.interface.base.generate_error_packet (&cmd.interface.base, &error_packet,
CERBERUS_PROTOCOL_NO_ERROR, 0, 1);
CuAssertIntEquals (test, 0, status);
CuAssertIntEquals (test, sizeof (struct cerberus_protocol_error), error_packet.length);
CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF, error->header.msg_type);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_MSFT_PCI_VID, error->header.pci_vendor_id);
CuAssertIntEquals (test, 0, error->header.crypt);
CuAssertIntEquals (test, 0, error->header.reserved2);
CuAssertIntEquals (test, 0, error->header.integrity_check);
CuAssertIntEquals (test, 0, error->header.reserved1);
CuAssertIntEquals (test, 1, error->header.rq);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_ERROR, error->header.command);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_NO_ERROR, error->error_code);
CuAssertIntEquals (test, 0, error->error_data);
complete_cmd_interface_dual_cmd_set_test (test, &cmd);
}
static void cmd_interface_dual_cmd_set_test_generate_error_packet_static_init (CuTest *test)
{
struct cmd_interface_dual_cmd_set_testing cmd;
struct cmd_interface_dual_cmd_set test_static =
cmd_interface_dual_cmd_set_static_init (&cmd.primary_handler.base,
&cmd.secondary_handler.base);
uint8_t error_data[sizeof (struct cerberus_protocol_error)];
struct cmd_interface_msg error_packet;
struct cerberus_protocol_error *error = (struct cerberus_protocol_error*) error_data;
int status;
TEST_START;
cmd_interface_dual_cmd_set_testing_init_dependencies (test, &cmd);
memset (&error_packet, 0, sizeof (error_packet));
memset (error_data, 0, sizeof (error_data));
error_packet.data = error_data;
error->header.msg_type = 0x7E;
error->header.pci_vendor_id = 0x1414;
error->header.crypt = 0;
error->header.reserved2 = 0;
error->header.integrity_check = 0;
error->header.reserved1 = 0;
error->header.rq = 0;
error->header.command = 0x7F;
error->error_code = CERBERUS_PROTOCOL_NO_ERROR;
error->error_data = 0;
error_packet.data = error_data;
error_packet.length = sizeof (error_data);
status = mock_expect (&cmd.primary_handler.mock, cmd.primary_handler.base.generate_error_packet,
&cmd.primary_handler, 0, MOCK_ARG_PTR (&error_packet),
MOCK_ARG (CERBERUS_PROTOCOL_NO_ERROR), MOCK_ARG (0), MOCK_ARG (0));
status |= mock_expect_output_deep_copy (&cmd.primary_handler.mock, 0, &error_packet,
sizeof (error_packet), cmd_interface_mock_copy_request);
CuAssertIntEquals (test, 0, status);
status = test_static.base.generate_error_packet (&test_static.base, &error_packet,
CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, 0, status);
CuAssertIntEquals (test, sizeof (struct cerberus_protocol_error), error_packet.length);
CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF, error->header.msg_type);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_MSFT_PCI_VID, error->header.pci_vendor_id);
CuAssertIntEquals (test, 0, error->header.crypt);
CuAssertIntEquals (test, 0, error->header.reserved2);
CuAssertIntEquals (test, 0, error->header.integrity_check);
CuAssertIntEquals (test, 0, error->header.reserved1);
CuAssertIntEquals (test, 0, error->header.rq);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_ERROR, error->header.command);
CuAssertIntEquals (test, CERBERUS_PROTOCOL_NO_ERROR, error->error_code);
CuAssertIntEquals (test, 0, error->error_data);
cmd_interface_dual_cmd_set_testing_release_dependencies (test, &cmd);
cmd_interface_dual_cmd_set_deinit (&test_static);
}
static void cmd_interface_dual_cmd_set_test_generate_error_packet_null (CuTest *test)
{
struct cmd_interface_dual_cmd_set_testing cmd;
struct cmd_interface_msg error_packet;
int status;
TEST_START;
setup_cmd_interface_dual_cmd_set_test (test, &cmd);
status = cmd.interface.base.generate_error_packet (NULL, &error_packet,
CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, CMD_HANDLER_INVALID_ARGUMENT, status);
complete_cmd_interface_dual_cmd_set_test (test, &cmd);
}
static void cmd_interface_dual_cmd_set_test_generate_error_packet_set_0_fail (CuTest *test)
{
struct cmd_interface_dual_cmd_set_testing cmd;
struct cmd_interface_msg error_packet;
int status;
TEST_START;
setup_cmd_interface_dual_cmd_set_test (test, &cmd);
status = mock_expect (&cmd.primary_handler.mock, cmd.primary_handler.base.generate_error_packet,
&cmd.primary_handler, CMD_HANDLER_NO_MEMORY, MOCK_ARG_PTR (&error_packet),
MOCK_ARG (CERBERUS_PROTOCOL_NO_ERROR), MOCK_ARG (0), MOCK_ARG (0));
CuAssertIntEquals (test, 0, status);
status = cmd.interface.base.generate_error_packet (&cmd.interface.base, &error_packet,
CERBERUS_PROTOCOL_NO_ERROR, 0, 0);
CuAssertIntEquals (test, CMD_HANDLER_NO_MEMORY, status);
complete_cmd_interface_dual_cmd_set_test (test, &cmd);
}
static void cmd_interface_dual_cmd_set_test_generate_error_packet_set_1_fail (CuTest *test)
{
struct cmd_interface_dual_cmd_set_testing cmd;
struct cmd_interface_msg error_packet;
int status;
TEST_START;
setup_cmd_interface_dual_cmd_set_test (test, &cmd);
status = mock_expect (&cmd.secondary_handler.mock,
cmd.secondary_handler.base.generate_error_packet, &cmd.secondary_handler,
CMD_HANDLER_NO_MEMORY, MOCK_ARG_PTR (&error_packet), MOCK_ARG (CERBERUS_PROTOCOL_NO_ERROR),
MOCK_ARG (0), MOCK_ARG (1));
CuAssertIntEquals (test, 0, status);
status = cmd.interface.base.generate_error_packet (&cmd.interface.base, &error_packet,
CERBERUS_PROTOCOL_NO_ERROR, 0, 1);
CuAssertIntEquals (test, CMD_HANDLER_NO_MEMORY, status);
complete_cmd_interface_dual_cmd_set_test (test, &cmd);
}
// *INDENT-OFF*
TEST_SUITE_START (cmd_interface_dual_cmd_set);
@ -1920,12 +1681,6 @@ TEST (cmd_interface_dual_cmd_set_test_process_response_cmd_set_0_reserved_fields
TEST (cmd_interface_dual_cmd_set_test_process_response_cmd_set_1_reserved_fields_not_zero);
TEST (cmd_interface_dual_cmd_set_test_process_response_cmd_set_0_fail);
TEST (cmd_interface_dual_cmd_set_test_process_response_cmd_set_1_fail);
TEST (cmd_interface_dual_cmd_set_test_generate_error_packet_set_0);
TEST (cmd_interface_dual_cmd_set_test_generate_error_packet_set_1);
TEST (cmd_interface_dual_cmd_set_test_generate_error_packet_static_init);
TEST (cmd_interface_dual_cmd_set_test_generate_error_packet_null);
TEST (cmd_interface_dual_cmd_set_test_generate_error_packet_set_0_fail);
TEST (cmd_interface_dual_cmd_set_test_generate_error_packet_set_1_fail);
TEST_SUITE_END;
// *INDENT-ON*

Просмотреть файл

@ -166,7 +166,6 @@ static void cmd_interface_multi_handler_test_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.test.base.process_request);
CuAssertPtrNotNull (test, cmd.test.base.process_response);
CuAssertPtrNotNull (test, cmd.test.base.generate_error_packet);
CuAssertPtrNotNull (test, cmd.test.is_message_type_supported);
@ -210,7 +209,6 @@ static void cmd_interface_multi_handler_test_static_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.test.base.process_request);
CuAssertPtrNotNull (test, cmd.test.base.process_response);
CuAssertPtrNotNull (test, cmd.test.base.generate_error_packet);
CuAssertPtrNotNull (test, cmd.test.is_message_type_supported);
@ -1438,40 +1436,6 @@ static void cmd_interface_multi_handler_test_process_response_static_init (CuTes
cmd_interface_multi_handler_testing_release (test, &cmd);
}
static void cmd_interface_multi_handler_test_generate_error_packet (CuTest *test)
{
struct cmd_interface_multi_handler_testing cmd;
struct cmd_interface_msg request;
int status;
TEST_START;
cmd_interface_multi_handler_testing_init (test, &cmd);
status = cmd.test.base.generate_error_packet (&cmd.test.base, &request, 0, 0, 0);
CuAssertIntEquals (test, CMD_HANDLER_UNSUPPORTED_OPERATION, status);
cmd_interface_multi_handler_testing_release (test, &cmd);
}
static void cmd_interface_multi_handler_test_generate_error_packet_static_init (CuTest *test)
{
struct cmd_interface_multi_handler_testing cmd = {
.test = cmd_interface_multi_handler_static_init (&cmd.protocol.base, cmd.msg_type, 3)
};
struct cmd_interface_msg request;
int status;
TEST_START;
cmd_interface_multi_handler_testing_init_dependencies (test, &cmd);
status = cmd.test.base.generate_error_packet (&cmd.test.base, &request, 0, 0, 0);
CuAssertIntEquals (test, CMD_HANDLER_UNSUPPORTED_OPERATION, status);
cmd_interface_multi_handler_testing_release (test, &cmd);
}
static void cmd_interface_multi_handler_test_is_message_type_supported (CuTest *test)
{
struct cmd_interface_multi_handler_testing cmd;
@ -1582,8 +1546,6 @@ TEST (cmd_interface_multi_handler_test_process_request_unknown_message_type_with
TEST (cmd_interface_multi_handler_test_process_request_unknown_message_type_no_response_handling);
TEST (cmd_interface_multi_handler_test_process_response);
TEST (cmd_interface_multi_handler_test_process_response_static_init);
TEST (cmd_interface_multi_handler_test_generate_error_packet);
TEST (cmd_interface_multi_handler_test_generate_error_packet_static_init);
TEST (cmd_interface_multi_handler_test_is_message_type_supported);
TEST (cmd_interface_multi_handler_test_is_message_type_supported_static_init);
TEST (cmd_interface_multi_handler_test_is_message_type_supported_null);

Просмотреть файл

@ -31,7 +31,6 @@ static void cmd_interface_null_test_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.base.process_request);
CuAssertPtrNotNull (test, cmd.base.process_response);
CuAssertPtrNotNull (test, cmd.base.generate_error_packet);
cmd_interface_null_release (&cmd);
}
@ -54,7 +53,6 @@ static void cmd_interface_null_test_static_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.base.process_request);
CuAssertPtrNotNull (test, cmd.base.process_response);
CuAssertPtrNotNull (test, cmd.base.generate_error_packet);
cmd_interface_null_release (&cmd);
}
@ -255,47 +253,6 @@ static void cmd_interface_null_test_init_process_response_null (CuTest *test)
cmd_interface_null_release (&cmd);
}
static void cmd_interface_null_test_init_generate_error_packet (CuTest *test)
{
struct cmd_interface_null cmd;
int status;
TEST_START;
status = cmd_interface_null_init (&cmd);
CuAssertIntEquals (test, 0, status);
cerberus_protocol_required_commands_testing_generate_error_packet (test, &cmd.base);
cmd_interface_null_release (&cmd);
}
static void cmd_interface_null_test_init_generate_error_packet_static_init (CuTest *test)
{
struct cmd_interface_null cmd = cmd_interface_null_static_init;
TEST_START;
cerberus_protocol_required_commands_testing_generate_error_packet (test, &cmd.base);
cmd_interface_null_release (&cmd);
}
static void cmd_interface_null_test_init_generate_error_packet_null (CuTest *test)
{
struct cmd_interface_null cmd;
int status;
TEST_START;
status = cmd_interface_null_init (&cmd);
CuAssertIntEquals (test, 0, status);
cerberus_protocol_required_commands_testing_generate_error_packet_invalid_arg (test, &cmd.base);
cmd_interface_null_release (&cmd);
}
// *INDENT-OFF*
TEST_SUITE_START (cmd_interface_null);
@ -310,9 +267,6 @@ TEST (cmd_interface_null_test_init_process_request_null);
TEST (cmd_interface_null_test_init_process_response);
TEST (cmd_interface_null_test_init_process_response_static_init);
TEST (cmd_interface_null_test_init_process_response_null);
TEST (cmd_interface_null_test_init_generate_error_packet);
TEST (cmd_interface_null_test_init_generate_error_packet_static_init);
TEST (cmd_interface_null_test_init_generate_error_packet_null);
TEST_SUITE_END;
// *INDENT-ON*

Просмотреть файл

@ -677,7 +677,6 @@ static void cmd_interface_system_test_init (CuTest *test)
CuAssertPtrNotNull (test, interface.base.process_request);
CuAssertPtrNotNull (test, interface.base.process_response);
CuAssertPtrNotNull (test, interface.base.generate_error_packet);
status = firmware_update_control_mock_validate_and_release (&update);
CuAssertIntEquals (test, 0, status);
@ -8301,65 +8300,6 @@ static void cmd_interface_system_test_process_response_device_capabilities_rsvd_
complete_cmd_interface_system_mock_test (test, &cmd);
}
static void cmd_interface_system_test_generate_error_packet (CuTest *test)
{
struct cmd_interface_system_testing cmd;
TEST_START;
setup_cmd_interface_system_mock_test (test, &cmd, true, true, true, true, false, false, true,
true, true, true);
cerberus_protocol_required_commands_testing_generate_error_packet (test, &cmd.handler.base);
complete_cmd_interface_system_mock_test (test, &cmd);
}
static void cmd_interface_system_test_generate_error_packet_encrypted (CuTest *test)
{
struct cmd_interface_system_testing cmd;
TEST_START;
setup_cmd_interface_system_mock_test (test, &cmd, true, true, true, true, false, false, true,
true, true, true);
cerberus_protocol_required_commands_testing_generate_error_packet_encrypted (test,
&cmd.handler.base, &cmd.session);
complete_cmd_interface_system_mock_test (test, &cmd);
}
static void cmd_interface_system_test_generate_error_packet_encrypted_fail (CuTest *test)
{
struct cmd_interface_system_testing cmd;
TEST_START;
setup_cmd_interface_system_mock_test (test, &cmd, true, true, true, true, false, false, true,
true, true, true);
cerberus_protocol_required_commands_testing_generate_error_packet_encrypted_fail (test,
&cmd.handler.base, &cmd.session);
complete_cmd_interface_system_mock_test (test, &cmd);
}
static void cmd_interface_system_test_generate_error_packet_invalid_arg (CuTest *test)
{
struct cmd_interface_system_testing cmd;
TEST_START;
setup_cmd_interface_system_mock_test (test, &cmd, true, true, true, true, false, false, true,
true, true, true);
cerberus_protocol_required_commands_testing_generate_error_packet_invalid_arg (test,
&cmd.handler.base);
complete_cmd_interface_system_mock_test (test, &cmd);
}
static void cmd_interface_system_test_add_cerberus_protocol_observer_invalid_arg (CuTest *test)
{
struct cmd_interface_system_testing cmd;
@ -8908,10 +8848,6 @@ TEST (cmd_interface_system_test_process_response_device_capabilities);
TEST (cmd_interface_system_test_process_response_device_capabilities_no_observer);
TEST (cmd_interface_system_test_process_response_device_capabilities_invalid_buf_len);
TEST (cmd_interface_system_test_process_response_device_capabilities_rsvd_not_fail);
TEST (cmd_interface_system_test_generate_error_packet);
TEST (cmd_interface_system_test_generate_error_packet_encrypted);
TEST (cmd_interface_system_test_generate_error_packet_encrypted_fail);
TEST (cmd_interface_system_test_generate_error_packet_invalid_arg);
TEST (cmd_interface_system_test_add_cerberus_protocol_observer_invalid_arg);
TEST (cmd_interface_system_test_remove_cerberus_protocol_observer);
TEST (cmd_interface_system_test_remove_cerberus_protocol_observer_invalid_arg);

Просмотреть файл

@ -109,7 +109,6 @@ static void cmd_interface_mctp_control_test_init (CuTest *test)
CuAssertIntEquals (test, 0, status);
CuAssertPtrNotNull (test, cmd.handler.base.process_request);
CuAssertPtrNotNull (test, cmd.handler.base.process_response);
CuAssertPtrNotNull (test, cmd.handler.base.generate_error_packet);
complete_cmd_interface_mctp_control_test (test, &cmd);
}
@ -1373,23 +1372,6 @@ static void cmd_interface_mctp_control_test_process_response_discovery_notify_no
complete_cmd_interface_mctp_control_test (test, &cmd);
}
static void cmd_interface_mctp_control_test_generate_error_packet (CuTest *test)
{
struct cmd_interface_mctp_control_testing cmd;
struct cmd_interface_msg request;
int status;
TEST_START;
setup_cmd_interface_mctp_control_test (test, &cmd, true);
status = cmd.handler.base.generate_error_packet (&cmd.handler.base, &request, 0x0A, 0xAABBCCDD,
1);
CuAssertIntEquals (test, CMD_HANDLER_MCTP_CTRL_UNSUPPORTED_OPERATION, status);
complete_cmd_interface_mctp_control_test (test, &cmd);
}
static void cmd_interface_mctp_control_test_add_mctp_control_protocol_observer_invalid_arg (
CuTest *test)
{
@ -1529,7 +1511,6 @@ TEST (cmd_interface_mctp_control_test_process_response_discovery_notify);
TEST (cmd_interface_mctp_control_test_process_response_discovery_notify_fail);
TEST (cmd_interface_mctp_control_test_process_response_discovery_notify_cc_fail);
TEST (cmd_interface_mctp_control_test_process_response_discovery_notify_no_observer);
TEST (cmd_interface_mctp_control_test_generate_error_packet);
TEST (cmd_interface_mctp_control_test_add_mctp_control_protocol_observer_invalid_arg);
TEST (cmd_interface_mctp_control_test_remove_mctp_control_protocol_observer);
TEST (cmd_interface_mctp_control_test_remove_mctp_control_protocol_observer_invalid_arg);

Просмотреть файл

@ -34,26 +34,9 @@ static int cmd_interface_mock_process_response (const struct cmd_interface *intf
MOCK_ARG_PTR_CALL (response));
}
static int cmd_interface_mock_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
struct cmd_interface_mock *mock = (struct cmd_interface_mock*) intf;
if (mock == NULL) {
return MOCK_INVALID_ARGUMENT;
}
MOCK_RETURN (&mock->mock, cmd_interface_mock_generate_error_packet, intf,
MOCK_ARG_PTR_CALL (request), MOCK_ARG_CALL (error_code), MOCK_ARG_CALL (error_data),
MOCK_ARG_CALL (cmd_set));
}
static int cmd_interface_mock_func_arg_count (void *func)
{
if (func == cmd_interface_mock_generate_error_packet) {
return 4;
}
else if ((func == cmd_interface_mock_process_request) ||
if ((func == cmd_interface_mock_process_request) ||
(func == cmd_interface_mock_process_response)) {
return 1;
}
@ -70,9 +53,6 @@ static const char* cmd_interface_mock_func_name_map (void *func)
else if (func == cmd_interface_mock_process_response) {
return "process_response";
}
else if (func == cmd_interface_mock_generate_error_packet) {
return "generate_error_packet";
}
else {
return "unknown";
}
@ -92,21 +72,6 @@ static const char* cmd_interface_mock_arg_name_map (void *func, int arg)
return "response";
}
}
else if (func == cmd_interface_mock_generate_error_packet) {
switch (arg) {
case 0:
return "request";
case 1:
return "error_code";
case 2:
return "error_data";
case 3:
return "cmd_set";
}
}
return "unknown";
}
@ -137,7 +102,6 @@ int cmd_interface_mock_init (struct cmd_interface_mock *mock)
mock->base.process_request = cmd_interface_mock_process_request;
mock->base.process_response = cmd_interface_mock_process_response;
mock->base.generate_error_packet = cmd_interface_mock_generate_error_packet;
mock->mock.func_arg_count = cmd_interface_mock_func_arg_count;
mock->mock.func_name_map = cmd_interface_mock_func_name_map;

Просмотреть файл

@ -33,20 +33,6 @@ static int cmd_interface_multi_handler_mock_process_response (const struct cmd_i
MOCK_ARG_PTR_CALL (response));
}
static int cmd_interface_multi_handler_mock_generate_error_packet (const struct cmd_interface *intf,
struct cmd_interface_msg *request, uint8_t error_code, uint32_t error_data, uint8_t cmd_set)
{
struct cmd_interface_multi_handler_mock *mock = (struct cmd_interface_multi_handler_mock*) intf;
if (mock == NULL) {
return MOCK_INVALID_ARGUMENT;
}
MOCK_RETURN (&mock->mock, cmd_interface_multi_handler_mock_generate_error_packet, intf,
MOCK_ARG_PTR_CALL (request), MOCK_ARG_CALL (error_code), MOCK_ARG_CALL (error_data),
MOCK_ARG_CALL (cmd_set));
}
static int cmd_interface_multi_handler_mock_is_message_type_supported (
const struct cmd_interface_multi_handler *intf, uint32_t message_type)
{
@ -62,10 +48,7 @@ static int cmd_interface_multi_handler_mock_is_message_type_supported (
static int cmd_interface_multi_handler_mock_func_arg_count (void *func)
{
if (func == cmd_interface_multi_handler_mock_generate_error_packet) {
return 4;
}
else if ((func == cmd_interface_multi_handler_mock_process_request) ||
if ((func == cmd_interface_multi_handler_mock_process_request) ||
(func == cmd_interface_multi_handler_mock_process_response) ||
(func == cmd_interface_multi_handler_mock_is_message_type_supported)) {
return 1;
@ -83,9 +66,6 @@ static const char* cmd_interface_multi_handler_mock_func_name_map (void *func)
else if (func == cmd_interface_multi_handler_mock_process_response) {
return "process_response";
}
else if (func == cmd_interface_multi_handler_mock_generate_error_packet) {
return "generate_error_packet";
}
else if (func == cmd_interface_multi_handler_mock_is_message_type_supported) {
return "is_message_type_supported";
}
@ -108,21 +88,6 @@ static const char* cmd_interface_multi_handler_mock_arg_name_map (void *func, in
return "response";
}
}
else if (func == cmd_interface_multi_handler_mock_generate_error_packet) {
switch (arg) {
case 0:
return "request";
case 1:
return "error_code";
case 2:
return "error_data";
case 3:
return "cmd_set";
}
}
else if (func == cmd_interface_multi_handler_mock_is_message_type_supported) {
switch (arg) {
case 0:
@ -159,7 +124,6 @@ int cmd_interface_multi_handler_mock_init (struct cmd_interface_multi_handler_mo
mock->base.base.process_request = cmd_interface_multi_handler_mock_process_request;
mock->base.base.process_response = cmd_interface_multi_handler_mock_process_response;
mock->base.base.generate_error_packet = cmd_interface_multi_handler_mock_generate_error_packet;
mock->base.is_message_type_supported =
cmd_interface_multi_handler_mock_is_message_type_supported;

Просмотреть файл

@ -103,7 +103,6 @@ static void cmd_interface_ide_responder_test_static_init (CuTest *test)
CuAssertPtrNotNull (test, ide_responder.base.process_request);
CuAssertPtrNotNull (test, ide_responder.base.process_response);
CuAssertPtrNotNull (test, ide_responder.base.generate_error_packet);
}
static void cmd_interface_ide_responder_test_init (CuTest *test)
@ -121,7 +120,6 @@ static void cmd_interface_ide_responder_test_init (CuTest *test)
CuAssertPtrNotNull (test, testing.ide_responder.base.process_request);
CuAssertPtrNotNull (test, testing.ide_responder.base.process_response);
CuAssertPtrNotNull (test, testing.ide_responder.base.generate_error_packet);
cmd_interface_ide_responder_testing_release (test, &testing);
}
@ -633,25 +631,6 @@ static void cmd_interface_ide_responder_test_process_response (CuTest *test)
cmd_interface_ide_responder_testing_release (test, &testing);
}
static void cmd_interface_ide_responder_test_generate_error_packet (CuTest *test)
{
int status;
struct cmd_interface_ide_responder *ide_responder;
struct cmd_interface_ide_responder_testing testing;
TEST_START;
cmd_interface_ide_responder_testing_init (test, &testing);
ide_responder = &testing.ide_responder;
status = ide_responder->base.generate_error_packet ((const struct cmd_interface*) 0xDEADBEEF,
(struct cmd_interface_msg*) 0xBAADB00F, 0, 0, 0);
CuAssertIntEquals (test, CMD_INTERFACE_IDE_RESPONDER_UNSUPPORTED_OPERATION, status);
cmd_interface_ide_responder_testing_release (test, &testing);
}
// *INDENT-OFF*
TEST_SUITE_START (cmd_interface_ide_responder);
@ -670,7 +649,6 @@ TEST (cmd_interface_ide_responder_test_process_request_invalid_params);
TEST (cmd_interface_ide_responder_test_process_request_invalid_msg_size);
TEST (cmd_interface_ide_responder_test_process_request_unkown_command);
TEST (cmd_interface_ide_responder_test_process_response);
TEST (cmd_interface_ide_responder_test_generate_error_packet);
TEST_SUITE_END;
// *INDENT-ON*

Просмотреть файл

@ -122,9 +122,7 @@ static void cmd_interface_tdisp_responder_test_static_init (CuTest *test)
CuAssertIntEquals (test, 0, status);
CuAssertPtrNotNull (test, tdisp_responder.base.process_request);
CuAssertPtrNotNull (test, tdisp_responder.base.process_response);
CuAssertPtrNotNull (test, tdisp_responder.base.generate_error_packet);
cmd_interface_tdisp_responder_release (&tdisp_responder);
@ -199,7 +197,6 @@ static void cmd_interface_tdisp_responder_test_init (CuTest *test)
CuAssertPtrNotNull (test, testing.tdisp_responder.base.process_request);
CuAssertPtrNotNull (test, testing.tdisp_responder.base.process_response);
CuAssertPtrNotNull (test, testing.tdisp_responder.base.generate_error_packet);
cmd_interface_tdisp_responder_testing_release (test, &testing);
}
@ -792,24 +789,6 @@ static void cmd_interface_tdisp_responder_test_process_response (CuTest *test)
cmd_interface_tdisp_responder_testing_release (test, &testing);
}
static void cmd_interface_tdisp_responder_test_generate_error_packet (CuTest *test)
{
int status;
struct cmd_interface_tdisp_responder *tdisp_responder;
struct cmd_interface_tdisp_responder_testing testing;
TEST_START;
cmd_interface_tdisp_responder_testing_init (test, &testing);
tdisp_responder = &testing.tdisp_responder;
status = tdisp_responder->base.generate_error_packet ((const struct cmd_interface*) 0xDEADBEEF,
(struct cmd_interface_msg*) 0xBAADB00F, 0, 0, 0);
CuAssertIntEquals (test, CMD_INTERFACE_TDISP_RESPONDER_UNSUPPORTED_OPERATION, status);
cmd_interface_tdisp_responder_testing_release (test, &testing);
}
// *INDENT-OFF*
TEST_SUITE_START (cmd_interface_tdisp_responder);
@ -830,7 +809,6 @@ TEST (cmd_interface_tdisp_responder_test_process_request_invalid_params);
TEST (cmd_interface_tdisp_responder_test_process_request_payload_lt_min_length);
TEST (cmd_interface_tdisp_responder_test_process_request_unsupported_message_type);
TEST (cmd_interface_tdisp_responder_test_process_response);
TEST (cmd_interface_tdisp_responder_test_generate_error_packet);
TEST_SUITE_END;
// *INDENT-ON*

Просмотреть файл

@ -202,7 +202,6 @@ static void cmd_interface_recovery_test_init (CuTest *test)
CuAssertPtrNotNull (test, interface.base.process_request);
CuAssertPtrNotNull (test, interface.base.process_response);
CuAssertPtrNotNull (test, interface.base.generate_error_packet);
status = firmware_update_control_mock_validate_and_release (&update);
CuAssertIntEquals (test, 0, status);
@ -288,7 +287,6 @@ static void cmd_interface_recovery_test_static_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.handler.base.process_request);
CuAssertPtrNotNull (test, cmd.handler.base.process_response);
CuAssertPtrNotNull (test, cmd.handler.base.generate_error_packet);
complete_cmd_interface_recovery_mock_test (test, &cmd);
}
@ -942,49 +940,6 @@ static void cmd_interface_recovery_test_process_response_null (CuTest *test)
complete_cmd_interface_recovery_mock_test (test, &cmd);
}
static void cmd_interface_recovery_test_generate_error_packet (CuTest *test)
{
struct cmd_interface_recovery_testing cmd;
TEST_START;
setup_cmd_interface_recovery_mock_test (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet (test, &cmd.handler.base);
complete_cmd_interface_recovery_mock_test (test, &cmd);
}
static void cmd_interface_recovery_test_generate_error_packet_static_init (CuTest *test)
{
struct cmd_interface_recovery_testing cmd = {
.handler = cmd_interface_recovery_static_init (&cmd.device_manager, &cmd.update.base,
&cmd.fw_version)
};
TEST_START;
setup_cmd_interface_recovery_mock_test (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet (test, &cmd.handler.base);
complete_cmd_interface_recovery_mock_test (test, &cmd);
}
static void cmd_interface_recovery_test_generate_error_packet_invalid_arg (CuTest *test)
{
struct cmd_interface_recovery_testing cmd;
TEST_START;
setup_cmd_interface_recovery_mock_test (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet_invalid_arg (test,
&cmd.handler.base);
complete_cmd_interface_recovery_mock_test (test, &cmd);
}
TEST_SUITE_START (cmd_interface_recovery);
@ -1032,9 +987,6 @@ TEST (cmd_interface_recovery_test_process_get_capabilities_invalid_len);
TEST (cmd_interface_recovery_test_process_response);
TEST (cmd_interface_recovery_test_process_response_static_init);
TEST (cmd_interface_recovery_test_process_response_null);
TEST (cmd_interface_recovery_test_generate_error_packet);
TEST (cmd_interface_recovery_test_generate_error_packet_static_init);
TEST (cmd_interface_recovery_test_generate_error_packet_invalid_arg);
/* Tear down after the tests in this suite have run. */
TEST (cmd_interface_recovery_testing_suite_tear_down);

Просмотреть файл

@ -109,7 +109,6 @@ static void cmd_interface_rma_test_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.handler.base.process_request);
CuAssertPtrNotNull (test, cmd.handler.base.process_response);
CuAssertPtrNotNull (test, cmd.handler.base.generate_error_packet);
cmd_interface_rma_testing_release (test, &cmd);
}
@ -142,7 +141,6 @@ static void cmd_interface_rma_test_static_init (CuTest *test)
CuAssertPtrNotNull (test, cmd.handler.base.process_request);
CuAssertPtrNotNull (test, cmd.handler.base.process_response);
CuAssertPtrNotNull (test, cmd.handler.base.generate_error_packet);
cmd_interface_rma_testing_init_dependencies (test, &cmd);
@ -418,48 +416,6 @@ static void cmd_interface_rma_test_process_response_null (CuTest *test)
cmd_interface_rma_testing_release (test, &cmd);
}
static void cmd_interface_rma_test_generate_error_packet (CuTest *test)
{
struct cmd_interface_rma_testing cmd;
TEST_START;
cmd_interface_rma_testing_init (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet (test, &cmd.handler.base);
cmd_interface_rma_testing_release (test, &cmd);
}
static void cmd_interface_rma_test_generate_error_packet_static_init (CuTest *test)
{
struct cmd_interface_rma_testing cmd = {
.handler = cmd_interface_rma_static_init (&cmd.device_manager)
};
TEST_START;
cmd_interface_rma_testing_init_dependencies (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet (test, &cmd.handler.base);
cmd_interface_rma_testing_release (test, &cmd);
}
static void cmd_interface_rma_test_generate_error_packet_error (CuTest *test)
{
struct cmd_interface_rma_testing cmd;
TEST_START;
cmd_interface_rma_testing_init (test, &cmd);
cerberus_protocol_required_commands_testing_generate_error_packet_invalid_arg (test,
&cmd.handler.base);
cmd_interface_rma_testing_release (test, &cmd);
}
// *INDENT-OFF*
TEST_SUITE_START (cmd_interface_rma);
@ -479,9 +435,6 @@ TEST (cmd_interface_rma_test_process_unknown_command);
TEST (cmd_interface_rma_test_process_response);
TEST (cmd_interface_rma_test_process_response_static_init);
TEST (cmd_interface_rma_test_process_response_null);
TEST (cmd_interface_rma_test_generate_error_packet);
TEST (cmd_interface_rma_test_generate_error_packet_static_init);
TEST (cmd_interface_rma_test_generate_error_packet_error);
TEST_SUITE_END;
// *INDENT-ON*

Просмотреть файл

@ -363,7 +363,6 @@ static void cmd_interface_spdm_responder_test_static_init (CuTest *test)
CuAssertPtrNotNull (test, spdm_responder.base.process_request);
CuAssertPtrNotNull (test, spdm_responder.base.process_response);
CuAssertPtrNotNull (test, spdm_responder.base.generate_error_packet);
cmd_interface_spdm_responder_deinit (&spdm_responder);
@ -391,7 +390,6 @@ static void cmd_interface_spdm_responder_test_static_init_non_secure (CuTest *te
CuAssertPtrNotNull (test, spdm_responder.base.process_request);
CuAssertPtrNotNull (test, spdm_responder.base.process_response);
CuAssertPtrNotNull (test, spdm_responder.base.generate_error_packet);
cmd_interface_spdm_responder_deinit (&spdm_responder);
@ -751,7 +749,6 @@ static void cmd_interface_spdm_responder_test_init (CuTest *test)
CuAssertPtrNotNull (test, testing.spdm_responder.base.process_request);
CuAssertPtrNotNull (test, testing.spdm_responder.base.process_response);
CuAssertPtrNotNull (test, testing.spdm_responder.base.generate_error_packet);
cmd_interface_spdm_responder_deinit (&testing.spdm_responder);
@ -776,7 +773,6 @@ static void cmd_interface_spdm_responder_test_init_non_secure (CuTest *test)
CuAssertPtrNotNull (test, testing.spdm_responder.base.process_request);
CuAssertPtrNotNull (test, testing.spdm_responder.base.process_response);
CuAssertPtrNotNull (test, testing.spdm_responder.base.generate_error_packet);
cmd_interface_spdm_responder_deinit (&testing.spdm_responder);
@ -3099,24 +3095,6 @@ static void cmd_interface_spdm_responder_test_process_response (
cmd_interface_spdm_responder_testing_release (test, &testing);
}
static void cmd_interface_spdm_responder_test_generate_error_packet (
CuTest *test)
{
int status;
struct cmd_interface_spdm_responder_testing testing;
TEST_START;
cmd_interface_spdm_responder_testing_init (test, &testing);
status =
testing.spdm_responder.base.generate_error_packet (
(const struct cmd_interface*) (0xDEADBEEF), (struct cmd_interface_msg*) (0xBAADF00D), -1,
-1, -1);
CuAssertIntEquals (test, CMD_HANDLER_SPDM_RESPONDER_UNSUPPORTED_OPERATION, status);
cmd_interface_spdm_responder_testing_release (test, &testing);
}
// *INDENT-OFF*
TEST_SUITE_START (cmd_interface_spdm_responder);
@ -3161,7 +3139,6 @@ TEST (cmd_interface_spdm_responder_test_process_request_invalid_arg);
TEST (cmd_interface_spdm_responder_test_process_request_spdm_get_command_id_failure_short_payload);
TEST (cmd_interface_spdm_responder_test_process_request_unsupported_request_code);
TEST (cmd_interface_spdm_responder_test_process_response);
TEST (cmd_interface_spdm_responder_test_generate_error_packet);
TEST_SUITE_END;
// *INDENT-ON*

Просмотреть файл

@ -84,7 +84,6 @@ static void cmd_interface_spdm_test_init (CuTest *test)
CuAssertPtrNotNull (test, interface.base.process_request);
CuAssertPtrNotNull (test, interface.base.process_response);
CuAssertPtrNotNull (test, interface.base.generate_error_packet);
cmd_interface_spdm_deinit (&interface);
}
@ -1508,22 +1507,6 @@ static void cmd_interface_spdm_test_process_response_unknown_command (CuTest *te
complete_cmd_interface_spdm_mock_test (test, &cmd);
}
static void cmd_interface_spdm_test_generate_error_packet (CuTest *test)
{
struct cmd_interface_spdm_testing cmd;
struct cmd_interface_msg request;
int status;
TEST_START;
setup_cmd_interface_spdm_mock_test (test, &cmd, true);
status = cmd.handler.base.generate_error_packet (&cmd.handler.base, &request, 0, 0, 0);
CuAssertIntEquals (test, CMD_HANDLER_SPDM_UNSUPPORTED_OPERATION, status);
complete_cmd_interface_spdm_mock_test (test, &cmd);
}
static void cmd_interface_spdm_test_add_spdm_protocol_observer_invalid_arg (CuTest *test)
{
struct cmd_interface_spdm_testing cmd;
@ -1597,7 +1580,6 @@ TEST (cmd_interface_spdm_test_process_response_error_response_incorrect_len);
TEST (cmd_interface_spdm_test_process_response_invalid_arg);
TEST (cmd_interface_spdm_test_process_response_payload_too_short);
TEST (cmd_interface_spdm_test_process_response_unknown_command);
TEST (cmd_interface_spdm_test_generate_error_packet);
TEST (cmd_interface_spdm_test_add_spdm_protocol_observer_invalid_arg);
TEST (cmd_interface_spdm_test_remove_spdm_protocol_observer_invalid_arg);