mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #14948 from Patater/lorawan-timer-unittest-fake-fix
Fix lorawantimer unit testpull/14952/head
commit
862a9420fe
|
|
@ -33,10 +33,14 @@ target_sources(mbed-fakes-ble
|
||||||
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/tests/UNITTESTS/doubles/fakes/SecurityManagerImpl_mock.h
|
${mbed-os_SOURCE_DIR}/connectivity/FEATURE_BLE/tests/UNITTESTS/doubles/fakes/SecurityManagerImpl_mock.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_options(mbed-fakes-ble
|
||||||
|
PRIVATE
|
||||||
|
--coverage
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(mbed-fakes-ble
|
target_link_libraries(mbed-fakes-ble
|
||||||
PRIVATE
|
PRIVATE
|
||||||
mbed-headers-base
|
mbed-headers-base
|
||||||
mbed-headers-platform
|
mbed-headers-platform
|
||||||
mbed-headers-events
|
mbed-headers-events
|
||||||
gcov
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -554,7 +554,7 @@ TEST_F(Test_LoRaWANStack, handle_rx)
|
||||||
}
|
}
|
||||||
ind.buffer = ind_buf;
|
ind.buffer = ind_buf;
|
||||||
ind.buffer_size = 50;
|
ind.buffer_size = 50;
|
||||||
ind.type = mcps_type_t(66);
|
ind.type = MCPS_MULTICAST;
|
||||||
radio._ev->rx_done(NULL, 0, 0, 0);
|
radio._ev->rx_done(NULL, 0, 0, 0);
|
||||||
EXPECT_TRUE(50 == object->handle_rx(data, 50, port, flags, false));
|
EXPECT_TRUE(50 == object->handle_rx(data, 50, port, flags, false));
|
||||||
EXPECT_EQ(10, data[10]);
|
EXPECT_EQ(10, data[10]);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ add_executable(${TEST_NAME})
|
||||||
|
|
||||||
target_compile_definitions(${TEST_NAME}
|
target_compile_definitions(${TEST_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
NDEBUG=1
|
NDEBUG=1
|
||||||
MBED_CONF_LORA_TX_MAX_SIZE=255
|
MBED_CONF_LORA_TX_MAX_SIZE=255
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,12 @@ TEST_F(Test_LoRaWANTimer, init)
|
||||||
|
|
||||||
TEST_F(Test_LoRaWANTimer, start)
|
TEST_F(Test_LoRaWANTimer, start)
|
||||||
{
|
{
|
||||||
equeue_stub.void_ptr = NULL;
|
struct equeue_event ptr;
|
||||||
|
equeue_stub.void_ptr = &ptr;
|
||||||
timer_event_t ev;
|
timer_event_t ev;
|
||||||
memset(&ev, 0, sizeof(ev));
|
memset(&ev, 0, sizeof(ev));
|
||||||
|
object->init(ev, my_callback);
|
||||||
|
equeue_stub.call_cb_immediately = true;
|
||||||
object->start(ev, 10);
|
object->start(ev, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,25 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __EQUEUE_STUB_H__
|
||||||
|
#define __EQUEUE_STUB_H__
|
||||||
|
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "stdbool.h"
|
#include "stdbool.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *void_ptr;
|
void *void_ptr;
|
||||||
bool call_cb_immediately;
|
bool call_cb_immediately;
|
||||||
} equeue_stub_def;
|
} equeue_stub_def;
|
||||||
|
|
||||||
extern equeue_stub_def equeue_stub;
|
extern equeue_stub_def equeue_stub;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,12 @@ target_include_directories(mbed-fakes-event-queue
|
||||||
.
|
.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_options(mbed-fakes-event-queue
|
||||||
|
PRIVATE
|
||||||
|
--coverage
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(mbed-fakes-event-queue
|
target_link_libraries(mbed-fakes-event-queue
|
||||||
PRIVATE
|
PRIVATE
|
||||||
mbed-headers
|
mbed-headers
|
||||||
gcov
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ TEST_F(TestCircularBuffer, push_pop_multiple)
|
||||||
const int test_numbers[TEST_BUFFER_SIZE] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
const int test_numbers[TEST_BUFFER_SIZE] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
|
||||||
/* this will check pushing across the buffer end */
|
/* this will check pushing across the buffer end */
|
||||||
for (int i = 0; i < TEST_BUFFER_SIZE; i++) {
|
for (int i = 1; i < TEST_BUFFER_SIZE; i++) {
|
||||||
int test_numbers_popped[TEST_BUFFER_SIZE] = { 0 };
|
int test_numbers_popped[TEST_BUFFER_SIZE] = { 0 };
|
||||||
buf->push(test_numbers, i);
|
buf->push(test_numbers, i);
|
||||||
EXPECT_EQ(buf->size(), i);
|
EXPECT_EQ(buf->size(), i);
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,5 @@ target_link_libraries(mbed-stubs-platform
|
||||||
mbed-headers-base
|
mbed-headers-base
|
||||||
mbed-headers-hal
|
mbed-headers-hal
|
||||||
mbed-headers-platform
|
mbed-headers-platform
|
||||||
|
gmock_main
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "platform/mbed_assert.h"
|
#include "platform/mbed_assert.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
@ -27,4 +28,10 @@ extern "C" void mbed_assert_internal(const char *expr, const char *file, int lin
|
||||||
if (mbed_assert_throw_errors) {
|
if (mbed_assert_throw_errors) {
|
||||||
throw 1;
|
throw 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure we fail the unit test if the Mbed assertion fails. Without this,
|
||||||
|
* we might not notice the assertion failure as it wouldn't be bubbled up
|
||||||
|
* to googletest. Note that this is after the above throw, as some tests
|
||||||
|
* check that an exception is thrown (i.e. negative tests). */
|
||||||
|
FAIL();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue