Skip to content

Commit

Permalink
Merge pull request #37 from SiliconLabs/test/unit-test-function-post-…
Browse files Browse the repository at this point in the history
…and-bist

Test/unit test function post and bist
  • Loading branch information
silabs-hieuhoang authored Nov 5, 2024
2 parents 05e78f8 + 3b8844d commit ad809c7
Show file tree
Hide file tree
Showing 24 changed files with 918 additions and 147 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Build
Test/test_script/__pycache__
Doc/html/EFR32_ICE60730_Libraries/latex
*.temp-stream*
iostream_usart/src/*
!iostream_usart/src/CMakeLists.txt
gecko_sdk/src/*
!gecko_sdk/src/CMakeLists.txt
cmake_build
5 changes: 1 addition & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,4 @@ string(REPLACE "$<$<COMPILE_LANGUAGE:CXX>:SHELL:-imacros sl_gcc_preinclude.h>;"
string(REPLACE "$<$<COMPILE_LANGUAGE:ASM>:SHELL:-imacros sl_gcc_preinclude.h>;" "" MAIN_CFLAGS_LIB_IEC60730 "${MAIN_CFLAGS_LIB_IEC60730}")
target_compile_options(unity PUBLIC
${MAIN_CFLAGS_LIB_IEC60730})

endif()


endif()
18 changes: 18 additions & 0 deletions cmake/generate_lib_iec60730.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function(generate_lib_iec60730 relative_dir)

set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir})

execute_process(COMMAND make prepare
WORKING_DIRECTORY ${FULL_DIR})

execute_process(COMMAND slc generate -p
${FULL_DIR} -np -d ${FULL_DIR}/src -cpproj -name=lib_iec60730 -o cmake --with ${BOARD_NAME}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

if (EXISTS ${FULL_DIR}/CMakeLists.txt)
message("-- Path have CMake File: ${FULL_DIR}/CMakeLists.txt")
add_subdirectory(${FULL_DIR})
else()
message("-- Path don't have CMake File: ${FULL_DIR}")
endif()
endfunction(generate_lib_iec60730)
47 changes: 47 additions & 0 deletions cmake/unit_test_bist.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

function(generate_unit_test_iec60730_bist relative_dir)
set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir})
set(UNIT_TEST_IEC60730_BIST "unit_test_iec60730_bist")
set(UNIT_TEST_IEC60730_BIST_BUILD_DIR "build/unit_test/iec60730_bist")
set(UNIT_TEST_SOURCES
"${FULL_DIR}/src/main.c"
"${FULL_DIR}/src/app.c"
"${FULL_DIR}/src/unit_test_common.c"
"${FULL_DIR}/src/unit_test_iec60730_bist.c"
"${FULL_DIR}/../../lib/src/sl_iec60730_bist.c"
)
set(UNIT_TEST_INCLUDES
"${FULL_DIR}/inc"
${UNITY_HEADER})

add_executable(${UNIT_TEST_IEC60730_BIST} ${UNIT_TEST_SOURCES})
target_include_directories(${UNIT_TEST_IEC60730_BIST} PUBLIC ${UNIT_TEST_INCLUDES})
target_compile_definitions(${UNIT_TEST_IEC60730_BIST} PUBLIC UNIT_TEST_IEC60730_BIST_ENABLE)

target_link_libraries(${UNIT_TEST_IEC60730_BIST} PUBLIC unity slc_lib_iec60730)

# Create .bin, .hex and .s37 artifacts after building the project
add_custom_command(TARGET ${UNIT_TEST_IEC60730_BIST}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O srec "$<TARGET_FILE:${UNIT_TEST_IEC60730_BIST}>" "$<TARGET_FILE_DIR:${UNIT_TEST_IEC60730_BIST}>/$<TARGET_FILE_BASE_NAME:${UNIT_TEST_IEC60730_BIST}>.s37"
COMMAND ${CMAKE_OBJCOPY} -O ihex "$<TARGET_FILE:${UNIT_TEST_IEC60730_BIST}>" "$<TARGET_FILE_DIR:${UNIT_TEST_IEC60730_BIST}>/$<TARGET_FILE_BASE_NAME:${UNIT_TEST_IEC60730_BIST}>.hex"
COMMAND ${CMAKE_OBJCOPY} -O binary "$<TARGET_FILE:${UNIT_TEST_IEC60730_BIST}>" "$<TARGET_FILE_DIR:${UNIT_TEST_IEC60730_BIST}>/$<TARGET_FILE_BASE_NAME:${UNIT_TEST_IEC60730_BIST}>.bin"
COMMAND rm -rf ./build/bist
COMMAND mkdir -p ${UNIT_TEST_IEC60730_BIST_BUILD_DIR}
COMMAND mv ${UNIT_TEST_IEC60730_BIST}.out ${UNIT_TEST_IEC60730_BIST_BUILD_DIR}
COMMAND mv ${UNIT_TEST_IEC60730_BIST}.bin ${UNIT_TEST_IEC60730_BIST_BUILD_DIR}
COMMAND mv ${UNIT_TEST_IEC60730_BIST}.hex ${UNIT_TEST_IEC60730_BIST_BUILD_DIR}
COMMAND mv ${UNIT_TEST_IEC60730_BIST}.s37 ${UNIT_TEST_IEC60730_BIST_BUILD_DIR}
)

set(post_build_command ${CMAKE_OBJDUMP} -t -h -d -S ${UNIT_TEST_IEC60730_BIST_BUILD_DIR}/${UNIT_TEST_IEC60730_BIST}.out > ${UNIT_TEST_IEC60730_BIST_BUILD_DIR}/${UNIT_TEST_IEC60730_BIST}.lst)

# Run post-build pipeline to perform additional post-processing
if(post_build_command)
add_custom_command(TARGET ${UNIT_TEST_IEC60730_BIST}
POST_BUILD
COMMAND ${post_build_command}
)
endif()
endfunction(generate_unit_test_iec60730_bist)

45 changes: 45 additions & 0 deletions cmake/unit_test_post.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
function(generate_unit_test_iec60730_post relative_dir)
set(FULL_DIR ${CMAKE_SOURCE_DIR}/${relative_dir})
set(UNIT_TEST_IEC60730_POST "unit_test_iec60730_post")
set(UNIT_TEST_IEC60730_POST_BUILD_DIR "build/unit_test/iec60730_post")
set(UNIT_TEST_SOURCES
"${FULL_DIR}/src/main.c"
"${FULL_DIR}/src/app.c"
"${FULL_DIR}/src/unit_test_common.c"
"${FULL_DIR}/src/unit_test_iec60730_post.c"
"${FULL_DIR}/../../lib/src/sl_iec60730_post.c"
)
set(UNIT_TEST_INCLUDES
"${FULL_DIR}/inc"
${UNITY_HEADER})

add_executable(${UNIT_TEST_IEC60730_POST} ${UNIT_TEST_SOURCES})
target_include_directories(${UNIT_TEST_IEC60730_POST} PUBLIC ${UNIT_TEST_INCLUDES})
target_compile_definitions(${UNIT_TEST_IEC60730_POST} PUBLIC UNIT_TEST_IEC60730_POST_ENABLE)

target_link_libraries(${UNIT_TEST_IEC60730_POST} PUBLIC unity slc_lib_iec60730)

# Create .bin, .hex and .s37 artifacts after building the project
add_custom_command(TARGET ${UNIT_TEST_IEC60730_POST}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} -O srec "$<TARGET_FILE:${UNIT_TEST_IEC60730_POST}>" "$<TARGET_FILE_DIR:${UNIT_TEST_IEC60730_POST}>/$<TARGET_FILE_BASE_NAME:${UNIT_TEST_IEC60730_POST}>.s37"
COMMAND ${CMAKE_OBJCOPY} -O ihex "$<TARGET_FILE:${UNIT_TEST_IEC60730_POST}>" "$<TARGET_FILE_DIR:${UNIT_TEST_IEC60730_POST}>/$<TARGET_FILE_BASE_NAME:${UNIT_TEST_IEC60730_POST}>.hex"
COMMAND ${CMAKE_OBJCOPY} -O binary "$<TARGET_FILE:${UNIT_TEST_IEC60730_POST}>" "$<TARGET_FILE_DIR:${UNIT_TEST_IEC60730_POST}>/$<TARGET_FILE_BASE_NAME:${UNIT_TEST_IEC60730_POST}>.bin"
COMMAND rm -rf ./build/post
COMMAND mkdir -p ${UNIT_TEST_IEC60730_POST_BUILD_DIR}
COMMAND mv ${UNIT_TEST_IEC60730_POST}.out ${UNIT_TEST_IEC60730_POST_BUILD_DIR}
COMMAND mv ${UNIT_TEST_IEC60730_POST}.bin ${UNIT_TEST_IEC60730_POST_BUILD_DIR}
COMMAND mv ${UNIT_TEST_IEC60730_POST}.hex ${UNIT_TEST_IEC60730_POST_BUILD_DIR}
COMMAND mv ${UNIT_TEST_IEC60730_POST}.s37 ${UNIT_TEST_IEC60730_POST_BUILD_DIR}
)

set(post_build_command ${CMAKE_OBJDUMP} -t -h -d -S ${UNIT_TEST_IEC60730_POST_BUILD_DIR}/${UNIT_TEST_IEC60730_POST}.out > ${UNIT_TEST_IEC60730_POST_BUILD_DIR}/${UNIT_TEST_IEC60730_POST}.lst)

# Run post-build pipeline to perform additional post-processing
if(post_build_command)
add_custom_command(TARGET ${UNIT_TEST_IEC60730_POST}
POST_BUILD
COMMAND ${post_build_command}
)
endif()
endfunction(generate_unit_test_iec60730_post)
34 changes: 34 additions & 0 deletions components/iec60730_unit_test.slcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package: iec60730
description: This components support run unit test function lib IEC60730
label: IEC60730 Unit Test
quality: test
id: iec60730_unit_test
category: Unit Test
provides:
- name: "iec60730_unit_test"
config_file:
- path: ./lib/config/sl_iec60730_config.h
include:
- path: ./lib/inc
file_list:
- path: coding_standard.h
- path: efr32_iec60730_release_notes.h
- path: sl_iec60730_toolchain.h
- path: sl_iec60730_board.h
- path: sl_iec60730_comm.h
- path: sl_iec60730_cpu_registers.h
- path: sl_iec60730_internal.h
- path: sl_iec60730_invariable_memory.h
- path: sl_iec60730_irq.h
- path: sl_iec60730_library_documentation.h
- path: sl_iec60730_program_counter.h
- path: sl_iec60730_system_clock.h
- path: sl_iec60730_variable_memory.h
- path: sl_iec60730_watchdog.h
- path: sl_iec60730.h
- path: silabs_license_agreement.h
define:
- name: IEC_BOARD_HEADER
value: "\"sl_iec60730_board.h\""
ui_hints:
visibility: never
14 changes: 0 additions & 14 deletions docs/html/EFR32_ICE60730_Libraries/globals.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ <h3><a id="index_i"></a>- i -</h3><ul>
<li>iec60730_WatchdogValid
: <a class="el" href="group__IEC60730__WDOG__Test.html#ggaece8bdb434f4c8bafba3590467815044a7f643e2fc022bee4149c82ec9c42f3ef">sl_iec60730_watchdog.h</a>
</li>
<<<<<<< HEAD:docs/html/EFR32_ICE60730_Libraries/globals.html
<li>SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_TEST
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#ga558de50fe1c89a1afb8292d2ee4346da">sl_iec60730.h</a>
</li>
Expand All @@ -391,19 +390,6 @@ <h3><a id="index_i"></a>- i -</h3><ul>
</li>
<li>SL_IEC60730_IMC_DATA_READ_BYTE_REVERSED
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba641228c714e8ef6fb667f3ee76761f22">sl_iec60730.h</a>
=======
<li>IMC_CRCBUFFER_SAMPLETEST
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#ga558de50fe1c89a1afb8292d2ee4346da">iec60730.h</a>
</li>
<li>IMC_DATA_READ
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba81e9d30c093158a799c13cf1d42df28a">iec60730.h</a>
</li>
<li>IMC_DATA_READ_BIT_REVERSED
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba14b98b0e584e8059ab9e3990ffe8e149">iec60730.h</a>
</li>
<li>IMC_DATA_READ_BYTE_REVERSED
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba641228c714e8ef6fb667f3ee76761f22">iec60730.h</a>
>>>>>>> develop:Doc/html/EFR32_ICE60730_Libraries/globals.html
</li>
<li>INV_CLASSB_PVAR
: <a class="el" href="group__IEC60730__POST.html#ga5e516d9dd091357c8ecb7ba3c10c7f9b">sl_iec60730.h</a>
Expand Down
5 changes: 0 additions & 5 deletions docs/html/EFR32_ICE60730_Libraries/globals_defs.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,8 @@ <h3><a id="index_i"></a>- i -</h3><ul>
<li>IEC60730_VMC_COMPLETE
: <a class="el" href="group__IEC60730__PROGRAMME__COUNTER.html#gac9c345ed684a034b5a5cb53efa21cc63">sl_iec60730.h</a>
</li>
<<<<<<< HEAD:docs/html/EFR32_ICE60730_Libraries/globals_defs.html
<li>SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_TEST
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#ga558de50fe1c89a1afb8292d2ee4346da">sl_iec60730.h</a>
=======
<li>IMC_CRCBUFFER_SAMPLETEST
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#ga558de50fe1c89a1afb8292d2ee4346da">iec60730.h</a>
>>>>>>> develop:Doc/html/EFR32_ICE60730_Libraries/globals_defs.html
</li>
<li>INV_CLASSB_PVAR
: <a class="el" href="group__IEC60730__POST.html#ga5e516d9dd091357c8ecb7ba3c10c7f9b">sl_iec60730.h</a>
Expand Down
11 changes: 0 additions & 11 deletions docs/html/EFR32_ICE60730_Libraries/globals_eval.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ <h3><a id="index_i"></a>- i -</h3><ul>
<li>iec60730_WatchdogValid
: <a class="el" href="group__IEC60730__WDOG__Test.html#ggaece8bdb434f4c8bafba3590467815044a7f643e2fc022bee4149c82ec9c42f3ef">sl_iec60730_watchdog.h</a>
</li>
<<<<<<< HEAD:docs/html/EFR32_ICE60730_Libraries/globals_eval.html
<li>SL_IEC60730_IMC_DATA_READ
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba81e9d30c093158a799c13cf1d42df28a">sl_iec60730.h</a>
</li>
Expand All @@ -178,16 +177,6 @@ <h3><a id="index_i"></a>- i -</h3><ul>
</li>
<li>SL_IEC60730_IMC_DATA_READ_BYTE_REVERSED
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba641228c714e8ef6fb667f3ee76761f22">sl_iec60730.h</a>
=======
<li>IMC_DATA_READ
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba81e9d30c093158a799c13cf1d42df28a">iec60730.h</a>
</li>
<li>IMC_DATA_READ_BIT_REVERSED
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba14b98b0e584e8059ab9e3990ffe8e149">iec60730.h</a>
</li>
<li>IMC_DATA_READ_BYTE_REVERSED
: <a class="el" href="group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba641228c714e8ef6fb667f3ee76761f22">iec60730.h</a>
>>>>>>> develop:Doc/html/EFR32_ICE60730_Libraries/globals_eval.html
</li>
</ul>
</div><!-- contents -->
Expand Down
7 changes: 0 additions & 7 deletions docs/html/EFR32_ICE60730_Libraries/search/all_9.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ad809c7

Please sign in to comment.