diff --git a/.gitignore b/.gitignore index 3a939434..4792ed03 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f4c5ee4..4fee3b5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,4 @@ string(REPLACE "$<$:SHELL:-imacros sl_gcc_preinclude.h>;" string(REPLACE "$<$: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() \ No newline at end of file diff --git a/cmake/generate_lib_iec60730.cmake b/cmake/generate_lib_iec60730.cmake new file mode 100644 index 00000000..fea10538 --- /dev/null +++ b/cmake/generate_lib_iec60730.cmake @@ -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) \ No newline at end of file diff --git a/cmake/unit_test_bist.cmake b/cmake/unit_test_bist.cmake new file mode 100644 index 00000000..5c33d4c4 --- /dev/null +++ b/cmake/unit_test_bist.cmake @@ -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 "$" "$/$.s37" + COMMAND ${CMAKE_OBJCOPY} -O ihex "$" "$/$.hex" + COMMAND ${CMAKE_OBJCOPY} -O binary "$" "$/$.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) + diff --git a/cmake/unit_test_post.cmake b/cmake/unit_test_post.cmake new file mode 100644 index 00000000..c59f4b52 --- /dev/null +++ b/cmake/unit_test_post.cmake @@ -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 "$" "$/$.s37" + COMMAND ${CMAKE_OBJCOPY} -O ihex "$" "$/$.hex" + COMMAND ${CMAKE_OBJCOPY} -O binary "$" "$/$.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) \ No newline at end of file diff --git a/components/iec60730_unit_test.slcc b/components/iec60730_unit_test.slcc new file mode 100644 index 00000000..36ffc5ff --- /dev/null +++ b/components/iec60730_unit_test.slcc @@ -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 diff --git a/docs/html/EFR32_ICE60730_Libraries/globals.html b/docs/html/EFR32_ICE60730_Libraries/globals.html index 69fccc27..8a82a15b 100644 --- a/docs/html/EFR32_ICE60730_Libraries/globals.html +++ b/docs/html/EFR32_ICE60730_Libraries/globals.html @@ -379,7 +379,6 @@

- i -

  • iec60730_WatchdogValid : sl_iec60730_watchdog.h
  • -<<<<<<< HEAD:docs/html/EFR32_ICE60730_Libraries/globals.html
  • SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_TEST : sl_iec60730.h
  • @@ -391,19 +390,6 @@

    - i -

    • SL_IEC60730_IMC_DATA_READ_BYTE_REVERSED : sl_iec60730.h -======= -
    • IMC_CRCBUFFER_SAMPLETEST -: iec60730.h -
    • -
    • IMC_DATA_READ -: iec60730.h -
    • -
    • IMC_DATA_READ_BIT_REVERSED -: iec60730.h -
    • -
    • IMC_DATA_READ_BYTE_REVERSED -: iec60730.h ->>>>>>> develop:Doc/html/EFR32_ICE60730_Libraries/globals.html
    • INV_CLASSB_PVAR : sl_iec60730.h diff --git a/docs/html/EFR32_ICE60730_Libraries/globals_defs.html b/docs/html/EFR32_ICE60730_Libraries/globals_defs.html index 241afb17..eaaa2383 100644 --- a/docs/html/EFR32_ICE60730_Libraries/globals_defs.html +++ b/docs/html/EFR32_ICE60730_Libraries/globals_defs.html @@ -175,13 +175,8 @@

      - i -

      • IEC60730_VMC_COMPLETE : sl_iec60730.h
      • -<<<<<<< HEAD:docs/html/EFR32_ICE60730_Libraries/globals_defs.html
      • SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_TEST : sl_iec60730.h -======= -
      • IMC_CRCBUFFER_SAMPLETEST -: iec60730.h ->>>>>>> develop:Doc/html/EFR32_ICE60730_Libraries/globals_defs.html
      • INV_CLASSB_PVAR : sl_iec60730.h diff --git a/docs/html/EFR32_ICE60730_Libraries/globals_eval.html b/docs/html/EFR32_ICE60730_Libraries/globals_eval.html index 1b27eb60..2782328c 100644 --- a/docs/html/EFR32_ICE60730_Libraries/globals_eval.html +++ b/docs/html/EFR32_ICE60730_Libraries/globals_eval.html @@ -169,7 +169,6 @@

        - i -

        • iec60730_WatchdogValid : sl_iec60730_watchdog.h
        • -<<<<<<< HEAD:docs/html/EFR32_ICE60730_Libraries/globals_eval.html
        • SL_IEC60730_IMC_DATA_READ : sl_iec60730.h
        • @@ -178,16 +177,6 @@

          - i -

          • SL_IEC60730_IMC_DATA_READ_BYTE_REVERSED : sl_iec60730.h -======= -
          • IMC_DATA_READ -: iec60730.h -
          • -
          • IMC_DATA_READ_BIT_REVERSED -: iec60730.h -
          • -
          • IMC_DATA_READ_BYTE_REVERSED -: iec60730.h ->>>>>>> develop:Doc/html/EFR32_ICE60730_Libraries/globals_eval.html
          diff --git a/docs/html/EFR32_ICE60730_Libraries/search/all_9.js b/docs/html/EFR32_ICE60730_Libraries/search/all_9.js index 09f33e4f..66233dd8 100644 --- a/docs/html/EFR32_ICE60730_Libraries/search/all_9.js +++ b/docs/html/EFR32_ICE60730_Libraries/search/all_9.js @@ -113,17 +113,10 @@ var searchData= ['iec60730_5fwatchdogtesting_149',['iec60730_WatchdogTesting',['../group__IEC60730__WDOG__Test.html#ggaece8bdb434f4c8bafba3590467815044a5d9a9cd963dc0a0bbccd807d674bffe9',1,'sl_iec60730_watchdog.h']]], ['iec60730_5fwatchdogvalid_150',['iec60730_WatchdogValid',['../group__IEC60730__WDOG__Test.html#ggaece8bdb434f4c8bafba3590467815044a7f643e2fc022bee4149c82ec9c42f3ef',1,'sl_iec60730_watchdog.h']]], ['iec60730testbase_151',['iec60730TestBase',['../classiec60730__test__base_1_1iec60730TestBase.html',1,'iec60730_test_base']]], -<<<<<<< HEAD:docs/html/EFR32_ICE60730_Libraries/search/all_9.js ['imc_5fcrcbuffer_5fsampletest_152',['SL_IEC60730_IMC_CRC_BUFFER_SAMPLE_TEST',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#ga558de50fe1c89a1afb8292d2ee4346da',1,'sl_iec60730.h']]], ['imc_5fdata_5fread_153',['SL_IEC60730_IMC_DATA_READ',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba81e9d30c093158a799c13cf1d42df28a',1,'sl_iec60730.h']]], ['imc_5fdata_5fread_5fbit_5freversed_154',['SL_IEC60730_IMC_DATA_READ_BIT_REVERSED',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba14b98b0e584e8059ab9e3990ffe8e149',1,'sl_iec60730.h']]], ['imc_5fdata_5fread_5fbyte_5freversed_155',['SL_IEC60730_IMC_DATA_READ_BYTE_REVERSED',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba641228c714e8ef6fb667f3ee76761f22',1,'sl_iec60730.h']]], -======= - ['imc_5fcrcbuffer_5fsampletest_152',['IMC_CRCBUFFER_SAMPLETEST',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#ga558de50fe1c89a1afb8292d2ee4346da',1,'iec60730.h']]], - ['imc_5fdata_5fread_153',['IMC_DATA_READ',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba81e9d30c093158a799c13cf1d42df28a',1,'iec60730.h']]], - ['imc_5fdata_5fread_5fbit_5freversed_154',['IMC_DATA_READ_BIT_REVERSED',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba14b98b0e584e8059ab9e3990ffe8e149',1,'iec60730.h']]], - ['imc_5fdata_5fread_5fbyte_5freversed_155',['IMC_DATA_READ_BYTE_REVERSED',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba641228c714e8ef6fb667f3ee76761f22',1,'iec60730.h']]], ->>>>>>> develop:Doc/html/EFR32_ICE60730_Libraries/search/all_9.js ['imcparams_5ft_156',['imcParams_t',['../structimcParams__t.html',1,'']]], ['init_157',['init',['../structupdateCrcParams__t.html#abcc7407def14860e8e7937ca993327cb',1,'updateCrcParams_t']]], ['inv_5fclassb_5fpvar_158',['INV_CLASSB_PVAR',['../group__IEC60730__POST.html#ga5e516d9dd091357c8ecb7ba3c10c7f9b',1,'sl_iec60730.h']]], diff --git a/docs/html/EFR32_ICE60730_Libraries/search/enumvalues_0.js b/docs/html/EFR32_ICE60730_Libraries/search/enumvalues_0.js index b7ca7363..b4b6ed3e 100644 --- a/docs/html/EFR32_ICE60730_Libraries/search/enumvalues_0.js +++ b/docs/html/EFR32_ICE60730_Libraries/search/enumvalues_0.js @@ -1,6 +1,5 @@ var searchData= [ -<<<<<<< HEAD:docs/html/EFR32_ICE60730_Libraries/search/enumvalues_0.js ['iec60730_5fanalogfail_525',['iec60730_AnalogFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a20099345d848be169d47f829ae6a0336',1,'sl_iec60730.h']]], ['iec60730_5fclockfail_526',['iec60730_ClockFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ad003937e7ee5395df23045f964f3749c',1,'sl_iec60730.h']]], ['iec60730_5fcpuregistersfail_527',['iec60730_CpuRegistersFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023af5015ade87ec06e17e02167377e10e3e',1,'sl_iec60730.h']]], @@ -39,44 +38,4 @@ var searchData= ['imc_5fdata_5fread_560',['SL_IEC60730_IMC_DATA_READ',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba81e9d30c093158a799c13cf1d42df28a',1,'sl_iec60730.h']]], ['imc_5fdata_5fread_5fbit_5freversed_561',['SL_IEC60730_IMC_DATA_READ_BIT_REVERSED',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba14b98b0e584e8059ab9e3990ffe8e149',1,'sl_iec60730.h']]], ['imc_5fdata_5fread_5fbyte_5freversed_562',['SL_IEC60730_IMC_DATA_READ_BYTE_REVERSED',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba641228c714e8ef6fb667f3ee76761f22',1,'sl_iec60730.h']]] -======= - ['iec60730_5fanalogfail_525',['iec60730_AnalogFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a20099345d848be169d47f829ae6a0336',1,'iec60730.h']]], - ['iec60730_5fclockfail_526',['iec60730_ClockFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ad003937e7ee5395df23045f964f3749c',1,'iec60730.h']]], - ['iec60730_5fcpuregistersfail_527',['iec60730_CpuRegistersFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023af5015ade87ec06e17e02167377e10e3e',1,'iec60730.h']]], - ['iec60730_5fcs0fail_528',['iec60730_Cs0Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ae13ecaf8f999311eeab49158b67bf6ed',1,'iec60730.h']]], - ['iec60730_5feuart0fail_529',['iec60730_Euart0Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023afb8e8e8231785b81e00711b3fe84fab6',1,'iec60730.h']]], - ['iec60730_5fgpiofail_530',['iec60730_GpioFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023afef1b5d3f282d2caea3db8d9fb8cee3d',1,'iec60730.h']]], - ['iec60730_5fi2c0fail_531',['iec60730_I2C0Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a04b440e5e7bd688fab1a429ef6e46972',1,'iec60730.h']]], - ['iec60730_5fi2c1fail_532',['iec60730_I2C1Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ac82d6bf3316e7aa84fabec0e68f33c3d',1,'iec60730.h']]], - ['iec60730_5fimcfail_533',['iec60730_IMCFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a00fa8cb85279e95b80245257295d1eb4',1,'iec60730.h']]], - ['iec60730_5finterruptfail_534',['iec60730_InterruptFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ad57c493440d16f911ef6c0fdfe03db3d',1,'iec60730.h']]], - ['iec60730_5flesense0fail_535',['iec60730_LeSense0Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ac87264cca086949be9c9aa9daea6b0a9',1,'iec60730.h']]], - ['iec60730_5fleuart0fail_536',['iec60730_LeUart0Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ada4e6b4f9c673b0d3c806faf59fe6fa8',1,'iec60730.h']]], - ['iec60730_5fnofailure_537',['iec60730_NoFailure',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a7afc614dedb7ebd805585fab8a83dda8',1,'iec60730.h']]], - ['iec60730_5foemfail_5f1_538',['iec60730_OEMFail_1',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a7c05b7386df07953405727367f758f5c',1,'iec60730.h']]], - ['iec60730_5foemfail_5f2_539',['iec60730_OEMFail_2',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a1722b60782680dfc96a7483bf840e1cf',1,'iec60730.h']]], - ['iec60730_5foemfail_5f3_540',['iec60730_OEMFail_3',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a4a75cdefcb04ee50969580efe5bcef75',1,'iec60730.h']]], - ['iec60730_5foemfail_5f4_541',['iec60730_OEMFail_4',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a6809805b6bbebc7280405b5d0a59f4c1',1,'iec60730.h']]], - ['iec60730_5fpdm0fail_542',['iec60730_Pdm0Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a88f37f65231d879973c84ef81a10f843',1,'iec60730.h']]], - ['iec60730_5fprogrammecounterfail_543',['iec60730_ProgrammeCounterFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a8f2d4992410253abe701c4d543937f6b',1,'iec60730.h']]], - ['iec60730_5fradiofail_544',['iec60730_RadioFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a8519cb420d2b3566c90c464d1dd98704',1,'iec60730.h']]], - ['iec60730_5ftestfailed_545',['iec60730_TestFailed',['../group__IEC60730__POST.html#gga15a78a582ee2ef5999615f3a64d26741a26db973cd4fdebd964685ce701486450',1,'iec60730.h']]], - ['iec60730_5ftestinprogress_546',['iec60730_TestInProgress',['../group__IEC60730__POST.html#gga15a78a582ee2ef5999615f3a64d26741a60b3c9c488facdb917c35ffca92960f9',1,'iec60730.h']]], - ['iec60730_5ftestpassed_547',['iec60730_TestPassed',['../group__IEC60730__POST.html#gga15a78a582ee2ef5999615f3a64d26741a6796830621fbae14b5c78b4a36af1b84',1,'iec60730.h']]], - ['iec60730_5ftestverify_548',['iec60730_TestVerify',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a2dfe01a597b96f83096e9667eb51617c',1,'iec60730.h']]], - ['iec60730_5ftimertestdisable_549',['iec60730_TimerTestDisable',['../group__IEC60730__SYSTEM__CLOCK__Test.html#gga5d9503d6c07fff2f4cf1ace3cb59c989a0ca88c5af3c7f609332ca92e279a3db1',1,'iec60730.h']]], - ['iec60730_5ftimertestenable_550',['iec60730_TimerTestEnable',['../group__IEC60730__SYSTEM__CLOCK__Test.html#gga5d9503d6c07fff2f4cf1ace3cb59c989a047379c994d751fca75b338a81569d74',1,'iec60730.h']]], - ['iec60730_5fusart0fail_551',['iec60730_Usart0Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a7a06d9691ab6362b3b9e1c520c66acdf',1,'iec60730.h']]], - ['iec60730_5fusart1fail_552',['iec60730_Usart1Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ab7190b1b31e1dd7e364e8a4b5910a9db',1,'iec60730.h']]], - ['iec60730_5fusart2fail_553',['iec60730_Usart2Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a11b62da15bc0da8e734f3a8b932d5c53',1,'iec60730.h']]], - ['iec60730_5fusart3fail_554',['iec60730_Usart3Fail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a96d303448c3808f6980700ffd24b93a9',1,'iec60730.h']]], - ['iec60730_5fvmcfail_555',['iec60730_VMCFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023ac4a9584420d98b8a3ea0846ac5b40f82',1,'iec60730.h']]], - ['iec60730_5fwatchdoginvalid_556',['iec60730_WatchdogInvalid',['../group__IEC60730__WDOG__Test.html#ggaece8bdb434f4c8bafba3590467815044a3dbff590e48b57859ec08cfff6c6812b',1,'iec60730_watchdog.h']]], - ['iec60730_5fwatchdogpostfail_557',['iec60730_WatchdogPostFail',['../group__IEC60730__POST.html#ggab423b676af8982b70e767164f1574023a25dd32462cffeb3067f286e07f87c27d',1,'iec60730.h']]], - ['iec60730_5fwatchdogtesting_558',['iec60730_WatchdogTesting',['../group__IEC60730__WDOG__Test.html#ggaece8bdb434f4c8bafba3590467815044a5d9a9cd963dc0a0bbccd807d674bffe9',1,'iec60730_watchdog.h']]], - ['iec60730_5fwatchdogvalid_559',['iec60730_WatchdogValid',['../group__IEC60730__WDOG__Test.html#ggaece8bdb434f4c8bafba3590467815044a7f643e2fc022bee4149c82ec9c42f3ef',1,'iec60730_watchdog.h']]], - ['imc_5fdata_5fread_560',['IMC_DATA_READ',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba81e9d30c093158a799c13cf1d42df28a',1,'iec60730.h']]], - ['imc_5fdata_5fread_5fbit_5freversed_561',['IMC_DATA_READ_BIT_REVERSED',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba14b98b0e584e8059ab9e3990ffe8e149',1,'iec60730.h']]], - ['imc_5fdata_5fread_5fbyte_5freversed_562',['IMC_DATA_READ_BYTE_REVERSED',['../group__IEC60730__INVARIABLE__MEMORY__Test.html#gga06fc87d81c62e9abb8790b6e5713c55ba641228c714e8ef6fb667f3ee76761f22',1,'iec60730.h']]] ->>>>>>> develop:Doc/html/EFR32_ICE60730_Libraries/search/enumvalues_0.js ]; diff --git a/gecko_sdk/lib_iec60730.slcp b/gecko_sdk/lib_iec60730.slcp index d872ba02..3277ecca 100644 --- a/gecko_sdk/lib_iec60730.slcp +++ b/gecko_sdk/lib_iec60730.slcp @@ -1,9 +1,9 @@ project_name: lib_iec60730 package: iec60730 quality: test -label: Souce code lib IEC60730 for unit test +label: Source code lib IEC60730 for unit test description: > - Souce code lib IEC60730 for unit test. + Source code lib IEC60730 for unit test. category: Example|iec60730 sdk: {id: gecko_sdk, version: 4.4.2} @@ -56,4 +56,4 @@ toolchain_settings: - option: iar_linker_option value: "--keep __checksum --place_holder __checksum,2,.checksum,64" condition: - - toolchain_iar + - toolchain_iar \ No newline at end of file diff --git a/test/test_script/Readme.txt b/test/test_script/Readme.txt index 4d2b7352..bcc3932c 100644 --- a/test/test_script/Readme.txt +++ b/test/test_script/Readme.txt @@ -1,13 +1,13 @@ 1 #Before run -export CHIP=EFR32MG21AXXXF1024 ADAPTER_SN=440043402 -export LST_PATH=~/devs_efx32_iec60730/Build/cpu_registers/efr32mg21/efr32mg21a020f1024im32/Out +export CHIP=EFR32MG21AXXXF1024 ADAPTER_SN=440043402 +export LST_PATH=~/devs_efx32_iec60730/Build/cpu_registers/efr32mg21/efr32mg21a020f1024im32/Out export JLINK_PATH=/opt/SEGGER/JLink/libjlinkarm.so #Run python3 iec60730_programme_counter.py -2. #Or +2. #Or CHIP=EFR32MG21AXXXF1024 ADAPTER_SN=440043402 LST_PATH=/home/admin-wfh/Downloads/devs_efx32_iec60730/Build/cpu_registers/efr32mg21/efr32mg21a020f1024im32/Out JLINK_PATH=/opt/SEGGER/JLink/libjlinkarm.so python3 iec60730_programme_counter.py diff --git a/test/test_script/iec60730_get_report_unit_test.py b/test/test_script/iec60730_get_report_unit_test.py index c73f1c14..852f41f0 100644 --- a/test/test_script/iec60730_get_report_unit_test.py +++ b/test/test_script/iec60730_get_report_unit_test.py @@ -66,9 +66,9 @@ def get_report_unit_test(result,file_test_case,log_report): list_test_case = get_test_case(file_test_case,logger,unity_begin_row,unity_end_row) if len(list_test_case) != len(result): - raise ValueError("The list of test cases " + str(len(list_test_case)) + " in the file" - + file_test + "is not equal " + str(len(result)) + " test cases" - "results received from device") + raise ValueError("The list of test cases " + str(len(list_test_case)) + " in the file" + + file_test + " is not equal " + str(len(result)) + " test cases" + " results received from device") for test_case in list_test_case: index = list_test_case.index(test_case) @@ -77,11 +77,10 @@ def get_report_unit_test(result,file_test_case,log_report): logger.info(file_test + ":" + test_case[2] + ":" + test_case[0] + ":PASS") else: test_fail +=1 - logger.info(file_test + ":" + test_case[2] + ":" + test_case[0] + ":FAIL") - logger.info("\n----------------------------------------------------------------------\n") - logger.info(str(len(list_test_case)) + " Tests " + str(test_fail) + " Failures ") + logger.info(file_test + ":" + test_case[2] + ":" + test_case[0] + ":FAIL") + logger.info("\n----------------------------------------------------------------------") + logger.info(str(len(list_test_case)) + " Tests " + str(test_fail) + " Failures") if test_fail != 0: - logger.info("FAIL") - else: - logger.info("PASS") - + logger.info("FAIL") + else: + logger.info("PASS") diff --git a/test/test_script/unit_test_iec60730_bist.py b/test/test_script/unit_test_iec60730_bist.py new file mode 100644 index 00000000..4c7ac274 --- /dev/null +++ b/test/test_script/unit_test_iec60730_bist.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# License +# Copyright 2021 Silicon Laboratories Inc. www.silabs.com +# ******************************************************************************* +# +# The licensor of this software is Silicon Laboratories Inc. Your use of this +# software is governed by the terms of Silicon Labs Master Software License +# Agreement (MSLA) available at +# www.silabs.com/about-us/legal/master-software-license-agreement. This +# software is distributed to you in Source Code format and is governed by the +# sections of the MSLA applicable to Source Code. +# ******************************************************************************* + +from binascii import hexlify +import random +import os +import sys +from time import sleep + +from iec60730_get_report_unit_test import * +from iec60730_test_base import * +import jlink, jlink_constants +import unittest +import enums + +def int_to_bytes(number: int) -> bytes: + return number.to_bytes(length=(8 + (number + (number < 0)).bit_length()) // 8, byteorder='big', signed=True) + + +## IEC60730 get unit test result +# +# @details This class runs IEC60730 get unit test results +# +# Hardware setup: +# Connect DUT to PC. No additional hardware setup required. + +class iec60730_unit_test_result(unittest.TestCase, iec60730TestBase): + + def get_unit_test_result(self): + def get_result(self): + self.adapter.halt() + self.adapter.clear_all_breakpoints() + + self.adapter.set_breakpoint(address = asm_labels['IEC60730_UNIT_TEST_END'], + typeflags=enums.JLinkBreakpoint.ANY) + + self.adapter.reset() + pc = self.adapter.run_to_breakpoint(3) + logging.info("Halted at label: " + self.get_label(pc)) + self.assertEqual(pc, asm_labels['IEC60730_UNIT_TEST_END'],\ + "DUT failed to stop at IEC60730_UNIT_TEST_END" \ + " , pc = " + hex(pc)) + #logging.info("Halted at label: " + self.get_label(pc)) + current_test_numth = variables['current_test_numth'] + self.assertNotEqual(0, current_test_numth,\ + "Can not read current_test_numth address") + reg = self.adapter.memory_read8(current_test_numth, 1, zone=None) + + current_test_numth = variables['current_test_numth'] + self.assertNotEqual(0, current_test_numth,\ + "Can not read current_test_numth address") + current_test_numth = self.adapter.memory_read8(current_test_numth, 1, zone=None) + + test_case_result = variables['test_case_result'] + self.assertNotEqual(0, test_case_result,\ + "Can not read test_case_result address") + result = self.adapter.memory_read(test_case_result,current_test_numth[0]) + return result + def connect_device(self): + self.pre_exec_test() + logging.info("----------------- Start get unit test result") + result = get_result(self) + logging.info("Get unit test result: Done. See unit_test_report.log") + logging.info("----------------- End get unit test result") + self.post_exec_test() + file_test_case = "../unit_test/src/unit_test_iec60730_bist.c" + log_report = '../../log/unit_test_iec60730_bist.log' + get_report_unit_test(result,file_test_case,log_report) + return connect_device(self) + +if __name__ == "__main__": + + chip_name = os.getenv('CHIP') + + app_type = os.getenv('APP_TYPE') + + lst_file_path = os.getenv('LST_PATH') + + adapter_serial_no = os.getenv('ADAPTER_SN') + + lib_path = os.getenv('JLINK_PATH') + + while len(sys.argv) > 1: + line = sys.argv.pop() + if len(sys.argv) == 1: + compiler = line + + print("Compiler: "+compiler) + + iec60730_unit_test_result = iec60730_unit_test_result() + iec60730_unit_test_result.env_setup(adapter_serial_no, + chip_name, + lst_file_path, + lib_path, + app_type, + compiler) + iec60730_unit_test_result.get_unit_test_result() + +## @} +# @} diff --git a/test/test_script/unit_test_iec60730_post.py b/test/test_script/unit_test_iec60730_post.py new file mode 100644 index 00000000..9ac7bdf4 --- /dev/null +++ b/test/test_script/unit_test_iec60730_post.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# License +# Copyright 2021 Silicon Laboratories Inc. www.silabs.com +# ******************************************************************************* +# +# The licensor of this software is Silicon Laboratories Inc. Your use of this +# software is governed by the terms of Silicon Labs Master Software License +# Agreement (MSLA) available at +# www.silabs.com/about-us/legal/master-software-license-agreement. This +# software is distributed to you in Source Code format and is governed by the +# sections of the MSLA applicable to Source Code. +# ******************************************************************************* + +from binascii import hexlify +import random +import os +import sys +from time import sleep + +from iec60730_get_report_unit_test import * +from iec60730_test_base import * +import jlink, jlink_constants +import unittest +import enums + +def int_to_bytes(number: int) -> bytes: + return number.to_bytes(length=(8 + (number + (number < 0)).bit_length()) // 8, byteorder='big', signed=True) + + +## IEC60730 get unit test result +# +# @details This class runs IEC60730 get unit test results +# +# Hardware setup: +# Connect DUT to PC. No additional hardware setup required. + +class iec60730_unit_test_result(unittest.TestCase, iec60730TestBase): + + def get_unit_test_result(self): + def get_result(self): + self.adapter.halt() + self.adapter.clear_all_breakpoints() + + self.adapter.set_breakpoint(address = asm_labels['IEC60730_UNIT_TEST_END'], + typeflags=enums.JLinkBreakpoint.ANY) + + self.adapter.reset() + pc = self.adapter.run_to_breakpoint(3) + logging.info("Halted at label: " + self.get_label(pc)) + self.assertEqual(pc, asm_labels['IEC60730_UNIT_TEST_END'],\ + "DUT failed to stop at IEC60730_UNIT_TEST_END" \ + " , pc = " + hex(pc)) + #logging.info("Halted at label: " + self.get_label(pc)) + current_test_numth = variables['current_test_numth'] + self.assertNotEqual(0, current_test_numth,\ + "Can not read current_test_numth address") + reg = self.adapter.memory_read8(current_test_numth, 1, zone=None) + + current_test_numth = variables['current_test_numth'] + self.assertNotEqual(0, current_test_numth,\ + "Can not read current_test_numth address") + current_test_numth = self.adapter.memory_read8(current_test_numth, 1, zone=None) + + test_case_result = variables['test_case_result'] + self.assertNotEqual(0, test_case_result,\ + "Can not read test_case_result address") + result = self.adapter.memory_read(test_case_result,current_test_numth[0]) + return result + def connect_device(self): + self.pre_exec_test() + logging.info("----------------- Start get unit test result") + result = get_result(self) + logging.info("Get unit test result: Done. See unit_test_report.log") + logging.info("----------------- End get unit test result") + self.post_exec_test() + file_test_case = "../unit_test/src/unit_test_iec60730_post.c" + log_report = '../../log/unit_test_iec60730_post.log' + get_report_unit_test(result,file_test_case,log_report) + return connect_device(self) + +if __name__ == "__main__": + + chip_name = os.getenv('CHIP') + + app_type = os.getenv('APP_TYPE') + + lst_file_path = os.getenv('LST_PATH') + + adapter_serial_no = os.getenv('ADAPTER_SN') + + lib_path = os.getenv('JLINK_PATH') + + while len(sys.argv) > 1: + line = sys.argv.pop() + if len(sys.argv) == 1: + compiler = line + + print("Compiler: "+compiler) + + iec60730_unit_test_result = iec60730_unit_test_result() + iec60730_unit_test_result.env_setup(adapter_serial_no, + chip_name, + lst_file_path, + lib_path, + app_type, + compiler) + iec60730_unit_test_result.get_unit_test_result() + +## @} +# @} diff --git a/test/unit_test/CMakeLists.txt b/test/unit_test/CMakeLists.txt index c8d1b168..02e5e801 100644 --- a/test/unit_test/CMakeLists.txt +++ b/test/unit_test/CMakeLists.txt @@ -1,52 +1,17 @@ +# unit test info set(UNIT_TEST_INFO "unit_test_info") -set(UNIT_TEST_COMPONENT "module_demo") +set(UNIT_TEST_COMPONENT "unit_test_iec60730_post unit_test_iec60730_bist") add_custom_target(${UNIT_TEST_INFO} - COMMAND echo "Components list: ${UNIT_TEST_COMPONENT}" || (exit 0) + COMMAND echo "Components list: ${UNIT_TEST_COMPONENT}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ ) +include(unit_test_post) +include(unit_test_bist) -set(UNIT_TEST_MODULE_DEMO "unit_test_iec60730_module_demo") -set(UNIT_TEST_MODULE_DEMO_BUILD_DIR "build/moule_demo") -set(UNIT_TEST_SOURCES - "./src/main.c" - "./src/app.c" - "./src/test_common.c" - "./src/test_iec60730_module_demo.c" -) -set(UNIT_TEST_INCLUDES "./inc" - ${UNITY_HEADER}) - -set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Build) -add_executable(${UNIT_TEST_MODULE_DEMO} ${UNIT_TEST_SOURCES}) -target_include_directories(${UNIT_TEST_MODULE_DEMO} PUBLIC ${UNIT_TEST_INCLUDES}) - -target_link_libraries(${UNIT_TEST_MODULE_DEMO} PUBLIC unity slc_iostream_usart ) - -# Create .bin, .hex and .s37 artifacts after building the project -add_custom_command(TARGET ${UNIT_TEST_MODULE_DEMO} - POST_BUILD - COMMAND ${CMAKE_OBJCOPY} -O srec "$" "$/$.s37" - COMMAND ${CMAKE_OBJCOPY} -O ihex "$" "$/$.hex" - COMMAND ${CMAKE_OBJCOPY} -O binary "$" "$/$.bin" - COMMAND rm -rf ./build - COMMAND mkdir -p ${UNIT_TEST_MODULE_DEMO_BUILD_DIR} - COMMAND mv ${UNIT_TEST_MODULE_DEMO}.out ${UNIT_TEST_MODULE_DEMO_BUILD_DIR} - COMMAND mv ${UNIT_TEST_MODULE_DEMO}.bin ${UNIT_TEST_MODULE_DEMO_BUILD_DIR} - COMMAND mv ${UNIT_TEST_MODULE_DEMO}.hex ${UNIT_TEST_MODULE_DEMO_BUILD_DIR} - COMMAND mv ${UNIT_TEST_MODULE_DEMO}.s37 ${UNIT_TEST_MODULE_DEMO_BUILD_DIR} -) - -set(post_build_command ${CMAKE_OBJDUMP} -t -h -d -S ${UNIT_TEST_MODULE_DEMO_BUILD_DIR}/${UNIT_TEST_MODULE_DEMO}.out > ${UNIT_TEST_MODULE_DEMO_BUILD_DIR}/${UNIT_TEST_MODULE_DEMO}.lst) - -# Run post-build pipeline to perform additional post-processing -if(post_build_command) -add_custom_command(TARGET ${UNIT_TEST_MODULE_DEMO} - POST_BUILD - COMMAND ${post_build_command} -) -endif() +generate_unit_test_iec60730_post(test/unit_test) +generate_unit_test_iec60730_bist(test/unit_test) if(${CORE_TYPE} MATCHES "cortex-m33") target_compile_options(unity PUBLIC @@ -66,4 +31,4 @@ target_compile_options(unity PUBLIC $<$:-Wall> $<$:-Wextra> $<$:-Os>) -endif() +endif() \ No newline at end of file diff --git a/test/unit_test/inc/unit_test_common.h b/test/unit_test/inc/unit_test_common.h new file mode 100644 index 00000000..e28bcfee --- /dev/null +++ b/test/unit_test/inc/unit_test_common.h @@ -0,0 +1,42 @@ +/***************************************************************************//** + * @file + * @brief common unit test api + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#ifndef _TEST_COMMON_H +#define _TEST_COMMON_H + +#include +#include +#include "unity.h" + +/*=======Result test case=====*/ +#define MAX_NUMBER_OF_TEST_CASE 20 + +extern uint8_t test_case_result[MAX_NUMBER_OF_TEST_CASE]; +extern uint8_t current_test_numth; + +/*=======Test Runner Used To Run Each Test=====*/ +extern void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num); +/*=======Test Reset Options=====*/ +extern void setUp(void); +extern void tearDown(void); +extern void resetTest(void); +/*=======Mock Management=====*/ +extern void cmock_set_value(int value); +extern int cmock_return_value(void); + + +#endif // _TEST_COMMON_H diff --git a/test/unit_test/inc/unit_test_iec60730_bist.h b/test/unit_test/inc/unit_test_iec60730_bist.h new file mode 100644 index 00000000..81e14b4a --- /dev/null +++ b/test/unit_test/inc/unit_test_iec60730_bist.h @@ -0,0 +1,83 @@ +/***************************************************************************/ /** + * @file test_bist.h + * @brief Unit test function sl_iec60730_bist(). + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +/**************************************************************************/ /** + * @addtogroup IEC60730_VERIFICATION + * @{ + * @defgroup IEC60730_BIST_VERIFICATION_UNIT_TEST Bist Verification Unit Tests + * @{ + * Header file list of test cases for the Verification operate function sl_iec60730_bist(). + * + ******************************************************************************/ + +#ifndef UNIT_TEST_IEC60730_BIST_H +#define UNIT_TEST_IEC60730_BIST_H + +/*======= External Functions =====*/ + +/**************************************************************************/ /** + * IEC60730 BIST Unit Tests + * + * @details These test cases run unit tests to check the operation of the function sl_iec60730_bist() + * + * Hardware setup: + * Connect DUT to PC. No additional hardware setup required. + ******************************************************************************/ + +/**************************************************************************/ /** + * Public Check sl_iec60730_bist() operate + * + * @returns None. + * If bool is_function_called variable equal false. + * It means test result rountine of sl_iec60730_bist is a pass, function sl_iec60730_safe_state() is not called. + * + *****************************************************************************/ +void test_sl_iec60730_bist_pass_all_check_condition(void); + +/**************************************************************************/ /** + * Public Check sl_iec60730_bist() operate + * + * @returns None. + * If bool is_function_called variable true. It means test result rountine + * of sl_iec60730_bist is a failure, function sl_iec60730_safe_state() is called. + * + *****************************************************************************/ +void test_sl_iec60730_bist_failed_check_condition(void); + +/**************************************************************************/ /** + * Public Check sl_iec60730_bist() operate + * + * @returns None. + * If bool is_function_called variable true, and iec60730_safety_check is not equal IEC60730_NO_FAILURE. + * It means test result rountine of sl_iec60730_bist is a failure, function sl_iec60730_safe_state() is called. + * + *****************************************************************************/ +void test_iec60730_SafetyCheck_is_failed(void); + +/**************************************************************************/ /** + * Public Funtion run all test cases above + * + * @returns None. + * + * Funtion runs all unit test cases of the function sl_iec60730_bist() + *****************************************************************************/ +extern void unit_test_iec60730_bist(void); + +#endif // UNIT_TEST_IEC60730_BIST_H + +/** @} (end defgroup IEC60730_BIST_VERIFICATION_UNIT_TEST) */ +/** @} (end addtogroup IEC60730_VERIFICATION) */ \ No newline at end of file diff --git a/test/unit_test/inc/unit_test_iec60730_post.h b/test/unit_test/inc/unit_test_iec60730_post.h new file mode 100644 index 00000000..d8bce5bb --- /dev/null +++ b/test/unit_test/inc/unit_test_iec60730_post.h @@ -0,0 +1,73 @@ +/***************************************************************************/ /** + * @file test_post.h + * @brief Unit test function iec60730_Post(). + ******************************************************************************* + * # License + * Copyright 2023 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +/**************************************************************************/ /** + * @addtogroup IEC60730_VERIFICATION + * @{ + * @defgroup IEC60730_POST_VERIFICATION_UNIT_TEST Post Verification Unit Tests + * @{ + * Header file list of test cases for the Verification operate function sl_iec60730_post(). + * + ******************************************************************************/ + +#ifndef UNIT_TEST_IEC60730_POST_H +#define UNIT_TEST_IEC60730_POST_H + +/*======= External Functions =====*/ + +/**************************************************************************/ /** + * IEC60730 POST Unit Tests + * + * @details These test cases run unit tests to check the operation of the function sl_iec60730_post() + * + * Hardware setup: + * Connect DUT to PC. No additional hardware setup required. + ******************************************************************************/ + +/**************************************************************************/ /** + * Public Check sl_iec60730_post() operate + * + * @returns None. + * If bool is_function_called variable equal false. It means test result rountine of sl_iec60730_post + * is a pass, function sl_iec60730_safe_state() is not called. So timer support test is enabled. + * + *****************************************************************************/ +void test_sl_iec60730_post_pass_all_check_condition(void); + +/**************************************************************************/ /** + * Public Check sl_iec60730_post() operate + * + * @returns None. + * If bool is_function_called variable true. It means test result rountine of sl_iec60730_post + * is a failure, function sl_iec60730_safe_state() is called. + * + *****************************************************************************/ +void test_sl_iec60730_post_failed_check_condition(void); + +/**************************************************************************/ /** + * Public Funtion run all test cases above + * + * @returns None. + * + * Funtion runs all unit test cases of the function sl_iec60730_post() + *****************************************************************************/ +extern void unit_test_iec60730_post(void); + +#endif // UNIT_TEST_IEC60730_POST_H + +/** @} (end defgroup IEC60730_POST_VERIFICATION_UNIT_TEST) */ +/** @} (end addtogroup IEC60730_VERIFICATION) */ diff --git a/test/unit_test/src/app.c b/test/unit_test/src/app.c index 53f405cd..4282b490 100644 --- a/test/unit_test/src/app.c +++ b/test/unit_test/src/app.c @@ -15,15 +15,31 @@ * ******************************************************************************/ -#include "test_common.h" -#include "test_iec60730_module_demo.h" +#include "unit_test_common.h" + +#ifdef UNIT_TEST_IEC60730_POST_ENABLE +#include "unit_test_iec60730_post.h" +#endif + +#ifdef UNIT_TEST_IEC60730_BIST_ENABLE +#include "unit_test_iec60730_bist.h" +#endif + void app_init(void) { - test_iec60730_module_demo(); + +#ifdef UNIT_TEST_IEC60730_POST_ENABLE + unit_test_iec60730_post(); +#endif + +#ifdef UNIT_TEST_IEC60730_BIST_ENABLE + unit_test_iec60730_bist(); +#endif + } void app_process_action(void) { -} +} \ No newline at end of file diff --git a/test/unit_test/src/unit_test_common.c b/test/unit_test/src/unit_test_common.c new file mode 100644 index 00000000..512c68d6 --- /dev/null +++ b/test/unit_test/src/unit_test_common.c @@ -0,0 +1,98 @@ +/***************************************************************************//** + * @file + * @brief common unit test api + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#include "unit_test_common.h" + +/*=======Result test case=====*/ + +uint8_t test_case_result[MAX_NUMBER_OF_TEST_CASE]; +uint8_t current_test_numth; +static uint8_t cmock_value_return; + +/*=======Mock Management=====*/ +static void cmock_init(void) +{ +} +static void cmock_verify(void) +{ +} +static void cmock_destroy(void) +{ +} + +void cmock_set_value(int value) +{ + cmock_value_return = value; +} + +int cmock_return_value(void) +{ + return cmock_value_return; +} +/*=======Test Reset Options=====*/ +void setUp(void) +{ +} + +void tearDown(void) +{ +} + +void resetTest(void) +{ + tearDown(); + cmock_verify(); + cmock_destroy(); + cmock_init(); + setUp(); +} +void verifyTest(void); +void verifyTest(void) +{ + cmock_verify(); +} +/*=======Test Runner Used To Run Each Test=====*/ +void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) +{ + Unity.CurrentTestName = name; + Unity.CurrentTestLineNumber = line_num; +#ifdef UNITY_USE_COMMAND_LINE_ARGS + if (!UnityTestMatches()) + return; +#endif + Unity.NumberOfTests++; + UNITY_CLR_DETAILS(); + UNITY_EXEC_TIME_START(); + cmock_init(); + if (TEST_PROTECT()) + { + setUp(); + func(); + } + if (TEST_PROTECT()) + { + tearDown(); + cmock_verify(); + } + cmock_destroy(); + UNITY_EXEC_TIME_STOP(); + + test_case_result[current_test_numth++] = Unity.CurrentTestFailed; + + UnityConcludeTest(); +} + diff --git a/test/unit_test/src/unit_test_iec60730_bist.c b/test/unit_test/src/unit_test_iec60730_bist.c new file mode 100644 index 00000000..0589d310 --- /dev/null +++ b/test/unit_test/src/unit_test_iec60730_bist.c @@ -0,0 +1,105 @@ +/***************************************************************************//** + * @file + * @brief Unit test bist + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#include "unit_test_common.h" +#include "unit_test_iec60730_bist.h" +#include "sl_iec60730_internal.h" + +/*=======Mock Code=====*/ +__no_init sl_iec60730_imc_params_t imc_unit_test __CLASSB_RAM; +__no_init sl_iec60730_vmc_params_t vmc_unit_test __CLASSB_RAM; +static bool is_function_called = false; + +__WEAK void sl_iec60730_safe_state(sl_iec60730_test_failure_t failure){ + (void)failure; + is_function_called = true; +} + +// Dump functions + +__WEAK sl_iec60730_test_result_t sl_iec60730_vmc_bist(void) +{ + return cmock_return_value(); +} + +__WEAK sl_iec60730_test_result_t sl_iec60730_imc_bist(void) +{ + return cmock_return_value(); +} + +__WEAK sl_iec60730_test_result_t sl_iec60730_cpu_registers_bist(void) +{ + return cmock_return_value(); +} + +__WEAK void sl_iec60730_restart_watchdogs(void) { + +} + +/*=======Test Case=====*/ +void test_sl_iec60730_bist_pass_all_check_condition(void) +{ + /*Setup*/ + is_function_called = false; + cmock_set_value(IEC60730_TEST_PASSED); + /*Execute test*/ + sl_iec60730_bist(); + TEST_ASSERT_EQUAL(false, is_function_called); +} + +void test_sl_iec60730_bist_failed_check_condition(void) +{ + /*Setup*/ + is_function_called = false; + cmock_set_value(IEC60730_TEST_FAILED); + /*Execute test*/ + sl_iec60730_bist(); + TEST_ASSERT_EQUAL(true, is_function_called); +} + +void test_iec60730_safety_check_error_occur(void) +{ + /*Setup*/ + is_function_called = false; + sl_iec60730_safety_check_error_occur(IEC60730_CLOCK_FAIL); + cmock_set_value(IEC60730_TEST_PASSED); + /*Execute test*/ + sl_iec60730_bist(); + TEST_ASSERT_EQUAL(true, is_function_called); +} + +/*=======Run Test Case=====*/ + +void unit_test_iec60730_bist(void) +{ + // Initialize + memset((void *)test_case_result, 0xff, sizeof(test_case_result)); + current_test_numth = 0; + + // Start run test + printf("--- BEGIN UNIT TEST ---\n"); + UnityBegin("/unit_test/src/unit_test_iec60730_bist.c"); + run_test(test_sl_iec60730_bist_pass_all_check_condition, "test_sl_iec60730_bist_pass_all_check_condition",54); + run_test(test_sl_iec60730_bist_failed_check_condition, "test_sl_iec60730_bist_failed_check_condition",64); + run_test(test_iec60730_safety_check_error_occur, "test_iec60730_safety_check_error_occur",74); + UnityEnd(); + __asm volatile("IEC60730_UNIT_TEST_END:"); + + while(1){ + // Do nothing + } +} \ No newline at end of file diff --git a/test/unit_test/src/unit_test_iec60730_post.c b/test/unit_test/src/unit_test_iec60730_post.c new file mode 100644 index 00000000..62ee9e90 --- /dev/null +++ b/test/unit_test/src/unit_test_iec60730_post.c @@ -0,0 +1,107 @@ +/***************************************************************************//** + * @file + * @brief Unit test post + ******************************************************************************* + * # License + * Copyright 2020 Silicon Laboratories Inc. www.silabs.com + ******************************************************************************* + * + * The licensor of this software is Silicon Laboratories Inc. Your use of this + * software is governed by the terms of Silicon Labs Master Software License + * Agreement (MSLA) available at + * www.silabs.com/about-us/legal/master-software-license-agreement. This + * software is distributed to you in Source Code format and is governed by the + * sections of the MSLA applicable to Source Code. + * + ******************************************************************************/ + +#include "unit_test_common.h" +#include "unit_test_iec60730_post.h" +#include "sl_iec60730_internal.h" + +/*=======Mock Code=====*/ +uint8_t iec60730_timer_test_control = SL_IEC60730_TIMER_TEST_ENABLE; +__no_init sl_iec60730_imc_params_t imc_unit_test __CLASSB_RAM; +__no_init sl_iec60730_vmc_params_t vmc_unit_test __CLASSB_RAM; +static bool is_function_called = false; + +__WEAK void sl_iec60730_safe_state(sl_iec60730_test_failure_t failure){ + (void)failure; + is_function_called = true; +} + +// Dump functions + +__WEAK sl_iec60730_test_result_t sl_iec60730_vmc_post(void) +{ + return cmock_return_value(); +} + +__WEAK sl_iec60730_test_result_t sl_iec60730_imc_post(void) +{ + return cmock_return_value(); +} + +__WEAK sl_iec60730_test_result_t sl_ec60730_cpu_registers_post(void) +{ + return cmock_return_value(); +} + +__WEAK sl_iec60730_test_result_t sl_iec60730_watchdog_post(void) +{ + return cmock_return_value(); +} + +__WEAK void sl_iec60730_safety_check_error_occur(sl_iec60730_test_failure_t failure) { + (void) failure; +} + +__WEAK void sl_iec60730_restart_watchdogs(void) { + +} + +__WEAK void sl_iec60730_sys_clock_test_enable(void) { + +} + +/*=======Test Case=====*/ +void test_sl_iec60730_post_pass_all_check_condition(void) +{ + /*Setup*/ + is_function_called = false; + cmock_set_value(IEC60730_TEST_PASSED); + /*Execute test*/ + sl_iec60730_post(); + TEST_ASSERT_EQUAL(false, is_function_called); +} + +void test_sl_iec60730_post_failed_check_condition(void) +{ + /*Setup*/ + is_function_called = false; + cmock_set_value(IEC60730_TEST_FAILED); + /*Execute test*/ + sl_iec60730_post(); + TEST_ASSERT_EQUAL(true, is_function_called); +} + +/*=======Run Test Case=====*/ + +void unit_test_iec60730_post(void) +{ + // Initialize + memset((void *)test_case_result, 0xff, sizeof(test_case_result)); + current_test_numth = 0; + + // Start run test + printf("--- BEGIN UNIT TEST ---\n"); + UnityBegin("/unit_test/src/unit_test_iec60730_post.c"); + run_test(test_sl_iec60730_post_pass_all_check_condition,"test_sl_iec60730_post_pass_all_check_condition",68); + run_test(test_sl_iec60730_post_failed_check_condition,"test_sl_iec60730_post_failed_check_condition",78); + UnityEnd(); + __asm volatile("IEC60730_UNIT_TEST_END:"); + + while(1){ + // Do nothing + } +} \ No newline at end of file