Skip to content

Commit

Permalink
Merge pull request #18 from SiliconLabs/unit-test-workflow
Browse files Browse the repository at this point in the history
Add unit test workflow
  • Loading branch information
silabs-bingocth authored Oct 9, 2024
2 parents 0092113 + e55dc6b commit c8a2f38
Show file tree
Hide file tree
Showing 1,035 changed files with 250,342 additions and 0 deletions.
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

0 comments on commit c8a2f38

Please sign in to comment.