test2.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2009, 2020 IBM Corp. and others
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v2.0
6  * and Eclipse Distribution License v1.0 which accompany this distribution.
7  *
8  * The Eclipse Public License is available at
9  * https://www.eclipse.org/legal/epl-2.0/
10  * and the Eclipse Distribution License is available at
11  * http://www.eclipse.org/org/documents/edl-v10.php.
12  *
13  * Contributors:
14  * Ian Craggs - initial API and implementation and/or initial documentation
15  * Ian Craggs - fix thread id display
16  *******************************************************************************/
17 
23 #include "MQTTClient.h"
24 #include "Thread.h"
25 #include <string.h>
26 #include <stdlib.h>
27 
28 #if !defined(_WINDOWS)
29  #include <sys/time.h>
30  #include <sys/socket.h>
31  #include <unistd.h>
32  #include <errno.h>
33  #define WINAPI
34 #else
35  #include <windows.h>
36  #define setenv(a, b, c) _putenv_s(a, b)
37 #endif
38 
39 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
40 
41 void usage(void)
42 {
43  printf("help!!\n");
44  exit(EXIT_FAILURE);
45 }
46 
47 struct Options
48 {
49  char* connection;
50  char** haconnections;
51  int hacount;
52  int verbose;
53  int test_no;
54  int MQTTVersion;
55  int iterations;
56 } options =
57 {
58  "tcp://m2m.eclipse.org:1883",
59  NULL,
60  0,
61  0,
62  0,
64  1,
65 };
66 
67 void getopts(int argc, char** argv)
68 {
69  int count = 1;
70 
71  while (count < argc)
72  {
73  if (strcmp(argv[count], "--test_no") == 0)
74  {
75  if (++count < argc)
76  options.test_no = atoi(argv[count]);
77  else
78  usage();
79  }
80  else if (strcmp(argv[count], "--connection") == 0)
81  {
82  if (++count < argc)
83  {
84  options.connection = argv[count];
85  printf("\nSetting connection to %s\n", options.connection);
86  }
87  else
88  usage();
89  }
90  else if (strcmp(argv[count], "--haconnections") == 0)
91  {
92  if (++count < argc)
93  {
94  char* tok = strtok(argv[count], " ");
95  options.hacount = 0;
96  options.haconnections = malloc(sizeof(char*) * 5);
97  while (tok)
98  {
99  options.haconnections[options.hacount] = malloc(strlen(tok) + 1);
100  strcpy(options.haconnections[options.hacount], tok);
101  options.hacount++;
102  tok = strtok(NULL, " ");
103  }
104  }
105  else
106  usage();
107  }
108  else if (strcmp(argv[count], "--MQTTversion") == 0)
109  {
110  if (++count < argc)
111  {
112  options.MQTTVersion = atoi(argv[count]);
113  printf("setting MQTT version to %d\n", options.MQTTVersion);
114  }
115  else
116  usage();
117  }
118  else if (strcmp(argv[count], "--iterations") == 0)
119  {
120  if (++count < argc)
121  options.iterations = atoi(argv[count]);
122  else
123  usage();
124  }
125  else if (strcmp(argv[count], "--verbose") == 0)
126  {
127  options.verbose = 1;
128  printf("\nSetting verbose on\n");
129  }
130  count++;
131  }
132 }
133 
134 
135 #define LOGA_DEBUG 0
136 #define LOGA_INFO 1
137 #include <stdarg.h>
138 #include <time.h>
139 #include <sys/timeb.h>
140 void MyLog(int LOGA_level, char* format, ...)
141 {
142  static char msg_buf[256];
143  va_list args;
144 #if defined(_WIN32) || defined(_WINDOWS)
145  struct timeb ts;
146 #else
147  struct timeval ts;
148 #endif
149  struct tm timeinfo;
150 
151  if (LOGA_level == LOGA_DEBUG && options.verbose == 0)
152  return;
153 
154 #if defined(_WIN32) || defined(_WINDOWS)
155  ftime(&ts);
156  localtime_s(&timeinfo, &ts.time);
157 #else
158  gettimeofday(&ts, NULL);
159  localtime_r(&ts.tv_sec, &timeinfo);
160 #endif
161  strftime(msg_buf, 80, "%Y%m%d %H%M%S", &timeinfo);
162 
163 #if defined(_WIN32) || defined(_WINDOWS)
164  sprintf(&msg_buf[strlen(msg_buf)], ".%.3hu ", ts.millitm);
165 #else
166  sprintf(&msg_buf[strlen(msg_buf)], ".%.3lu ", ts.tv_usec / 1000);
167 #endif
168 
169  va_start(args, format);
170  vsnprintf(&msg_buf[strlen(msg_buf)], sizeof(msg_buf) - strlen(msg_buf), format, args);
171  va_end(args);
172 
173  printf("%s\n", msg_buf);
174  fflush(stdout);
175 }
176 
177 
178 #if defined(_WIN32) || defined(_WINDOWS)
179 #define mqsleep(A) Sleep(1000*A)
180 #define START_TIME_TYPE DWORD
181 static DWORD start_time = 0;
183 {
184  return GetTickCount();
185 }
186 #elif defined(AIX)
187 #define mqsleep sleep
188 #define START_TIME_TYPE struct timespec
190 {
191  static struct timespec start;
192  clock_gettime(CLOCK_REALTIME, &start);
193  return start;
194 }
195 #else
196 #define mqsleep sleep
197 #define START_TIME_TYPE struct timeval
198 /* TODO - unused - remove? static struct timeval start_time; */
200 {
201  struct timeval start_time;
202  gettimeofday(&start_time, NULL);
203  return start_time;
204 }
205 #endif
206 
207 
208 #if defined(_WIN32)
209 long elapsed(START_TIME_TYPE start_time)
210 {
211  return GetTickCount() - start_time;
212 }
213 #elif defined(AIX)
214 #define assert(a)
215 long elapsed(struct timespec start)
216 {
217  struct timespec now, res;
218 
219  clock_gettime(CLOCK_REALTIME, &now);
220  ntimersub(now, start, res);
221  return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L;
222 }
223 #else
224 long elapsed(START_TIME_TYPE start_time)
225 {
226  struct timeval now, res;
227 
228  gettimeofday(&now, NULL);
229  timersub(&now, &start_time, &res);
230  return (res.tv_sec)*1000 + (res.tv_usec)/1000;
231 }
232 #endif
233 
234 
235 #define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d)
236 #define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e)
237 
238 int tests = 0;
239 int failures = 0;
240 FILE* xml;
242 char output[3000];
244 
245 
247 {
248  long duration = elapsed(global_start_time);
249 
250  fprintf(xml, " time=\"%ld.%.3ld\" >\n", duration / 1000, duration % 1000);
251  if (cur_output != output)
252  {
253  fprintf(xml, "%s", output);
254  cur_output = output;
255  }
256  fprintf(xml, "</testcase>\n");
257 }
258 
259 
260 void myassert(char* filename, int lineno, char* description, int value, char* format, ...)
261 {
262  ++tests;
263  if (!value)
264  {
265  va_list args;
266 
267  ++failures;
268  MyLog(LOGA_INFO, "Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description);
269 
270  va_start(args, format);
271  vprintf(format, args);
272  va_end(args);
273 
274  cur_output += sprintf(cur_output, "<failure type=\"%s\">file %s, line %d </failure>\n",
275  description, filename, lineno);
276  }
277  else
278  MyLog(LOGA_DEBUG, "Assertion succeeded, file %s, line %d, description: %s", filename, lineno, description);
279 }
280 
281 
282 #if defined(_WIN32) || defined(_WIN64)
284 #else
285 pthread_mutex_t deliveryCompleted_mutex_store = PTHREAD_MUTEX_INITIALIZER;
287 #endif
288 
289 void lock_mutex(mutex_type amutex)
290 {
291  int rc = Thread_lock_mutex(amutex);
292  if (rc != 0)
293  MyLog(LOGA_INFO, "Error %s locking mutex", strerror(rc));
294 }
295 
297 {
298  int rc = Thread_unlock_mutex(amutex);
299  if (rc != 0)
300  MyLog(LOGA_INFO, "Error %s unlocking mutex", strerror(rc));
301 }
302 
303 
304 /*********************************************************************
305 
306 Test1: multiple threads to single client object
307 
308 *********************************************************************/
309 volatile int test1_arrivedcount = 0;
310 volatile int test1_arrivedcount_qos[3] = {0, 0, 0};
311 volatile int test1_deliveryCompleted = 0;
313 
314 
316 {
318  MyLog(LOGA_DEBUG, "Delivery complete for token %d", dt);
321 }
322 
323 int test1_messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m)
324 {
325  ++(test1_arrivedcount_qos[m->qos]);
327 
328  MyLog(LOGA_DEBUG, "messageArrived: %d message received on topic %s is %.*s.",
329  test1_arrivedcount, topicName, m->payloadlen, (char*)(m->payload));
330  if (test1_pubmsg_check.payloadlen != m->payloadlen ||
331  memcmp(m->payload, test1_pubmsg_check.payload, m->payloadlen) != 0)
332  {
333  failures++;
334  MyLog(LOGA_INFO, "Error: wrong data received lengths %d %d\n", test1_pubmsg_check.payloadlen, m->payloadlen);
335  }
336  MQTTClient_free(topicName);
338  return 1;
339 }
340 
341 
343 {
345  int qos;
346  char* test_topic;
347 };
348 
349 static int iterations = 50;
350 
352 {
354  int i = 0;
355  int rc = 0;
356  int wait_seconds = 30;
358  int subsqos = 2;
359 
360  struct thread_parms *parms = n;
361  MQTTClient* c = parms->c;
362  int qos = parms->qos;
363  char* test_topic = parms->test_topic;
364 
365  rc = MQTTClient_subscribe(c, test_topic, subsqos);
366  assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
367 
368  MyLog(LOGA_INFO, "Thread %u, %d messages at QoS %d", Thread_getid(), iterations, qos);
369  test1_pubmsg.payload = test1_pubmsg_check.payload;
370  test1_pubmsg.payloadlen = test1_pubmsg_check.payloadlen;
371  test1_pubmsg.retained = 0;
372  test1_pubmsg.qos = qos;
373 
374  for (i = 1; i <= iterations; ++i)
375  {
376  if (i % 10 == 0)
377  rc = MQTTClient_publish(c, test_topic, test1_pubmsg.payloadlen, test1_pubmsg.payload,
378  qos, test1_pubmsg.retained, &dt);
379  else
380  rc = MQTTClient_publishMessage(c, test_topic, &test1_pubmsg, &dt);
381  assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
382 
383  #if defined(_WIN32)
384  Sleep(100);
385  #else
386  usleep(100000L);
387  #endif
388 
389  wait_seconds = 30;
390  while ((test1_arrivedcount_qos[qos] < i) && (wait_seconds-- > 0))
391  {
392  MyLog(LOGA_DEBUG, "Arrived %d count %d", test1_arrivedcount_qos[qos], i);
393  #if defined(_WIN32)
394  Sleep(1000);
395  #else
396  usleep(1000000L);
397  #endif
398  }
399  assert("Message Arrived", wait_seconds > 0,
400  "Timed out waiting for message %d\n", i);
401  }
402 
403 #if defined(_WINDOWS)
404  return 0;
405 #else
406  return NULL;
407 #endif
408 }
409 
410 
411 int test1(struct Options options)
412 {
413  MQTTClient c;
416  int rc = 0;
417  char* test_topic = "C client test1";
418 
419  fprintf(xml, "<testcase classname=\"test1\" name=\"multiple threads using same client object\"");
421  failures = 0;
422  MyLog(LOGA_INFO, "Starting test 1 - multiple threads using same client object");
423 
424  rc = MQTTClient_create(&c, options.connection, "single_object, multiple threads",
426  assert("good rc from create", rc == MQTTCLIENT_SUCCESS, "rc was %d\n", rc);
427  if (rc != MQTTCLIENT_SUCCESS)
428  {
429  MQTTClient_destroy(&c);
430  goto exit;
431  }
432 
434  assert("Good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
435 
436  opts.keepAliveInterval = 20;
437  opts.cleansession = 1;
438  opts.username = "testuser";
439  opts.password = "testpassword";
440  opts.MQTTVersion = options.MQTTVersion;
441  if (options.haconnections != NULL)
442  {
443  opts.serverURIs = options.haconnections;
444  opts.serverURIcount = options.hacount;
445  }
446 
447  opts.will = &wopts;
448  opts.will->message = "will message";
449  opts.will->qos = 1;
450  opts.will->retained = 0;
451  opts.will->topicName = "will topic";
452  opts.will = NULL;
453 
454  MyLog(LOGA_DEBUG, "Connecting");
455  rc = MQTTClient_connect(c, &opts);
456  assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
457  if (rc != MQTTCLIENT_SUCCESS)
458  goto exit;
459 
460  test1_pubmsg_check.payload = "a much longer message that we can shorten to the extent that we need to";
461  test1_pubmsg_check.payloadlen = 27;
463 
464  struct thread_parms parms0 = {c, 0, test_topic};
465  Thread_start(test1_sendAndReceive, (void*)&parms0);
466 
467  struct thread_parms parms1 = {c, 1, test_topic};
468  Thread_start(test1_sendAndReceive, (void*)&parms1);
469 
470  struct thread_parms parms2 = {c, 2, test_topic};
471  Thread_start(test1_sendAndReceive, (void*)&parms2);
472 
473  /* MQTT servers can send a message to a subscriber before the server has
474  completed the QoS 2 handshake with the publisher. For QoS 1 and 2,
475  allow time for the final delivery complete callback before checking
476  that all expected callbacks have been made */
477 
478  int wait_seconds = 90;
479  while (((test1_arrivedcount < iterations*3) || (test1_deliveryCompleted < iterations*2)) && (wait_seconds-- > 0))
480  {
481  #if defined(_WIN32)
482  Sleep(1000);
483  #else
484  usleep(1000000L);
485  #endif
486  }
487  assert("Arrived count == 150", test1_arrivedcount == iterations*3, "arrivedcount was %d", test1_arrivedcount);
488  assert("All Deliveries Complete", test1_deliveryCompleted == iterations*2,
489  "Number of deliveryCompleted callbacks was %d\n", test1_deliveryCompleted);
490 
491  MyLog(LOGA_DEBUG, "Stopping\n");
492 
493  rc = MQTTClient_unsubscribe(c, test_topic);
494  assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
495  rc = MQTTClient_disconnect(c, 0);
496  assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
497 
498  /* Just to make sure we can connect again */
499  rc = MQTTClient_connect(c, &opts);
500  assert("Connect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
501  rc = MQTTClient_disconnect(c, 0);
502  assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
503 
504  MQTTClient_destroy(&c);
505 
506 exit:
507  MyLog(LOGA_INFO, "TEST1: test %s. %d tests run, %d failures.",
508  (failures == 0) ? "passed" : "failed", tests, failures);
510  return failures;
511 }
512 
513 
514 /*********************************************************************
515 
516 Test2: multiple client objects used from multiple threads
517 
518 *********************************************************************/
519 volatile int test2_arrivedcount = 0;
520 
521 volatile int test2_deliveryCompleted = 0;
522 
524 
526 {
528  MyLog(LOGA_DEBUG, "Delivery complete for token %d", dt);
531 }
532 
533 int test2_messageArrived(void* context, char* topicName, int topicLen, MQTTClient_message* m)
534 {
536  MyLog(LOGA_DEBUG, "Callback: %d message received on topic %s is %.*s.",
537  test2_arrivedcount, topicName, m->payloadlen, (char*)(m->payload));
538  if (test2_pubmsg.payloadlen != m->payloadlen ||
539  memcmp(m->payload, test2_pubmsg.payload, m->payloadlen) != 0)
540  {
541  failures++;
542  MyLog(LOGA_INFO, "Error: wrong data received lengths %d %d\n", test2_pubmsg.payloadlen, m->payloadlen);
543  }
544  MQTTClient_free(topicName);
546  return 1;
547 }
548 
549 
551 {
553  int i = 0;
554  int iterations = 50;
555  int rc = 0;
556  int wait_seconds = 0;
557 
559 
560  MyLog(LOGA_INFO, "%d messages at QoS %d", iterations, qos);
561  test2_pubmsg.payload = "a much longer message that we can shorten to the extent that we need to";
562  test2_pubmsg.payloadlen = 27;
563  test2_pubmsg.qos = qos;
564  test2_pubmsg.retained = 0;
565 
566  for (i = 1; i <= iterations; ++i)
567  {
568  if (i % 10 == 0)
569  rc = MQTTClient_publish(c, test_topic, test2_pubmsg.payloadlen, test2_pubmsg.payload,
570  test2_pubmsg.qos, test2_pubmsg.retained, NULL);
571  else
572  rc = MQTTClient_publishMessage(c, test_topic, &test2_pubmsg, &dt);
573  assert("Good rc from publish", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
574 
575  #if defined(_WIN32)
576  Sleep(100);
577  #else
578  usleep(100000L);
579  #endif
580 
581  wait_seconds = 10;
582  while ((test2_arrivedcount < i) && (wait_seconds-- > 0))
583  {
584  MyLog(LOGA_DEBUG, "Arrived %d count %d", test2_arrivedcount, i);
585  #if defined(_WIN32)
586  Sleep(1000);
587  #else
588  usleep(1000000L);
589  #endif
590  }
591  assert("Message Arrived", wait_seconds > 0,
592  "Time out waiting for message %d\n", i );
593  }
594  if (qos > 0)
595  {
596  /* MQ Telemetry can send a message to a subscriber before the server has
597  completed the QoS 2 handshake with the publisher. For QoS 1 and 2,
598  allow time for the final delivery complete callback before checking
599  that all expected callbacks have been made */
600  wait_seconds = 40;
601  while ((test2_deliveryCompleted < iterations) && (wait_seconds-- > 0))
602  {
603  MyLog(LOGA_DEBUG, "Delivery Completed %d count %d", test2_deliveryCompleted, i);
604  #if defined(_WIN32)
605  Sleep(1000);
606  #else
607  usleep(1000000L);
608  #endif
609  }
610  assert("All Deliveries Complete", test2_deliveryCompleted == iterations,
611  "Number of deliveryCompleted callbacks was %d\n",
613  }
614 }
615 
616 
617 int test2(struct Options options)
618 {
619  char* testname = "test2";
620  int subsqos = 2;
621  /* TODO - usused - remove ? MQTTClient_deliveryToken* dt = NULL; */
622  MQTTClient c;
624  int rc = 0;
625  char* test_topic = "C client test2";
626 
627  fprintf(xml, "<testcase classname=\"test1\" name=\"multi-threaded client using callbacks\"");
628  MyLog(LOGA_INFO, "Starting test 2 - multi-threaded client using callbacks");
630  failures = 0;
631 
632  MQTTClient_create(&c, options.connection, "multi_threaded_sample", MQTTCLIENT_PERSISTENCE_NONE, NULL);
633 
634  opts.keepAliveInterval = 20;
635  opts.cleansession = 1;
636  opts.MQTTVersion = options.MQTTVersion;
637  if (options.haconnections != NULL)
638  {
639  opts.serverURIs = options.haconnections;
640  opts.serverURIcount = options.hacount;
641  }
642 
644  assert("Good rc from setCallbacks", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
645 
646  MyLog(LOGA_DEBUG, "Connecting");
647  rc = MQTTClient_connect(c, &opts);
648  assert("Good rc from connect", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
649  if (rc != MQTTCLIENT_SUCCESS)
650  goto exit;
651 
652  rc = MQTTClient_subscribe(c, test_topic, subsqos);
653  assert("Good rc from subscribe", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
654 
655  test2_sendAndReceive(c, 0, test_topic);
656  test2_sendAndReceive(c, 1, test_topic);
657  test2_sendAndReceive(c, 2, test_topic);
658 
659  MyLog(LOGA_DEBUG, "Stopping");
660 
661  rc = MQTTClient_unsubscribe(c, test_topic);
662  assert("Unsubscribe successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
663  rc = MQTTClient_disconnect(c, 0);
664  assert("Disconnect successful", rc == MQTTCLIENT_SUCCESS, "rc was %d", rc);
665 
666  MQTTClient_destroy(&c);
667 
668 exit:
669  MyLog(LOGA_INFO, "%s: test %s. %d tests run, %d failures.",
670  (failures == 0) ? "passed" : "failed", testname, tests, failures);
672  return failures;
673 }
674 
675 
676 int main(int argc, char** argv)
677 {
678  int rc = 0;
679  int (*tests[])() = {NULL, test1};
680  int i;
681 
682  #if defined(_WIN32) || defined(_WIN64)
683  deliveryCompleted_mutex = CreateMutex(NULL, 0, NULL);
684  #endif
685 
686  xml = fopen("TEST-test2.xml", "w");
687  fprintf(xml, "<testsuite name=\"test1\" tests=\"%d\">\n", (int)(ARRAY_SIZE(tests) - 1));
688 
689  setenv("MQTT_C_CLIENT_TRACE", "ON", 1);
690  setenv("MQTT_C_CLIENT_TRACE_LEVEL", "ERROR", 1);
691 
692  getopts(argc, argv);
693 
694  for (i = 0; i < options.iterations; ++i)
695  {
696  if (options.test_no == 0)
697  { /* run all the tests */
699  rc += tests[options.test_no](options); /* return number of failures. 0 = test succeeded */
700  }
701  else
702  rc = tests[options.test_no](options); /* run just the selected test */
703  }
704 
705  if (rc == 0)
706  MyLog(LOGA_INFO, "verdict pass");
707  else
708  MyLog(LOGA_INFO, "verdict fail");
709 
710  fprintf(xml, "</testsuite>\n");
711  fclose(xml);
712  return rc;
713 }
int main(int argc, char **argv)
Definition: test2.c:676
enum MQTTPropertyCodes value
volatile int test2_deliveryCompleted
Definition: test2.c:521
char ** haconnections
Definition: test1.c:50
pthread_mutex_t deliveryCompleted_mutex_store
Definition: test2.c:285
MQTTClient_message test2_pubmsg
Definition: test2.c:523
FMT_INLINE std::basic_string< Char > format(const S &format_str, Args &&...args)
Definition: core.h:2081
#define MQTTCLIENT_SUCCESS
Definition: MQTTClient.h:131
#define LOGA_INFO
Definition: test2.c:136
int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions *options)
Definition: MQTTClient.c:1644
int MQTTClient_publish(MQTTClient handle, const char *topicName, int payloadlen, const void *payload, int qos, int retained, MQTTClient_deliveryToken *deliveryToken)
Definition: MQTTClient.c:2387
char * connection
int MQTTClient_disconnect(MQTTClient handle, int timeout)
Definition: MQTTClient.c:1908
void getopts(int argc, char **argv)
Definition: test2.c:67
int Thread_lock_mutex(mutex_type mutex)
Definition: Thread.c:112
struct pubsub_opts opts
Definition: paho_c_pub.c:42
size_t strftime(char *str, size_t count, const char *format, const std::tm *time)
Definition: chrono.h:375
#define malloc(x)
Definition: Heap.h:41
MQTTClient * c
Definition: test2.c:344
void lock_mutex(mutex_type amutex)
Definition: test2.c:289
thread_return_type WINAPI test1_sendAndReceive(void *n)
Definition: test2.c:351
long elapsed(START_TIME_TYPE start_time)
Definition: test2.c:224
int failures
Definition: test2.c:239
#define MQTTClient_message_initializer
Definition: MQTTClient.h:327
static char msg_buf[512]
Definition: Log.c:122
volatile int test1_arrivedcount_qos[3]
Definition: test2.c:310
int test2_messageArrived(void *context, char *topicName, int topicLen, MQTTClient_message *m)
Definition: test2.c:533
void test2_deliveryComplete(void *context, MQTTClient_deliveryToken dt)
Definition: test2.c:525
#define MQTTClient_willOptions_initializer
Definition: MQTTClient.h:639
void myassert(char *filename, int lineno, char *description, int value, char *format,...)
Definition: test2.c:260
void test1_deliveryComplete(void *context, MQTTClient_deliveryToken dt)
Definition: test2.c:315
int MQTTClient_setCallbacks(MQTTClient handle, void *context, MQTTClient_connectionLost *cl, MQTTClient_messageArrived *ma, MQTTClient_deliveryComplete *dc)
Definition: MQTTClient.c:1032
void test2_sendAndReceive(MQTTClient *c, int qos, char *test_topic)
Definition: test2.c:550
void MyLog(int LOGA_level, char *format,...)
Definition: test2.c:140
#define LOGA_DEBUG
Definition: test2.c:135
constexpr size_t count()
Definition: core.h:960
int MQTTClient_publishMessage(MQTTClient handle, const char *topicName, MQTTClient_message *message, MQTTClient_deliveryToken *deliveryToken)
Definition: MQTTClient.c:2432
char * cur_output
Definition: test2.c:243
int hacount
Definition: test1.c:52
description
Definition: setup.py:19
void unlock_mutex(mutex_type amutex)
Definition: test2.c:296
int MQTTClient_unsubscribe(MQTTClient handle, const char *topic)
Definition: MQTTClient.c:2239
int Thread_unlock_mutex(mutex_type mutex)
Definition: Thread.c:133
void usage(void)
Definition: test2.c:41
char output[3000]
Definition: test2.c:242
int qos
Definition: test6.c:56
mutex_type deliveryCompleted_mutex
Definition: test2.c:286
const char * topicName
Definition: MQTTClient.h:619
#define mutex_type
Definition: mutex_type.h:22
void MQTTClient_freeMessage(MQTTClient_message **message)
Definition: MQTTClient.c:601
void * MQTTClient
Definition: MQTTClient.h:246
void write_test_result(void)
Definition: test2.c:246
#define assert(a, b, c, d)
Definition: test2.c:235
START_TIME_TYPE global_start_time
Definition: test2.c:241
void MQTTClient_destroy(MQTTClient *handle)
Definition: MQTTClient.c:556
int qos
Definition: test2.c:345
int tests
Definition: test2.c:238
volatile int test2_arrivedcount
Definition: test2.c:519
int test1(struct Options options)
Definition: test2.c:411
volatile int test1_arrivedcount
Definition: test2.c:309
int MQTTClient_subscribe(MQTTClient handle, const char *topic, int qos)
Definition: MQTTClient.c:2104
MQTTClient_message test1_pubmsg_check
Definition: test2.c:312
char * test_topic
Definition: test11.c:307
MQTTClient c
Definition: test10.c:1656
dictionary context
Definition: test2.py:57
#define thread_return_type
Definition: Thread.h:44
thread_id_type Thread_getid(void)
Definition: Thread.c:176
void MQTTClient_free(void *memory)
Definition: MQTTClient.c:612
char * test_topic
Definition: test2.c:346
null localtime_s(...)
Definition: chrono.h:286
#define MQTTCLIENT_PERSISTENCE_NONE
#define WINAPI
Definition: test2.c:33
#define MQTTClient_connectOptions_initializer
Definition: MQTTClient.h:953
int MQTTClient_deliveryToken
Definition: MQTTClient.h:257
START_TIME_TYPE start_clock(void)
Definition: test2.c:199
thread_type Thread_start(thread_fn fn, void *parameter)
Definition: Thread.c:60
int test1_messageArrived(void *context, char *topicName, int topicLen, MQTTClient_message *m)
Definition: test2.c:323
char *const * serverURIs
Definition: MQTTClient.h:913
struct Options options
const char * message
Definition: MQTTClient.h:621
enum MQTTReasonCodes rc
Definition: test10.c:1112
#define START_TIME_TYPE
Definition: test2.c:197
volatile int test1_deliveryCompleted
Definition: test2.c:311
int MQTTClient_create(MQTTClient *handle, const char *serverURI, const char *clientId, int persistence_type, void *persistence_context)
Definition: MQTTClient.c:507
int test2(struct Options options)
Definition: test2.c:617
#define MQTTVERSION_DEFAULT
Definition: MQTTAsync.h:195
MQTTClient_willOptions * will
Definition: MQTTClient.h:866
#define ARRAY_SIZE(a)
Definition: test2.c:39
int test_no
Definition: test1.c:54
FILE * xml
Definition: test2.c:240
Definition: test1.py:1


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 04:02:48