AWS IoT Device SDK C:
MQTT
MQTT 3.1.1 client library
|
Return to main page ↑ |
Tests for the function IotMqtt_ReceiveCallback. More...
#include "iot_config.h"
#include <string.h>
#include "iot_init.h"
#include "platform/iot_threads.h"
#include "private/iot_mqtt_internal.h"
#include "unity_fixture.h"
#include "iot_test_access_mqtt.h"
Data Structures | |
struct | _receiveContext_t |
Context for calls to the network receive function. More... | |
Macros | |
#define | AWS_IOT_MQTT_SERVER true |
Determine which MQTT server mode to test (AWS IoT or Mosquitto). | |
#define | TEST_TOPIC_NAME "/test/topic" |
Topic name and filter used in the tests. | |
#define | TEST_TOPIC_LENGTH ( ( uint16_t ) ( sizeof( TEST_TOPIC_NAME ) - 1 ) ) |
Length of TEST_TOPIC_NAME. | |
#define | PUBLISH_CALLBACK_TIMEOUT ( 1000 ) |
Timeout for waiting on a PUBLISH callback. | |
#define | DECLARE_PACKET(pTemplate, bufferName, sizeName) |
Declare a buffer holding a packet and its size. More... | |
#define | INITIALIZE_OPERATION(name) |
Initializer for operations in the tests. More... | |
Functions | |
static uint8_t | _getPacketType (IotNetworkConnection_t pNetworkConnection, const IotNetworkInterface_t *pNetworkInterface) |
Get packet type function override. | |
static size_t | _getRemainingLength (IotNetworkConnection_t pNetworkConnection, const IotNetworkInterface_t *pNetworkInterface) |
Get remaining length function override. | |
static IotMqttError_t | _serializePuback (uint16_t packetIdentifier, uint8_t **pPubackPacket, size_t *pPacketSize) |
Serializer override for PUBACK. | |
static IotMqttError_t | _deserializeConnack (_mqttPacket_t *pConnack) |
Deserializer override for CONNACK. | |
static IotMqttError_t | _deserializePublish (_mqttPacket_t *pPublish) |
Deserializer override for PUBLISH. | |
static IotMqttError_t | _deserializePuback (_mqttPacket_t *pPuback) |
Deserializer override for PUBACK. | |
static IotMqttError_t | _deserializeSuback (_mqttPacket_t *pSuback) |
Deserializer override for SUBACK. | |
static IotMqttError_t | _deserializeUnsuback (_mqttPacket_t *pUnsuback) |
Deserializer override for UNSUBACK. | |
static IotMqttError_t | _deserializePingresp (_mqttPacket_t *pPingresp) |
Deserializer override for PINGRESP. | |
static void | _operationResetAndPush (_mqttOperation_t *pOperation) |
Reset the status of an _mqttOperation_t and push it to the list of MQTT operations awaiting network response. | |
static bool | _processBuffer (const _mqttOperation_t *pOperation, const uint8_t *pBuffer, size_t bufferSize, IotMqttError_t expectedResult) |
Process a non-PUBLISH buffer and check the result. | |
static bool | _processPublish (const uint8_t *pPublish, size_t publishSize, uint32_t expectedInvokeCount) |
Process a PUBLISH message and check the result. | |
static void | _publishCallback (void *pCallbackContext, IotMqttCallbackParam_t *pPublish) |
Called when a PUBLISH message is "received". | |
static size_t | _receive (IotNetworkConnection_t pConnection, uint8_t *pBuffer, size_t bytesRequested) |
Simulates a network receive function. | |
static size_t | _checkPuback (IotNetworkConnection_t pConnection, const uint8_t *pMessage, size_t messageLength) |
A network send function that checks the message is a PUBACK. | |
static IotNetworkError_t | _close (IotNetworkConnection_t pConnection) |
A network close function that reports if it was invoked. | |
static void | _disconnectCallback (void *pCallbackContext, IotMqttCallbackParam_t *pCallbackParam) |
A disconnect callback function that checks for a "bad packet" reason and reports if it was invoked. | |
static void | _publishMallocFail (IotMqttQos_t qos) |
Common code for PUBLISH malloc failure tests. | |
TEST_GROUP (MQTT_Unit_Receive) | |
Test group for MQTT Receive tests. | |
TEST_SETUP (MQTT_Unit_Receive) | |
Test setup for MQTT Receive tests. | |
TEST_TEAR_DOWN (MQTT_Unit_Receive) | |
Test tear down for MQTT Receive tests. | |
TEST_GROUP_RUNNER (MQTT_Unit_Receive) | |
Test group runner for MQTT Receive tests. | |
void | TEST_MQTT_Unit_Receive_DecodeRemainingLength_ (void) |
Tests the function for decoding MQTT remaining length. | |
void | TEST_MQTT_Unit_Receive_InvalidPacket_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with an invalid control packet type. | |
void | TEST_MQTT_Unit_Receive_ReceiveMallocFail_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback when memory allocation fails. | |
void | TEST_MQTT_Unit_Receive_ConnackValid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a spec-compliant CONNACK. | |
void | TEST_MQTT_Unit_Receive_ConnackInvalid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a CONNACK that doesn't comply to MQTT spec. | |
void | TEST_MQTT_Unit_Receive_PublishValid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a spec-compliant PUBLISH. | |
void | TEST_MQTT_Unit_Receive_PublishInvalid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a PUBLISH that doesn't comply to MQTT spec. | |
void | TEST_MQTT_Unit_Receive_PublishResourceFailure_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with errors such as memory allocation failure and closed connections. | |
void | TEST_MQTT_Unit_Receive_PubackValid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a spec-compliant PUBACK. | |
void | TEST_MQTT_Unit_Receive_PubackInvalid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a PUBACK that doesn't comply to MQTT spec. | |
void | TEST_MQTT_Unit_Receive_SubackValid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a spec-compliant SUBACK. | |
void | TEST_MQTT_Unit_Receive_SubackInvalid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a SUBACK that doesn't comply to MQTT spec. | |
void | TEST_MQTT_Unit_Receive_UnsubackValid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with a spec-compliant UNSUBACK. | |
void | TEST_MQTT_Unit_Receive_UnsubackInvalid_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback with an UNSUBACK that doesn't comply to MQTT spec. | |
void | TEST_MQTT_Unit_Receive_Pingresp_ (void) |
Tests the behavior of IotMqtt_ReceiveCallback when receiving a PINGRESP packet (both compliant and non-compliant packets). | |
Variables | |
static const uint8_t | _pConnackTemplate [] = { 0x20, 0x02, 0x00, 0x00 } |
Default CONNACK packet for the receive tests. | |
static const uint8_t | _pPublishTemplate [] |
Default PUBLISH packet for the receive tests. More... | |
static const uint8_t | _pPubackTemplate [] = { 0x40, 0x02, 0x00, 0x01 } |
Default PUBACK packet for the receive tests. | |
static const uint8_t | _pSubackTemplate [] = { 0x90, 0x05, 0x00, 0x01, 0x00, 0x01, 0x02 } |
Default SUBACK packet for the receive tests. | |
static const uint8_t | _pUnsubackTemplate [] = { 0xb0, 0x02, 0x00, 0x01 } |
Default UNSUBACK packet for the receive tests. | |
static const uint8_t | _pPingrespTemplate [] = { 0xd0, 0x00 } |
Default PINGRESP packet for the receive tests. | |
static _mqttConnection_t * | _pMqttConnection = IOT_MQTT_CONNECTION_INITIALIZER |
The MQTT connection shared by all the tests. | |
static IotNetworkInterface_t | _networkInterface = { 0 } |
The network interface shared by all the tests. | |
static IotMqttSubscription_t | _subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER |
The subscription shared by all the tests. | |
static bool | _deserializeOverrideCalled = false |
Tracks whether a deserializer override was called for a test. | |
static bool | _getPacketTypeCalled = false |
Tracks whether _getPacketType has been called. | |
static bool | _getRemainingLengthCalled = false |
Tracks whether _getRemainingLength has been called. | |
static bool | _networkCloseCalled = false |
Tracks whether _close has been called. | |
static bool | _disconnectCallbackCalled = false |
Tracks whether _disconnectCallback has been called. | |
Tests for the function IotMqtt_ReceiveCallback.
#define DECLARE_PACKET | ( | pTemplate, | |
bufferName, | |||
sizeName | |||
) |
Declare a buffer holding a packet and its size.
#define INITIALIZE_OPERATION | ( | name | ) |
Initializer for operations in the tests.
|
static |
Default PUBLISH packet for the receive tests.