ublox-at-cellular-interface_R412M

Committer:
fahim.alavi@u-blox.com
Date:
Thu Jan 24 17:26:53 2019 +0500
Revision:
18:59ced2f6aadf
Parent:
14:e7dcf3388403
Replace macro as don't need to call connect modem stack for R412M

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobMeades 14:e7dcf3388403 1 #include "UbloxATCellularInterface.h"
RobMeades 14:e7dcf3388403 2 #include "greentea-client/test_env.h"
RobMeades 14:e7dcf3388403 3 #include "unity.h"
RobMeades 14:e7dcf3388403 4 #include "utest.h"
RobMeades 14:e7dcf3388403 5 #include "UDPSocket.h"
RobMeades 14:e7dcf3388403 6 #include "mbed_stats.h"
RobMeades 14:e7dcf3388403 7 #ifdef FEATURE_COMMON_PAL
RobMeades 14:e7dcf3388403 8 #include "mbed_trace.h"
RobMeades 14:e7dcf3388403 9 #define TRACE_GROUP "TEST"
RobMeades 14:e7dcf3388403 10 #else
RobMeades 14:e7dcf3388403 11 #define tr_debug(format, ...) debug(format "\n", ## __VA_ARGS__)
RobMeades 14:e7dcf3388403 12 #define tr_info(format, ...) debug(format "\n", ## __VA_ARGS__)
RobMeades 14:e7dcf3388403 13 #define tr_warn(format, ...) debug(format "\n", ## __VA_ARGS__)
RobMeades 14:e7dcf3388403 14 #define tr_error(format, ...) debug(format "\n", ## __VA_ARGS__)
RobMeades 14:e7dcf3388403 15 #endif
RobMeades 14:e7dcf3388403 16
RobMeades 14:e7dcf3388403 17 using namespace utest::v1;
RobMeades 14:e7dcf3388403 18
RobMeades 14:e7dcf3388403 19 // IMPORTANT!!! if you make a change to the tests here you should
RobMeades 14:e7dcf3388403 20 // check whether the same change should be made to the tests under
RobMeades 14:e7dcf3388403 21 // the PPP interface.
RobMeades 14:e7dcf3388403 22
RobMeades 14:e7dcf3388403 23 // NOTE: these test are only as reliable as UDP across the internet
RobMeades 14:e7dcf3388403 24 // over a radio link. The tests expect an NTP server to respond
RobMeades 14:e7dcf3388403 25 // to UDP packets and, if configured, an echo server to respond
RobMeades 14:e7dcf3388403 26 // to UDP packets. This simply may not happen. Please be patient.
RobMeades 14:e7dcf3388403 27
RobMeades 14:e7dcf3388403 28 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 29 // COMPILE-TIME MACROS
RobMeades 14:e7dcf3388403 30 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 31
RobMeades 14:e7dcf3388403 32 // These macros can be overridden with an mbed_app.json file and
RobMeades 14:e7dcf3388403 33 // contents of the following form:
RobMeades 14:e7dcf3388403 34 //
RobMeades 14:e7dcf3388403 35 //{
RobMeades 14:e7dcf3388403 36 // "config": {
RobMeades 14:e7dcf3388403 37 // "default-pin": {
RobMeades 14:e7dcf3388403 38 // "value": "\"1234\""
RobMeades 14:e7dcf3388403 39 // }
RobMeades 14:e7dcf3388403 40 //}
RobMeades 14:e7dcf3388403 41 //
RobMeades 14:e7dcf3388403 42 // See the template_mbed_app.txt in this directory for a fuller example.
RobMeades 14:e7dcf3388403 43
RobMeades 14:e7dcf3388403 44 // Whether we can do the mbed stats tests or not
RobMeades 14:e7dcf3388403 45 #ifndef MBED_HEAP_STATS_ENABLED
RobMeades 14:e7dcf3388403 46 # define MBED_HEAP_STATS_ENABLED 0
RobMeades 14:e7dcf3388403 47 #endif
RobMeades 14:e7dcf3388403 48
RobMeades 14:e7dcf3388403 49 // Whether debug trace is on
RobMeades 14:e7dcf3388403 50 #ifndef MBED_CONF_APP_DEBUG_ON
RobMeades 14:e7dcf3388403 51 # define MBED_CONF_APP_DEBUG_ON false
RobMeades 14:e7dcf3388403 52 #endif
RobMeades 14:e7dcf3388403 53
RobMeades 14:e7dcf3388403 54 // The credentials of the SIM in the board.
RobMeades 14:e7dcf3388403 55 #ifndef MBED_CONF_APP_DEFAULT_PIN
RobMeades 14:e7dcf3388403 56 // Note: if PIN is enabled on your SIM, or you wish to run the SIM PIN change
RobMeades 14:e7dcf3388403 57 // tests, you must define the PIN for your SIM (see note above on using
RobMeades 14:e7dcf3388403 58 // mbed_app.json to do so).
RobMeades 14:e7dcf3388403 59 # define MBED_CONF_APP_DEFAULT_PIN "0000"
RobMeades 14:e7dcf3388403 60 #endif
RobMeades 14:e7dcf3388403 61 #ifndef MBED_CONF_APP_APN
RobMeades 14:e7dcf3388403 62 # define MBED_CONF_APP_APN NULL
RobMeades 14:e7dcf3388403 63 #endif
RobMeades 14:e7dcf3388403 64 #ifndef MBED_CONF_APP_USERNAME
RobMeades 14:e7dcf3388403 65 # define MBED_CONF_APP_USERNAME NULL
RobMeades 14:e7dcf3388403 66 #endif
RobMeades 14:e7dcf3388403 67 #ifndef MBED_CONF_APP_PASSWORD
RobMeades 14:e7dcf3388403 68 # define MBED_CONF_APP_PASSWORD NULL
RobMeades 14:e7dcf3388403 69 #endif
RobMeades 14:e7dcf3388403 70
RobMeades 14:e7dcf3388403 71 // Servers and ports
RobMeades 14:e7dcf3388403 72 #ifndef MBED_CONF_APP_NTP_SERVER
RobMeades 14:e7dcf3388403 73 # define MBED_CONF_APP_NTP_SERVER "2.pool.ntp.org"
RobMeades 14:e7dcf3388403 74 #else
RobMeades 14:e7dcf3388403 75 # ifndef MBED_CONF_APP_NTP_PORT
RobMeades 14:e7dcf3388403 76 # error "MBED_CONF_APP_NTP_PORT must be defined if MBED_CONF_APP_NTP_SERVER is defined"
RobMeades 14:e7dcf3388403 77 # endif
RobMeades 14:e7dcf3388403 78 #endif
RobMeades 14:e7dcf3388403 79 #ifndef MBED_CONF_APP_NTP_PORT
RobMeades 14:e7dcf3388403 80 # define MBED_CONF_APP_NTP_PORT 123
RobMeades 14:e7dcf3388403 81 #endif
RobMeades 14:e7dcf3388403 82
RobMeades 14:e7dcf3388403 83 // UDP packet size limit for testing
RobMeades 14:e7dcf3388403 84 #ifndef MBED_CONF_APP_UDP_MAX_PACKET_SIZE
RobMeades 14:e7dcf3388403 85 # define MBED_CONF_APP_UDP_MAX_PACKET_SIZE 1024
RobMeades 14:e7dcf3388403 86 #endif
RobMeades 14:e7dcf3388403 87
RobMeades 14:e7dcf3388403 88 // The number of retries for UDP exchanges
RobMeades 14:e7dcf3388403 89 #define NUM_UDP_RETRIES 5
RobMeades 14:e7dcf3388403 90
RobMeades 14:e7dcf3388403 91 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 92 // PRIVATE VARIABLES
RobMeades 14:e7dcf3388403 93 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 94
RobMeades 14:e7dcf3388403 95 #ifdef FEATURE_COMMON_PAL
RobMeades 14:e7dcf3388403 96 // Lock for debug prints
RobMeades 14:e7dcf3388403 97 static Mutex mtx;
RobMeades 14:e7dcf3388403 98 #endif
RobMeades 14:e7dcf3388403 99
RobMeades 14:e7dcf3388403 100 // Connection flag
RobMeades 14:e7dcf3388403 101 static bool connection_has_gone_down = false;
RobMeades 14:e7dcf3388403 102
RobMeades 14:e7dcf3388403 103 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 104 // PRIVATE FUNCTIONS
RobMeades 14:e7dcf3388403 105 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 106
RobMeades 14:e7dcf3388403 107 #ifdef FEATURE_COMMON_PAL
RobMeades 14:e7dcf3388403 108 // Locks for debug prints
RobMeades 14:e7dcf3388403 109 static void lock()
RobMeades 14:e7dcf3388403 110 {
RobMeades 14:e7dcf3388403 111 mtx.lock();
RobMeades 14:e7dcf3388403 112 }
RobMeades 14:e7dcf3388403 113
RobMeades 14:e7dcf3388403 114 static void unlock()
RobMeades 14:e7dcf3388403 115 {
RobMeades 14:e7dcf3388403 116 mtx.unlock();
RobMeades 14:e7dcf3388403 117 }
RobMeades 14:e7dcf3388403 118 #endif
RobMeades 14:e7dcf3388403 119
RobMeades 14:e7dcf3388403 120 // Callback in case the connection goes down
RobMeades 14:e7dcf3388403 121 static void connection_down_cb(nsapi_error_t err)
RobMeades 14:e7dcf3388403 122 {
RobMeades 14:e7dcf3388403 123 connection_has_gone_down = true;
RobMeades 14:e7dcf3388403 124 }
RobMeades 14:e7dcf3388403 125
RobMeades 14:e7dcf3388403 126 // Get NTP time from a socket
RobMeades 14:e7dcf3388403 127 static void do_ntp_sock (UDPSocket *sock, SocketAddress ntp_address)
RobMeades 14:e7dcf3388403 128 {
RobMeades 14:e7dcf3388403 129 char ntp_values[48] = { 0 };
RobMeades 14:e7dcf3388403 130 time_t timestamp = 0;
RobMeades 14:e7dcf3388403 131 struct tm *localTime;
RobMeades 14:e7dcf3388403 132 char timeString[25];
RobMeades 14:e7dcf3388403 133 time_t TIME1970 = 2208988800U;
RobMeades 14:e7dcf3388403 134 int len;
RobMeades 14:e7dcf3388403 135 bool comms_done = false;
RobMeades 14:e7dcf3388403 136
RobMeades 14:e7dcf3388403 137 ntp_values[0] = '\x1b';
RobMeades 14:e7dcf3388403 138
RobMeades 14:e7dcf3388403 139 // Retry this a few times, don't want to fail due to a flaky link
RobMeades 14:e7dcf3388403 140 for (unsigned int x = 0; !comms_done && (x < NUM_UDP_RETRIES); x++) {
RobMeades 14:e7dcf3388403 141 sock->sendto(ntp_address, (void*) ntp_values, sizeof(ntp_values));
RobMeades 14:e7dcf3388403 142 len = sock->recvfrom(&ntp_address, (void*) ntp_values, sizeof(ntp_values));
RobMeades 14:e7dcf3388403 143 if (len > 0) {
RobMeades 14:e7dcf3388403 144 comms_done = true;
RobMeades 14:e7dcf3388403 145 }
RobMeades 14:e7dcf3388403 146 }
RobMeades 14:e7dcf3388403 147 TEST_ASSERT (comms_done);
RobMeades 14:e7dcf3388403 148
RobMeades 14:e7dcf3388403 149 tr_debug("UDP: %d byte(s) returned by NTP server.", len);
RobMeades 14:e7dcf3388403 150 if (len >= 43) {
RobMeades 14:e7dcf3388403 151 timestamp |= ((int) *(ntp_values + 40)) << 24;
RobMeades 14:e7dcf3388403 152 timestamp |= ((int) *(ntp_values + 41)) << 16;
RobMeades 14:e7dcf3388403 153 timestamp |= ((int) *(ntp_values + 42)) << 8;
RobMeades 14:e7dcf3388403 154 timestamp |= ((int) *(ntp_values + 43));
RobMeades 14:e7dcf3388403 155 timestamp -= TIME1970;
RobMeades 14:e7dcf3388403 156 srand (timestamp);
RobMeades 14:e7dcf3388403 157 tr_debug("srand() called");
RobMeades 14:e7dcf3388403 158 localTime = localtime(&timestamp);
RobMeades 14:e7dcf3388403 159 if (localTime) {
RobMeades 14:e7dcf3388403 160 if (strftime(timeString, sizeof(timeString), "%a %b %d %H:%M:%S %Y", localTime) > 0) {
RobMeades 14:e7dcf3388403 161 printf("NTP timestamp is %s.\n", timeString);
RobMeades 14:e7dcf3388403 162 }
RobMeades 14:e7dcf3388403 163 }
RobMeades 14:e7dcf3388403 164 }
RobMeades 14:e7dcf3388403 165 }
RobMeades 14:e7dcf3388403 166
RobMeades 14:e7dcf3388403 167 // Get NTP time
RobMeades 14:e7dcf3388403 168 static void do_ntp(UbloxATCellularInterface *interface)
RobMeades 14:e7dcf3388403 169 {
RobMeades 14:e7dcf3388403 170 UDPSocket sock;
RobMeades 14:e7dcf3388403 171 SocketAddress host_address;
RobMeades 14:e7dcf3388403 172
RobMeades 14:e7dcf3388403 173 TEST_ASSERT(sock.open(interface) == 0)
RobMeades 14:e7dcf3388403 174
RobMeades 14:e7dcf3388403 175 TEST_ASSERT(interface->gethostbyname(MBED_CONF_APP_NTP_SERVER, &host_address) == 0);
RobMeades 14:e7dcf3388403 176 host_address.set_port(MBED_CONF_APP_NTP_PORT);
RobMeades 14:e7dcf3388403 177
RobMeades 14:e7dcf3388403 178 tr_debug("UDP: NIST server %s address: %s on port %d.", MBED_CONF_APP_NTP_SERVER,
RobMeades 14:e7dcf3388403 179 host_address.get_ip_address(), host_address.get_port());
RobMeades 14:e7dcf3388403 180
RobMeades 14:e7dcf3388403 181 sock.set_timeout(10000);
RobMeades 14:e7dcf3388403 182
RobMeades 14:e7dcf3388403 183 do_ntp_sock(&sock, host_address);
RobMeades 14:e7dcf3388403 184
RobMeades 14:e7dcf3388403 185 sock.close();
RobMeades 14:e7dcf3388403 186 }
RobMeades 14:e7dcf3388403 187
RobMeades 14:e7dcf3388403 188 // Use a connection, checking that it is good
RobMeades 14:e7dcf3388403 189 static void use_connection(UbloxATCellularInterface *interface)
RobMeades 14:e7dcf3388403 190 {
RobMeades 14:e7dcf3388403 191 const char * ip_address = interface->get_ip_address();
RobMeades 14:e7dcf3388403 192 const char * net_mask = interface->get_netmask();
RobMeades 14:e7dcf3388403 193 const char * gateway = interface->get_gateway();
RobMeades 14:e7dcf3388403 194
RobMeades 14:e7dcf3388403 195 TEST_ASSERT(interface->is_connected());
RobMeades 14:e7dcf3388403 196
RobMeades 14:e7dcf3388403 197 TEST_ASSERT(ip_address != NULL);
RobMeades 14:e7dcf3388403 198 tr_debug ("IP address %s.", ip_address);
RobMeades 14:e7dcf3388403 199 TEST_ASSERT(net_mask == NULL);
RobMeades 14:e7dcf3388403 200 tr_debug ("Net mask %s.", net_mask);
RobMeades 14:e7dcf3388403 201 TEST_ASSERT(gateway != NULL);
RobMeades 14:e7dcf3388403 202 tr_debug ("Gateway %s.", gateway);
RobMeades 14:e7dcf3388403 203
RobMeades 14:e7dcf3388403 204 do_ntp(interface);
RobMeades 14:e7dcf3388403 205 TEST_ASSERT(!connection_has_gone_down);
RobMeades 14:e7dcf3388403 206 }
RobMeades 14:e7dcf3388403 207
RobMeades 14:e7dcf3388403 208 // Drop a connection and check that it has dropped
RobMeades 14:e7dcf3388403 209 static void drop_connection(UbloxATCellularInterface *interface)
RobMeades 14:e7dcf3388403 210 {
RobMeades 14:e7dcf3388403 211 TEST_ASSERT(interface->disconnect() == 0);
RobMeades 14:e7dcf3388403 212 TEST_ASSERT(connection_has_gone_down);
RobMeades 14:e7dcf3388403 213 connection_has_gone_down = false;
RobMeades 14:e7dcf3388403 214 TEST_ASSERT(!interface->is_connected());
RobMeades 14:e7dcf3388403 215 }
RobMeades 14:e7dcf3388403 216
RobMeades 14:e7dcf3388403 217 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 218 // TESTS
RobMeades 14:e7dcf3388403 219 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 220
RobMeades 14:e7dcf3388403 221 // Test that sleep is possible both
RobMeades 14:e7dcf3388403 222 // before and after running the driver.
RobMeades 14:e7dcf3388403 223 void test_sleep() {
RobMeades 14:e7dcf3388403 224
RobMeades 14:e7dcf3388403 225 TEST_ASSERT(sleep_manager_can_deep_sleep() == true);
RobMeades 14:e7dcf3388403 226
RobMeades 14:e7dcf3388403 227 // Create an instance of the cellular interface
RobMeades 14:e7dcf3388403 228 UbloxATCellularInterface *interface =
RobMeades 14:e7dcf3388403 229 new UbloxATCellularInterface(MDMTXD, MDMRXD,
RobMeades 14:e7dcf3388403 230 MBED_CONF_UBLOX_CELL_BAUD_RATE,
RobMeades 14:e7dcf3388403 231 MBED_CONF_APP_DEBUG_ON);
RobMeades 14:e7dcf3388403 232 interface->connection_status_cb(connection_down_cb);
RobMeades 14:e7dcf3388403 233
RobMeades 14:e7dcf3388403 234 // Use it
RobMeades 14:e7dcf3388403 235 TEST_ASSERT(interface->init(MBED_CONF_APP_DEFAULT_PIN));
RobMeades 14:e7dcf3388403 236 TEST_ASSERT(interface->connect(MBED_CONF_APP_DEFAULT_PIN, MBED_CONF_APP_APN,
RobMeades 14:e7dcf3388403 237 MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD) == 0);
RobMeades 14:e7dcf3388403 238 use_connection(interface);
RobMeades 14:e7dcf3388403 239 TEST_ASSERT(sleep_manager_can_deep_sleep() == false);
RobMeades 14:e7dcf3388403 240 drop_connection(interface);
RobMeades 14:e7dcf3388403 241
RobMeades 14:e7dcf3388403 242 // Destroy the instance
RobMeades 14:e7dcf3388403 243 delete interface;
RobMeades 14:e7dcf3388403 244
RobMeades 14:e7dcf3388403 245 TEST_ASSERT(sleep_manager_can_deep_sleep() == true);
RobMeades 14:e7dcf3388403 246 }
RobMeades 14:e7dcf3388403 247
RobMeades 14:e7dcf3388403 248 // Test that if communication with the modem
RobMeades 14:e7dcf3388403 249 // fails for some reason that sleeping is possible
RobMeades 14:e7dcf3388403 250 // afterwards (specific case found by Rostyslav Y.)
RobMeades 14:e7dcf3388403 251 void test_sleep_failed_connection() {
RobMeades 14:e7dcf3388403 252
RobMeades 14:e7dcf3388403 253 TEST_ASSERT(sleep_manager_can_deep_sleep() == true);
RobMeades 14:e7dcf3388403 254
RobMeades 14:e7dcf3388403 255 // Create a bad instance of the cellular interface
RobMeades 14:e7dcf3388403 256 UbloxATCellularInterface *interface =
RobMeades 14:e7dcf3388403 257 new UbloxATCellularInterface(MDMTXD, MDMRXD,
RobMeades 14:e7dcf3388403 258 20, /* Silly baud rate */
RobMeades 14:e7dcf3388403 259 MBED_CONF_APP_DEBUG_ON);
RobMeades 14:e7dcf3388403 260
RobMeades 14:e7dcf3388403 261 // [Fail to] use it
RobMeades 14:e7dcf3388403 262 TEST_ASSERT_FALSE(interface->init(MBED_CONF_APP_DEFAULT_PIN));
RobMeades 14:e7dcf3388403 263 TEST_ASSERT(interface->connect(MBED_CONF_APP_DEFAULT_PIN, MBED_CONF_APP_APN,
RobMeades 14:e7dcf3388403 264 MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD) != NSAPI_ERROR_OK);
RobMeades 14:e7dcf3388403 265 // Destroy the instance
RobMeades 14:e7dcf3388403 266 delete interface;
RobMeades 14:e7dcf3388403 267
RobMeades 14:e7dcf3388403 268 TEST_ASSERT(sleep_manager_can_deep_sleep() == true);
RobMeades 14:e7dcf3388403 269 }
RobMeades 14:e7dcf3388403 270
RobMeades 14:e7dcf3388403 271 #if MBED_HEAP_STATS_ENABLED
RobMeades 14:e7dcf3388403 272 // Test for memory leaks.
RobMeades 14:e7dcf3388403 273 void test_memory_leak() {
RobMeades 14:e7dcf3388403 274
RobMeades 14:e7dcf3388403 275 mbed_stats_heap_t heap_stats_start;
RobMeades 14:e7dcf3388403 276 mbed_stats_heap_t heap_stats;
RobMeades 14:e7dcf3388403 277
RobMeades 14:e7dcf3388403 278 mbed_stats_heap_get(&heap_stats_start);
RobMeades 14:e7dcf3388403 279
RobMeades 14:e7dcf3388403 280 // Create an instance of the cellular interface
RobMeades 14:e7dcf3388403 281 UbloxATCellularInterface *interface =
RobMeades 14:e7dcf3388403 282 new UbloxATCellularInterface(MDMTXD, MDMRXD,
RobMeades 14:e7dcf3388403 283 MBED_CONF_UBLOX_CELL_BAUD_RATE,
RobMeades 14:e7dcf3388403 284 MBED_CONF_APP_DEBUG_ON);
RobMeades 14:e7dcf3388403 285 interface->connection_status_cb(connection_down_cb);
RobMeades 14:e7dcf3388403 286
RobMeades 14:e7dcf3388403 287 // Use it
RobMeades 14:e7dcf3388403 288 TEST_ASSERT(interface->init(MBED_CONF_APP_DEFAULT_PIN));
RobMeades 14:e7dcf3388403 289 TEST_ASSERT(interface->connect(MBED_CONF_APP_DEFAULT_PIN, MBED_CONF_APP_APN,
RobMeades 14:e7dcf3388403 290 MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD) == 0);
RobMeades 14:e7dcf3388403 291 mbed_stats_heap_get(&heap_stats);
RobMeades 14:e7dcf3388403 292 TEST_ASSERT(heap_stats.current_size > heap_stats_start.current_size);
RobMeades 14:e7dcf3388403 293 use_connection(interface);
RobMeades 14:e7dcf3388403 294 drop_connection(interface);
RobMeades 14:e7dcf3388403 295
RobMeades 14:e7dcf3388403 296 // Destroy the instance
RobMeades 14:e7dcf3388403 297 delete interface;
RobMeades 14:e7dcf3388403 298
RobMeades 14:e7dcf3388403 299 mbed_stats_heap_get(&heap_stats);
RobMeades 14:e7dcf3388403 300 TEST_ASSERT(heap_stats.current_size == heap_stats_start.current_size);
RobMeades 14:e7dcf3388403 301 }
RobMeades 14:e7dcf3388403 302 #endif
RobMeades 14:e7dcf3388403 303
RobMeades 14:e7dcf3388403 304 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 305 // TEST ENVIRONMENT
RobMeades 14:e7dcf3388403 306 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 307
RobMeades 14:e7dcf3388403 308 // Setup the test environment
RobMeades 14:e7dcf3388403 309 utest::v1::status_t test_setup(const size_t number_of_cases) {
RobMeades 14:e7dcf3388403 310 // Setup Greentea with a timeout
RobMeades 14:e7dcf3388403 311 GREENTEA_SETUP(300, "default_auto");
RobMeades 14:e7dcf3388403 312 return verbose_test_setup_handler(number_of_cases);
RobMeades 14:e7dcf3388403 313 }
RobMeades 14:e7dcf3388403 314
RobMeades 14:e7dcf3388403 315 // IMPORTANT!!! if you make a change to the tests here you should
RobMeades 14:e7dcf3388403 316 // check whether the same change should be made to the tests under
RobMeades 14:e7dcf3388403 317 // the PPP interface.
RobMeades 14:e7dcf3388403 318
RobMeades 14:e7dcf3388403 319 // Test cases
RobMeades 14:e7dcf3388403 320 Case cases[] = {
RobMeades 14:e7dcf3388403 321 Case("Sleep test", test_sleep),
RobMeades 14:e7dcf3388403 322 Case("Sleep test with failed modem comms", test_sleep_failed_connection)
RobMeades 14:e7dcf3388403 323 #if MBED_HEAP_STATS_ENABLED
RobMeades 14:e7dcf3388403 324 , Case("Memory leak test", test_memory_leak)
RobMeades 14:e7dcf3388403 325 #endif
RobMeades 14:e7dcf3388403 326 };
RobMeades 14:e7dcf3388403 327
RobMeades 14:e7dcf3388403 328 Specification specification(test_setup, cases);
RobMeades 14:e7dcf3388403 329
RobMeades 14:e7dcf3388403 330 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 331 // MAIN
RobMeades 14:e7dcf3388403 332 // ----------------------------------------------------------------
RobMeades 14:e7dcf3388403 333
RobMeades 14:e7dcf3388403 334 int main() {
RobMeades 14:e7dcf3388403 335
RobMeades 14:e7dcf3388403 336 #ifdef FEATURE_COMMON_PAL
RobMeades 14:e7dcf3388403 337 mbed_trace_init();
RobMeades 14:e7dcf3388403 338
RobMeades 14:e7dcf3388403 339 mbed_trace_mutex_wait_function_set(lock);
RobMeades 14:e7dcf3388403 340 mbed_trace_mutex_release_function_set(unlock);
RobMeades 14:e7dcf3388403 341 #endif
RobMeades 14:e7dcf3388403 342
RobMeades 14:e7dcf3388403 343 // Run tests
RobMeades 14:e7dcf3388403 344 return !Harness::run(specification);
RobMeades 14:e7dcf3388403 345 }
RobMeades 14:e7dcf3388403 346
RobMeades 14:e7dcf3388403 347 // End Of File