Fork of my original MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:43:14 2017 +0000
Revision:
0:a1734fe1ec4b
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vpcola 0:a1734fe1ec4b 1 /*******************************************************************************
vpcola 0:a1734fe1ec4b 2 * Copyright (c) 2014 IBM Corp.
vpcola 0:a1734fe1ec4b 3 *
vpcola 0:a1734fe1ec4b 4 * All rights reserved. This program and the accompanying materials
vpcola 0:a1734fe1ec4b 5 * are made available under the terms of the Eclipse Public License v1.0
vpcola 0:a1734fe1ec4b 6 * and Eclipse Distribution License v1.0 which accompany this distribution.
vpcola 0:a1734fe1ec4b 7 *
vpcola 0:a1734fe1ec4b 8 * The Eclipse Public License is available at
vpcola 0:a1734fe1ec4b 9 * http://www.eclipse.org/legal/epl-v10.html
vpcola 0:a1734fe1ec4b 10 * and the Eclipse Distribution License is available at
vpcola 0:a1734fe1ec4b 11 * http://www.eclipse.org/org/documents/edl-v10.php.
vpcola 0:a1734fe1ec4b 12 *
vpcola 0:a1734fe1ec4b 13 * Contributors:
vpcola 0:a1734fe1ec4b 14 * Ian Craggs - initial API and implementation and/or initial documentation
vpcola 0:a1734fe1ec4b 15 *******************************************************************************/
vpcola 0:a1734fe1ec4b 16
vpcola 0:a1734fe1ec4b 17
vpcola 0:a1734fe1ec4b 18 #include "MQTTPacket.h"
vpcola 0:a1734fe1ec4b 19 #include <string.h>
vpcola 0:a1734fe1ec4b 20 #include <stdlib.h>
vpcola 0:a1734fe1ec4b 21 #include <stdio.h>
vpcola 0:a1734fe1ec4b 22
vpcola 0:a1734fe1ec4b 23 #if !defined(_WINDOWS)
vpcola 0:a1734fe1ec4b 24 #include <sys/time.h>
vpcola 0:a1734fe1ec4b 25 #include <sys/socket.h>
vpcola 0:a1734fe1ec4b 26 #include <unistd.h>
vpcola 0:a1734fe1ec4b 27 #include <errno.h>
vpcola 0:a1734fe1ec4b 28 #else
vpcola 0:a1734fe1ec4b 29 #include <winsock2.h>
vpcola 0:a1734fe1ec4b 30 #include <ws2tcpip.h>
vpcola 0:a1734fe1ec4b 31 #define MAXHOSTNAMELEN 256
vpcola 0:a1734fe1ec4b 32 #define EAGAIN WSAEWOULDBLOCK
vpcola 0:a1734fe1ec4b 33 #define EINTR WSAEINTR
vpcola 0:a1734fe1ec4b 34 #define EINPROGRESS WSAEINPROGRESS
vpcola 0:a1734fe1ec4b 35 #define EWOULDBLOCK WSAEWOULDBLOCK
vpcola 0:a1734fe1ec4b 36 #define ENOTCONN WSAENOTCONN
vpcola 0:a1734fe1ec4b 37 #define ECONNRESET WSAECONNRESET
vpcola 0:a1734fe1ec4b 38 #endif
vpcola 0:a1734fe1ec4b 39
vpcola 0:a1734fe1ec4b 40 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
vpcola 0:a1734fe1ec4b 41
vpcola 0:a1734fe1ec4b 42 struct Options
vpcola 0:a1734fe1ec4b 43 {
vpcola 0:a1734fe1ec4b 44 char* connection; /**< connection to system under test. */
vpcola 0:a1734fe1ec4b 45 char** haconnections;
vpcola 0:a1734fe1ec4b 46 int hacount;
vpcola 0:a1734fe1ec4b 47 int verbose;
vpcola 0:a1734fe1ec4b 48 int test_no;
vpcola 0:a1734fe1ec4b 49 } options =
vpcola 0:a1734fe1ec4b 50 {
vpcola 0:a1734fe1ec4b 51 "tcp://m2m.eclipse.org:1883",
vpcola 0:a1734fe1ec4b 52 NULL,
vpcola 0:a1734fe1ec4b 53 0,
vpcola 0:a1734fe1ec4b 54 0,
vpcola 0:a1734fe1ec4b 55 0,
vpcola 0:a1734fe1ec4b 56 };
vpcola 0:a1734fe1ec4b 57
vpcola 0:a1734fe1ec4b 58 void usage()
vpcola 0:a1734fe1ec4b 59 {
vpcola 0:a1734fe1ec4b 60
vpcola 0:a1734fe1ec4b 61 }
vpcola 0:a1734fe1ec4b 62
vpcola 0:a1734fe1ec4b 63 void getopts(int argc, char** argv)
vpcola 0:a1734fe1ec4b 64 {
vpcola 0:a1734fe1ec4b 65 int count = 1;
vpcola 0:a1734fe1ec4b 66
vpcola 0:a1734fe1ec4b 67 while (count < argc)
vpcola 0:a1734fe1ec4b 68 {
vpcola 0:a1734fe1ec4b 69 if (strcmp(argv[count], "--test_no") == 0)
vpcola 0:a1734fe1ec4b 70 {
vpcola 0:a1734fe1ec4b 71 if (++count < argc)
vpcola 0:a1734fe1ec4b 72 options.test_no = atoi(argv[count]);
vpcola 0:a1734fe1ec4b 73 else
vpcola 0:a1734fe1ec4b 74 usage();
vpcola 0:a1734fe1ec4b 75 }
vpcola 0:a1734fe1ec4b 76 else if (strcmp(argv[count], "--connection") == 0)
vpcola 0:a1734fe1ec4b 77 {
vpcola 0:a1734fe1ec4b 78 if (++count < argc)
vpcola 0:a1734fe1ec4b 79 {
vpcola 0:a1734fe1ec4b 80 options.connection = argv[count];
vpcola 0:a1734fe1ec4b 81 printf("\nSetting connection to %s\n", options.connection);
vpcola 0:a1734fe1ec4b 82 }
vpcola 0:a1734fe1ec4b 83 else
vpcola 0:a1734fe1ec4b 84 usage();
vpcola 0:a1734fe1ec4b 85 }
vpcola 0:a1734fe1ec4b 86 else if (strcmp(argv[count], "--haconnections") == 0)
vpcola 0:a1734fe1ec4b 87 {
vpcola 0:a1734fe1ec4b 88 if (++count < argc)
vpcola 0:a1734fe1ec4b 89 {
vpcola 0:a1734fe1ec4b 90 char* tok = strtok(argv[count], " ");
vpcola 0:a1734fe1ec4b 91 options.hacount = 0;
vpcola 0:a1734fe1ec4b 92 options.haconnections = malloc(sizeof(char*) * 5);
vpcola 0:a1734fe1ec4b 93 while (tok)
vpcola 0:a1734fe1ec4b 94 {
vpcola 0:a1734fe1ec4b 95 options.haconnections[options.hacount] = malloc(strlen(tok) + 1);
vpcola 0:a1734fe1ec4b 96 strcpy(options.haconnections[options.hacount], tok);
vpcola 0:a1734fe1ec4b 97 options.hacount++;
vpcola 0:a1734fe1ec4b 98 tok = strtok(NULL, " ");
vpcola 0:a1734fe1ec4b 99 }
vpcola 0:a1734fe1ec4b 100 }
vpcola 0:a1734fe1ec4b 101 else
vpcola 0:a1734fe1ec4b 102 usage();
vpcola 0:a1734fe1ec4b 103 }
vpcola 0:a1734fe1ec4b 104 else if (strcmp(argv[count], "--verbose") == 0)
vpcola 0:a1734fe1ec4b 105 {
vpcola 0:a1734fe1ec4b 106 options.verbose = 1;
vpcola 0:a1734fe1ec4b 107 printf("\nSetting verbose on\n");
vpcola 0:a1734fe1ec4b 108 }
vpcola 0:a1734fe1ec4b 109 count++;
vpcola 0:a1734fe1ec4b 110 }
vpcola 0:a1734fe1ec4b 111 }
vpcola 0:a1734fe1ec4b 112
vpcola 0:a1734fe1ec4b 113
vpcola 0:a1734fe1ec4b 114 #define LOGA_DEBUG 0
vpcola 0:a1734fe1ec4b 115 #define LOGA_INFO 1
vpcola 0:a1734fe1ec4b 116 #include <stdarg.h>
vpcola 0:a1734fe1ec4b 117 #include <time.h>
vpcola 0:a1734fe1ec4b 118 #include <sys/timeb.h>
vpcola 0:a1734fe1ec4b 119 void MyLog(int LOGA_level, char* format, ...)
vpcola 0:a1734fe1ec4b 120 {
vpcola 0:a1734fe1ec4b 121 static char msg_buf[256];
vpcola 0:a1734fe1ec4b 122 va_list args;
vpcola 0:a1734fe1ec4b 123 struct timeb ts;
vpcola 0:a1734fe1ec4b 124
vpcola 0:a1734fe1ec4b 125 struct tm *timeinfo;
vpcola 0:a1734fe1ec4b 126
vpcola 0:a1734fe1ec4b 127 if (LOGA_level == LOGA_DEBUG && options.verbose == 0)
vpcola 0:a1734fe1ec4b 128 return;
vpcola 0:a1734fe1ec4b 129
vpcola 0:a1734fe1ec4b 130 ftime(&ts);
vpcola 0:a1734fe1ec4b 131 timeinfo = localtime(&ts.time);
vpcola 0:a1734fe1ec4b 132 strftime(msg_buf, 80, "%Y%m%d %H%M%S", timeinfo);
vpcola 0:a1734fe1ec4b 133
vpcola 0:a1734fe1ec4b 134 sprintf(&msg_buf[strlen(msg_buf)], ".%.3hu ", ts.millitm);
vpcola 0:a1734fe1ec4b 135
vpcola 0:a1734fe1ec4b 136 va_start(args, format);
vpcola 0:a1734fe1ec4b 137 vsnprintf(&msg_buf[strlen(msg_buf)], sizeof(msg_buf) - strlen(msg_buf), format, args);
vpcola 0:a1734fe1ec4b 138 va_end(args);
vpcola 0:a1734fe1ec4b 139
vpcola 0:a1734fe1ec4b 140 printf("%s\n", msg_buf);
vpcola 0:a1734fe1ec4b 141 fflush(stdout);
vpcola 0:a1734fe1ec4b 142 }
vpcola 0:a1734fe1ec4b 143
vpcola 0:a1734fe1ec4b 144
vpcola 0:a1734fe1ec4b 145 #if defined(WIN32) || defined(_WINDOWS)
vpcola 0:a1734fe1ec4b 146 #define mqsleep(A) Sleep(1000*A)
vpcola 0:a1734fe1ec4b 147 #define START_TIME_TYPE DWORD
vpcola 0:a1734fe1ec4b 148 static DWORD start_time = 0;
vpcola 0:a1734fe1ec4b 149 START_TIME_TYPE start_clock(void)
vpcola 0:a1734fe1ec4b 150 {
vpcola 0:a1734fe1ec4b 151 return GetTickCount();
vpcola 0:a1734fe1ec4b 152 }
vpcola 0:a1734fe1ec4b 153 #elif defined(AIX)
vpcola 0:a1734fe1ec4b 154 #define mqsleep sleep
vpcola 0:a1734fe1ec4b 155 #define START_TIME_TYPE struct timespec
vpcola 0:a1734fe1ec4b 156 START_TIME_TYPE start_clock(void)
vpcola 0:a1734fe1ec4b 157 {
vpcola 0:a1734fe1ec4b 158 static struct timespec start;
vpcola 0:a1734fe1ec4b 159 clock_gettime(CLOCK_REALTIME, &start);
vpcola 0:a1734fe1ec4b 160 return start;
vpcola 0:a1734fe1ec4b 161 }
vpcola 0:a1734fe1ec4b 162 #else
vpcola 0:a1734fe1ec4b 163 #define mqsleep sleep
vpcola 0:a1734fe1ec4b 164 #define START_TIME_TYPE struct timeval
vpcola 0:a1734fe1ec4b 165 /* TODO - unused - remove? static struct timeval start_time; */
vpcola 0:a1734fe1ec4b 166 START_TIME_TYPE start_clock(void)
vpcola 0:a1734fe1ec4b 167 {
vpcola 0:a1734fe1ec4b 168 struct timeval start_time;
vpcola 0:a1734fe1ec4b 169 gettimeofday(&start_time, NULL);
vpcola 0:a1734fe1ec4b 170 return start_time;
vpcola 0:a1734fe1ec4b 171 }
vpcola 0:a1734fe1ec4b 172 #endif
vpcola 0:a1734fe1ec4b 173
vpcola 0:a1734fe1ec4b 174
vpcola 0:a1734fe1ec4b 175 #if defined(WIN32)
vpcola 0:a1734fe1ec4b 176 long elapsed(START_TIME_TYPE start_time)
vpcola 0:a1734fe1ec4b 177 {
vpcola 0:a1734fe1ec4b 178 return GetTickCount() - start_time;
vpcola 0:a1734fe1ec4b 179 }
vpcola 0:a1734fe1ec4b 180 #elif defined(AIX)
vpcola 0:a1734fe1ec4b 181 #define assert(a)
vpcola 0:a1734fe1ec4b 182 long elapsed(struct timespec start)
vpcola 0:a1734fe1ec4b 183 {
vpcola 0:a1734fe1ec4b 184 struct timespec now, res;
vpcola 0:a1734fe1ec4b 185
vpcola 0:a1734fe1ec4b 186 clock_gettime(CLOCK_REALTIME, &now);
vpcola 0:a1734fe1ec4b 187 ntimersub(now, start, res);
vpcola 0:a1734fe1ec4b 188 return (res.tv_sec)*1000L + (res.tv_nsec)/1000000L;
vpcola 0:a1734fe1ec4b 189 }
vpcola 0:a1734fe1ec4b 190 #else
vpcola 0:a1734fe1ec4b 191 long elapsed(START_TIME_TYPE start_time)
vpcola 0:a1734fe1ec4b 192 {
vpcola 0:a1734fe1ec4b 193 struct timeval now, res;
vpcola 0:a1734fe1ec4b 194
vpcola 0:a1734fe1ec4b 195 gettimeofday(&now, NULL);
vpcola 0:a1734fe1ec4b 196 timersub(&now, &start_time, &res);
vpcola 0:a1734fe1ec4b 197 return (res.tv_sec)*1000 + (res.tv_usec)/1000;
vpcola 0:a1734fe1ec4b 198 }
vpcola 0:a1734fe1ec4b 199 #endif
vpcola 0:a1734fe1ec4b 200
vpcola 0:a1734fe1ec4b 201
vpcola 0:a1734fe1ec4b 202 #define assert(a, b, c, d) myassert(__FILE__, __LINE__, a, b, c, d)
vpcola 0:a1734fe1ec4b 203 #define assert1(a, b, c, d, e) myassert(__FILE__, __LINE__, a, b, c, d, e)
vpcola 0:a1734fe1ec4b 204
vpcola 0:a1734fe1ec4b 205 int tests = 0;
vpcola 0:a1734fe1ec4b 206 int failures = 0;
vpcola 0:a1734fe1ec4b 207 FILE* xml;
vpcola 0:a1734fe1ec4b 208 START_TIME_TYPE global_start_time;
vpcola 0:a1734fe1ec4b 209 char output[3000];
vpcola 0:a1734fe1ec4b 210 char* cur_output = output;
vpcola 0:a1734fe1ec4b 211
vpcola 0:a1734fe1ec4b 212
vpcola 0:a1734fe1ec4b 213 void write_test_result()
vpcola 0:a1734fe1ec4b 214 {
vpcola 0:a1734fe1ec4b 215 long duration = elapsed(global_start_time);
vpcola 0:a1734fe1ec4b 216
vpcola 0:a1734fe1ec4b 217 fprintf(xml, " time=\"%ld.%.3ld\" >\n", duration / 1000, duration % 1000);
vpcola 0:a1734fe1ec4b 218 if (cur_output != output)
vpcola 0:a1734fe1ec4b 219 {
vpcola 0:a1734fe1ec4b 220 fprintf(xml, "%s", output);
vpcola 0:a1734fe1ec4b 221 cur_output = output;
vpcola 0:a1734fe1ec4b 222 }
vpcola 0:a1734fe1ec4b 223 fprintf(xml, "</testcase>\n");
vpcola 0:a1734fe1ec4b 224 }
vpcola 0:a1734fe1ec4b 225
vpcola 0:a1734fe1ec4b 226
vpcola 0:a1734fe1ec4b 227 void myassert(char* filename, int lineno, char* description, int value, char* format, ...)
vpcola 0:a1734fe1ec4b 228 {
vpcola 0:a1734fe1ec4b 229 ++tests;
vpcola 0:a1734fe1ec4b 230 if (!value)
vpcola 0:a1734fe1ec4b 231 {
vpcola 0:a1734fe1ec4b 232 va_list args;
vpcola 0:a1734fe1ec4b 233
vpcola 0:a1734fe1ec4b 234 ++failures;
vpcola 0:a1734fe1ec4b 235 printf("Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description);
vpcola 0:a1734fe1ec4b 236
vpcola 0:a1734fe1ec4b 237 va_start(args, format);
vpcola 0:a1734fe1ec4b 238 vprintf(format, args);
vpcola 0:a1734fe1ec4b 239 va_end(args);
vpcola 0:a1734fe1ec4b 240
vpcola 0:a1734fe1ec4b 241 cur_output += sprintf(cur_output, "<failure type=\"%s\">file %s, line %d </failure>\n",
vpcola 0:a1734fe1ec4b 242 description, filename, lineno);
vpcola 0:a1734fe1ec4b 243 }
vpcola 0:a1734fe1ec4b 244 else
vpcola 0:a1734fe1ec4b 245 MyLog(LOGA_DEBUG, "Assertion succeeded, file %s, line %d, description: %s", filename, lineno, description);
vpcola 0:a1734fe1ec4b 246 }
vpcola 0:a1734fe1ec4b 247
vpcola 0:a1734fe1ec4b 248 #define min(a, b) ((a < b) ? a : b)
vpcola 0:a1734fe1ec4b 249
vpcola 0:a1734fe1ec4b 250 int checkMQTTStrings(MQTTString a, MQTTString b)
vpcola 0:a1734fe1ec4b 251 {
vpcola 0:a1734fe1ec4b 252 if (!a.lenstring.data)
vpcola 0:a1734fe1ec4b 253 {
vpcola 0:a1734fe1ec4b 254 a.lenstring.data = a.cstring;
vpcola 0:a1734fe1ec4b 255 if (a.cstring)
vpcola 0:a1734fe1ec4b 256 a.lenstring.len = strlen(a.cstring);
vpcola 0:a1734fe1ec4b 257 }
vpcola 0:a1734fe1ec4b 258 if (!b.lenstring.data)
vpcola 0:a1734fe1ec4b 259 {
vpcola 0:a1734fe1ec4b 260 b.lenstring.data = b.cstring;
vpcola 0:a1734fe1ec4b 261 if (b.cstring)
vpcola 0:a1734fe1ec4b 262 b.lenstring.len = strlen(b.cstring);
vpcola 0:a1734fe1ec4b 263 }
vpcola 0:a1734fe1ec4b 264 return memcmp(a.lenstring.data, b.lenstring.data, min(a.lenstring.len, b.lenstring.len)) == 0;
vpcola 0:a1734fe1ec4b 265 }
vpcola 0:a1734fe1ec4b 266
vpcola 0:a1734fe1ec4b 267
vpcola 0:a1734fe1ec4b 268 int checkConnectPackets(MQTTPacket_connectData* before, MQTTPacket_connectData* after)
vpcola 0:a1734fe1ec4b 269 {
vpcola 0:a1734fe1ec4b 270 int rc = 0;
vpcola 0:a1734fe1ec4b 271 int start_failures = failures;
vpcola 0:a1734fe1ec4b 272
vpcola 0:a1734fe1ec4b 273 assert("struct_ids should be the same",
vpcola 0:a1734fe1ec4b 274 memcmp(before->struct_id, after->struct_id, 4) == 0, "struct_ids were different %.4s\n", after->struct_id);
vpcola 0:a1734fe1ec4b 275
vpcola 0:a1734fe1ec4b 276 assert("struct_versions should be the same",
vpcola 0:a1734fe1ec4b 277 before->struct_version == after->struct_version, "struct_versions were different\n", rc);
vpcola 0:a1734fe1ec4b 278
vpcola 0:a1734fe1ec4b 279 assert("MQTT versions should be the same",
vpcola 0:a1734fe1ec4b 280 before->MQTTVersion == after->MQTTVersion, "MQTT versions were different\n", rc);
vpcola 0:a1734fe1ec4b 281
vpcola 0:a1734fe1ec4b 282 assert("ClientIDs should be the same",
vpcola 0:a1734fe1ec4b 283 checkMQTTStrings(before->clientID, after->clientID), "ClientIDs were different\n", rc);
vpcola 0:a1734fe1ec4b 284
vpcola 0:a1734fe1ec4b 285 assert("keepAliveIntervals should be the same",
vpcola 0:a1734fe1ec4b 286 before->keepAliveInterval == after->keepAliveInterval, "keepAliveIntervals were different %d\n", after->keepAliveInterval);
vpcola 0:a1734fe1ec4b 287
vpcola 0:a1734fe1ec4b 288 assert("cleansessions should be the same",
vpcola 0:a1734fe1ec4b 289 before->cleansession == after->cleansession, "cleansessions were different\n", rc);
vpcola 0:a1734fe1ec4b 290
vpcola 0:a1734fe1ec4b 291 assert("willFlags should be the same",
vpcola 0:a1734fe1ec4b 292 before->willFlag == after->willFlag, "willFlags were different\n", rc);
vpcola 0:a1734fe1ec4b 293
vpcola 0:a1734fe1ec4b 294 if (before->willFlag)
vpcola 0:a1734fe1ec4b 295 {
vpcola 0:a1734fe1ec4b 296 assert("will struct_ids should be the same",
vpcola 0:a1734fe1ec4b 297 memcmp(before->will.struct_id, after->will.struct_id, 4) == 0, "will struct_ids were different %.4s\n", after->struct_id);
vpcola 0:a1734fe1ec4b 298
vpcola 0:a1734fe1ec4b 299 assert("will struct_versions should be the same",
vpcola 0:a1734fe1ec4b 300 before->will.struct_version == after->will.struct_version, "will struct_versions were different\n", rc);
vpcola 0:a1734fe1ec4b 301
vpcola 0:a1734fe1ec4b 302 assert("topic names should be the same",
vpcola 0:a1734fe1ec4b 303 checkMQTTStrings(before->will.topicName, after->will.topicName), "topic names were different\n", rc);
vpcola 0:a1734fe1ec4b 304
vpcola 0:a1734fe1ec4b 305 assert("messages should be the same",
vpcola 0:a1734fe1ec4b 306 checkMQTTStrings(before->will.message, after->will.message), "messages were different\n", rc);
vpcola 0:a1734fe1ec4b 307
vpcola 0:a1734fe1ec4b 308 assert("retained flags should be the same",
vpcola 0:a1734fe1ec4b 309 before->will.retained == after->will.retained, "retained flags were different\n", rc);
vpcola 0:a1734fe1ec4b 310
vpcola 0:a1734fe1ec4b 311 assert("will qos should be the same",
vpcola 0:a1734fe1ec4b 312 before->will.qos == after->will.qos, "will qos were different\n", rc);
vpcola 0:a1734fe1ec4b 313 }
vpcola 0:a1734fe1ec4b 314
vpcola 0:a1734fe1ec4b 315 assert("usernames should be the same",
vpcola 0:a1734fe1ec4b 316 checkMQTTStrings(before->clientID, after->clientID), "usernames were different\n", rc);
vpcola 0:a1734fe1ec4b 317 assert("passwords should be the same",
vpcola 0:a1734fe1ec4b 318 checkMQTTStrings(before->password, after->password), "passwords were different\n", rc);
vpcola 0:a1734fe1ec4b 319 return failures == start_failures;
vpcola 0:a1734fe1ec4b 320 }
vpcola 0:a1734fe1ec4b 321
vpcola 0:a1734fe1ec4b 322 int test1(struct Options options)
vpcola 0:a1734fe1ec4b 323 {
vpcola 0:a1734fe1ec4b 324 MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
vpcola 0:a1734fe1ec4b 325 MQTTPacket_connectData data_after = MQTTPacket_connectData_initializer;
vpcola 0:a1734fe1ec4b 326 int rc = 0;
vpcola 0:a1734fe1ec4b 327 char buf[100];
vpcola 0:a1734fe1ec4b 328 int buflen = sizeof(buf);
vpcola 0:a1734fe1ec4b 329
vpcola 0:a1734fe1ec4b 330 fprintf(xml, "<testcase classname=\"test1\" name=\"de/serialization\"");
vpcola 0:a1734fe1ec4b 331 global_start_time = start_clock();
vpcola 0:a1734fe1ec4b 332 failures = 0;
vpcola 0:a1734fe1ec4b 333 MyLog(LOGA_INFO, "Starting test 1 - serialization of connect and back");
vpcola 0:a1734fe1ec4b 334
vpcola 0:a1734fe1ec4b 335 data.clientID.cstring = "me";
vpcola 0:a1734fe1ec4b 336
vpcola 0:a1734fe1ec4b 337 data.keepAliveInterval = 20;
vpcola 0:a1734fe1ec4b 338 data.cleansession = 1;
vpcola 0:a1734fe1ec4b 339 data.username.cstring = "testuser";
vpcola 0:a1734fe1ec4b 340 data.password.cstring = "testpassword";
vpcola 0:a1734fe1ec4b 341
vpcola 0:a1734fe1ec4b 342 data.willFlag = 1;
vpcola 0:a1734fe1ec4b 343 data.will.message.cstring = "will message";
vpcola 0:a1734fe1ec4b 344 data.will.qos = 1;
vpcola 0:a1734fe1ec4b 345 data.will.retained = 0;
vpcola 0:a1734fe1ec4b 346 data.will.topicName.cstring = "will topic";
vpcola 0:a1734fe1ec4b 347
vpcola 0:a1734fe1ec4b 348 rc = MQTTSerialize_connect(buf, buflen, &data);
vpcola 0:a1734fe1ec4b 349 assert("good rc from serialize connect", rc > 0, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 350
vpcola 0:a1734fe1ec4b 351 rc = MQTTDeserialize_connect(&data_after, buf, buflen);
vpcola 0:a1734fe1ec4b 352 assert("good rc from deserialize connect", rc == 1, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 353
vpcola 0:a1734fe1ec4b 354 /* data after should be the same as data before */
vpcola 0:a1734fe1ec4b 355 rc = checkConnectPackets(&data, &data_after);
vpcola 0:a1734fe1ec4b 356 assert("packets should be the same", rc == 1, "packets were different\n", rc);
vpcola 0:a1734fe1ec4b 357
vpcola 0:a1734fe1ec4b 358 /* exit: */
vpcola 0:a1734fe1ec4b 359 MyLog(LOGA_INFO, "TEST1: test %s. %d tests run, %d failures.",
vpcola 0:a1734fe1ec4b 360 (failures == 0) ? "passed" : "failed", tests, failures);
vpcola 0:a1734fe1ec4b 361 write_test_result();
vpcola 0:a1734fe1ec4b 362 return failures;
vpcola 0:a1734fe1ec4b 363 }
vpcola 0:a1734fe1ec4b 364
vpcola 0:a1734fe1ec4b 365
vpcola 0:a1734fe1ec4b 366 int test2(struct Options options)
vpcola 0:a1734fe1ec4b 367 {
vpcola 0:a1734fe1ec4b 368 int rc = 0;
vpcola 0:a1734fe1ec4b 369 char buf[100];
vpcola 0:a1734fe1ec4b 370 int buflen = sizeof(buf);
vpcola 0:a1734fe1ec4b 371
vpcola 0:a1734fe1ec4b 372 unsigned char dup = 0;
vpcola 0:a1734fe1ec4b 373 int qos = 2;
vpcola 0:a1734fe1ec4b 374 unsigned char retained = 0;
vpcola 0:a1734fe1ec4b 375 int msgid = 23;
vpcola 0:a1734fe1ec4b 376 MQTTString topicString = MQTTString_initializer;
vpcola 0:a1734fe1ec4b 377 char *payload = "kkhkhkjkj jkjjk jk jk ";
vpcola 0:a1734fe1ec4b 378 int payloadlen = strlen(payload);
vpcola 0:a1734fe1ec4b 379
vpcola 0:a1734fe1ec4b 380 unsigned char dup2 = 1;
vpcola 0:a1734fe1ec4b 381 int qos2 = 1;
vpcola 0:a1734fe1ec4b 382 unsigned char retained2 = 1;
vpcola 0:a1734fe1ec4b 383 int msgid2 = 3243;
vpcola 0:a1734fe1ec4b 384 MQTTString topicString2 = MQTTString_initializer;
vpcola 0:a1734fe1ec4b 385 char *payload2 = NULL;
vpcola 0:a1734fe1ec4b 386 int payloadlen2 = 0;
vpcola 0:a1734fe1ec4b 387
vpcola 0:a1734fe1ec4b 388 fprintf(xml, "<testcase classname=\"test1\" name=\"de/serialization\"");
vpcola 0:a1734fe1ec4b 389 global_start_time = start_clock();
vpcola 0:a1734fe1ec4b 390 failures = 0;
vpcola 0:a1734fe1ec4b 391 MyLog(LOGA_INFO, "Starting test 2 - serialization of publish and back");
vpcola 0:a1734fe1ec4b 392
vpcola 0:a1734fe1ec4b 393 topicString.cstring = "mytopic";
vpcola 0:a1734fe1ec4b 394 rc = MQTTSerialize_publish(buf, buflen, dup, qos, retained, msgid, topicString,
vpcola 0:a1734fe1ec4b 395 payload, payloadlen);
vpcola 0:a1734fe1ec4b 396 assert("good rc from serialize publish", rc > 0, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 397
vpcola 0:a1734fe1ec4b 398 rc = MQTTDeserialize_publish(&dup2, &qos2, &retained2, &msgid2, &topicString2,
vpcola 0:a1734fe1ec4b 399 &payload2, &payloadlen2, buf, buflen);
vpcola 0:a1734fe1ec4b 400 assert("good rc from deserialize publish", rc == 1, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 401
vpcola 0:a1734fe1ec4b 402 /* data after should be the same as data before */
vpcola 0:a1734fe1ec4b 403 assert("dups should be the same", dup == dup2, "dups were different %d\n", dup2);
vpcola 0:a1734fe1ec4b 404 assert("qoss should be the same", qos == qos2, "qoss were different %d\n", qos2);
vpcola 0:a1734fe1ec4b 405 assert("retaineds should be the same", retained == retained2, "retaineds were different %d\n", retained2);
vpcola 0:a1734fe1ec4b 406 assert("msgids should be the same", msgid == msgid2, "msgids were different %d\n", msgid2);
vpcola 0:a1734fe1ec4b 407
vpcola 0:a1734fe1ec4b 408 assert("topics should be the same",
vpcola 0:a1734fe1ec4b 409 checkMQTTStrings(topicString, topicString2), "topics were different %s\n", ""); //topicString2);
vpcola 0:a1734fe1ec4b 410
vpcola 0:a1734fe1ec4b 411 assert("payload lengths should be the same",
vpcola 0:a1734fe1ec4b 412 payloadlen == payloadlen2, "payload lengths were different %d\n", payloadlen2);
vpcola 0:a1734fe1ec4b 413
vpcola 0:a1734fe1ec4b 414 assert("payloads should be the same",
vpcola 0:a1734fe1ec4b 415 memcmp(payload, payload2, payloadlen) == 0, "payloads were different %s\n", "");
vpcola 0:a1734fe1ec4b 416
vpcola 0:a1734fe1ec4b 417 /*exit:*/
vpcola 0:a1734fe1ec4b 418 MyLog(LOGA_INFO, "TEST2: test %s. %d tests run, %d failures.",
vpcola 0:a1734fe1ec4b 419 (failures == 0) ? "passed" : "failed", tests, failures);
vpcola 0:a1734fe1ec4b 420 write_test_result();
vpcola 0:a1734fe1ec4b 421 return failures;
vpcola 0:a1734fe1ec4b 422 }
vpcola 0:a1734fe1ec4b 423
vpcola 0:a1734fe1ec4b 424
vpcola 0:a1734fe1ec4b 425
vpcola 0:a1734fe1ec4b 426 int test3(struct Options options)
vpcola 0:a1734fe1ec4b 427 {
vpcola 0:a1734fe1ec4b 428 int i = 0;
vpcola 0:a1734fe1ec4b 429 int rc = 0;
vpcola 0:a1734fe1ec4b 430 char buf[100];
vpcola 0:a1734fe1ec4b 431 int buflen = sizeof(buf);
vpcola 0:a1734fe1ec4b 432 #define TOPIC_COUNT 2
vpcola 0:a1734fe1ec4b 433
vpcola 0:a1734fe1ec4b 434 int dup = 0;
vpcola 0:a1734fe1ec4b 435 int msgid = 23;
vpcola 0:a1734fe1ec4b 436 int count = TOPIC_COUNT;
vpcola 0:a1734fe1ec4b 437 MQTTString topicStrings[TOPIC_COUNT] = { MQTTString_initializer, MQTTString_initializer };
vpcola 0:a1734fe1ec4b 438 int req_qoss[TOPIC_COUNT] = {2, 1};
vpcola 0:a1734fe1ec4b 439
vpcola 0:a1734fe1ec4b 440 int dup2 = 1;
vpcola 0:a1734fe1ec4b 441 int msgid2 = 2223;
vpcola 0:a1734fe1ec4b 442 int count2 = 0;
vpcola 0:a1734fe1ec4b 443 MQTTString topicStrings2[TOPIC_COUNT] = { MQTTString_initializer, MQTTString_initializer };
vpcola 0:a1734fe1ec4b 444 int req_qoss2[TOPIC_COUNT] = {0, 0};
vpcola 0:a1734fe1ec4b 445
vpcola 0:a1734fe1ec4b 446 fprintf(xml, "<testcase classname=\"test1\" name=\"de/serialization\"");
vpcola 0:a1734fe1ec4b 447 global_start_time = start_clock();
vpcola 0:a1734fe1ec4b 448 failures = 0;
vpcola 0:a1734fe1ec4b 449 MyLog(LOGA_INFO, "Starting test 2 - serialization of subscribe and back");
vpcola 0:a1734fe1ec4b 450
vpcola 0:a1734fe1ec4b 451 topicStrings[0].cstring = "mytopic";
vpcola 0:a1734fe1ec4b 452 topicStrings[1].cstring = "mytopic2";
vpcola 0:a1734fe1ec4b 453 rc = MQTTSerialize_subscribe(buf, buflen, dup, msgid, count, topicStrings, req_qoss);
vpcola 0:a1734fe1ec4b 454 assert("good rc from serialize subscribe", rc > 0, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 455
vpcola 0:a1734fe1ec4b 456 rc = MQTTDeserialize_subscribe(&dup2, &msgid2, 2, &count2, topicStrings2, req_qoss2, buf, buflen);
vpcola 0:a1734fe1ec4b 457 assert("good rc from deserialize subscribe", rc == 1, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 458
vpcola 0:a1734fe1ec4b 459 /* data after should be the same as data before */
vpcola 0:a1734fe1ec4b 460 assert("dups should be the same", dup == dup2, "dups were different %d\n", dup2);
vpcola 0:a1734fe1ec4b 461 assert("msgids should be the same", msgid == msgid2, "msgids were different %d\n", msgid2);
vpcola 0:a1734fe1ec4b 462
vpcola 0:a1734fe1ec4b 463 assert("count should be the same", count == count2, "counts were different %d\n", count2);
vpcola 0:a1734fe1ec4b 464
vpcola 0:a1734fe1ec4b 465 for (i = 0; i < count2; ++i)
vpcola 0:a1734fe1ec4b 466 {
vpcola 0:a1734fe1ec4b 467 assert("topics should be the same",
vpcola 0:a1734fe1ec4b 468 checkMQTTStrings(topicStrings[i], topicStrings2[i]), "topics were different %s\n", "");
vpcola 0:a1734fe1ec4b 469
vpcola 0:a1734fe1ec4b 470 assert("qoss should be the same", req_qoss[i] == req_qoss2[i], "qoss were different %d\n", req_qoss2[i]);
vpcola 0:a1734fe1ec4b 471 }
vpcola 0:a1734fe1ec4b 472
vpcola 0:a1734fe1ec4b 473 /*exit:*/
vpcola 0:a1734fe1ec4b 474 MyLog(LOGA_INFO, "TEST3: test %s. %d tests run, %d failures.",
vpcola 0:a1734fe1ec4b 475 (failures == 0) ? "passed" : "failed", tests, failures);
vpcola 0:a1734fe1ec4b 476 write_test_result();
vpcola 0:a1734fe1ec4b 477 return failures;
vpcola 0:a1734fe1ec4b 478 }
vpcola 0:a1734fe1ec4b 479
vpcola 0:a1734fe1ec4b 480
vpcola 0:a1734fe1ec4b 481 int test4(struct Options options)
vpcola 0:a1734fe1ec4b 482 {
vpcola 0:a1734fe1ec4b 483 int i = 0;
vpcola 0:a1734fe1ec4b 484 int rc = 0;
vpcola 0:a1734fe1ec4b 485 char buf[100];
vpcola 0:a1734fe1ec4b 486 int buflen = sizeof(buf);
vpcola 0:a1734fe1ec4b 487 #define TOPIC_COUNT 2
vpcola 0:a1734fe1ec4b 488
vpcola 0:a1734fe1ec4b 489 int msgid = 23;
vpcola 0:a1734fe1ec4b 490 int count = TOPIC_COUNT;
vpcola 0:a1734fe1ec4b 491 int granted_qoss[TOPIC_COUNT] = {2, 1};
vpcola 0:a1734fe1ec4b 492 ;
vpcola 0:a1734fe1ec4b 493 int msgid2 = 2223;
vpcola 0:a1734fe1ec4b 494 int count2 = 0;
vpcola 0:a1734fe1ec4b 495 int granted_qoss2[TOPIC_COUNT] = {0, 0};
vpcola 0:a1734fe1ec4b 496
vpcola 0:a1734fe1ec4b 497 fprintf(xml, "<testcase classname=\"test1\" name=\"de/serialization\"");
vpcola 0:a1734fe1ec4b 498 global_start_time = start_clock();
vpcola 0:a1734fe1ec4b 499 failures = 0;
vpcola 0:a1734fe1ec4b 500 MyLog(LOGA_INFO, "Starting test 4 - serialization of suback and back");
vpcola 0:a1734fe1ec4b 501
vpcola 0:a1734fe1ec4b 502 rc = MQTTSerialize_suback(buf, buflen, msgid, count, granted_qoss);
vpcola 0:a1734fe1ec4b 503 assert("good rc from serialize suback", rc > 0, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 504
vpcola 0:a1734fe1ec4b 505 rc = MQTTDeserialize_suback(&msgid2, 2, &count2, granted_qoss2, buf, buflen);
vpcola 0:a1734fe1ec4b 506 assert("good rc from deserialize suback", rc == 1, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 507
vpcola 0:a1734fe1ec4b 508 /* data after should be the same as data before */
vpcola 0:a1734fe1ec4b 509 assert("msgids should be the same", msgid == msgid2, "msgids were different %d\n", msgid2);
vpcola 0:a1734fe1ec4b 510
vpcola 0:a1734fe1ec4b 511 assert("count should be the same", count == count2, "counts were different %d\n", count2);
vpcola 0:a1734fe1ec4b 512
vpcola 0:a1734fe1ec4b 513 for (i = 0; i < count2; ++i)
vpcola 0:a1734fe1ec4b 514 assert("qoss should be the same", granted_qoss[i] == granted_qoss2[i], "qoss were different %d\n", granted_qoss2[i]);
vpcola 0:a1734fe1ec4b 515
vpcola 0:a1734fe1ec4b 516 /* exit: */
vpcola 0:a1734fe1ec4b 517 MyLog(LOGA_INFO, "TEST4: test %s. %d tests run, %d failures.",
vpcola 0:a1734fe1ec4b 518 (failures == 0) ? "passed" : "failed", tests, failures);
vpcola 0:a1734fe1ec4b 519 write_test_result();
vpcola 0:a1734fe1ec4b 520 return failures;
vpcola 0:a1734fe1ec4b 521 }
vpcola 0:a1734fe1ec4b 522
vpcola 0:a1734fe1ec4b 523
vpcola 0:a1734fe1ec4b 524 int test5(struct Options options)
vpcola 0:a1734fe1ec4b 525 {
vpcola 0:a1734fe1ec4b 526 int i = 0;
vpcola 0:a1734fe1ec4b 527 int rc = 0;
vpcola 0:a1734fe1ec4b 528 char buf[100];
vpcola 0:a1734fe1ec4b 529 int buflen = sizeof(buf);
vpcola 0:a1734fe1ec4b 530 #define TOPIC_COUNT 2
vpcola 0:a1734fe1ec4b 531
vpcola 0:a1734fe1ec4b 532 int dup = 0;
vpcola 0:a1734fe1ec4b 533 int msgid = 23;
vpcola 0:a1734fe1ec4b 534 int count = TOPIC_COUNT;
vpcola 0:a1734fe1ec4b 535 MQTTString topicStrings[TOPIC_COUNT] = { MQTTString_initializer, MQTTString_initializer };
vpcola 0:a1734fe1ec4b 536
vpcola 0:a1734fe1ec4b 537 int dup2 = 1;
vpcola 0:a1734fe1ec4b 538 int msgid2 = 2223;
vpcola 0:a1734fe1ec4b 539 int count2 = 0;
vpcola 0:a1734fe1ec4b 540 MQTTString topicStrings2[TOPIC_COUNT] = { MQTTString_initializer, MQTTString_initializer };
vpcola 0:a1734fe1ec4b 541
vpcola 0:a1734fe1ec4b 542 fprintf(xml, "<testcase classname=\"test1\" name=\"de/serialization\"");
vpcola 0:a1734fe1ec4b 543 global_start_time = start_clock();
vpcola 0:a1734fe1ec4b 544 failures = 0;
vpcola 0:a1734fe1ec4b 545 MyLog(LOGA_INFO, "Starting test 2 - serialization of unsubscribe and back");
vpcola 0:a1734fe1ec4b 546
vpcola 0:a1734fe1ec4b 547 topicStrings[0].cstring = "mytopic";
vpcola 0:a1734fe1ec4b 548 topicStrings[1].cstring = "mytopic2";
vpcola 0:a1734fe1ec4b 549 rc = MQTTSerialize_unsubscribe(buf, buflen, dup, msgid, count, topicStrings);
vpcola 0:a1734fe1ec4b 550 assert("good rc from serialize unsubscribe", rc > 0, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 551
vpcola 0:a1734fe1ec4b 552 rc = MQTTDeserialize_unsubscribe(&dup2, &msgid2, 2, &count2, topicStrings2, buf, buflen);
vpcola 0:a1734fe1ec4b 553 assert("good rc from deserialize unsubscribe", rc == 1, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 554
vpcola 0:a1734fe1ec4b 555 /* data after should be the same as data before */
vpcola 0:a1734fe1ec4b 556 assert("dups should be the same", dup == dup2, "dups were different %d\n", dup2);
vpcola 0:a1734fe1ec4b 557 assert("msgids should be the same", msgid == msgid2, "msgids were different %d\n", msgid2);
vpcola 0:a1734fe1ec4b 558
vpcola 0:a1734fe1ec4b 559 assert("count should be the same", count == count2, "counts were different %d\n", count2);
vpcola 0:a1734fe1ec4b 560
vpcola 0:a1734fe1ec4b 561 for (i = 0; i < count2; ++i)
vpcola 0:a1734fe1ec4b 562 assert("topics should be the same",
vpcola 0:a1734fe1ec4b 563 checkMQTTStrings(topicStrings[i], topicStrings2[i]), "topics were different %s\n", "");
vpcola 0:a1734fe1ec4b 564
vpcola 0:a1734fe1ec4b 565 /* exit: */
vpcola 0:a1734fe1ec4b 566 MyLog(LOGA_INFO, "TEST5: test %s. %d tests run, %d failures.",
vpcola 0:a1734fe1ec4b 567 (failures == 0) ? "passed" : "failed", tests, failures);
vpcola 0:a1734fe1ec4b 568 write_test_result();
vpcola 0:a1734fe1ec4b 569 return failures;
vpcola 0:a1734fe1ec4b 570 }
vpcola 0:a1734fe1ec4b 571
vpcola 0:a1734fe1ec4b 572
vpcola 0:a1734fe1ec4b 573 int test6(struct Options options)
vpcola 0:a1734fe1ec4b 574 {
vpcola 0:a1734fe1ec4b 575 int rc = 0;
vpcola 0:a1734fe1ec4b 576 char buf[100];
vpcola 0:a1734fe1ec4b 577 int buflen = sizeof(buf);
vpcola 0:a1734fe1ec4b 578
vpcola 0:a1734fe1ec4b 579 int connack_rc = 77;
vpcola 0:a1734fe1ec4b 580
vpcola 0:a1734fe1ec4b 581 int connack_rc2 = 0;
vpcola 0:a1734fe1ec4b 582
vpcola 0:a1734fe1ec4b 583 fprintf(xml, "<testcase classname=\"test1\" name=\"de/serialization\"");
vpcola 0:a1734fe1ec4b 584 global_start_time = start_clock();
vpcola 0:a1734fe1ec4b 585 failures = 0;
vpcola 0:a1734fe1ec4b 586 MyLog(LOGA_INFO, "Starting test 2 - serialization of connack and back");
vpcola 0:a1734fe1ec4b 587
vpcola 0:a1734fe1ec4b 588 rc = MQTTSerialize_connack(buf, buflen, connack_rc);
vpcola 0:a1734fe1ec4b 589 assert("good rc from serialize connack", rc > 0, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 590
vpcola 0:a1734fe1ec4b 591 rc = MQTTDeserialize_connack(&connack_rc2, buf, buflen);
vpcola 0:a1734fe1ec4b 592 assert("good rc from deserialize connack", rc == 1, "rc was %d\n", rc);
vpcola 0:a1734fe1ec4b 593
vpcola 0:a1734fe1ec4b 594 /* data after should be the same as data before */
vpcola 0:a1734fe1ec4b 595 assert("dups should be the same", connack_rc == connack_rc2, "dups were different %d\n", connack_rc2);
vpcola 0:a1734fe1ec4b 596
vpcola 0:a1734fe1ec4b 597 /* exit: */
vpcola 0:a1734fe1ec4b 598 MyLog(LOGA_INFO, "TEST6: test %s. %d tests run, %d failures.",
vpcola 0:a1734fe1ec4b 599 (failures == 0) ? "passed" : "failed", tests, failures);
vpcola 0:a1734fe1ec4b 600 write_test_result();
vpcola 0:a1734fe1ec4b 601 return failures;
vpcola 0:a1734fe1ec4b 602 }
vpcola 0:a1734fe1ec4b 603
vpcola 0:a1734fe1ec4b 604
vpcola 0:a1734fe1ec4b 605 int main(int argc, char** argv)
vpcola 0:a1734fe1ec4b 606 {
vpcola 0:a1734fe1ec4b 607 int rc = 0;
vpcola 0:a1734fe1ec4b 608 int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6};
vpcola 0:a1734fe1ec4b 609
vpcola 0:a1734fe1ec4b 610 xml = fopen("TEST-test1.xml", "w");
vpcola 0:a1734fe1ec4b 611 fprintf(xml, "<testsuite name=\"test1\" tests=\"%d\">\n", (int)(ARRAY_SIZE(tests) - 1));
vpcola 0:a1734fe1ec4b 612
vpcola 0:a1734fe1ec4b 613 getopts(argc, argv);
vpcola 0:a1734fe1ec4b 614
vpcola 0:a1734fe1ec4b 615 if (options.test_no == 0)
vpcola 0:a1734fe1ec4b 616 { /* run all the tests */
vpcola 0:a1734fe1ec4b 617 for (options.test_no = 1; options.test_no < ARRAY_SIZE(tests); ++options.test_no)
vpcola 0:a1734fe1ec4b 618 rc += tests[options.test_no](options); /* return number of failures. 0 = test succeeded */
vpcola 0:a1734fe1ec4b 619 }
vpcola 0:a1734fe1ec4b 620 else
vpcola 0:a1734fe1ec4b 621 rc = tests[options.test_no](options); /* run just the selected test */
vpcola 0:a1734fe1ec4b 622
vpcola 0:a1734fe1ec4b 623 if (rc == 0)
vpcola 0:a1734fe1ec4b 624 MyLog(LOGA_INFO, "verdict pass");
vpcola 0:a1734fe1ec4b 625 else
vpcola 0:a1734fe1ec4b 626 MyLog(LOGA_INFO, "verdict fail");
vpcola 0:a1734fe1ec4b 627
vpcola 0:a1734fe1ec4b 628 fprintf(xml, "</testsuite>\n");
vpcola 0:a1734fe1ec4b 629 fclose(xml);
vpcola 0:a1734fe1ec4b 630 return rc;
vpcola 0:a1734fe1ec4b 631 }