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