Skip to content

Commit

Permalink
Address CI check failures
Browse files Browse the repository at this point in the history
  • Loading branch information
aggarw13 committed Jul 22, 2021
1 parent 3c4acf8 commit 008f03f
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 35 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ jobs:
cmake -S test -B build/ \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_CLONE_SUBMODULES=ON \
-DCMAKE_C_FLAGS='-O0 -Wall -Wextra -Werror -Wformat -Wformat-security -Warray-bounds'
make -C build/ coverity_analysis -j8
- name: Build Library in Release mode
run: |
rm -rf ./build
cmake -S test -B build/ -G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_CLONE_SUBMODULES=ON \
-DCMAKE_C_FLAGS='-Wall -Wextra -Werror -DNDEBUG -Wformat -Wformat-security -Warray-bounds'
make -C build/ coverity_analysis -j8
build-code-example:
Expand All @@ -33,9 +31,9 @@ jobs:
- name: Clone This Repo
uses: actions/checkout@v2
- name: Build Code Example used in Doxygen
run: |
run: |
cmake -S test -B Build
make code_example_posix -j8
make -C build code_example_posix -j8
unittest-with-sanitizer:
runs-on: ubuntu-latest
steps:
Expand All @@ -57,7 +55,7 @@ jobs:
cmake -S test -B build/ \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_CLONE_SUBMODULES=ON \
-DUNIT_TESTS=ON \
-DCMAKE_C_FLAGS="${CFLAGS}"
make -C build all -j8
- name: Run unit tests with sanitizer
Expand All @@ -77,7 +75,7 @@ jobs:
cmake -S test -B build/ \
-G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_CLONE_SUBMODULES=ON \
-DUNIT_TESTS=ON \
-DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG -Wno-error=pedantic -Wno-variadic-macros -DLOGGING_LEVEL_DEBUG=1'
make -C build/ all
- name: Test
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ git submodule update --checkout --init --recursive test/unit-test/CMock

