|
AWS IoT Device SDK C:
MQTT
MQTT 3.1.1 client library
|
| Return to main page ↑ |
Tests interaction of MQTT with the lower layers, such as network and task pool. More...
#include "iot_config.h"#include <string.h>#include "platform/iot_clock.h"#include "platform/iot_threads.h"#include "iot_init.h"#include "private/iot_mqtt_internal.h"#include "iot_mqtt_protocol.h"#include "iot_mqtt_lightweight.h"#include "../src/private/iot_taskpool_internal.h"#include "iot_test_access_mqtt.h"#include "iot_tests_mqtt_mock.h"#include <IOT_TEST_NETWORK_HEADER>#include "unity_fixture.h"Macros | |
| #define | TIMEOUT_MS ( 400 ) |
| Timeout to use for the tests. This can be short, but should allow time for other threads to run. | |
| #define | CLIENT_IDENTIFIER ( "test" ) |
| Client identifier. | |
| #define | CLIENT_IDENTIFIER_LENGTH ( ( uint16_t ) ( sizeof( CLIENT_IDENTIFIER ) - 1 ) ) |
| Length of client identifier. | |
| #define | SUBSCRIPTION_CALLBACK_FUNCTION |
| A non-NULL function pointer to use for subscription callback. This "function" should cause a crash if actually called. More... | |
| #define | PACKET_LENGTH ( 1 ) |
| Length of an arbitrary packet for testing. A buffer will be allocated for it, but its contents don't matter. | |
| #define | SHORT_KEEP_ALIVE_MS ( 100 ) |
| A short keep-alive interval to use for the keep-alive tests. It may be shorter than the minimum 1 second specified by the MQTT spec. | |
| #define | AWS_IOT_MQTT_SERVER true |
| Determine which MQTT server mode to test (AWS IoT or Mosquitto). | |
| #define | CLIENT_IDENTIFIER_MAX_LENGTH ( 24 ) |
| The maximum length of an MQTT client identifier. More... | |
| #define | GENERATE_TOPIC_WITH_SUFFIX(bufferName, suffix) |
| Generates a topic by suffixing the client identifier with a suffix. More... | |
| #define | TEST_TOPIC_NAME ( "/test/topic" ) |
| An arbitrary topic name. | |
| #define | TEST_TOPIC_NAME_LENGTH ( ( uint16_t ) ( sizeof( TEST_TOPIC_NAME ) - 1 ) ) |
| Length of topic name. | |
| #define | DUP_CHECK_RETRY_MS ( 100 ) |
| When to start sending duplicate packets. | |
| #define | DUP_CHECK_RETRY_LIMIT ( 3 ) |
| How many duplicate packets to send. | |
| #define | DUP_CHECK_TIMEOUT ( 3000 ) |
| Total time allowed to send all duplicate packets. Duplicates are sent using an exponential backoff strategy. | |
Functions | |
| static IotMqttError_t | _mqttConnect (const IotMqttNetworkInfo_t *pNetworkInfo, const IotMqttConnectInfo_t *pConnectInfo, uint32_t timeoutMs, IotMqttConnection_t *const pMqttConnection) |
| Establish an MQTT connection. Retry if enabled. | |
| static IotNetworkError_t | _networkCreate (IotNetworkServerInfo_t pServerInfo, IotNetworkCredentials_t pCredentialInfo, IotNetworkConnection_t *pConnection) |
| Mocked network create function. | |
| static IotNetworkError_t | _networkSetReceiveCallback (IotNetworkConnection_t pConnection, IotNetworkReceiveCallback_t receiveCallback, void *pContext) |
| Mocked network set receive callback function. | |
| static size_t | _networkSend (IotNetworkConnection_t pConnection, const uint8_t *pMessage, size_t messageLength) |
| Mocked network send function. | |
| static IotNetworkError_t | _networkClose (IotNetworkConnection_t pConnection) |
| Mocked network close function. | |
| static IotNetworkError_t | _networkDestroy (IotNetworkConnection_t pConnection) |
| Mocked network destroy function. | |
| static void | _publishReceived (void *pArgument, IotMqttCallbackParam_t *pPublish) |
| Subscription callback function. Checks for valid parameters and unblocks the main test thread. | |
| static void | _blockingCallback (void *pArgument, IotMqttCallbackParam_t *pPublish) |
| A subscription callback function that blocks on a semaphore until signaled. | |
| static void | _reentrantCallback (void *pArgument, IotMqttCallbackParam_t *pOperation) |
| Callback that makes additional MQTT API calls. | |
| static IotMqttError_t | _serializePuback (uint16_t packetIdentifier, uint8_t **pPubackPacket, size_t *pPacketSize) |
| Serializer override for PUBACK that always fails. | |
| static bool | _waitForCount (IotMutex_t *pMutex, const int32_t *pReferenceCount, int32_t target) |
| Wait for a reference count to reach a target value, subject to a timeout. | |
| TEST_GROUP (MQTT_Unit_Platform) | |
| Test group for MQTT platform tests. | |
| TEST_GROUP (MQTT_System_Platform) | |
| Test group for MQTT platform tests requiring the network. | |
| TEST_SETUP (MQTT_Unit_Platform) | |
| Test setup for MQTT platform tests. | |
| TEST_SETUP (MQTT_System_Platform) | |
| Test setup for MQTT system platform tests. | |
| TEST_TEAR_DOWN (MQTT_Unit_Platform) | |
| Test tear down for MQTT platform tests. | |
| TEST_TEAR_DOWN (MQTT_System_Platform) | |
| Test tear down for MQTT system platform tests. | |
| TEST_GROUP_RUNNER (MQTT_Unit_Platform) | |
| Test group runner for MQTT platform tests. | |
| TEST_GROUP_RUNNER (MQTT_System_Platform) | |
| Test group runner for MQTT system platform tests. | |
| void | TEST_MQTT_Unit_Platform_ConnectNetworkFailure_ (void) |
| Tests the behavior of IotMqtt_Connect when the network fails. | |
| void | TEST_MQTT_Unit_Platform_ConnectScheduleFailure_ (void) |
| Tests the behavior of IotMqtt_Connect when the keep-alive job fails to schedule. | |
| void | TEST_MQTT_Unit_Platform_DisconnectNetworkFailure_ (void) |
| Tests the behavior of IotMqtt_Disconnect when the network fails. | |
| void | TEST_MQTT_Unit_Platform_PingreqSendFailure_ (void) |
| Tests the behavior when a PINGREQ cannot be sent. | |
| void | TEST_MQTT_Unit_Platform_PublishScheduleFailure_ (void) |
| Tests the behavior of IotMqtt_PublishAsync when scheduling fails. | |
| void | TEST_MQTT_Unit_Platform_PublishRetryScheduleFailure_ (void) |
| Tests the behavior when a client-to-server PUBLISH retry fails to schedule. | |
| void | TEST_MQTT_Unit_Platform_PubackScheduleSerializeFailure_ (void) |
| Tests the behavior of the client-to-server PUBACK when scheduling and serializing fail. | |
| void | TEST_MQTT_Unit_Platform_SubscriptionScheduleFailure_ (void) |
| Tests the behavior of IotMqtt_SubscribeAsync and IotMqtt_UnsubscribeAsync when scheduling fails. | |
| void | TEST_MQTT_Unit_Platform_NotifyScheduleFailure_ (void) |
| Tests the behavior of _IotMqtt_Notify when scheduling fails. | |
| void | TEST_MQTT_Unit_Platform_SingleThreaded_ (void) |
| Test that MQTT can work in a single thread without the task pool. | |
| void | TEST_MQTT_Unit_Platform_SubscriptionReferences_ (void) |
| Tests that subscriptions are properly reference counted. | |
| void | TEST_MQTT_Unit_Platform_SubscriptionListTooLarge_ (void) |
| Test the behavior when the subscription list exceeds the size of an MQTT packet. Requires a large amount of memory not available on smaller systems. | |
| void | TEST_MQTT_Unit_Platform_LongUserName_ (void) |
| Test the behavior when the maximum length user name. Requires a large amount of memory not available on smaller systems. | |
| void | TEST_MQTT_System_Platform_SubscribeCompleteReentrancy_ (void) |
| Test that API functions can be invoked from a callback for a completed subscription operation. | |
| void | TEST_MQTT_System_Platform_IncomingPublishReentrancy_ (void) |
| Test that API functions can be invoked from a callback for an incoming PUBLISH. | |
Tests interaction of MQTT with the lower layers, such as network and task pool.
| #define SUBSCRIPTION_CALLBACK_FUNCTION |
A non-NULL function pointer to use for subscription callback. This "function" should cause a crash if actually called.
| #define CLIENT_IDENTIFIER_MAX_LENGTH ( 24 ) |
The maximum length of an MQTT client identifier.
When IOT_TEST_MQTT_CLIENT_IDENTIFIER is defined, this value must accommodate the length of IOT_TEST_MQTT_CLIENT_IDENTIFIER plus 4 to accommodate the Last Will and Testament test. Otherwise, this value is set to 24, which is the longest client identifier length an MQTT server is obligated to accept plus a NULL terminator.
| #define GENERATE_TOPIC_WITH_SUFFIX | ( | bufferName, | |
| suffix | |||
| ) |
Generates a topic by suffixing the client identifier with a suffix.
| [in] | bufferName | The name of the buffer for the topic. |
| [in] | suffix | The suffix to place at the end of the client identifier. |
|
static |
Network credential info to use for the re-entrancy tests.
Function pointers to the default MQTT serializers.
|
static |
Filler text to publish.