Merge pull request #14948 from Patater/lorawan-timer-unittest-fake-fix

Fix lorawantimer unit test
pull/14952/head
Jaeden Amero 2021-07-27 14:02:47 +01:00 committed by GitHub
commit 862a9420fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 6 deletions

View File

@ -33,10 +33,14 @@ target_sources(mbed-fakes-ble
${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
PRIVATE
mbed-headers-base
mbed-headers-platform
mbed-headers-events
gcov
)

View File

@ -554,7 +554,7 @@ TEST_F(Test_LoRaWANStack, handle_rx)
}
ind.buffer = ind_buf;
ind.buffer_size = 50;
ind.type = mcps_type_t(66);
ind.type = MCPS_MULTICAST;
radio._ev->rx_done(NULL, 0, 0, 0);
EXPECT_TRUE(50 == object->handle_rx(data, 50, port, flags, false));
EXPECT_EQ(10, data[10]);

View File

@ -7,7 +7,7 @@ add_executable(${TEST_NAME})
target_compile_definitions(${TEST_NAME}
PRIVATE
NDEBUG=1
NDEBUG=1
MBED_CONF_LORA_TX_MAX_SIZE=255
)

View File

@ -71,9 +71,12 @@ TEST_F(Test_LoRaWANTimer, init)
TEST_F(Test_LoRaWANTimer, start)
{
equeue_stub.void_ptr = NULL;
struct equeue_event ptr;
equeue_stub.void_ptr = &ptr;
timer_event_t ev;
memset(&ev, 0, sizeof(ev));
object->init(ev, my_callback);
equeue_stub.call_cb_immediately = true;
object->start(ev, 10);
}

View File

@ -15,12 +15,25 @@
* limitations under the License.
*/
#ifndef __EQUEUE_STUB_H__
#define __EQUEUE_STUB_H__
#include "stdint.h"
#include "stdbool.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
void *void_ptr;
bool call_cb_immediately;
} equeue_stub_def;
extern equeue_stub_def equeue_stub;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -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
PRIVATE
mbed-headers
gcov
)

View File

@ -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 };
/* 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 };
buf->push(test_numbers, i);
EXPECT_EQ(buf->size(), i);

View File

@ -35,4 +35,5 @@ target_link_libraries(mbed-stubs-platform
mbed-headers-base
mbed-headers-hal
mbed-headers-platform
gmock_main
)

View File

@ -16,6 +16,7 @@
*/
#include "platform/mbed_assert.h"
#include "gtest/gtest.h"
#include <stdio.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) {
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();
}