1. Go to the root directory of this repository. (Make sure that the **CMock** submodule is cloned as described [above](#checkout-cmock-submodule))

1. Run the *cmake* command: `cmake -S test -B build`
1. Run the *cmake* command: `cmake -S test -B build -DUNIT_TESTS=ON`

1. Run this command to build the library and unit tests: `make -C build all`

Expand Down
8 changes: 4 additions & 4 deletions docs/doxygen/pages.dox
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ All the configurations settings for the coreSNTP library are function-like macro
@snippet core_sntp_client.h define_sntp_init
@copydoc Sntp_Init

For an example POSIX application of using the coreSNTP library APIs to create an SNTP client, refer to @ref code_example.
For an example POSIX application of using the coreSNTP library APIs to create an SNTP client, refer to @ref code_example.
Below is the part of the code example relevant to the @ref Sntp_Init API.
@snippet example_sntp_client_posix.c code_example_sntp_init

@page sntp_sendtimerequest_function Sntp_SendTimeRequest
@copydoc Sntp_SendTimeRequest

For an example POSIX application of using the coreSNTP library APIs to create an SNTP client, refer to @ref code_example.
For an example POSIX application of using the coreSNTP library APIs to create an SNTP client, refer to @ref code_example.
Below is the part of the code example relevant to the @ref Sntp_ReceiveTimeResponse API.
@snippet example_sntp_client_posix.c code_example_sntp_send_receive

@page sntp_receivetimeresponse_function Sntp_ReceiveTimeResponse
@copydoc Sntp_ReceiveTimeResponse

For an example POSIX application of the coreSNTP library APIs to create an SNTP client, refer to @ref code_example.
For an example POSIX application of the coreSNTP library APIs to create an SNTP client, refer to @ref code_example.
Below is the part of the example application relevant to the @ref Sntp_ReceiveTimeResponse API.
@snippet example_sntp_client_posix.c code_example_sntp_send_receive

Expand All @@ -130,7 +130,7 @@ Here is a code example of using the API.
@page code_example Example application of using coreSNTP APIs
@brief Example application of setting up an SNTP client with coreSNTP Library on POSIX platforms.

This code ONLY showcases how coreSNTP library APIs can be used. For best practices on running an SNTP client,
This code ONLY showcases how coreSNTP library APIs can be used. For best practices on running an SNTP client,
refer to the [FreeRTOS Demo on GitHub](https://github.com/FreeRTOS/FreeRTOS/tree/main/FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator).<br>
@include example_sntp_client_posix.c
*/
Expand Down
2 changes: 1 addition & 1 deletion docs/doxygen/porting.dox
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ address information of a time server before sending it a time request.

@see [DNS Resolve Function](@ref SntpResolveDns_t)

@note The coreSNTP library will re-resolve DNS name of a time server on every attempt of requesting time from it.
@note The coreSNTP library will re-resolve DNS name of a time server on every attempt of requesting time from it.
For efficiency of DNS resolution operations, your implementation can utilize DNS caching of resolved domains, if
your platform supports it.

Expand Down
1 change: 1 addition & 0 deletions lexicon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ loginfo
logwarn
lsb
mainpage
md
mdash
misra
mtu
Expand Down
53 changes: 30 additions & 23 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cmake_minimum_required( VERSION 3.13.0 )
project( "coreSNTP unit test"
VERSION 1.0.0
LANGUAGES C )

# Allow the project to be organized into folders.
Expand Down Expand Up @@ -48,36 +47,44 @@ target_include_directories( coverity_analysis
# Build SNTP library target without custom config dependency.
target_compile_definitions( coverity_analysis PUBLIC SNTP_DO_NOT_USE_CUSTOM_CONFIG=1 )

# ==================================== Code Example Build ====================================

# Target for Coverity analysis that builds the library.
add_executable( code_example_posix
${MODULE_ROOT_DIR}/docs/doxygen/code_examples/example_sntp_client_posix.c )

# Add coreSNTP library public include path.
target_link_libraries( code_example_posix
coverity_analysis )

# ==================================== Unit Test Configuration ====================================

# Include CMock build configuration.
include( unit-test/cmock_build.cmake )

# Check if the CMock source directory exists, and if not present, clone the submodule
# if BUILD_CLONE_SUBMODULES configuration is enabled.
if( NOT EXISTS ${CMOCK_DIR}/src )
# Attempt to clone CMock.
if( ${BUILD_CLONE_SUBMODULES} )
clone_cmock()
else()
message( FATAL_ERROR "The required submodule CMock does not exist. Either clone it manually, or set BUILD_CLONE_SUBMODULES to 1 to automatically clone it during build." )
if(${UNIT_TESTS})
# Include CMock build configuration.
include( unit-test/cmock_build.cmake )

# Check if the CMock source directory exists, and if not present, clone the submodule
# if BUILD_CLONE_SUBMODULES configuration is enabled.
if( NOT EXISTS ${CMOCK_DIR}/src )
# Attempt to clone CMock.
clone_cmock()
endif()
endif()

# Add unit test and coverage configuration.
# Add unit test and coverage configuration.

# Use CTest utility for managing test runs. This has to be added BEFORE
# defining test targets with add_test()
enable_testing()
# Use CTest utility for managing test runs. This has to be added BEFORE
# defining test targets with add_test()
enable_testing()

# Add build targets for CMock, required for unit testing.
add_cmock_targets()
# Add build targets for CMock, required for unit testing.
add_cmock_targets()

# Add function to enable CMock/Unity based tests and coverage.
include( ${MODULE_ROOT_DIR}/tools/cmock/create_test.cmake )
# Add function to enable CMock/Unity based tests and coverage.
include( ${MODULE_ROOT_DIR}/tools/cmock/create_test.cmake )

# Include build configuration for unit tests.
add_subdirectory( unit-test )
# Include build configuration for unit tests.
add_subdirectory( unit-test )
endif()

# ==================================== Coverage Analysis configuration ============================

Expand Down
2 changes: 2 additions & 0 deletions test/unit-test/core_sntp_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/* Standard include. */
#include <stdio.h>

/* @[code_example_loggingmacros] */
/************* Define Logging Macros using printf function ***********/

#define PrintfError( ... ) printf( "Error: "__VA_ARGS__ ); printf( "\n" )
Expand All @@ -54,5 +55,6 @@
#endif /* ifdef LOGGING_LEVEL_ERROR */

/**************************************************/
/* @[code_example_loggingmacros] */

#endif /* ifndef CORE_SNTP_CONFIG_H_ */

0 comments on commit 008f03f

Please sign in to comment.