Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for and debug mqtt_agent_task.c #85

Merged
merged 7 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ endif()
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
include(AddUnitTest)
# Include helpers mocks.
add_subdirectory(applications/helpers)
endif()


Expand Down
28 changes: 16 additions & 12 deletions applications/helpers/device_advisor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
# <[email protected]>
# SPDX-License-Identifier: MIT

add_library(helpers-device-advisor
src/aws_device_advisor_task.c
)
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
# left empty for future mocks.
else()
add_library(helpers-device-advisor
src/aws_device_advisor_task.c
)

target_include_directories(helpers-device-advisor
PUBLIC
inc
)
target_include_directories(helpers-device-advisor
PUBLIC
inc
)

target_link_libraries(helpers-device-advisor
coremqtt
coremqtt-agent
helpers-events
)
target_link_libraries(helpers-device-advisor
coremqtt
coremqtt-agent
helpers-events
)
endif()
26 changes: 15 additions & 11 deletions applications/helpers/events/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Copyright 2023 Arm Limited and/or its affiliates
# Copyright 2023-2024 Arm Limited and/or its affiliates
# <[email protected]>
# SPDX-License-Identifier: MIT

add_library(helpers-events
src/events.c
)
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
add_subdirectory(mocks)
else()
add_library(helpers-events
src/events.c
)

target_include_directories(helpers-events
PUBLIC
inc
)
target_include_directories(helpers-events
PUBLIC
inc
)

target_link_libraries(helpers-events
freertos_kernel
)
target_link_libraries(helpers-events
freertos_kernel
)
endif()
17 changes: 17 additions & 0 deletions applications/helpers/events/mocks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Arm Limited and/or its affiliates
# <[email protected]>
# SPDX-License-Identifier: MIT

add_library(helpers-events-mock
src/events.c
)

target_include_directories(helpers-events-mock
PUBLIC
inc
)

target_link_libraries(helpers-events-mock
PRIVATE
fff
)
20 changes: 20 additions & 0 deletions applications/helpers/events/mocks/inc/events.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Copyright 2023-2024 Arm Limited and/or its affiliates
* <[email protected]>
* SPDX-License-Identifier: MIT
*/

#ifndef EVENT_H
#define EVENT_H

#include "fff.h"

#define EVENT_MASK_MQTT_INIT 0x02
#define EVENT_MASK_MQTT_CONNECTED 0x04

typedef void * EventGroupHandle_t;

extern EventGroupHandle_t xSystemEvents;

DECLARE_FAKE_VOID_FUNC( vWaitUntilNetworkIsUp );

#endif /* EVENT_H */
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* SPDX-License-Identifier: MIT
*/

#ifndef INC_FREERTOS_H
#define INC_FREERTOS_H
#include "events.h"

#define configTICK_RATE_HZ ( 1000 )
EventGroupHandle_t xSystemEvents;

#endif
DEFINE_FAKE_VOID_FUNC( vWaitUntilNetworkIsUp );
30 changes: 17 additions & 13 deletions applications/helpers/hdlcd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@
# <[email protected]>
# SPDX-License-Identifier: MIT

add_library(helpers-hdlcd STATIC)
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
# left empty for future mocks.
else()
add_library(helpers-hdlcd STATIC)

target_include_directories(helpers-hdlcd
PUBLIC
.
)
target_include_directories(helpers-hdlcd
PUBLIC
.
)

target_sources(helpers-hdlcd
PUBLIC
hdlcd_helper.c
)
target_sources(helpers-hdlcd
PUBLIC
hdlcd_helper.c
)

target_link_libraries(helpers-hdlcd
PUBLIC
fri-bsp
)
target_link_libraries(helpers-hdlcd
PUBLIC
fri-bsp
)
endif()
26 changes: 15 additions & 11 deletions applications/helpers/logging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Copyright 2023 Arm Limited and/or its affiliates
# Copyright 2023-2024 Arm Limited and/or its affiliates
# <[email protected]>
# SPDX-License-Identifier: MIT

add_library(helpers-logging
src/iot_logging_task_dynamic_buffers.c
)
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
add_subdirectory(mocks)
else()
add_library(helpers-logging
src/iot_logging_task_dynamic_buffers.c
)

target_include_directories(helpers-logging
PUBLIC
inc
)
target_include_directories(helpers-logging
PUBLIC
inc
)

target_link_libraries(helpers-logging
freertos_kernel
)
target_link_libraries(helpers-logging
freertos_kernel
)
endif()
17 changes: 17 additions & 0 deletions applications/helpers/logging/mocks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2024 Arm Limited and/or its affiliates
# <[email protected]>
# SPDX-License-Identifier: MIT

add_library(helpers-logging-mock
INTERFACE
)

target_include_directories(helpers-logging-mock
INTERFACE
inc
)

target_link_libraries(helpers-logging-mock
INTERFACE
fff
)
28 changes: 28 additions & 0 deletions applications/helpers/logging/mocks/inc/logging_levels.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* FreeRTOS Common V1.1.3
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2024 Arm Limited and/or its affiliates
* <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef LOGGING_LEVELS_H_
#define LOGGING_LEVELS_H_

#endif /* LOGGING_LEVELS_H_ */
48 changes: 48 additions & 0 deletions applications/helpers/logging/mocks/inc/logging_stack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* FreeRTOS Common V1.1.3
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Copyright 2024 Arm Limited and/or its affiliates
* <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef LOGGING_STACK_H_
#define LOGGING_STACK_H_

#include "fff.h"

DECLARE_FAKE_VOID_FUNC_VARARG( SdkLogError,
const char *,
... );
#define LogError( message ) ( SdkLogError message )
/* The macro suppresses errors for now. */
DECLARE_FAKE_VOID_FUNC_VARARG( SdkLogWarn,
const char *,
... );
#define LogWarn( message ) ( SdkLogError message )
DECLARE_FAKE_VOID_FUNC_VARARG( SdkLogInfo,
const char *,
... );
#define LogInfo( message ) ( SdkLogInfo message )
DECLARE_FAKE_VOID_FUNC_VARARG( SdkLogDebug,
const char *,
... );
#define LogDebug( message ) ( SdkLogDebug message )

#endif /* ifndef LOGGING_STACK_H_ */
Loading
Loading