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 unit test workflow #18

Merged
merged 23 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
068b756
Merge pull request #3 from SiliconLabs/update-workflows
silabs-bingocth Aug 12, 2024
9f37427
Merge pull request #5 from SiliconLabs/update-workflows
silabs-bingocth Aug 12, 2024
c89ff07
Update source code lib iec60730
Sep 16, 2024
63d6640
Create source code unit tests and write bash scripts to support autom…
Sep 16, 2024
ff9204b
Update run_test.md
silabs-hieuhoang Sep 20, 2024
b23772f
Create unit_test_auto.yaml
silabs-bingocth Sep 30, 2024
0370c1b
Update unit_test_auto.yaml
silabs-bingocth Sep 30, 2024
f375dad
Update unit_test_auto.yaml
silabs-bingocth Sep 30, 2024
c6c2517
Update unit_test_auto.yaml
silabs-bingocth Sep 30, 2024
b8b11b3
Update unit_test_auto.yaml
silabs-bingocth Sep 30, 2024
c7c03b1
Update unit_test_auto.yaml
silabs-bingocth Sep 30, 2024
de834b7
Update unit_test_auto.yaml
silabs-bingocth Sep 30, 2024
8f5bc98
Update unit_test_auto.yaml
silabs-bingocth Sep 30, 2024
8c23f5d
Update unit_test_auto.yaml
silabs-bingocth Oct 1, 2024
bfc5879
Update unit_test_auto.yaml
silabs-bingocth Oct 6, 2024
a417bae
Update unit_test_auto.yaml
silabs-bingocth Oct 6, 2024
153e346
Update unit_test_auto.yaml
silabs-bingocth Oct 6, 2024
154a278
Update unit_test_auto.yaml
silabs-bingocth Oct 6, 2024
1f9f036
Update unit_test_auto.yaml
silabs-bingocth Oct 6, 2024
884678f
Update unit_test_auto.yaml
silabs-bingocth Oct 6, 2024
980d03c
Update unit_test_auto.yaml
silabs-bingocth Oct 6, 2024
f495c10
Update unit_test_auto.yaml
silabs-bingocth Oct 6, 2024
e55dc6b
Update unit_test_auto.yaml
Silabs-ThieuVu Oct 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
52 changes: 52 additions & 0 deletions .github/workflows/unit_test_auto.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Unit Tests Auto Trigger
on:
push:
branches:
- '*' # matches every branch that doesn't contain a '/'
- '*/*' # matches every branch containing a single '/'
- '**' # matches every branc
workflow_dispatch:
inputs:
branch:
description: 'Branch to test'
type: string
default: 'main'
jobs:
job1:
name: Unit test
runs-on: [self-hosted, ds-sqa-hn-iec]
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/[email protected]
with:
ref: create-unit-test-functions-in-lib-iec60730
- name: Unit Testing
run: |
export PATH=$PATH:/home/sqa/SimplicityStudio-5/SimplicityStudio_v5/developer/adapter_packs/commander
export PATH=$PATH:~/slc_cli
export JLINK_PATH=/opt/SEGGER/JLink/libjlinkarm.so
export TOOL_DIRS=/home/sqa/SimplicityStudio-5/SimplicityStudio_v5/developer/toolchains/gnu_arm/12.2.rel1_2023.7/bin
export PATH=$PATH:/usr/bin/
export SDK_PATH=/home/sqa/SimplicityStudio/SDKs/gecko_sdk
export PATH=$PATH:/home/sqa/amazon-corretto-17.0.12.7.1-linux-x64/bin
export START_ADDR_FLASH=0x8000000
export CHIP=EFR32MG12
export ADAPTER_SN=440189400
export LST_PATH=~/devs_cooper_lighting_safty_lib/build/test/integration_test/build/brd4187c/integration_test_iec60730_watchdog/S
export HOST_IP=192.168.1.69
slc configuration --sdk=${SDK_PATH}
ninja --version
slc signature trust --sdk $SDK_PATH
slc configuration -gcc=$TOOL_DIRS
make prepare
cd build
slc signature trust -extpath /home/sqa/SimplicityStudio/SDKs/gecko_sdk/extension/devs_cooper_lighting_safty_lib
cmake --toolchain ../cmake/toolchain.cmake .. -DENABLE_UNIT_TESTING=ON -DBOARD_NAME=brd4161a
make unit_test_info -j4
cd ../test
ls -la
bash execute_unit_test.sh brd4161a all all $ADAPTER_SN GCC

