27 #if !defined(_WINDOWS) 29 #include <sys/socket.h> 43 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 75 if (strcmp(argv[count],
"--test_no") == 0)
82 else if (strcmp(argv[count],
"--connection") == 0)
89 else if (strcmp(argv[count],
"--proxy_connection") == 0)
96 else if (strcmp(argv[count],
"--verbose") == 0)
107 #include <sys/timeb.h> 112 #if defined(_WIN32) || defined(_WINDOWS) 122 #if defined(_WIN32) || defined(_WINDOWS) 126 gettimeofday(&ts, NULL);
129 strftime(msg_buf, 80,
"%Y%m%d %H%M%S", timeinfo);
131 #if defined(_WIN32) || defined(_WINDOWS) 132 sprintf(&msg_buf[strlen(msg_buf)],
".%.3hu ", ts.millitm);
134 sprintf(&msg_buf[strlen(msg_buf)],
".%.3lu ", ts.tv_usec / 1000);
137 va_start(args, format);
138 vsnprintf(&msg_buf[strlen(msg_buf)],
sizeof(msg_buf) - strlen(msg_buf), format, args);
141 printf(
"%s\n", msg_buf);
147 #if defined(_WIN32) || defined(_WIN64) 150 usleep(milliseconds*1000);
154 #define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d) 175 MyLog(
LOGA_INFO,
"Assertion failed, file %s, line %d, description: %s", filename,
176 lineno, description);
178 va_start(args, format);
179 vprintf(format, args);
183 MyLog(
LOGA_DEBUG,
"Assertion succeeded, file %s, line %d, description: %s",
184 filename, lineno, description);
190 MyLog(
LOGA_INFO,
"In connect onFailure callback, context %p", context);
200 char MqttVersion[40];
204 sprintf(MqttVersion,
" MQTT version 3.1");
207 sprintf(MqttVersion,
" MQTT version 3.1.1");
210 sprintf(MqttVersion,
" MQTT version %d",response->
alt.
connect.MQTTVersion);
219 MyLog(
LOGA_INFO,
"Disconnected from MQTT broker reason %s",cause);
267 MyLog(
LOGA_INFO,
"Failed to queue message for send with retvalue %d",rc);
274 char* testname =
"test373";
299 opts.
context = mqttasyncContext;
315 MyLog(
LOGA_INFO,
"PublishCnt %d, FailedCnt %d, Pending %d maxPending %d",
317 #if !defined(_WINDOWS) 319 MyLog(
LOGA_INFO,
"MQTT mem current %ld, max %ld",mqtt_mem->current_size,mqtt_mem->max_size);
341 for(topicId=0; topicId < 100; topicId++)
350 MyLog(
LOGA_INFO,
"PublishCnt %d, FailedCnt %d, Pending %d maxPending %d",
352 #if !defined(_WINDOWS) 354 MyLog(
LOGA_INFO,
"MQTT mem current %ld, max %ld",mqtt_mem->current_size,mqtt_mem->max_size);
358 MyLog(
LOGA_INFO,
"PublishCnt %d, FailedCnt %d, Pending %d maxPending %d",
360 #if !defined(_WINDOWS) 362 MyLog(
LOGA_INFO,
"MQTT mem current %ld, max %ld",mqtt_mem->current_size,mqtt_mem->max_size);
366 #if !defined(_WINDOWS) 368 MyLog(
LOGA_INFO,
"MQTT mem current %ld, max %ld",mqtt_mem->current_size,mqtt_mem->max_size);
369 if (mqtt_mem->current_size > 0)
failures++;
376 printf(
"%s\n", message);
379 int main(
int argc,
char** argv)
381 int* numtests = &
tests;
386 sprintf(
unique,
"%u", rand());
397 for (QoS = 0; QoS < 3; QoS++)
MQTTAsync_onFailure * onFailure
void test373DeliveryComplete(void *context, MQTTAsync_token token)
enum MQTTPropertyCodes value
FMT_INLINE std::basic_string< Char > format(const S &format_str, Args &&...args)
int test373_messageArrived(void *context, char *topicName, int topicLen, MQTTAsync_message *message)
union MQTTAsync_successData::@46 alt
#define MQTTAsync_responseOptions_initializer
void test373_onWriteSuccess(void *context, MQTTAsync_successData *response)
int MQTTAsync_disconnect(MQTTAsync handle, const MQTTAsync_disconnectOptions *options)
int MQTTAsync_setCallbacks(MQTTAsync handle, void *context, MQTTAsync_connectionLost *cl, MQTTAsync_messageArrived *ma, MQTTAsync_deliveryComplete *dc)
size_t strftime(char *str, size_t count, const char *format, const std::tm *time)
void handleTrace(enum MQTTASYNC_TRACE_LEVELS level, char *message)
std::tm localtime(std::time_t time)
void MQTTAsync_setTraceCallback(MQTTAsync_traceCallback *callback)
struct MQTTAsync_successData::@46::@48 connect
int MQTTAsync_connect(MQTTAsync handle, const MQTTAsync_connectOptions *options)
void getopts(int argc, char **argv)
void MySleep(long milliseconds)
void MyLog(int LOGA_level, char *format,...)
#define MQTTAsync_willOptions_initializer
int test_373(struct Options options)
int MQTTAsync_create(MQTTAsync *handle, const char *serverURI, const char *clientId, int persistence_type, void *persistence_context)
void test373ConnectionLost(void *context, char *cause)
int test373SendPublishMessage(MQTTAsync handle, int id, const unsigned int QoS)
MQTTAsync_onFailure * onFailure
#define MQTTVERSION_3_1_1
heap_info * Heap_get_info(void)
#define MQTTAsync_connectOptions_initializer
MQTTAsync_onSuccess * onSuccess
#define assert(a, b, c, d)
void MQTTAsync_destroy(MQTTAsync *handle)
void test373OnConnect(void *context, MQTTAsync_successData *response)
void test373_onWriteFailure(void *context, MQTTAsync_failureData *response)
#define MQTTASYNC_SUCCESS
void MQTTAsync_setTraceLevel(enum MQTTASYNC_TRACE_LEVELS level)
int MQTTAsync_sendMessage(MQTTAsync handle, const char *destinationName, const MQTTAsync_message *message, MQTTAsync_responseOptions *response)
#define MQTTCLIENT_PERSISTENCE_NONE
static char test373Payload[]
int main(int argc, char **argv)
void test1373OnFailure(void *context, MQTTAsync_failureData *response)
#define MQTTAsync_message_initializer
MQTTAsync_onSuccess * onSuccess
#define MQTTVERSION_DEFAULT
void myassert(char *filename, int lineno, char *description, int value, char *format,...)