Unittests fixed + readme updated

- Unittests were broken and are now fixed
- README.md is updated to have small instructiopn how to run unittests
pull/6082/head
Antti Kauppila 2018-02-28 13:01:20 +02:00 committed by Ari Parkkila
parent 6c6223ae25
commit 020e15828d
21 changed files with 212 additions and 144 deletions

View File

@ -62,3 +62,15 @@ Debug tracing level can be defined in mbed_app.json configuration file:
"value": "TRACE_LEVEL_INFO"
}
}
## Unit tests
UNITTESTS folder contains unittests for Cellular specific classes. Unittests are based on stubbing method and some of the platform headers has been hacked under target_h/ folder to get things working.
You can run those tests locally by running ./run_tests script under UNITTESTS/ folder.
you will need at least following applications: cpputest, gcov and lcov (genhtml) for running the tests.
After run_tests script has been run you can find test results under UNITTESTS/results folder and line & function coverages under UNITTESTS/coverages folder

View File

@ -38,7 +38,7 @@ void Test_AT_CellularBase::test_AT_CellularBase_get_at_handler()
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 100);
ATHandler ah(&fh, eq, 100, ",");
AT_CellularBase at(ah);
CHECK(&ah == &at.get_at_handler());
@ -48,7 +48,7 @@ void Test_AT_CellularBase::test_AT_CellularBase_get_device_error()
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0);
ATHandler ah(&fh, eq, 0, ",");
AT_CellularBase at(ah);
ATHandler_stub::device_err_value.errCode = 8;

View File

@ -159,7 +159,7 @@ void Test_AT_CellularDevice::test_AT_CellularDevice_close_information()
dev.close_information();
ATHandler_stub::fh_value = &fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularBase_stub::handler_value = &at;
CHECK(dev.open_information(&fh1));

View File