10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.json
GNU ARM */
build
test/test_script/__pycache__
doc/html/EFR32_ICE60730_Libraries/latex
*.temp-stream*
gecko_sdk/src/*
!gecko_sdk/src/CMakeLists.txt
cmake_build
log/
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exclude: ^(Doc/|Build/|artifact|Lib/asm|Lib/CMSIS|Lib/Device/efm32pg22|Lib/Device/efr32bg22|Lib/Device/efr32fg22|Lib/Device/efr32fg23|Lib/Device/efr32mg12p|Lib/Device/efr32mg21|Lib/Device/efr32mg22|Lib/Device/efr32mg24|Lib/Device/efr32zg23|Make|Test/test_script|Test/test_compile|Test/test_script|Test/artifact|Test/comm/emlib|Lib/inc/coding_standard.h|Releases)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
args: [-w,--config,./tools/.codespell/.codespellrc]
- repo: https://github.com/pocc/pre-commit-hooks
rev: v1.3.5
hooks:
- id: clang-format
args: [-i,--style=file:./tools/.clang-format]
- id: cppcheck
args: [--language=c,--std=c99,--check-config,-DIEC_BOARD_HEADER="sl_iec60730_board.h",-DEFR32MG24_DEVICE,-D__CM33_REV,--suppress=missingInclude,--suppress=unmatchedSuppression]
68 changes: 68 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Define minimal required version of CMake.
cmake_minimum_required(VERSION "3.25")

# Project definition
project(
IE60730_LIBRARY
VERSION 1.2.0
LANGUAGES C ASM CXX
)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
set(CMAKE_CXX_EXTENSIONS OFF)

set(LIBRARY_NAME iec60730)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
set(LIB_IEC60730_MAP "lib_iec60730.map")
set(SDK_CMAKE_RELATIVE_DIR "gecko_sdk")
set(SDK_LIB_CMAKE_RELATIVE_DIR "${SDK_CMAKE_RELATIVE_DIR}/src/lib_iec60730_cmake")

# choose toolchain
if(DEFINED ENV{TOOL_CHAINS})
set(TOOL_CHAINS "$ENV{TOOL_CHAINS}")
else()
set(TOOL_CHAINS "GCC")
endif()
message("-- Toolchains build: ${TOOL_CHAINS}")

# enable unit test
option(ENABLE_UNIT_TESTING "Enable a Unit Testing Build" OFF)

# choose board name
option(BOARD_NAME "choose board name" brd4187c)
message("-- Board name: ${BOARD_NAME}")

#Add external libraries with Fetch Content
include(FetchContent)

if(ENABLE_UNIT_TESTING)
FetchContent_Declare(
unity
GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity
GIT_TAG v2.6.0
GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(unity)
endif()

add_subdirectory(lib)
add_subdirectory(test)
# Run Make file
include(makefile)

if(ENABLE_UNIT_TESTING)

# Run generate_lib_iec60730
include(generate_lib_iec60730)

generate_lib_iec60730(${SDK_CMAKE_RELATIVE_DIR})
get_target_property(MAIN_CFLAGS_LIB_IEC60730 slc_lib_iec60730 COMPILE_OPTIONS)
string(REPLACE "$<$<COMPILE_LANGUAGE:C>:SHELL:-imacros sl_gcc_preinclude.h>;" "" MAIN_CFLAGS_LIB_IEC60730 "${MAIN_CFLAGS_LIB_IEC60730}")
string(REPLACE "$<$<COMPILE_LANGUAGE:CXX>:SHELL:-imacros sl_gcc_preinclude.h>;" "" MAIN_CFLAGS_LIB_IEC60730 "${MAIN_CFLAGS_LIB_IEC60730}")
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()


Loading