This class adds HTTP, FTP and CellLocate client support for u-blox modules for the C027 and C030 boards (excepting the C030 N2xx flavour) from mbed 5.5 onwards. The HTTP, FTP and CellLocate operations are all hosted on the module, minimizing RAM consumption in the mbed MCU. It also sub-classes ublox-cellular-driver-gen to bring in SMS, USSD and modem file system support if you need to use these functions at the same time as the cellular interface.
Dependencies: ublox-at-cellular-interface
Dependents: example-ublox-at-cellular-interface-ext HelloMQTT ublox_new_driver_test example-ublox-at-cellular-interface-ext ... more
TESTS/unit_tests/ftp/main.cpp@0:0b75e22c9231, 2017-06-05 (annotated)
- Committer:
- RobMeades
- Date:
- Mon Jun 05 12:58:04 2017 +0000
- Revision:
- 0:0b75e22c9231
- Child:
- 5:9fd89567f769
Initial revision.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobMeades | 0:0b75e22c9231 | 1 | #include "mbed.h" |
RobMeades | 0:0b75e22c9231 | 2 | #include "greentea-client/test_env.h" |
RobMeades | 0:0b75e22c9231 | 3 | #include "unity.h" |
RobMeades | 0:0b75e22c9231 | 4 | #include "utest.h" |
RobMeades | 0:0b75e22c9231 | 5 | #include "UbloxATCellularInterfaceExt.h" |
RobMeades | 0:0b75e22c9231 | 6 | #include "UDPSocket.h" |
RobMeades | 0:0b75e22c9231 | 7 | #include "FEATURE_COMMON_PAL/nanostack-libservice/mbed-client-libservice/common_functions.h" |
RobMeades | 0:0b75e22c9231 | 8 | #include "mbed_trace.h" |
RobMeades | 0:0b75e22c9231 | 9 | #define TRACE_GROUP "TEST" |
RobMeades | 0:0b75e22c9231 | 10 | |
RobMeades | 0:0b75e22c9231 | 11 | using namespace utest::v1; |
RobMeades | 0:0b75e22c9231 | 12 | |
RobMeades | 0:0b75e22c9231 | 13 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 14 | // COMPILE-TIME MACROS |
RobMeades | 0:0b75e22c9231 | 15 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 16 | |
RobMeades | 0:0b75e22c9231 | 17 | // These macros can be overridden with an mbed_app.json file and |
RobMeades | 0:0b75e22c9231 | 18 | // contents of the following form: |
RobMeades | 0:0b75e22c9231 | 19 | // |
RobMeades | 0:0b75e22c9231 | 20 | //{ |
RobMeades | 0:0b75e22c9231 | 21 | // "config": { |
RobMeades | 0:0b75e22c9231 | 22 | // "apn": { |
RobMeades | 0:0b75e22c9231 | 23 | // "value": "\"my_apn\"" |
RobMeades | 0:0b75e22c9231 | 24 | // }, |
RobMeades | 0:0b75e22c9231 | 25 | // "ftp-server": { |
RobMeades | 0:0b75e22c9231 | 26 | // "value": "\"test.rebex.net\"" |
RobMeades | 0:0b75e22c9231 | 27 | // }, |
RobMeades | 0:0b75e22c9231 | 28 | // "ftp-username": { |
RobMeades | 0:0b75e22c9231 | 29 | // "value": "\"demo\"" |
RobMeades | 0:0b75e22c9231 | 30 | // }, |
RobMeades | 0:0b75e22c9231 | 31 | // "ftp-password": { |
RobMeades | 0:0b75e22c9231 | 32 | // "value": "\"password\"" |
RobMeades | 0:0b75e22c9231 | 33 | // }, |
RobMeades | 0:0b75e22c9231 | 34 | // "ftp-use-passive": { |
RobMeades | 0:0b75e22c9231 | 35 | // "value": true |
RobMeades | 0:0b75e22c9231 | 36 | // }, |
RobMeades | 0:0b75e22c9231 | 37 | // "ftp-server-supports-write": { |
RobMeades | 0:0b75e22c9231 | 38 | // "value": false |
RobMeades | 0:0b75e22c9231 | 39 | // }, |
RobMeades | 0:0b75e22c9231 | 40 | // "ftp-filename": { |
RobMeades | 0:0b75e22c9231 | 41 | // "value": "\"readme.txt\"" |
RobMeades | 0:0b75e22c9231 | 42 | // }, |
RobMeades | 0:0b75e22c9231 | 43 | // "ftp-dirname": { |
RobMeades | 0:0b75e22c9231 | 44 | // "value": "\"pub\"" |
RobMeades | 0:0b75e22c9231 | 45 | // } |
RobMeades | 0:0b75e22c9231 | 46 | //} |
RobMeades | 0:0b75e22c9231 | 47 | |
RobMeades | 0:0b75e22c9231 | 48 | // The credentials of the SIM in the board. |
RobMeades | 0:0b75e22c9231 | 49 | #ifndef MBED_CONF_APP_DEFAULT_PIN |
RobMeades | 0:0b75e22c9231 | 50 | // Note: this is the PIN for the SIM with ICCID |
RobMeades | 0:0b75e22c9231 | 51 | // 8944501104169548380. |
RobMeades | 0:0b75e22c9231 | 52 | # define MBED_CONF_APP_DEFAULT_PIN "5134" |
RobMeades | 0:0b75e22c9231 | 53 | #endif |
RobMeades | 0:0b75e22c9231 | 54 | |
RobMeades | 0:0b75e22c9231 | 55 | // Network credentials. |
RobMeades | 0:0b75e22c9231 | 56 | #ifndef MBED_CONF_APP_APN |
RobMeades | 0:0b75e22c9231 | 57 | # define MBED_CONF_APP_APN NULL |
RobMeades | 0:0b75e22c9231 | 58 | #endif |
RobMeades | 0:0b75e22c9231 | 59 | #ifndef MBED_CONF_APP_USERNAME |
RobMeades | 0:0b75e22c9231 | 60 | # define MBED_CONF_APP_USERNAME NULL |
RobMeades | 0:0b75e22c9231 | 61 | #endif |
RobMeades | 0:0b75e22c9231 | 62 | #ifndef MBED_CONF_APP_PASSWORD |
RobMeades | 0:0b75e22c9231 | 63 | # define MBED_CONF_APP_PASSWORD NULL |
RobMeades | 0:0b75e22c9231 | 64 | #endif |
RobMeades | 0:0b75e22c9231 | 65 | |
RobMeades | 0:0b75e22c9231 | 66 | // FTP server name |
RobMeades | 0:0b75e22c9231 | 67 | #ifndef MBED_CONF_APP_FTP_SERVER |
RobMeades | 0:0b75e22c9231 | 68 | # error "Must define an FTP server name to run these tests" |
RobMeades | 0:0b75e22c9231 | 69 | #endif |
RobMeades | 0:0b75e22c9231 | 70 | |
RobMeades | 0:0b75e22c9231 | 71 | // User name on the FTP server |
RobMeades | 0:0b75e22c9231 | 72 | #ifndef MBED_CONF_APP_FTP_USERNAME |
RobMeades | 0:0b75e22c9231 | 73 | # define MBED_CONF_APP_FTP_SERVER_USERNAME "" |
RobMeades | 0:0b75e22c9231 | 74 | #endif |
RobMeades | 0:0b75e22c9231 | 75 | |
RobMeades | 0:0b75e22c9231 | 76 | // Password on the FTP server |
RobMeades | 0:0b75e22c9231 | 77 | #ifndef MBED_CONF_APP_FTP_PASSWORD |
RobMeades | 0:0b75e22c9231 | 78 | # define MBED_CONF_APP_FTP_SERVER_PASSWORD "" |
RobMeades | 0:0b75e22c9231 | 79 | #endif |
RobMeades | 0:0b75e22c9231 | 80 | |
RobMeades | 0:0b75e22c9231 | 81 | // Whether to use SFTP or not |
RobMeades | 0:0b75e22c9231 | 82 | #ifndef MBED_CONF_APP_FTP_SECURE |
RobMeades | 0:0b75e22c9231 | 83 | # define MBED_CONF_APP_FTP_SECURE false |
RobMeades | 0:0b75e22c9231 | 84 | #endif |
RobMeades | 0:0b75e22c9231 | 85 | |
RobMeades | 0:0b75e22c9231 | 86 | // Port to use on the remote server |
RobMeades | 0:0b75e22c9231 | 87 | #ifndef MBED_CONF_APP_FTP_SERVER_PORT |
RobMeades | 0:0b75e22c9231 | 88 | # if MBED_CONF_APP_FTP_SECURE |
RobMeades | 0:0b75e22c9231 | 89 | # define MBED_CONF_APP_FTP_SERVER_PORT 22 |
RobMeades | 0:0b75e22c9231 | 90 | # else |
RobMeades | 0:0b75e22c9231 | 91 | # define MBED_CONF_APP_FTP_SERVER_PORT 21 |
RobMeades | 0:0b75e22c9231 | 92 | # endif |
RobMeades | 0:0b75e22c9231 | 93 | #endif |
RobMeades | 0:0b75e22c9231 | 94 | |
RobMeades | 0:0b75e22c9231 | 95 | // Whether to use passive or active mode |
RobMeades | 0:0b75e22c9231 | 96 | // default to true as many servers/networks |
RobMeades | 0:0b75e22c9231 | 97 | // require this |
RobMeades | 0:0b75e22c9231 | 98 | #ifndef MBED_CONF_APP_FTP_USE_PASSIVE |
RobMeades | 0:0b75e22c9231 | 99 | # define MBED_CONF_APP_FTP_USE_PASSIVE true |
RobMeades | 0:0b75e22c9231 | 100 | #endif |
RobMeades | 0:0b75e22c9231 | 101 | |
RobMeades | 0:0b75e22c9231 | 102 | // Whether the server supports FTP write operations |
RobMeades | 0:0b75e22c9231 | 103 | #ifndef MBED_CONF_APP_FTP_SERVER_SUPPORTS_WRITE |
RobMeades | 0:0b75e22c9231 | 104 | # define MBED_CONF_APP_FTP_SERVER_SUPPORTS_WRITE false |
RobMeades | 0:0b75e22c9231 | 105 | #endif |
RobMeades | 0:0b75e22c9231 | 106 | |
RobMeades | 0:0b75e22c9231 | 107 | #if MBED_CONF_APP_FTP_SERVER_SUPPORTS_WRITE |
RobMeades | 0:0b75e22c9231 | 108 | // The name of the file to PUT, GET and then delete |
RobMeades | 0:0b75e22c9231 | 109 | # ifndef MBED_CONF_APP_FTP_FILENAME |
RobMeades | 0:0b75e22c9231 | 110 | # define MBED_CONF_APP_FTP_FILENAME "test_file_delete_me" |
RobMeades | 0:0b75e22c9231 | 111 | # endif |
RobMeades | 0:0b75e22c9231 | 112 | // The name of the directory to create, CD to and then remove |
RobMeades | 0:0b75e22c9231 | 113 | # ifndef MBED_CONF_APP_FTP_DIRNAME |
RobMeades | 0:0b75e22c9231 | 114 | # define MBED_CONF_APP_FTP_DIRNAME "test_dir_delete_me" |
RobMeades | 0:0b75e22c9231 | 115 | # endif |
RobMeades | 0:0b75e22c9231 | 116 | #else |
RobMeades | 0:0b75e22c9231 | 117 | // The name of the file to GET |
RobMeades | 0:0b75e22c9231 | 118 | # ifndef MBED_CONF_APP_FTP_FILENAME |
RobMeades | 0:0b75e22c9231 | 119 | # error "Must define the name of a file you know exists on the FTP server" |
RobMeades | 0:0b75e22c9231 | 120 | # endif |
RobMeades | 0:0b75e22c9231 | 121 | // The name of the directory to CD to |
RobMeades | 0:0b75e22c9231 | 122 | # ifndef MBED_CONF_APP_FTP_DIRNAME |
RobMeades | 0:0b75e22c9231 | 123 | # error "Must define the name of a directory you know exists on the FTP server" |
RobMeades | 0:0b75e22c9231 | 124 | # endif |
RobMeades | 0:0b75e22c9231 | 125 | #endif |
RobMeades | 0:0b75e22c9231 | 126 | |
RobMeades | 0:0b75e22c9231 | 127 | // The size of file when testing PUT/GET |
RobMeades | 0:0b75e22c9231 | 128 | #ifndef MBED_CONF_APP_FTP_FILE_SIZE |
RobMeades | 0:0b75e22c9231 | 129 | # define MBED_CONF_APP_FTP_FILE_SIZE 42000 |
RobMeades | 0:0b75e22c9231 | 130 | #endif |
RobMeades | 0:0b75e22c9231 | 131 | |
RobMeades | 0:0b75e22c9231 | 132 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 133 | // PRIVATE VARIABLES |
RobMeades | 0:0b75e22c9231 | 134 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 135 | |
RobMeades | 0:0b75e22c9231 | 136 | // Lock for debug prints |
RobMeades | 0:0b75e22c9231 | 137 | static Mutex mtx; |
RobMeades | 0:0b75e22c9231 | 138 | |
RobMeades | 0:0b75e22c9231 | 139 | // An instance of the cellular interface |
RobMeades | 0:0b75e22c9231 | 140 | static UbloxATCellularInterfaceExt *pDriver = |
RobMeades | 0:0b75e22c9231 | 141 | new UbloxATCellularInterfaceExt(MDMTXD, MDMRXD, |
RobMeades | 0:0b75e22c9231 | 142 | MBED_CONF_UBLOX_CELL_BAUD_RATE, |
RobMeades | 0:0b75e22c9231 | 143 | true); |
RobMeades | 0:0b75e22c9231 | 144 | // A buffer for general use |
RobMeades | 0:0b75e22c9231 | 145 | static char buf[MBED_CONF_APP_FTP_FILE_SIZE]; |
RobMeades | 0:0b75e22c9231 | 146 | |
RobMeades | 0:0b75e22c9231 | 147 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 148 | // PRIVATE FUNCTIONS |
RobMeades | 0:0b75e22c9231 | 149 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 150 | |
RobMeades | 0:0b75e22c9231 | 151 | // Locks for debug prints |
RobMeades | 0:0b75e22c9231 | 152 | static void lock() |
RobMeades | 0:0b75e22c9231 | 153 | { |
RobMeades | 0:0b75e22c9231 | 154 | mtx.lock(); |
RobMeades | 0:0b75e22c9231 | 155 | } |
RobMeades | 0:0b75e22c9231 | 156 | |
RobMeades | 0:0b75e22c9231 | 157 | static void unlock() |
RobMeades | 0:0b75e22c9231 | 158 | { |
RobMeades | 0:0b75e22c9231 | 159 | mtx.unlock(); |
RobMeades | 0:0b75e22c9231 | 160 | } |
RobMeades | 0:0b75e22c9231 | 161 | |
RobMeades | 0:0b75e22c9231 | 162 | |
RobMeades | 0:0b75e22c9231 | 163 | // Write a file to the module's file system with known contents |
RobMeades | 0:0b75e22c9231 | 164 | void createFile(const char * filename) { |
RobMeades | 0:0b75e22c9231 | 165 | |
RobMeades | 0:0b75e22c9231 | 166 | for (unsigned int x = 0; x < sizeof (buf); x++) { |
RobMeades | 0:0b75e22c9231 | 167 | buf[x] = (char) x; |
RobMeades | 0:0b75e22c9231 | 168 | } |
RobMeades | 0:0b75e22c9231 | 169 | |
RobMeades | 0:0b75e22c9231 | 170 | TEST_ASSERT(pDriver->writeFile(filename, buf, sizeof (buf)) == sizeof (buf)); |
RobMeades | 0:0b75e22c9231 | 171 | tr_debug("%d bytes written to file \"%s\"", sizeof (buf), filename); |
RobMeades | 0:0b75e22c9231 | 172 | } |
RobMeades | 0:0b75e22c9231 | 173 | |
RobMeades | 0:0b75e22c9231 | 174 | // Read a file back from the module's file system and check the contents |
RobMeades | 0:0b75e22c9231 | 175 | void checkFile(const char * filename) { |
RobMeades | 0:0b75e22c9231 | 176 | memset(buf, 0, sizeof (buf)); |
RobMeades | 0:0b75e22c9231 | 177 | |
RobMeades | 0:0b75e22c9231 | 178 | int x = pDriver->readFile(filename, buf, sizeof (buf)); |
RobMeades | 0:0b75e22c9231 | 179 | tr_debug ("File is %d bytes big", x); |
RobMeades | 0:0b75e22c9231 | 180 | TEST_ASSERT(x == sizeof (buf)); |
RobMeades | 0:0b75e22c9231 | 181 | |
RobMeades | 0:0b75e22c9231 | 182 | tr_debug("%d bytes read from file \"%s\"", sizeof (buf), filename); |
RobMeades | 0:0b75e22c9231 | 183 | |
RobMeades | 0:0b75e22c9231 | 184 | for (unsigned int x = 0; x < sizeof (buf); x++) { |
RobMeades | 0:0b75e22c9231 | 185 | TEST_ASSERT(buf[x] == (char) x); |
RobMeades | 0:0b75e22c9231 | 186 | } |
RobMeades | 0:0b75e22c9231 | 187 | } |
RobMeades | 0:0b75e22c9231 | 188 | |
RobMeades | 0:0b75e22c9231 | 189 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 190 | // TESTS |
RobMeades | 0:0b75e22c9231 | 191 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 192 | |
RobMeades | 0:0b75e22c9231 | 193 | // Test the setting up of parameters, connection and login to an FTP session |
RobMeades | 0:0b75e22c9231 | 194 | void test_ftp_login() { |
RobMeades | 0:0b75e22c9231 | 195 | SocketAddress address; |
RobMeades | 0:0b75e22c9231 | 196 | char portString[10]; |
RobMeades | 0:0b75e22c9231 | 197 | |
RobMeades | 0:0b75e22c9231 | 198 | sprintf(portString, "%d", MBED_CONF_APP_FTP_SERVER_PORT); |
RobMeades | 0:0b75e22c9231 | 199 | |
RobMeades | 0:0b75e22c9231 | 200 | TEST_ASSERT(pDriver->init(MBED_CONF_APP_DEFAULT_PIN)); |
RobMeades | 0:0b75e22c9231 | 201 | |
RobMeades | 0:0b75e22c9231 | 202 | // Reset parameters to default to begin with |
RobMeades | 0:0b75e22c9231 | 203 | TEST_ASSERT(pDriver->ftpResetPar()); |
RobMeades | 0:0b75e22c9231 | 204 | |
RobMeades | 0:0b75e22c9231 | 205 | // Set a timeout for FTP commands |
RobMeades | 0:0b75e22c9231 | 206 | TEST_ASSERT(pDriver->ftpSetTimeout(60000)); |
RobMeades | 0:0b75e22c9231 | 207 | |
RobMeades | 0:0b75e22c9231 | 208 | // Set up the FTP server parameters |
RobMeades | 0:0b75e22c9231 | 209 | TEST_ASSERT(pDriver->ftpSetPar(UbloxATCellularInterfaceExt::FTP_SERVER_NAME, |
RobMeades | 0:0b75e22c9231 | 210 | MBED_CONF_APP_FTP_SERVER)); |
RobMeades | 0:0b75e22c9231 | 211 | TEST_ASSERT(pDriver->ftpSetPar(UbloxATCellularInterfaceExt::FTP_SERVER_PORT, |
RobMeades | 0:0b75e22c9231 | 212 | portString)); |
RobMeades | 0:0b75e22c9231 | 213 | TEST_ASSERT(pDriver->ftpSetPar(UbloxATCellularInterfaceExt::FTP_USER_NAME, |
RobMeades | 0:0b75e22c9231 | 214 | MBED_CONF_APP_FTP_USERNAME)); |
RobMeades | 0:0b75e22c9231 | 215 | TEST_ASSERT(pDriver->ftpSetPar(UbloxATCellularInterfaceExt::FTP_PASSWORD, |
RobMeades | 0:0b75e22c9231 | 216 | MBED_CONF_APP_FTP_PASSWORD)); |
RobMeades | 0:0b75e22c9231 | 217 | #ifdef MBED_CONF_APP_FTP_ACCOUNT |
RobMeades | 0:0b75e22c9231 | 218 | TEST_ASSERT(pDriver->ftpSetPar(UbloxATCellularInterfaceExt::FTP_ACCOUNT, |
RobMeades | 0:0b75e22c9231 | 219 | MBED_CONF_APP_FTP_ACCOUNT)); |
RobMeades | 0:0b75e22c9231 | 220 | #endif |
RobMeades | 0:0b75e22c9231 | 221 | #if MBED_CONF_APP_FTP_SECURE |
RobMeades | 0:0b75e22c9231 | 222 | TEST_ASSERT(pDriver->ftpSetPar(UbloxATCellularInterfaceExt::FTP_SECURE, "1")); |
RobMeades | 0:0b75e22c9231 | 223 | #endif |
RobMeades | 0:0b75e22c9231 | 224 | #if MBED_CONF_APP_FTP_USE_PASSIVE |
RobMeades | 0:0b75e22c9231 | 225 | TEST_ASSERT(pDriver->ftpSetPar(UbloxATCellularInterfaceExt::FTP_MODE, "1")); |
RobMeades | 0:0b75e22c9231 | 226 | #endif |
RobMeades | 0:0b75e22c9231 | 227 | |
RobMeades | 0:0b75e22c9231 | 228 | // Now connect to the network |
RobMeades | 0:0b75e22c9231 | 229 | TEST_ASSERT(pDriver->connect(MBED_CONF_APP_DEFAULT_PIN, MBED_CONF_APP_APN, |
RobMeades | 0:0b75e22c9231 | 230 | MBED_CONF_APP_USERNAME, MBED_CONF_APP_PASSWORD) == 0); |
RobMeades | 0:0b75e22c9231 | 231 | |
RobMeades | 0:0b75e22c9231 | 232 | // Get the server IP address, purely to make sure it's there |
RobMeades | 0:0b75e22c9231 | 233 | TEST_ASSERT(pDriver->gethostbyname(MBED_CONF_APP_FTP_SERVER, &address) == 0); |
RobMeades | 0:0b75e22c9231 | 234 | tr_debug ("Using FTP \"%s\", which is at %s", MBED_CONF_APP_FTP_SERVER, |
RobMeades | 0:0b75e22c9231 | 235 | address.get_ip_address()); |
RobMeades | 0:0b75e22c9231 | 236 | |
RobMeades | 0:0b75e22c9231 | 237 | // Log into the FTP server |
RobMeades | 0:0b75e22c9231 | 238 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LOGIN) == NULL); |
RobMeades | 0:0b75e22c9231 | 239 | } |
RobMeades | 0:0b75e22c9231 | 240 | |
RobMeades | 0:0b75e22c9231 | 241 | // Test FTP directory listing |
RobMeades | 0:0b75e22c9231 | 242 | void test_ftp_dir() { |
RobMeades | 0:0b75e22c9231 | 243 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 244 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 245 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 246 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 247 | |
RobMeades | 0:0b75e22c9231 | 248 | // The file we will GET should appear in the directory listing |
RobMeades | 0:0b75e22c9231 | 249 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_FILENAME) > NULL); |
RobMeades | 0:0b75e22c9231 | 250 | // As should the directory name we will change to |
RobMeades | 0:0b75e22c9231 | 251 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_DIRNAME) > NULL); |
RobMeades | 0:0b75e22c9231 | 252 | } |
RobMeades | 0:0b75e22c9231 | 253 | |
RobMeades | 0:0b75e22c9231 | 254 | // Test FTP file information |
RobMeades | 0:0b75e22c9231 | 255 | void test_ftp_fileinfo() { |
RobMeades | 0:0b75e22c9231 | 256 | // Get the info |
RobMeades | 0:0b75e22c9231 | 257 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_FILE_INFO, |
RobMeades | 0:0b75e22c9231 | 258 | MBED_CONF_APP_FTP_FILENAME, NULL, 0, |
RobMeades | 0:0b75e22c9231 | 259 | buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 260 | tr_debug("File info:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 261 | |
RobMeades | 0:0b75e22c9231 | 262 | // The file info string should at least include the file name |
RobMeades | 0:0b75e22c9231 | 263 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_FILENAME) > NULL); |
RobMeades | 0:0b75e22c9231 | 264 | } |
RobMeades | 0:0b75e22c9231 | 265 | |
RobMeades | 0:0b75e22c9231 | 266 | #if MBED_CONF_APP_FTP_SERVER_SUPPORTS_WRITE |
RobMeades | 0:0b75e22c9231 | 267 | |
RobMeades | 0:0b75e22c9231 | 268 | // In case a previous test failed half way, do some cleaning up first |
RobMeades | 0:0b75e22c9231 | 269 | // Note: don't check return values as these operations will fail |
RobMeades | 0:0b75e22c9231 | 270 | // if there's nothing to clean up |
RobMeades | 0:0b75e22c9231 | 271 | void test_ftp_write_cleanup() { |
RobMeades | 0:0b75e22c9231 | 272 | pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_DELETE_FILE, |
RobMeades | 0:0b75e22c9231 | 273 | MBED_CONF_APP_FTP_FILENAME); |
RobMeades | 0:0b75e22c9231 | 274 | pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_DELETE_FILE, |
RobMeades | 0:0b75e22c9231 | 275 | MBED_CONF_APP_FTP_FILENAME "_2"); |
RobMeades | 0:0b75e22c9231 | 276 | pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_RMDIR, |
RobMeades | 0:0b75e22c9231 | 277 | MBED_CONF_APP_FTP_DIRNAME); |
RobMeades | 0:0b75e22c9231 | 278 | pDriver->delFile(MBED_CONF_APP_FTP_FILENAME); |
RobMeades | 0:0b75e22c9231 | 279 | pDriver->delFile(MBED_CONF_APP_FTP_FILENAME "_1"); |
RobMeades | 0:0b75e22c9231 | 280 | } |
RobMeades | 0:0b75e22c9231 | 281 | |
RobMeades | 0:0b75e22c9231 | 282 | // Test FTP put and then get |
RobMeades | 0:0b75e22c9231 | 283 | void test_ftp_put_get() { |
RobMeades | 0:0b75e22c9231 | 284 | // Create the file |
RobMeades | 0:0b75e22c9231 | 285 | createFile(MBED_CONF_APP_FTP_FILENAME); |
RobMeades | 0:0b75e22c9231 | 286 | |
RobMeades | 0:0b75e22c9231 | 287 | // Put the file |
RobMeades | 0:0b75e22c9231 | 288 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_PUT_FILE, |
RobMeades | 0:0b75e22c9231 | 289 | MBED_CONF_APP_FTP_FILENAME) == NULL); |
RobMeades | 0:0b75e22c9231 | 290 | |
RobMeades | 0:0b75e22c9231 | 291 | // Get the file |
RobMeades | 0:0b75e22c9231 | 292 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_GET_FILE, |
RobMeades | 0:0b75e22c9231 | 293 | MBED_CONF_APP_FTP_FILENAME, |
RobMeades | 0:0b75e22c9231 | 294 | MBED_CONF_APP_FTP_FILENAME "_1") == NULL); |
RobMeades | 0:0b75e22c9231 | 295 | |
RobMeades | 0:0b75e22c9231 | 296 | // Check that it is the same as we sent |
RobMeades | 0:0b75e22c9231 | 297 | checkFile(MBED_CONF_APP_FTP_FILENAME "_1"); |
RobMeades | 0:0b75e22c9231 | 298 | } |
RobMeades | 0:0b75e22c9231 | 299 | |
RobMeades | 0:0b75e22c9231 | 300 | // Test FTP rename file |
RobMeades | 0:0b75e22c9231 | 301 | void test_ftp_rename() { |
RobMeades | 0:0b75e22c9231 | 302 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 303 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 304 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 305 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 306 | |
RobMeades | 0:0b75e22c9231 | 307 | // The file we are renaming to should not appear |
RobMeades | 0:0b75e22c9231 | 308 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_FILENAME "_2") == NULL); |
RobMeades | 0:0b75e22c9231 | 309 | |
RobMeades | 0:0b75e22c9231 | 310 | // Rename the file |
RobMeades | 0:0b75e22c9231 | 311 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_RENAME_FILE, |
RobMeades | 0:0b75e22c9231 | 312 | MBED_CONF_APP_FTP_FILENAME, |
RobMeades | 0:0b75e22c9231 | 313 | MBED_CONF_APP_FTP_FILENAME "_2") == NULL); |
RobMeades | 0:0b75e22c9231 | 314 | |
RobMeades | 0:0b75e22c9231 | 315 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 316 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 317 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 318 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 319 | |
RobMeades | 0:0b75e22c9231 | 320 | // The new file should now exist |
RobMeades | 0:0b75e22c9231 | 321 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_FILENAME "_2") > NULL); |
RobMeades | 0:0b75e22c9231 | 322 | |
RobMeades | 0:0b75e22c9231 | 323 | } |
RobMeades | 0:0b75e22c9231 | 324 | |
RobMeades | 0:0b75e22c9231 | 325 | // Test FTP delete file |
RobMeades | 0:0b75e22c9231 | 326 | void test_ftp_delete() { |
RobMeades | 0:0b75e22c9231 | 327 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 328 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 329 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 330 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 331 | |
RobMeades | 0:0b75e22c9231 | 332 | // The file we are to delete should appear in the list |
RobMeades | 0:0b75e22c9231 | 333 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_FILENAME "_2") > NULL); |
RobMeades | 0:0b75e22c9231 | 334 | |
RobMeades | 0:0b75e22c9231 | 335 | // Delete the file |
RobMeades | 0:0b75e22c9231 | 336 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_DELETE_FILE, |
RobMeades | 0:0b75e22c9231 | 337 | MBED_CONF_APP_FTP_FILENAME "_2") == NULL); |
RobMeades | 0:0b75e22c9231 | 338 | |
RobMeades | 0:0b75e22c9231 | 339 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 340 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 341 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 342 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 343 | |
RobMeades | 0:0b75e22c9231 | 344 | // The file we deleted should no longer appear in the list |
RobMeades | 0:0b75e22c9231 | 345 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_FILENAME "_2") == NULL); |
RobMeades | 0:0b75e22c9231 | 346 | } |
RobMeades | 0:0b75e22c9231 | 347 | |
RobMeades | 0:0b75e22c9231 | 348 | // Test FTP MKDIR |
RobMeades | 0:0b75e22c9231 | 349 | void test_ftp_mkdir() { |
RobMeades | 0:0b75e22c9231 | 350 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 351 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 352 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 353 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 354 | |
RobMeades | 0:0b75e22c9231 | 355 | // The directory we are to create should not appear in the list |
RobMeades | 0:0b75e22c9231 | 356 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_DIRNAME) == NULL); |
RobMeades | 0:0b75e22c9231 | 357 | |
RobMeades | 0:0b75e22c9231 | 358 | // Create the directory |
RobMeades | 0:0b75e22c9231 | 359 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_MKDIR, |
RobMeades | 0:0b75e22c9231 | 360 | MBED_CONF_APP_FTP_DIRNAME) == NULL); |
RobMeades | 0:0b75e22c9231 | 361 | |
RobMeades | 0:0b75e22c9231 | 362 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 363 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 364 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 365 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 366 | |
RobMeades | 0:0b75e22c9231 | 367 | // The directory we created should now appear in the list |
RobMeades | 0:0b75e22c9231 | 368 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_DIRNAME) > NULL); |
RobMeades | 0:0b75e22c9231 | 369 | } |
RobMeades | 0:0b75e22c9231 | 370 | |
RobMeades | 0:0b75e22c9231 | 371 | // Test FTP RMDIR |
RobMeades | 0:0b75e22c9231 | 372 | void test_ftp_rmdir() { |
RobMeades | 0:0b75e22c9231 | 373 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 374 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 375 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 376 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 377 | |
RobMeades | 0:0b75e22c9231 | 378 | // The directory we are to remove should appear in the list |
RobMeades | 0:0b75e22c9231 | 379 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_DIRNAME) > NULL); |
RobMeades | 0:0b75e22c9231 | 380 | |
RobMeades | 0:0b75e22c9231 | 381 | // Remove the directory |
RobMeades | 0:0b75e22c9231 | 382 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_RMDIR, |
RobMeades | 0:0b75e22c9231 | 383 | MBED_CONF_APP_FTP_DIRNAME) == NULL); |
RobMeades | 0:0b75e22c9231 | 384 | |
RobMeades | 0:0b75e22c9231 | 385 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 386 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 387 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 388 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 389 | |
RobMeades | 0:0b75e22c9231 | 390 | // The directory we removed should no longer appear in the list |
RobMeades | 0:0b75e22c9231 | 391 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_DIRNAME) == NULL); |
RobMeades | 0:0b75e22c9231 | 392 | } |
RobMeades | 0:0b75e22c9231 | 393 | |
RobMeades | 0:0b75e22c9231 | 394 | #endif // MBED_CONF_APP_FTP_SERVER_SUPPORTS_WRITE |
RobMeades | 0:0b75e22c9231 | 395 | |
RobMeades | 0:0b75e22c9231 | 396 | // Test FTP get |
RobMeades | 0:0b75e22c9231 | 397 | void test_ftp_get() { |
RobMeades | 0:0b75e22c9231 | 398 | // Make sure that the 'get' filename we're going to use |
RobMeades | 0:0b75e22c9231 | 399 | // isn't already here (but don't assert on this one |
RobMeades | 0:0b75e22c9231 | 400 | // as, if the file isn't there, we will get an error) |
RobMeades | 0:0b75e22c9231 | 401 | pDriver->delFile(MBED_CONF_APP_FTP_FILENAME); |
RobMeades | 0:0b75e22c9231 | 402 | |
RobMeades | 0:0b75e22c9231 | 403 | // Get the file |
RobMeades | 0:0b75e22c9231 | 404 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_GET_FILE, |
RobMeades | 0:0b75e22c9231 | 405 | MBED_CONF_APP_FTP_FILENAME) == NULL); |
RobMeades | 0:0b75e22c9231 | 406 | |
RobMeades | 0:0b75e22c9231 | 407 | // Check that it has arrived |
RobMeades | 0:0b75e22c9231 | 408 | TEST_ASSERT(pDriver->fileSize(MBED_CONF_APP_FTP_FILENAME) > 0); |
RobMeades | 0:0b75e22c9231 | 409 | } |
RobMeades | 0:0b75e22c9231 | 410 | |
RobMeades | 0:0b75e22c9231 | 411 | // Test FTP change directory |
RobMeades | 0:0b75e22c9231 | 412 | void test_ftp_cd() { |
RobMeades | 0:0b75e22c9231 | 413 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 414 | *buf = 0; |
RobMeades | 0:0b75e22c9231 | 415 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 416 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 417 | |
RobMeades | 0:0b75e22c9231 | 418 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 419 | |
RobMeades | 0:0b75e22c9231 | 420 | // The listing should include the directory name we are going to move to |
RobMeades | 0:0b75e22c9231 | 421 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_DIRNAME) > NULL); |
RobMeades | 0:0b75e22c9231 | 422 | |
RobMeades | 0:0b75e22c9231 | 423 | // Change directories |
RobMeades | 0:0b75e22c9231 | 424 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_CD, |
RobMeades | 0:0b75e22c9231 | 425 | MBED_CONF_APP_FTP_DIRNAME) == NULL); |
RobMeades | 0:0b75e22c9231 | 426 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 427 | *buf = 0; |
RobMeades | 0:0b75e22c9231 | 428 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 429 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 430 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 431 | |
RobMeades | 0:0b75e22c9231 | 432 | // The listing should no longer include the directory name we have moved |
RobMeades | 0:0b75e22c9231 | 433 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_DIRNAME) == NULL); |
RobMeades | 0:0b75e22c9231 | 434 | |
RobMeades | 0:0b75e22c9231 | 435 | // Go back to where we were |
RobMeades | 0:0b75e22c9231 | 436 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_CD, "..") |
RobMeades | 0:0b75e22c9231 | 437 | == NULL); |
RobMeades | 0:0b75e22c9231 | 438 | |
RobMeades | 0:0b75e22c9231 | 439 | // Get a directory listing |
RobMeades | 0:0b75e22c9231 | 440 | *buf = 0; |
RobMeades | 0:0b75e22c9231 | 441 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LS, |
RobMeades | 0:0b75e22c9231 | 442 | NULL, NULL, 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 443 | tr_debug("Listing:\n%s", buf); |
RobMeades | 0:0b75e22c9231 | 444 | |
RobMeades | 0:0b75e22c9231 | 445 | // The listing should include the directory name we went to once more |
RobMeades | 0:0b75e22c9231 | 446 | TEST_ASSERT(strstr(buf, MBED_CONF_APP_FTP_DIRNAME) > NULL); |
RobMeades | 0:0b75e22c9231 | 447 | } |
RobMeades | 0:0b75e22c9231 | 448 | |
RobMeades | 0:0b75e22c9231 | 449 | #ifdef MBED_CONF_APP_FTP_FOTA_FILENAME |
RobMeades | 0:0b75e22c9231 | 450 | // Test FTP FOTA |
RobMeades | 0:0b75e22c9231 | 451 | // TODO: test not tested as I don't have a module that supports the FTP FOTA operation |
RobMeades | 0:0b75e22c9231 | 452 | void test_ftp_fota() { |
RobMeades | 0:0b75e22c9231 | 453 | *buf = 0; |
RobMeades | 0:0b75e22c9231 | 454 | // Do FOTA on a file |
RobMeades | 0:0b75e22c9231 | 455 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_FOTA_FILE, |
RobMeades | 0:0b75e22c9231 | 456 | MBED_CONF_APP_FTP_FOTA_FILENAME, NULL, |
RobMeades | 0:0b75e22c9231 | 457 | 0, buf, sizeof (buf)) == NULL); |
RobMeades | 0:0b75e22c9231 | 458 | tr_debug("MD5 sum: %s\n", buf); |
RobMeades | 0:0b75e22c9231 | 459 | |
RobMeades | 0:0b75e22c9231 | 460 | // Check that the 128 bit MD5 sum is now there |
RobMeades | 0:0b75e22c9231 | 461 | TEST_ASSERT(strlen (buf) == 32); |
RobMeades | 0:0b75e22c9231 | 462 | } |
RobMeades | 0:0b75e22c9231 | 463 | #endif |
RobMeades | 0:0b75e22c9231 | 464 | |
RobMeades | 0:0b75e22c9231 | 465 | // Test logout and disconnect from an FTP session |
RobMeades | 0:0b75e22c9231 | 466 | void test_ftp_logout() { |
RobMeades | 0:0b75e22c9231 | 467 | // Log out from the FTP server |
RobMeades | 0:0b75e22c9231 | 468 | TEST_ASSERT(pDriver->ftpCommand(UbloxATCellularInterfaceExt::FTP_LOGOUT) == NULL); |
RobMeades | 0:0b75e22c9231 | 469 | |
RobMeades | 0:0b75e22c9231 | 470 | TEST_ASSERT(pDriver->disconnect() == 0); |
RobMeades | 0:0b75e22c9231 | 471 | |
RobMeades | 0:0b75e22c9231 | 472 | // Wait for printfs to leave the building or the test result string gets messed up |
RobMeades | 0:0b75e22c9231 | 473 | wait_ms(500); |
RobMeades | 0:0b75e22c9231 | 474 | } |
RobMeades | 0:0b75e22c9231 | 475 | |
RobMeades | 0:0b75e22c9231 | 476 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 477 | // TEST ENVIRONMENT |
RobMeades | 0:0b75e22c9231 | 478 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 479 | |
RobMeades | 0:0b75e22c9231 | 480 | // Setup the test environment |
RobMeades | 0:0b75e22c9231 | 481 | utest::v1::status_t test_setup(const size_t number_of_cases) { |
RobMeades | 0:0b75e22c9231 | 482 | // Setup Greentea with a timeout |
RobMeades | 0:0b75e22c9231 | 483 | GREENTEA_SETUP(540, "default_auto"); |
RobMeades | 0:0b75e22c9231 | 484 | return verbose_test_setup_handler(number_of_cases); |
RobMeades | 0:0b75e22c9231 | 485 | } |
RobMeades | 0:0b75e22c9231 | 486 | |
RobMeades | 0:0b75e22c9231 | 487 | // Test cases |
RobMeades | 0:0b75e22c9231 | 488 | Case cases[] = { |
RobMeades | 0:0b75e22c9231 | 489 | Case("FTP log in", test_ftp_login), |
RobMeades | 0:0b75e22c9231 | 490 | #if MBED_CONF_APP_FTP_SERVER_SUPPORTS_WRITE |
RobMeades | 0:0b75e22c9231 | 491 | Case("Clean-up", test_ftp_write_cleanup), |
RobMeades | 0:0b75e22c9231 | 492 | Case("FTP put and get", test_ftp_put_get), |
RobMeades | 0:0b75e22c9231 | 493 | Case("FTP file info", test_ftp_fileinfo), |
RobMeades | 0:0b75e22c9231 | 494 | Case("FTP rename", test_ftp_rename), |
RobMeades | 0:0b75e22c9231 | 495 | Case("FTP make directory", test_ftp_mkdir), |
RobMeades | 0:0b75e22c9231 | 496 | Case("FTP directory list", test_ftp_dir), |
RobMeades | 0:0b75e22c9231 | 497 | Case("FTP delete", test_ftp_delete), |
RobMeades | 0:0b75e22c9231 | 498 | Case("FTP change directory", test_ftp_cd), |
RobMeades | 0:0b75e22c9231 | 499 | Case("FTP delete directory", test_ftp_rmdir), |
RobMeades | 0:0b75e22c9231 | 500 | #else |
RobMeades | 0:0b75e22c9231 | 501 | Case("FTP directory list", test_ftp_dir), |
RobMeades | 0:0b75e22c9231 | 502 | Case("FTP file info", test_ftp_fileinfo), |
RobMeades | 0:0b75e22c9231 | 503 | Case("FTP get", test_ftp_get), |
RobMeades | 0:0b75e22c9231 | 504 | Case("FTP change directory", test_ftp_cd), |
RobMeades | 0:0b75e22c9231 | 505 | #endif |
RobMeades | 0:0b75e22c9231 | 506 | #ifdef MBED_CONF_APP_FTP_FOTA_FILENAME |
RobMeades | 0:0b75e22c9231 | 507 | Case("FTP FOTA", test_ftp_fota), |
RobMeades | 0:0b75e22c9231 | 508 | #endif |
RobMeades | 0:0b75e22c9231 | 509 | Case("FTP log out", test_ftp_logout) |
RobMeades | 0:0b75e22c9231 | 510 | }; |
RobMeades | 0:0b75e22c9231 | 511 | |
RobMeades | 0:0b75e22c9231 | 512 | Specification specification(test_setup, cases); |
RobMeades | 0:0b75e22c9231 | 513 | |
RobMeades | 0:0b75e22c9231 | 514 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 515 | // MAIN |
RobMeades | 0:0b75e22c9231 | 516 | // ---------------------------------------------------------------- |
RobMeades | 0:0b75e22c9231 | 517 | |
RobMeades | 0:0b75e22c9231 | 518 | int main() { |
RobMeades | 0:0b75e22c9231 | 519 | mbed_trace_init(); |
RobMeades | 0:0b75e22c9231 | 520 | |
RobMeades | 0:0b75e22c9231 | 521 | mbed_trace_mutex_wait_function_set(lock); |
RobMeades | 0:0b75e22c9231 | 522 | mbed_trace_mutex_release_function_set(unlock); |
RobMeades | 0:0b75e22c9231 | 523 | |
RobMeades | 0:0b75e22c9231 | 524 | // Run tests |
RobMeades | 0:0b75e22c9231 | 525 | return !Harness::run(specification); |
RobMeades | 0:0b75e22c9231 | 526 | } |
RobMeades | 0:0b75e22c9231 | 527 | |
RobMeades | 0:0b75e22c9231 | 528 | // End Of File |
RobMeades | 0:0b75e22c9231 | 529 |