Skip to content

Commit

Permalink
tests: lwm2m_client_utils: Add stubbing for LWM2M init macros
Browse files Browse the repository at this point in the history
Add initialization stub for LwM2M_***_INIT() macros to
work.

Remove CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT=y as it
is already directly included in CMakeListst.txt

Signed-off-by: Seppo Takalo <[email protected]>
  • Loading branch information
SeppoTakalo committed Mar 6, 2024
1 parent 40d15cb commit 86685d9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions tests/subsys/net/lib/lwm2m_fota_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,5 @@ target_include_directories(app
PRIVATE
${includes}
)

zephyr_linker_sources(SECTIONS src/iterables.ld)
1 change: 0 additions & 1 deletion tests/subsys/net/lib/lwm2m_fota_utils/prj_obj5.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
CONFIG_ZTEST=y
CONFIG_LWM2M_CLIENT_UTILS=y
CONFIG_LWM2M_CLIENT_UTILS_FIRMWARE_UPDATE_OBJ_SUPPORT=y
CONFIG_LWM2M_FIRMWARE_UPDATE_OBJ_SUPPORT=y
CONFIG_LWM2M_CLIENT_UTILS_LOCATION_OBJ_SUPPORT=n
CONFIG_HEAP_MEM_POOL_SIZE=1024
1 change: 1 addition & 0 deletions tests/subsys/net/lib/lwm2m_fota_utils/src/iterables.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ITERABLE_SECTION_ROM(lwm2m_init_func, 4)
14 changes: 14 additions & 0 deletions tests/subsys/net/lib/lwm2m_fota_utils/src/stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,17 @@ DEFINE_FAKE_VALUE_FUNC(int, fota_download_util_download_cancel);
DEFINE_FAKE_VALUE_FUNC(int, fota_download_util_image_schedule, enum dfu_target_image_type);
DEFINE_FAKE_VALUE_FUNC(int, fota_download_util_image_reset, enum dfu_target_image_type);
DEFINE_FAKE_VALUE_FUNC(int, fota_download_util_apply_update, enum dfu_target_image_type);

static int lwm2m_engine_init(void)
{
STRUCT_SECTION_FOREACH(lwm2m_init_func, init) {
int ret = init->f();

if (ret) {
printf("Init function %p returned %d\n", init, ret);
}
}
return 0;
}

SYS_INIT(lwm2m_engine_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);

0 comments on commit 86685d9

Please sign in to comment.