@ -40,7 +40,7 @@ void Test_AT_CellularInformation::test_AT_CellularInformation_get_manufacturer()
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0);
ATHandler ah(&fh, eq, 0, ",");
AT_CellularInformation aci(ah);
ATHandler_stub::nsapi_error_value = 8;
@ -53,7 +53,7 @@ void Test_AT_CellularInformation::test_AT_CellularInformation_get_model()
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0);
ATHandler ah(&fh, eq, 0, ",");
AT_CellularInformation aci(ah);
ATHandler_stub::nsapi_error_value = 7;
@ -66,7 +66,7 @@ void Test_AT_CellularInformation::test_AT_CellularInformation_get_revision()
{
EventQueue eq;
FileHandle_stub fh;
ATHandler ah(&fh, eq, 0);
ATHandler ah(&fh, eq, 0, ",");
//Used heap var here to visit heap constructor
AT_CellularInformation *aci = new AT_CellularInformation(ah);

View File

@ -39,7 +39,7 @@ void Test_AT_CellularMultiplexer::test_AT_CellularMultiplexer_constructor()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularMultiplexer *cm = new AT_CellularMultiplexer(at);
delete cm;
@ -49,7 +49,7 @@ void Test_AT_CellularMultiplexer::test_AT_CellularMultiplexer_multiplexer_mode_s
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularMultiplexer cm(at);
CHECK(!cm.multiplexer_mode_start());

View File

@ -92,11 +92,6 @@ TEST(AT_CellularNetwork, test_AT_CellularNetwork_get_backoff_time)
unit->test_AT_CellularNetwork_get_backoff_time();
}
TEST(AT_CellularNetwork, test_AT_CellularNetwork_connection_status_cb)
{
unit->test_AT_CellularNetwork_connection_status_cb();
}
TEST(AT_CellularNetwork, test_AT_CellularNetwork_get_ip_address)
{
unit->test_AT_CellularNetwork_get_ip_address();

View File

@ -28,6 +28,13 @@
using namespace mbed;
using namespace events;
class my_AT_CN : public AT_CellularNetwork {
public:
my_AT_CN(ATHandler &atHandler) : AT_CellularNetwork(atHandler) {}
virtual ~my_AT_CN() {}
NetworkStack *get_stack() {return AT_CellularNetwork::get_stack();}
};
void conn_stat_cb(nsapi_error_t error)
{
@ -47,7 +54,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_constructor()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork *cn = new AT_CellularNetwork(at);
@ -58,7 +65,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_set_credentials()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CHECK(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP));
@ -70,7 +77,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_connect()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
cn.set_stack_type(IPV4V6_STACK);
@ -84,7 +91,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_disconnect()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CHECK(NSAPI_ERROR_OK == cn.disconnect());
@ -94,9 +101,9 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_stack()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
my_AT_CN cn(at);
CHECK(!cn.get_stack());
}
@ -104,7 +111,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_set_registration()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_CONNECTION_LOST;
@ -115,7 +122,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_registration_status()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CellularNetwork::RegistrationStatus stat;
@ -126,7 +133,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_set_attach()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_CONNECTION_LOST;
@ -137,7 +144,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_attach()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CellularNetwork::AttachStatus stat;
@ -149,7 +156,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_rate_control()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
int ur;
@ -162,7 +169,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_backoff_time()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
int time;
@ -170,25 +177,12 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_backoff_time()
CHECK(NSAPI_ERROR_CONNECTION_LOST == cn.get_backoff_time(time));
}
void Test_AT_CellularNetwork::test_AT_CellularNetwork_connection_status_cb()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
AT_CellularNetwork cn(at);
cn.connection_status_cb(conn_stat_cb);
if(ATHandler_stub::callback){
ATHandler_stub::callback();
}
}
void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_ip_address()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CHECK(!cn.get_ip_address());
@ -198,7 +192,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_set_access_technology()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CHECK(NSAPI_ERROR_UNSUPPORTED == cn.set_access_technology(CellularNetwork::operator_t::RAT_UNKNOWN));
@ -209,7 +203,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_scan_plmn()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
int c;
@ -222,7 +216,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_set_ciot_optimization_conf
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_CONNECTION_LOST;
@ -233,7 +227,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_ciot_optimization_conf
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CellularNetwork::Supported_UE_Opt sup;
@ -246,7 +240,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_set_stack_type()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CHECK(NSAPI_ERROR_PARAMETER == cn.set_stack_type(IPV4_STACK));
@ -258,7 +252,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_stack_type()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CHECK(DEFAULT_STACK == cn.get_stack_type());
@ -268,7 +262,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_pdpcontext_params()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
CellularNetwork::pdpContextList_t list;
@ -280,7 +274,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_extended_signal_qualit
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
int rx,be,rs,ec,rsrq,rsrp;
@ -294,7 +288,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_signal_quality()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
int rs,ber;
@ -308,7 +302,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_cell_id()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
int id;
@ -320,10 +314,10 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_3gpp_error()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
ATHandler_stub::uint8_value = 8;
ATHandler_stub::int_value = 8;
CHECK(8 == cn.get_3gpp_error());
}
@ -331,7 +325,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_operator_params()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularNetwork cn(at);
int format;

View File

@ -46,8 +46,6 @@ public:
void test_AT_CellularNetwork_get_backoff_time();
void test_AT_CellularNetwork_connection_status_cb();
void test_AT_CellularNetwork_get_ip_address();
void test_AT_CellularNetwork_set_access_technology();

View File

