Cellular Greentea tests fixed

pull/6496/head
Ari Parkkila 2018-03-27 15:16:37 +03:00 committed by Teppo Järvelin
parent ac9b882049
commit d7cabe2183
5 changed files with 38 additions and 24 deletions

View File

@ -12,6 +12,10 @@ This is the Github repo for Mbed cellular connectivity:
common Common and utility sources common Common and utility sources
targets Vendor specific cellular module adaptations targets Vendor specific cellular module adaptations
TESTS Cellular Greentea test
UNITTESTS Cellular unit test
## Known limitations ## Known limitations
**Please note that this is a first release of Cellular framework and is subject to further development in future.** **Please note that this is a first release of Cellular framework and is subject to further development in future.**
@ -24,7 +28,9 @@ You can find currently supported cellular modules in the `framework/targets/` fo
## Cellular configuration ## Cellular configuration
You can change cellular defaults in the `mbed_app.json` configuration file: You can change cellular defaults in the `mbed_lib.json` configuration file.
You can also override cellular defaults in the `mbed_app.json` configuration file:
"config": { "config": {
"cellular_plmn": { "cellular_plmn": {
@ -62,6 +68,14 @@ You can define the debug tracing level in the `mbed_app.json` configuration file
} }
} }
## Greentea tests
The `TESTS` folder contains Greentea tests for cellular specific classes. You need to give relevant configuration file with `--app-config` parameter, e.g.:
mbed test -n features-cellular-tests-* --app-config features\cellular\TESTS\socket\udp\template_mbed_app.json -vv
Note that Greentea tests use SIM PIN so you need to change that or your SIM card may get locked.
## Unit tests ## Unit tests
The `UNITTESTS` folder contains unit tests for cellular specific classes. Unit tests are based on the stubbing method. The `UNITTESTS` folder contains unit tests for cellular specific classes. Unit tests are based on the stubbing method.

View File

@ -213,7 +213,7 @@ static Case cases[] = {
static utest::v1::status_t test_setup(const size_t number_of_cases) static utest::v1::status_t test_setup(const size_t number_of_cases)
{ {
GREENTEA_SETUP(180, "default_auto"); GREENTEA_SETUP(10*60, "default_auto"); // network registration may take up to 180 seconds, DNS query a couple of minutes, etc.
return verbose_test_setup_handler(number_of_cases); return verbose_test_setup_handler(number_of_cases);
} }

View File

@ -1,9 +1,5 @@
{ {
"config": { "config": {
"network-interface":{
"help": "Options are ETHERNET,CELLULAR",
"value": "CELLULAR"
},
"cellular_sim_pin": { "cellular_sim_pin": {
"help": "PIN code", "help": "PIN code",
"value": "\"1234\"" "value": "\"1234\""

View File

@ -1001,9 +1001,7 @@ void ATHandler::cmd_start(const char* cmd)
} }
} }
tr_debug("AT> %s", cmd); at_debug("AT cmd %s (err %d)\n", cmd, _last_err);
if (_last_err != NSAPI_ERROR_OK) { if (_last_err != NSAPI_ERROR_OK) {
return; return;
@ -1016,7 +1014,7 @@ void ATHandler::cmd_start(const char* cmd)
void ATHandler::write_int(int32_t param) void ATHandler::write_int(int32_t param)
{ {
tr_debug("write_int: %d", param); at_debug("AT int %d\n", param);
// do common checks before sending subparameter // do common checks before sending subparameter
if (check_cmd_send() == false) { if (check_cmd_send() == false) {
return; return;
@ -1033,7 +1031,7 @@ void ATHandler::write_int(int32_t param)
void ATHandler::write_string(const char* param, bool useQuotations) void ATHandler::write_string(const char* param, bool useQuotations)
{ {
tr_debug("write_string: %s, %d", param, useQuotations); at_debug("AT str %s (with quotes %d)\n", param, useQuotations);
// do common checks before sending subparameter // do common checks before sending subparameter
if (check_cmd_send() == false) { if (check_cmd_send() == false) {
return; return;
@ -1054,6 +1052,7 @@ void ATHandler::write_string(const char* param, bool useQuotations)
void ATHandler::cmd_stop() void ATHandler::cmd_stop()
{ {
at_debug("AT stop %s (err %d)\n", _output_delimiter, _last_err);
if (_last_err != NSAPI_ERROR_OK) { if (_last_err != NSAPI_ERROR_OK) {
return; return;
} }
@ -1063,28 +1062,33 @@ void ATHandler::cmd_stop()
size_t ATHandler::write_bytes(const uint8_t *data, size_t len) size_t ATHandler::write_bytes(const uint8_t *data, size_t len)
{ {
at_debug("AT write bytes %d (err %d)\n", len, _last_err);
if (_last_err != NSAPI_ERROR_OK) { if (_last_err != NSAPI_ERROR_OK) {
return 0; return 0;
} }
ssize_t write_len = write(data, len); return write(data, len);
return write_len < 0 ? 0 : (size_t)write_len;
} }
ssize_t ATHandler::write(const void *data, size_t len) size_t ATHandler::write(const void *data, size_t len)
{ {
pollfh fhs; pollfh fhs;
fhs.fh = _fileHandle; fhs.fh = _fileHandle;
fhs.events = POLLOUT; fhs.events = POLLOUT;
ssize_t write_len = -1; size_t write_len = 0;
for (; write_len < len; ) {
int count = poll(&fhs, 1, _at_timeout); int count = poll(&fhs, 1, _at_timeout);
if (count > 0 && (fhs.revents & POLLOUT)) { if (count <= 0 || !(fhs.revents & POLLOUT)) {
write_len = _fileHandle->write(data, len); set_error(NSAPI_ERROR_DEVICE_ERROR);
} return 0;
}
if (write_len < 0 || (size_t)write_len != len) { ssize_t ret = _fileHandle->write((uint8_t*)data + write_len, len - write_len);
set_error(NSAPI_ERROR_DEVICE_ERROR); if (ret < 0) {
set_error(NSAPI_ERROR_DEVICE_ERROR);
return 0;
}
write_len += (size_t)ret;
} }
return write_len; return write_len;

View File

@ -458,7 +458,7 @@ private:
void set_3gpp_error(int err, DeviceErrorType error_type); void set_3gpp_error(int err, DeviceErrorType error_type);
bool check_cmd_send(); bool check_cmd_send();
ssize_t write(const void *data, size_t len); size_t write(const void *data, size_t len);
/** Copy content of one char buffer to another buffer and sets NULL terminator /** Copy content of one char buffer to another buffer and sets NULL terminator
* *