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