@ -40,7 +40,7 @@ void Test_AT_CellularPower::test_AT_CellularPower_constructor()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularPower *pow = new AT_CellularPower(at);
@ -51,7 +51,7 @@ void Test_AT_CellularPower::test_AT_CellularPower_on()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularPower pow(at);
CHECK(NSAPI_ERROR_UNSUPPORTED == pow.on())
@ -61,7 +61,7 @@ void Test_AT_CellularPower::test_AT_CellularPower_off()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularPower pow(at);
CHECK(NSAPI_ERROR_UNSUPPORTED == pow.off())
@ -71,7 +71,7 @@ void Test_AT_CellularPower::test_AT_CellularPower_set_at_mode()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularPower pow(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -82,7 +82,7 @@ void Test_AT_CellularPower::test_AT_CellularPower_set_power_level()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularPower pow(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -93,7 +93,7 @@ void Test_AT_CellularPower::test_AT_CellularPower_reset()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularPower pow(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -104,7 +104,7 @@ void Test_AT_CellularPower::test_AT_CellularPower_opt_power_save_mode()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularPower pow(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -130,7 +130,7 @@ void Test_AT_CellularPower::test_AT_CellularPower_opt_receive_period()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularPower pow(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;

View File

@ -43,7 +43,7 @@ void Test_AT_CellularSIM::test_AT_CellularSIM_constructor()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSIM *sim = new AT_CellularSIM(at);
@ -54,7 +54,7 @@ void Test_AT_CellularSIM::test_AT_CellularSIM_set_pin()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSIM sim(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -71,7 +71,7 @@ void Test_AT_CellularSIM::test_AT_CellularSIM_change_pin()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSIM sim(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -82,7 +82,7 @@ void Test_AT_CellularSIM::test_AT_CellularSIM_set_pin_query()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSIM sim(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -96,7 +96,7 @@ void Test_AT_CellularSIM::test_AT_CellularSIM_get_sim_state()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSIM sim(at);
CellularSIM::SimState state;

View File

@ -42,7 +42,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_constructor()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS *sms = new AT_CellularSMS(at);
@ -53,7 +53,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_initialize()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -65,7 +65,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_send_sms()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
CHECK(NSAPI_ERROR_PARAMETER == sms.send_sms(NULL, "2", 1));
@ -107,7 +107,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_get_sms()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
char buf[16];
@ -139,7 +139,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_set_sms_callback()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
sms.set_sms_callback(NULL);
@ -150,7 +150,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_set_cpms()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -162,7 +162,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_set_csca()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -174,7 +174,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_set_cscs()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -186,7 +186,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_delete_all_messages()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_AUTH_FAILURE;
@ -198,7 +198,7 @@ void Test_AT_CellularSMS::test_AT_CellularSMS_set_extra_sim_wait_time()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
AT_CellularSMS sms(at);
sms.set_extra_sim_wait_time(56);

View File

@ -59,6 +59,33 @@ public:
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
void *buffer, nsapi_size_t size) {return NSAPI_ERROR_OK;}
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto) {return AT_CellularStack::socket_open(handle, proto);}
virtual nsapi_error_t socket_close(nsapi_socket_t handle) {return AT_CellularStack::socket_close(handle);}
virtual nsapi_error_t socket_bind(nsapi_socket_t handle, const SocketAddress &address) {return AT_CellularStack::socket_bind(handle, address);}
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog) {return AT_CellularStack::socket_listen(handle, backlog);}
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address) {return AT_CellularStack::socket_connect(handle, address);}
virtual nsapi_error_t socket_accept(nsapi_socket_t server,
nsapi_socket_t *handle, SocketAddress *address=0) {return AT_CellularStack::socket_accept(server, handle, address);}
virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle,
const void *data, nsapi_size_t size) {return AT_CellularStack::socket_send(handle, data, size);}
virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle,
void *data, nsapi_size_t size) {return AT_CellularStack::socket_recv(handle, data, size);}
virtual nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle, const SocketAddress &address,
const void *data, nsapi_size_t size) {return AT_CellularStack::socket_sendto(handle, address, data, size);}
virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address,
void *buffer, nsapi_size_t size) {return AT_CellularStack::socket_recvfrom(handle, address, buffer, size);}
virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data) {return AT_CellularStack::socket_attach(handle, callback, data);}
};
Test_AT_CellularStack::Test_AT_CellularStack()
@ -76,7 +103,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_constructor()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack *st = new MyStack(at, 0, IPV4_STACK);
@ -87,7 +114,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_get_ip_address()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
CHECK(0 == strlen(st.get_ip_address()));
@ -108,7 +135,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_open()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
st.bool_value = false;
@ -130,7 +157,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_close()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t soc = NULL;
@ -155,7 +182,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_bind()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t sock;
@ -170,7 +197,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_listen()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t sock;
@ -181,7 +208,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_connect()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
SocketAddress addr;
@ -195,7 +222,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_accept()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
nsapi_socket_t sock;
@ -206,7 +233,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_send()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
CHECK(NSAPI_ERROR_DEVICE_ERROR == st.socket_send(NULL, "addr", 4));
@ -226,7 +253,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_sendto()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
@ -250,7 +277,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_recv()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
char table[4];
@ -261,7 +288,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_recvfrom()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);
char table[4];
@ -285,7 +312,7 @@ void Test_AT_CellularStack::test_AT_CellularStack_socket_attach()
{
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
MyStack st(at, 0, IPV6_STACK);

View File

@ -48,7 +48,7 @@ void Test_ATHandler::test_ATHandler_constructor()
EventQueue que;
FileHandle_stub fh1;
ATHandler *at = new ATHandler(&fh1, que, 0);
ATHandler *at = new ATHandler(&fh1, que, 0, ",");
delete at;
@ -62,7 +62,7 @@ void Test_ATHandler::test_ATHandler_get_file_handle()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
CHECK_EQUAL(&fh1, at.get_file_handle());
}
@ -71,7 +71,7 @@ void Test_ATHandler::test_ATHandler_set_file_handle()
EventQueue que;
FileHandle_stub fh1, fh2;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.set_file_handle(&fh2);
}
@ -81,7 +81,7 @@ void Test_ATHandler::test_ATHandler_lock()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.lock();
}
@ -91,7 +91,7 @@ void Test_ATHandler::test_ATHandler_unlock()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
filehandle_stub_short_value_counter = 1;
fh1.short_value = POLLIN;
at.unlock();
@ -102,7 +102,7 @@ void Test_ATHandler::test_ATHandler_unlock_return_error()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
CHECK(NSAPI_ERROR_OK == at.unlock_return_error());
}
@ -111,7 +111,7 @@ void Test_ATHandler::test_ATHandler_set_urc_handler()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
const char ch[] = "testtesttesttest";
at.set_urc_handler(ch, &urc_callback);
}
@ -121,7 +121,7 @@ void Test_ATHandler::test_ATHandler_get_last_error()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
CHECK(NSAPI_ERROR_OK == at.get_last_error());
}
@ -130,7 +130,7 @@ void Test_ATHandler::test_ATHandler_get_last_device_error()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
CHECK(0 == at.get_last_device_error().errCode);
}
@ -139,7 +139,7 @@ void Test_ATHandler::test_ATHandler_inc_ref_count()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.inc_ref_count();
}
@ -148,7 +148,7 @@ void Test_ATHandler::test_ATHandler_dec_ref_count()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.dec_ref_count();
}
@ -157,7 +157,7 @@ void Test_ATHandler::test_ATHandler_get_ref_count()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
CHECK(1 == at.get_ref_count());
at.inc_ref_count();
@ -176,7 +176,7 @@ void Test_ATHandler::test_ATHandler_set_at_timeout()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.set_at_timeout(8);
at.set_at_timeout(80, true);
@ -187,7 +187,7 @@ void Test_ATHandler::test_ATHandler_restore_at_timeout()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.set_at_timeout(80, true);
at.set_at_timeout(800);
at.restore_at_timeout();
@ -198,7 +198,7 @@ void Test_ATHandler::test_ATHandler_clear_error()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.clear_error();
}
@ -207,7 +207,7 @@ void Test_ATHandler::test_ATHandler_process_oob()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
filehandle_stub_short_value_counter = 1;
fh1.short_value = POLLIN;
at.set_urc_handler("s", &urc_callback);
@ -264,7 +264,7 @@ void Test_ATHandler::test_ATHandler_set_filehandle_sigio()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.set_filehandle_sigio();
}
@ -273,7 +273,7 @@ void Test_ATHandler::test_ATHandler_flush()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
filehandle_stub_short_value_counter = 1;
fh1.short_value = POLLIN;
at.flush();
@ -284,7 +284,7 @@ void Test_ATHandler::test_ATHandler_cmd_start()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
mbed_poll_stub::revents_value = POLLOUT;
mbed_poll_stub::int_value = 1;
fh1.size_value = 1;
@ -302,7 +302,7 @@ void Test_ATHandler::test_ATHandler_write_int()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.write_int(4);
at.clear_error();
@ -324,7 +324,7 @@ void Test_ATHandler::test_ATHandler_write_string()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.write_string("help");
CHECK(NSAPI_ERROR_DEVICE_ERROR == at.get_last_error());
@ -356,7 +356,7 @@ void Test_ATHandler::test_ATHandler_cmd_stop()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.cmd_stop();
at.write_string("help", true);
@ -370,7 +370,7 @@ void Test_ATHandler::test_ATHandler_write_bytes()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
uint8_t data[] = "data";
at.write_bytes(data, 4);
@ -383,7 +383,7 @@ void Test_ATHandler::test_ATHandler_set_stop_tag()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.set_stop_tag("s");
}
@ -392,7 +392,7 @@ void Test_ATHandler::test_ATHandler_set_delimiter()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.set_delimiter('+');
}
@ -401,7 +401,7 @@ void Test_ATHandler::test_ATHandler_skip_param()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.skip_param();
char table[] = "ssssssssssssssssssssssssssssOK\r\n\0";
@ -437,7 +437,7 @@ void Test_ATHandler::test_ATHandler_skip_param()
filehandle_stub_table_pos = 0;
//Need to create a new instance because stop tag already found
ATHandler at2(&fh1, que, 0);
ATHandler at2(&fh1, que, 0, ",");
at2.flush();
at2.clear_error();
at2.resp_start();
@ -467,7 +467,7 @@ void Test_ATHandler::test_ATHandler_read_bytes()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
uint8_t buf[5];
CHECK(-1 == at.read_bytes(buf, 25));
@ -486,7 +486,7 @@ void Test_ATHandler::test_ATHandler_read_string()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
char table[] = "\"s,\"OK\r\n\0";
filehandle_stub_table = table;
@ -546,7 +546,7 @@ void Test_ATHandler::test_ATHandler_read_int()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
int32_t ret= at.read_int();
CHECK(-1 == ret);
@ -583,7 +583,7 @@ void Test_ATHandler::test_ATHandler_resp_start()
filehandle_stub_table = NULL;
filehandle_stub_table_pos = 0;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.resp_start();
at.resp_start();
@ -648,7 +648,7 @@ void Test_ATHandler::test_ATHandler_resp_stop()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
char table[] = "21 OK\r\n\0";
filehandle_stub_table = table;
@ -685,7 +685,7 @@ void Test_ATHandler::test_ATHandler_info_resp()
filehandle_stub_table = NULL;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
CHECK(at.info_resp());
at.resp_start();
@ -720,7 +720,7 @@ void Test_ATHandler::test_ATHandler_info_elem()
filehandle_stub_table = table;
filehandle_stub_table_pos = 0;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
CHECK(!at.info_elem(char(79)));
char table2[] = "21 OK\r\n\0";
@ -748,7 +748,7 @@ void Test_ATHandler::test_ATHandler_consume_to_stop_tag()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
CHECK(at.consume_to_stop_tag());
}
@ -757,7 +757,7 @@ void Test_ATHandler::test_ATHandler_enable_debug()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
ATHandler at(&fh1, que, 0, ",");
at.enable_debug(true);
at.enable_debug(false);
@ -768,6 +768,6 @@ void Test_ATHandler::test_ATHandler_get_3gpp_error()
EventQueue que;
FileHandle_stub fh1;
ATHandler at(&fh1, que, 0);
uint8_t ret = at.get_3gpp_error();
ATHandler at(&fh1, que, 0, ",");
int ret = at.get_3gpp_error();
}

View File

@ -152,13 +152,17 @@ void ATHandler::set_delimiter(char delimiter)
{
}
void ATHandler::set_default_delimiter()
{
}
void ATHandler::set_stop_tag(const char *stop_tag_seq)
{
}
uint8_t ATHandler::get_3gpp_error()
int ATHandler::get_3gpp_error()
{
return ATHandler_stub::uint8_value;
return ATHandler_stub::int_value;
}
void ATHandler::resp_start(const char *prefix, bool stop)
@ -200,7 +204,7 @@ void ATHandler::write_string(const char* param, bool useQuotations)
{
}
size_t ATHandler::write_bytes(uint8_t* param, size_t len)
size_t ATHandler::write_bytes(const uint8_t* param, size_t len)
{
if (ATHandler_stub::return_given_size) {
return len;

View File

@ -66,24 +66,34 @@ nsapi_error_t AT_CellularNetwork::disconnect()
return NSAPI_ERROR_OK;
}
void AT_CellularNetwork::connection_status_cb(Callback<void(nsapi_error_t)> cb)
void AT_CellularNetwork::attach(Callback<void(nsapi_event_t, intptr_t)> status_cb)
{
}
nsapi_connection_status_t AT_CellularNetwork::get_connection_status() const
{
return NSAPI_STATUS_LOCAL_UP;
}
nsapi_error_t AT_CellularNetwork::set_blocking(bool blocking)
{
return NSAPI_ERROR_OK;;
}
nsapi_error_t AT_CellularNetwork::set_context_to_be_activated()
{
return NSAPI_ERROR_OK;
}
bool AT_CellularNetwork::set_new_context(nsapi_ip_stack_t stack, int cid)
{
return false;
}
//bool AT_CellularNetwork::set_new_context(nsapi_ip_stack_t stack, int cid)
//{
// return false;
//}
bool AT_CellularNetwork::get_context(nsapi_ip_stack_t requested_stack)
{
return false;
}
//bool AT_CellularNetwork::get_context(nsapi_ip_stack_t requested_stack)
//{
// return false;
//}
nsapi_ip_stack_t AT_CellularNetwork::string_to_stack_type(const char* pdp_type)
{
@ -216,7 +226,7 @@ nsapi_error_t AT_CellularNetwork::get_operator_params(int &format, operator_t &o
return NSAPI_ERROR_OK;
}
uint8_t AT_CellularNetwork::get_3gpp_error()
int AT_CellularNetwork::get_3gpp_error()
{
return 0;
}

View File

@ -48,3 +48,7 @@ nsapi_error_t AT_CellularSIM::set_pin_query(const char *sim_pin, bool query_pin)
return NSAPI_ERROR_OK;
}
nsapi_error_t AT_CellularSIM::get_imsi(char* imsi)
{
return NSAPI_ERROR_OK;
}

View File

@ -80,7 +80,8 @@ void AT_CellularSMS::set_extra_sim_wait_time(int sim_wait_time)
{
}
char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message, uint8_t message_length, uint8_t msg_parts, uint8_t msg_part_number)
char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message, uint8_t message_length, uint8_t msg_parts,
uint8_t msg_part_number, uint8_t& header_size)
{
return NULL;
}
@ -147,12 +148,12 @@ nsapi_size_or_error_t AT_CellularSMS::get_data_from_pdu(const char* pdu, sms_inf
}
// read params from User DEfined Header
int AT_CellularSMS::read_udh_from_pdu(const char* pdu, sms_info_t *info, int &part_number, int &parts, int &padding_bits)
int AT_CellularSMS::read_udh_from_pdu(const char* pdu, sms_info_t *info, int &part_number, int &padding_bits)
{
return 0;
}
nsapi_size_or_error_t AT_CellularSMS::read_pdu_payload(const char* pdu, int scheme, char *msg, int padding_bits, bool last_part)
nsapi_size_or_error_t AT_CellularSMS::read_pdu_payload(const char* pdu, int msg_len, int scheme, char *msg, int padding_bits)
{
return NSAPI_ERROR_OK;
}

View File

@ -62,3 +62,18 @@ nsapi_error_t NetworkInterface::add_dns_server(const SocketAddress &address)
return NSAPI_ERROR_UNSUPPORTED;
}
void NetworkInterface::attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
{
}
nsapi_connection_status_t NetworkInterface::get_connection_status() const
{
return NSAPI_STATUS_LOCAL_UP;
}
nsapi_error_t NetworkInterface::set_blocking(bool blocking)
{
return NSAPI_ERROR_UNSUPPORTED;
}

View File

@ -30,6 +30,10 @@ ssize_t MuxDataService::read(void *buffer, size_t size)
return 0;
}
short MuxDataService::poll(short events) const
{
return 0;
}
off_t MuxDataService::seek(off_t offset, int whence)
{

View File

@ -14,3 +14,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define EAGAIN 11

View File

@ -14,3 +14,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define EAGAIN 11