From 427674d6ca16dec66a877e75573c483ff3ec11ef Mon Sep 17 00:00:00 2001 From: Antti Kauppila Date: Tue, 20 Feb 2018 16:26:56 +0200 Subject: [PATCH] IOTCELL-553 fixed Unittests reports an error as there is no coverage file created for cellular_mux. This is now fixed by running an init function. --- .../UNITTESTS/mux/cellular_mux/Makefile | 6 +++ .../mux/cellular_mux/cellular_muxtest.cpp | 25 ++++++++++++- .../mux/cellular_mux/test_cellular_mux.cpp | 28 ++++++++++++++ .../mux/cellular_mux/test_cellular_mux.h | 10 +++++ .../UNITTESTS/stubs/Semaphore_stub.cpp | 37 +++++++++++++++++++ .../cellular_mux_data_service_stub.cpp} | 36 ++++++++++++++++-- 6 files changed, 138 insertions(+), 4 deletions(-) rename features/cellular/UNITTESTS/{target_h/Semaphore2.h => stubs/cellular_mux_data_service_stub.cpp} (63%) diff --git a/features/cellular/UNITTESTS/mux/cellular_mux/Makefile b/features/cellular/UNITTESTS/mux/cellular_mux/Makefile index 175292aad3..d19c94571f 100644 --- a/features/cellular/UNITTESTS/mux/cellular_mux/Makefile +++ b/features/cellular/UNITTESTS/mux/cellular_mux/Makefile @@ -10,6 +10,12 @@ TEST_SRC_FILES = \ main.cpp \ cellular_muxtest.cpp \ test_cellular_mux.cpp \ + ../../stubs/mbed_assert_stub.cpp \ + ../../stubs/FileHandle_stub.cpp \ + ../../stubs/EventQueue_stub.cpp \ + ../../stubs/equeue_stub.c \ + ../../stubs/cellular_mux_data_service_stub.cpp \ + ../../stubs/Semaphore_stub.cpp \ include ../../MakefileWorker.mk diff --git a/features/cellular/UNITTESTS/mux/cellular_mux/cellular_muxtest.cpp b/features/cellular/UNITTESTS/mux/cellular_mux/cellular_muxtest.cpp index 83599888ec..2bc976a1c5 100644 --- a/features/cellular/UNITTESTS/mux/cellular_mux/cellular_muxtest.cpp +++ b/features/cellular/UNITTESTS/mux/cellular_mux/cellular_muxtest.cpp @@ -37,6 +37,29 @@ TEST(cellular_mux, Create) CHECK(unit != NULL); } - +TEST(cellular_mux, test_cellular_mux_module_init) +{ + unit->test_cellular_mux_module_init(); +} + +TEST(cellular_mux, test_cellular_mux_mux_start) +{ + unit->test_cellular_mux_mux_start(); +} + +TEST(cellular_mux, test_cellular_mux_dlci_establish) +{ + unit->test_cellular_mux_dlci_establish(); +} + +TEST(cellular_mux, test_cellular_mux_serial_attach) +{ + unit->test_cellular_mux_serial_attach(); +} + +TEST(cellular_mux, test_cellular_mux_eventqueue_attach) +{ + unit->test_cellular_mux_eventqueue_attach(); +} diff --git a/features/cellular/UNITTESTS/mux/cellular_mux/test_cellular_mux.cpp b/features/cellular/UNITTESTS/mux/cellular_mux/test_cellular_mux.cpp index 3946989d60..1b17525704 100644 --- a/features/cellular/UNITTESTS/mux/cellular_mux/test_cellular_mux.cpp +++ b/features/cellular/UNITTESTS/mux/cellular_mux/test_cellular_mux.cpp @@ -16,8 +16,12 @@ */ #include "CppUTest/TestHarness.h" #include "test_cellular_mux.h" +#include "cellular_mux.h" #include +using namespace mbed; +using namespace events; + Test_cellular_mux::Test_cellular_mux() { @@ -27,3 +31,27 @@ Test_cellular_mux::~Test_cellular_mux() { } +void Test_cellular_mux::test_cellular_mux_module_init() +{ + Mux::module_init(); +} + +void Test_cellular_mux::test_cellular_mux_mux_start() +{ +} + +void Test_cellular_mux::test_cellular_mux_dlci_establish() +{ + +} + +void Test_cellular_mux::test_cellular_mux_serial_attach() +{ + +} + +void Test_cellular_mux::test_cellular_mux_eventqueue_attach() +{ + +} + diff --git a/features/cellular/UNITTESTS/mux/cellular_mux/test_cellular_mux.h b/features/cellular/UNITTESTS/mux/cellular_mux/test_cellular_mux.h index 5e2b86ac11..9c0b2f38b3 100644 --- a/features/cellular/UNITTESTS/mux/cellular_mux/test_cellular_mux.h +++ b/features/cellular/UNITTESTS/mux/cellular_mux/test_cellular_mux.h @@ -23,6 +23,16 @@ public: Test_cellular_mux(); virtual ~Test_cellular_mux(); + + void test_cellular_mux_module_init(); + + void test_cellular_mux_mux_start(); + + void test_cellular_mux_dlci_establish(); + + void test_cellular_mux_serial_attach(); + + void test_cellular_mux_eventqueue_attach(); }; #endif // TEST_cellular_mux_H diff --git a/features/cellular/UNITTESTS/stubs/Semaphore_stub.cpp b/features/cellular/UNITTESTS/stubs/Semaphore_stub.cpp index 4fb6bf1899..3782b77f8c 100644 --- a/features/cellular/UNITTESTS/stubs/Semaphore_stub.cpp +++ b/features/cellular/UNITTESTS/stubs/Semaphore_stub.cpp @@ -17,4 +17,41 @@ #include "Semaphore.h" +namespace rtos { +Semaphore::Semaphore(int32_t count) +{ + +} + +Semaphore::Semaphore(int32_t count, uint16_t max_count) +{ + +} + +void Semaphore::constructor(int32_t count, uint16_t max_count) +{ + +} + +int32_t Semaphore::wait(uint32_t millisec) +{ + return 0; +} + +int32_t Semaphore::wait_until(uint64_t millisec) +{ + return 0; +} + +osStatus Semaphore::release(void) +{ + return 0; +} + +Semaphore::~Semaphore() +{ + +} + +} diff --git a/features/cellular/UNITTESTS/target_h/Semaphore2.h b/features/cellular/UNITTESTS/stubs/cellular_mux_data_service_stub.cpp similarity index 63% rename from features/cellular/UNITTESTS/target_h/Semaphore2.h rename to features/cellular/UNITTESTS/stubs/cellular_mux_data_service_stub.cpp index 22fb59fa00..ffaf8e13a5 100644 --- a/features/cellular/UNITTESTS/target_h/Semaphore2.h +++ b/features/cellular/UNITTESTS/stubs/cellular_mux_data_service_stub.cpp @@ -14,7 +14,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -namespace rtos { -class Semaphore { -}; +#include "cellular_mux.h" + +namespace mbed +{ + +ssize_t MuxDataService::write(const void* buffer, size_t size) +{ + return 0; +} + + +ssize_t MuxDataService::read(void *buffer, size_t size) +{ + return 0; +} + + +off_t MuxDataService::seek(off_t offset, int whence) +{ + return 0; +} + + +int MuxDataService::close() +{ + return 0; +} + + +void MuxDataService::sigio(Callback func) +{ +} + }