From 983425e4fc3d62ba9396fcc46f41d09d67232086 Mon Sep 17 00:00:00 2001 From: Mirela Chirica Date: Mon, 24 Sep 2018 15:15:18 +0300 Subject: [PATCH] Cellular: Fix cellular network unit test --- .../AT/at_cellularnetwork/at_cellularnetworktest.cpp | 5 ++--- features/cellular/framework/API/CellularNetwork.h | 3 +++ features/cellular/framework/AT/AT_CellularNetwork.cpp | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp b/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp index 4ff0837b16..e54a8d2844 100644 --- a/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp +++ b/UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp @@ -227,9 +227,8 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_activate_context) ATHandler_stub::resp_stop_success_count = 2; ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK; ATHandler_stub::bool_value = false; - EXPECT_TRUE(NSAPI_ERROR_OK == cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd")); - EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == cn.activate_context()); - + EXPECT_TRUE(NSAPI_ERROR_OK == my_cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd")); + EXPECT_TRUE(NSAPI_ERROR_AUTH_FAILURE == my_cn.activate_context()); // get_context return true and new context created, also do_user_authentication called with success. // Now there is stack. diff --git a/features/cellular/framework/API/CellularNetwork.h b/features/cellular/framework/API/CellularNetwork.h index 6600c17167..609ccd844a 100644 --- a/features/cellular/framework/API/CellularNetwork.h +++ b/features/cellular/framework/API/CellularNetwork.h @@ -150,6 +150,9 @@ public: op_status = Unknown; op_rat = RAT_UNKNOWN; next = NULL; + op_long[0] = NULL; + op_short[0] = NULL; + op_num[0] = NULL; } }; diff --git a/features/cellular/framework/AT/AT_CellularNetwork.cpp b/features/cellular/framework/AT/AT_CellularNetwork.cpp index 09aaa15877..4c6a960c56 100644 --- a/features/cellular/framework/AT/AT_CellularNetwork.cpp +++ b/features/cellular/framework/AT/AT_CellularNetwork.cpp @@ -316,9 +316,10 @@ nsapi_error_t AT_CellularNetwork::activate_context() if (!_is_context_active) { // authenticate before activating or modifying context - if (do_user_authentication() != NSAPI_ERROR_OK) { + nsapi_error_t err = do_user_authentication(); + if (err != NSAPI_ERROR_OK) { tr_error("Cellular authentication failed!"); - return _at.unlock_return_error(); + return err; } tr_info("Activate PDP context %d", _cid);