Commit bf67bab4 authored by Ian Craggs's avatar Ian Craggs

Get rid of compiler warnings on MacOSX

parent 93a064db
...@@ -2619,7 +2619,7 @@ exit: ...@@ -2619,7 +2619,7 @@ exit:
void MQTTAsync_setTraceLevel(enum MQTTASYNC_TRACE_LEVELS level) void MQTTAsync_setTraceLevel(enum MQTTASYNC_TRACE_LEVELS level)
{ {
Log_setTraceLevel(level); Log_setTraceLevel((enum LOG_LEVELS)level);
} }
......
...@@ -104,7 +104,7 @@ void StackTrace_entry(const char* name, int line, int trace_level) ...@@ -104,7 +104,7 @@ void StackTrace_entry(const char* name, int line, int trace_level)
if (!setStack(1)) if (!setStack(1))
goto exit; goto exit;
if (trace_level != -1) if (trace_level != -1)
Log_stackTrace(trace_level, 9, cur_thread->id, cur_thread->current_depth, name, line, NULL); Log_stackTrace(trace_level, 9, (int)cur_thread->id, cur_thread->current_depth, name, line, NULL);
strncpy(cur_thread->callstack[cur_thread->current_depth].name, name, sizeof(cur_thread->callstack[0].name)-1); strncpy(cur_thread->callstack[cur_thread->current_depth].name, name, sizeof(cur_thread->callstack[0].name)-1);
cur_thread->callstack[(cur_thread->current_depth)++].line = line; cur_thread->callstack[(cur_thread->current_depth)++].line = line;
if (cur_thread->current_depth > cur_thread->maxdepth) if (cur_thread->current_depth > cur_thread->maxdepth)
...@@ -128,9 +128,9 @@ void StackTrace_exit(const char* name, int line, void* rc, int trace_level) ...@@ -128,9 +128,9 @@ void StackTrace_exit(const char* name, int line, void* rc, int trace_level)
if (trace_level != -1) if (trace_level != -1)
{ {
if (rc == NULL) if (rc == NULL)
Log_stackTrace(trace_level, 10, cur_thread->id, cur_thread->current_depth, name, line, NULL); Log_stackTrace(trace_level, 10, (int)cur_thread->id, cur_thread->current_depth, name, line, NULL);
else else
Log_stackTrace(trace_level, 11, cur_thread->id, cur_thread->current_depth, name, line, (int*)rc); Log_stackTrace(trace_level, 11, (int)cur_thread->id, cur_thread->current_depth, name, line, (int*)rc);
} }
exit: exit:
Thread_unlock_mutex(stack_mutex); Thread_unlock_mutex(stack_mutex);
...@@ -152,14 +152,14 @@ void StackTrace_printStack(FILE* dest) ...@@ -152,14 +152,14 @@ void StackTrace_printStack(FILE* dest)
{ {
int i = cur_thread->current_depth - 1; int i = cur_thread->current_depth - 1;
fprintf(file, "=========== Start of stack trace for thread %lu ==========\n", cur_thread->id); fprintf(file, "=========== Start of stack trace for thread %lu ==========\n", (unsigned long)cur_thread->id);
if (i >= 0) if (i >= 0)
{ {
fprintf(file, "%s (%d)\n", cur_thread->callstack[i].name, cur_thread->callstack[i].line); fprintf(file, "%s (%d)\n", cur_thread->callstack[i].name, cur_thread->callstack[i].line);
while (--i >= 0) while (--i >= 0)
fprintf(file, " at %s (%d)\n", cur_thread->callstack[i].name, cur_thread->callstack[i].line); fprintf(file, " at %s (%d)\n", cur_thread->callstack[i].name, cur_thread->callstack[i].line);
} }
fprintf(file, "=========== End of stack trace for thread %lu ==========\n\n", cur_thread->id); fprintf(file, "=========== End of stack trace for thread %lu ==========\n\n", (unsigned long)cur_thread->id);
} }
} }
if (file != stdout && file != stderr && file != NULL) if (file != stdout && file != stderr && file != NULL)
...@@ -167,7 +167,7 @@ void StackTrace_printStack(FILE* dest) ...@@ -167,7 +167,7 @@ void StackTrace_printStack(FILE* dest)
} }
char* StackTrace_get(unsigned long threadid) char* StackTrace_get(thread_id_type threadid)
{ {
int bufsize = 256; int bufsize = 256;
char* buf = NULL; char* buf = NULL;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <stdio.h> #include <stdio.h>
#include "Log.h" #include "Log.h"
#include "Thread.h"
#if defined(NOSTACKTRACE) #if defined(NOSTACKTRACE)
#define FUNC_ENTRY #define FUNC_ENTRY
...@@ -65,6 +66,6 @@ void StackTrace_entry(const char* name, int line, int trace); ...@@ -65,6 +66,6 @@ void StackTrace_entry(const char* name, int line, int trace);
void StackTrace_exit(const char* name, int line, void* return_value, int trace); void StackTrace_exit(const char* name, int line, void* return_value, int trace);
void StackTrace_printStack(FILE* dest); void StackTrace_printStack(FILE* dest);
char* StackTrace_get(unsigned long); char* StackTrace_get(thread_id_type);
#endif /* STACKTRACE_H_ */ #endif /* STACKTRACE_H_ */
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#include "string.h" #include "string.h"
#include "MQTTAsync.h" #include "MQTTAsync.h"
#if !defined(WIN32)
#include <unistd.h>
#endif
#define ADDRESS "tcp://m2m.eclipse.org:1883" #define ADDRESS "tcp://m2m.eclipse.org:1883"
#define CLIENTID "ExampleClientPub" #define CLIENTID "ExampleClientPub"
#define TOPIC "MQTT Examples" #define TOPIC "MQTT Examples"
......
...@@ -19,6 +19,10 @@ ...@@ -19,6 +19,10 @@
#include "string.h" #include "string.h"
#include "MQTTAsync.h" #include "MQTTAsync.h"
#if !defined(WIN32)
#include <unistd.h>
#endif
#define ADDRESS "tcp://localhost:1883" #define ADDRESS "tcp://localhost:1883"
#define CLIENTID "ExampleClientSub" #define CLIENTID "ExampleClientSub"
#define TOPIC "MQTT Examples" #define TOPIC "MQTT Examples"
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#else #else
#include <sys/time.h> #include <sys/time.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#endif #endif
......
...@@ -606,7 +606,7 @@ int test3(struct Options options) ...@@ -606,7 +606,7 @@ int test3(struct Options options)
/* authorization failure (RC = 5) */ /* authorization failure (RC = 5) */
opts.username = "Admin"; opts.username = "Admin";
opts.password = "Admin"; opts.password = "Admin";
/*opts.will = &wopts; /* "Admin" not authorized to publish to Will topic by default /*opts.will = &wopts; "Admin" not authorized to publish to Will topic by default
opts.will->message = "will message"; opts.will->message = "will message";
opts.will->qos = 1; opts.will->qos = 1;
opts.will->retained = 0; opts.will->retained = 0;
......
...@@ -577,8 +577,8 @@ int test1(struct Options options) ...@@ -577,8 +577,8 @@ int test1(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"SSL connect fail to nonSSL MQTT server\""); fprintf(xml, "<testcase classname=\"test3\" name=\"SSL connect fail to nonSSL MQTT server\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.connection, "test1", rc = MQTTClient_create(&c, options.connection, "test1", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d \n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d \n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -597,7 +597,8 @@ int test1(struct Options options) ...@@ -597,7 +597,8 @@ int test1(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Connect should fail", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_FAILURE, "rc was %d ", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Connect should fail", rc == MQTTCLIENT_FAILURE, "rc was %d ", rc)))
goto exit; goto exit;
exit: exit:
...@@ -631,8 +632,8 @@ int test2a_s(struct Options options) ...@@ -631,8 +632,8 @@ int test2a_s(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 2a_s\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 2a_s\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.server_auth_connection, "test2a_s", rc = MQTTClient_create(&c, options.server_auth_connection, "test2a_s", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -656,10 +657,12 @@ int test2a_s(struct Options options) ...@@ -656,10 +657,12 @@ int test2a_s(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Good rc from subscribe", (rc = MQTTClient_subscribe(c, test_topic, subsqos)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_subscribe(c, test_topic, subsqos);
if (!(assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
singleThread_sendAndReceive(c, 0, test_topic); singleThread_sendAndReceive(c, 0, test_topic);
...@@ -668,16 +671,19 @@ int test2a_s(struct Options options) ...@@ -668,16 +671,19 @@ int test2a_s(struct Options options)
MyLog(LOGA_DEBUG, "Stopping\n"); MyLog(LOGA_DEBUG, "Stopping\n");
if (!(assert("Unsubscribe successful", (rc = MQTTClient_unsubscribe(c, test_topic)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_unsubscribe(c, test_topic);
if (!(assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
/* Just to make sure we can connect again */ /* Just to make sure we can connect again */
rc = MQTTClient_connect(c, &opts);
if (!(assert("Connect successful", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) if (!(assert("Connect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -711,8 +717,8 @@ int test2a_m(struct Options options) ...@@ -711,8 +717,8 @@ int test2a_m(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 2a_m\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 2a_m\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.mutual_auth_connection, "test2a_m", rc = MQTTClient_create(&c, options.mutual_auth_connection, "test2a_m", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -736,16 +742,18 @@ int test2a_m(struct Options options) ...@@ -736,16 +742,18 @@ int test2a_m(struct Options options)
//opts.ssl->enabledCipherSuites = "DEFAULT"; //opts.ssl->enabledCipherSuites = "DEFAULT";
//opts.ssl->enabledServerCertAuth = 1; //opts.ssl->enabledServerCertAuth = 1;
if (!(assert("Good rc from setCallbacks", (rc = MQTTClient_setCallbacks(c, NULL, NULL, multiThread_messageArrived, rc = MQTTClient_setCallbacks(c, NULL, NULL, multiThread_messageArrived, multiThread_deliveryComplete);
multiThread_deliveryComplete)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) if (!(assert("Good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Good rc from subscribe", (rc = MQTTClient_subscribe(c, test_topic, subsqos)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_subscribe(c, test_topic, subsqos);
if (!(assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
multiThread_sendAndReceive(c, 0, test_topic); multiThread_sendAndReceive(c, 0, test_topic);
...@@ -754,9 +762,11 @@ int test2a_m(struct Options options) ...@@ -754,9 +762,11 @@ int test2a_m(struct Options options)
MyLog(LOGA_DEBUG, "Stopping"); MyLog(LOGA_DEBUG, "Stopping");
if (!(assert("Unsubscribe successful", (rc = MQTTClient_unsubscribe(c, test_topic)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_unsubscribe(c, test_topic);
if (!(assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -788,8 +798,8 @@ int test2b(struct Options options) ...@@ -788,8 +798,8 @@ int test2b(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 2b\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 2b\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.nocert_mutual_auth_connection, "test2b", rc = MQTTClient_create(&c, options.nocert_mutual_auth_connection, "test2b", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -815,8 +825,8 @@ int test2b(struct Options options) ...@@ -815,8 +825,8 @@ int test2b(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Bad rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_FAILURE, rc = MQTTClient_connect(c, &opts);
"rc was %d\n", rc))) if (!(assert("Bad rc from connect", rc == MQTTCLIENT_FAILURE, "rc was %d\n", rc)))
goto exit; goto exit;
exit: exit:
...@@ -848,8 +858,8 @@ int test2c(struct Options options) ...@@ -848,8 +858,8 @@ int test2c(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 2c\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 2c\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.mutual_auth_connection, "test2c", rc = MQTTClient_create(&c, options.mutual_auth_connection, "test2c", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -875,7 +885,8 @@ int test2c(struct Options options) ...@@ -875,7 +885,8 @@ int test2c(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_FAILURE, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_FAILURE, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -908,8 +919,8 @@ int test3a_s(struct Options options) ...@@ -908,8 +919,8 @@ int test3a_s(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 3a_s\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 3a_s\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.server_auth_connection, "test3a_s", rc = MQTTClient_create(&c, options.server_auth_connection, "test3a_s", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -928,10 +939,12 @@ int test3a_s(struct Options options) ...@@ -928,10 +939,12 @@ int test3a_s(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Good rc from subscribe", (rc = MQTTClient_subscribe(c, test_topic, subsqos)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_subscribe(c, test_topic, subsqos);
if (!(assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
singleThread_sendAndReceive(c, 0, test_topic); singleThread_sendAndReceive(c, 0, test_topic);
singleThread_sendAndReceive(c, 1, test_topic); singleThread_sendAndReceive(c, 1, test_topic);
...@@ -939,16 +952,20 @@ int test3a_s(struct Options options) ...@@ -939,16 +952,20 @@ int test3a_s(struct Options options)
MyLog(LOGA_DEBUG, "Stopping\n"); MyLog(LOGA_DEBUG, "Stopping\n");
if (!(assert("Unsubscribe successful", (rc = MQTTClient_unsubscribe(c, test_topic)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_unsubscribe(c, test_topic);
if (!(assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
/* Just to make sure we can connect again */ /* Just to make sure we can connect again */
if (!(assert("Connect successful", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Connect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -981,8 +998,8 @@ int test3a_m(struct Options options) ...@@ -981,8 +998,8 @@ int test3a_m(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 3a_m\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 3a_m\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.server_auth_connection, "test3a_m", rc = MQTTClient_create(&c, options.server_auth_connection, "test3a_m", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -999,15 +1016,18 @@ int test3a_m(struct Options options) ...@@ -999,15 +1016,18 @@ int test3a_m(struct Options options)
if (options.server_key_file != NULL) if (options.server_key_file != NULL)
opts.ssl->trustStore = options.server_key_file; /*file of certificates trusted by client*/ opts.ssl->trustStore = options.server_key_file; /*file of certificates trusted by client*/
if (!(assert("Good rc from setCallbacks", (rc = MQTTClient_setCallbacks(c, NULL, NULL, multiThread_messageArrived, rc = MQTTClient_setCallbacks(c, NULL, NULL, multiThread_messageArrived, multiThread_deliveryComplete);
multiThread_deliveryComplete)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) if (!(assert("Good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit;
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Good rc from subscribe", (rc = MQTTClient_subscribe(c, test_topic, subsqos)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_subscribe(c, test_topic, subsqos);
if (!(assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
multiThread_sendAndReceive(c, 0, test_topic); multiThread_sendAndReceive(c, 0, test_topic);
...@@ -1016,9 +1036,11 @@ int test3a_m(struct Options options) ...@@ -1016,9 +1036,11 @@ int test3a_m(struct Options options)
MyLog(LOGA_DEBUG, "Stopping\n"); MyLog(LOGA_DEBUG, "Stopping\n");
if (!(assert("Unsubscribe successful", (rc = MQTTClient_unsubscribe(c, test_topic)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_unsubscribe(c, test_topic);
if (!(assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -1050,8 +1072,8 @@ int test3b(struct Options options) ...@@ -1050,8 +1072,8 @@ int test3b(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 3b\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 3b\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.server_auth_connection, "test3b", rc = MQTTClient_create(&c, options.server_auth_connection, "test3b", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -1068,7 +1090,8 @@ int test3b(struct Options options) ...@@ -1068,7 +1090,8 @@ int test3b(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_FAILURE, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_FAILURE, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -1101,8 +1124,8 @@ int test4_s(struct Options options) ...@@ -1101,8 +1124,8 @@ int test4_s(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 4_s\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 4_s\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.server_auth_connection, "test4_s", rc = MQTTClient_create(&c, options.server_auth_connection, "test4_s", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -1120,9 +1143,11 @@ int test4_s(struct Options options) ...@@ -1120,9 +1143,11 @@ int test4_s(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Good rc from subscribe", (rc = MQTTClient_subscribe(c, test_topic, subsqos)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_subscribe(c, test_topic, subsqos);
if (!(assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
singleThread_sendAndReceive(c, 0, test_topic); singleThread_sendAndReceive(c, 0, test_topic);
...@@ -1131,16 +1156,19 @@ int test4_s(struct Options options) ...@@ -1131,16 +1156,19 @@ int test4_s(struct Options options)
MyLog(LOGA_DEBUG, "Stopping\n"); MyLog(LOGA_DEBUG, "Stopping\n");
if (!(assert("Unsubscribe successful", (rc = MQTTClient_unsubscribe(c, test_topic)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_unsubscribe(c, test_topic);
if (!(assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
/* Just to make sure we can connect again */ /* Just to make sure we can connect again */
rc = MQTTClient_connect(c, &opts);
if (!(assert("Connect successful", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) if (!(assert("Connect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -1173,8 +1201,8 @@ int test4_m(struct Options options) ...@@ -1173,8 +1201,8 @@ int test4_m(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 4_m\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 4_m\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.server_auth_connection, rc = MQTTClient_create(&c, options.server_auth_connection, "test4_m", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
"test4_m", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -1190,14 +1218,17 @@ int test4_m(struct Options options) ...@@ -1190,14 +1218,17 @@ int test4_m(struct Options options)
opts.ssl = &sslopts; opts.ssl = &sslopts;
opts.ssl->enableServerCertAuth = 0; opts.ssl->enableServerCertAuth = 0;
if (!(assert("Good rc from setCallbacks", (rc = MQTTClient_setCallbacks(c, NULL, NULL, multiThread_messageArrived, multiThread_deliveryComplete)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_setCallbacks(c, NULL, NULL, multiThread_messageArrived, multiThread_deliveryComplete);
if (!(assert("Good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Good rc from subscribe", (rc = MQTTClient_subscribe(c, test_topic, subsqos)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_subscribe(c, test_topic, subsqos);
if (!(assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
multiThread_sendAndReceive(c, 0, test_topic); multiThread_sendAndReceive(c, 0, test_topic);
...@@ -1206,9 +1237,11 @@ int test4_m(struct Options options) ...@@ -1206,9 +1237,11 @@ int test4_m(struct Options options)
MyLog(LOGA_DEBUG, "Stopping"); MyLog(LOGA_DEBUG, "Stopping");
if (!(assert("Unsubscribe successful", (rc = MQTTClient_unsubscribe(c, test_topic)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_unsubscribe(c, test_topic);
if (!(assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -1242,8 +1275,8 @@ int test5a(struct Options options) ...@@ -1242,8 +1275,8 @@ int test5a(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 5a\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 5a\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.anon_connection, "test5a", rc = MQTTClient_create(&c, options.anon_connection, "test5a", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -1262,9 +1295,11 @@ int test5a(struct Options options) ...@@ -1262,9 +1295,11 @@ int test5a(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Good rc from subscribe", (rc = MQTTClient_subscribe(c, test_topic, subsqos)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_subscribe(c, test_topic, subsqos);
if (!(assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
singleThread_sendAndReceive(c, 0, test_topic); singleThread_sendAndReceive(c, 0, test_topic);
...@@ -1273,16 +1308,20 @@ int test5a(struct Options options) ...@@ -1273,16 +1308,20 @@ int test5a(struct Options options)
MyLog(LOGA_DEBUG, "Stopping\n"); MyLog(LOGA_DEBUG, "Stopping\n");
if (!(assert("Unsubscribe successful", (rc = MQTTClient_unsubscribe(c, test_topic)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_unsubscribe(c, test_topic);
if (!(assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
/* Just to make sure we can connect again */ /* Just to make sure we can connect again */
if (!(assert("Connect successful", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Connect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -1315,8 +1354,8 @@ int test5b(struct Options options) ...@@ -1315,8 +1354,8 @@ int test5b(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 5b\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 5b\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.anon_connection, "test5b", rc = MQTTClient_create(&c, options.anon_connection, "test5b", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -1338,9 +1377,11 @@ int test5b(struct Options options) ...@@ -1338,9 +1377,11 @@ int test5b(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Good rc from subscribe", (rc = MQTTClient_subscribe(c, test_topic, subsqos)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_subscribe(c, test_topic, subsqos);
if (!(assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
singleThread_sendAndReceive(c, 0, test_topic); singleThread_sendAndReceive(c, 0, test_topic);
...@@ -1349,16 +1390,19 @@ int test5b(struct Options options) ...@@ -1349,16 +1390,19 @@ int test5b(struct Options options)
MyLog(LOGA_DEBUG, "Stopping\n"); MyLog(LOGA_DEBUG, "Stopping\n");
if (!(assert("Unsubscribe successful", (rc = MQTTClient_unsubscribe(c, test_topic)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_unsubscribe(c, test_topic);
if (!(assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
/* Just to make sure we can connect again */ /* Just to make sure we can connect again */
rc = MQTTClient_connect(c, &opts);
if (!(assert("Connect successful", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) if (!(assert("Connect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
if (!(assert("Disconnect successful", (rc = MQTTClient_disconnect(c, 0)) == MQTTCLIENT_SUCCESS, "rc was %d", rc))) rc = MQTTClient_disconnect(c, 0);
if (!(assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
...@@ -1392,8 +1436,8 @@ int test5c(struct Options options) ...@@ -1392,8 +1436,8 @@ int test5c(struct Options options)
fprintf(xml, "<testcase classname=\"test3\" name=\"test 5c\""); fprintf(xml, "<testcase classname=\"test3\" name=\"test 5c\"");
global_start_time = start_clock(); global_start_time = start_clock();
if (!(assert("good rc from create", (rc = MQTTClient_create(&c, options.anon_connection, "test5c", rc = MQTTClient_create(&c, options.anon_connection, "test5c", MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore);
MQTTCLIENT_PERSISTENCE_DEFAULT, persistenceStore)) == MQTTCLIENT_SUCCESS, "rc was %d\n", rc))) if (!(assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc)))
goto exit; goto exit;
opts.keepAliveInterval = 20; opts.keepAliveInterval = 20;
...@@ -1415,7 +1459,8 @@ int test5c(struct Options options) ...@@ -1415,7 +1459,8 @@ int test5c(struct Options options)
MyLog(LOGA_DEBUG, "Connecting"); MyLog(LOGA_DEBUG, "Connecting");
if (!(assert("Good rc from connect", (rc = MQTTClient_connect(c, &opts)) == MQTTCLIENT_FAILURE, "rc was %d", rc))) rc = MQTTClient_connect(c, &opts);
if (!(assert("Good rc from connect", rc == MQTTCLIENT_FAILURE, "rc was %d", rc)))
goto exit; goto exit;
exit: exit:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment