forked from PAWPAW-Mirror/lib_xua
Working xcommon cmake unit test build
This commit is contained in:
@@ -1,12 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
|
||||
|
||||
## App name
|
||||
set( APP_NAME xua_unit_tests )
|
||||
|
||||
|
||||
# Auto-generate schedule and top level config files
|
||||
|
||||
if( NOT ${Python3_FOUND} )
|
||||
message(FATAL_ERROR "Python3 not found for running . ")
|
||||
endif()
|
||||
@@ -24,35 +19,28 @@ set( GEN_RUNNER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/generate_unity_runner.py )
|
||||
set( RUNNERS_DIR ${CMAKE_CURRENT_BINARY_DIR}/src.runners )
|
||||
file( MAKE_DIRECTORY ${RUNNERS_DIR} )
|
||||
|
||||
# Find unit test files
|
||||
file( GLOB_RECURSE TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/test_*/*.c )
|
||||
|
||||
message(STATUS "HERE: ${TEST_SOURCES}")
|
||||
|
||||
|
||||
# For every source file in xua_unit_tests/
|
||||
foreach(testfile ${TEST_SOURCES})
|
||||
message(STATUS "Processing: ${testfile}")
|
||||
|
||||
# Get test name
|
||||
#cmake_path( GET testfile STEM TESTNAME )
|
||||
get_filename_component(TESTNAME ${testfile} NAME_WLE)
|
||||
|
||||
message(STATUS "Unit test name: ${TESTNAME}")
|
||||
foreach(TESTFILE ${TEST_SOURCES})
|
||||
# Get test name from C file stem
|
||||
cmake_path(GET TESTFILE STEM TESTNAME)
|
||||
project(${TESTNAME})
|
||||
message(STATUS "Processing unit test: ${TESTNAME}")
|
||||
|
||||
|
||||
|
||||
# Create runner file directory
|
||||
file(MAKE_DIRECTORY ${RUNNERS_DIR}/${TESTNAME} )
|
||||
file(MAKE_DIRECTORY ${RUNNERS_DIR}/${TESTNAME})
|
||||
|
||||
#########
|
||||
#####################
|
||||
## Create runner file
|
||||
#####################
|
||||
set( RUNNER_FILE ${RUNNERS_DIR}/${TESTNAME}/${TESTNAME}_Runner.c )
|
||||
set( GEN_RUNNER_SCRIPT_BYPRODUCTS ${RUNNER_FILE} )
|
||||
set( GEN_RUNNER_SCRIPT_BYPRODUCTS ${RUNNER_FILE})
|
||||
|
||||
unset(GEN_RUNNER_SCRIPT_ARGS)
|
||||
list(APPEND GEN_RUNNER_SCRIPT_ARGS --project-root ${UNITY_PATH}/.. )
|
||||
list(APPEND GEN_RUNNER_SCRIPT_ARGS --source-file ${testfile} )
|
||||
list(APPEND GEN_RUNNER_SCRIPT_ARGS --project-root ${UNITY_PATH}/..)
|
||||
list(APPEND GEN_RUNNER_SCRIPT_ARGS --source-file ${TESTFILE})
|
||||
list(APPEND GEN_RUNNER_SCRIPT_ARGS --runner-file ${RUNNER_FILE})
|
||||
|
||||
## Add command to generate runner file
|
||||
@@ -64,23 +52,43 @@ foreach(testfile ${TEST_SOURCES})
|
||||
##########################
|
||||
## Do xcommon cmake build
|
||||
##########################
|
||||
|
||||
set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
|
||||
|
||||
set(APP_HW_TARGET XK-EVK-XU316)
|
||||
set(APP_DEPENDENT_MODULES "lib_xua")
|
||||
set(APP_PCA_ENABLE ON)
|
||||
# set(APP_PCA_ENABLE ON)
|
||||
set(APP_COMPILER_FLAGS ${EXTRA_BUILD_FLAGS} -fcomment-asm
|
||||
-Wall
|
||||
-O3
|
||||
-O2
|
||||
-report
|
||||
-g
|
||||
-fxscope
|
||||
-DUSB_TILE=tile[0]
|
||||
-DUNITY_SUPPORT_64
|
||||
-DUNITY_INCLUDE_DOUBLE
|
||||
-DXUD_CORE_CLOCK=600
|
||||
-DXUD_SERIES_SUPPORT=4
|
||||
)
|
||||
|
||||
# For HID tests only enable HID
|
||||
if(${TESTFILE} MATCHES ".+hid.*")
|
||||
list(APPEND APP_COMPILER_FLAGS "-DHID_CONTROLS=1")
|
||||
endif()
|
||||
|
||||
|
||||
# Workaround for xcommon cmake pre-pending CMAKE_CURRENT_LIST_DIR
|
||||
string(REPLACE ${CMAKE_CURRENT_LIST_DIR} "" UNIT_TEST_SOURCE_RELATIVE ${TESTFILE})
|
||||
|
||||
set(APP_C_SRCS runners/${TESTNAME}/${TESTNAME}_Runner.c
|
||||
${UNIT_TEST_SOURCE_RELATIVE}
|
||||
../../../Unity/src/unity.c
|
||||
)
|
||||
|
||||
|
||||
get_filename_component(TEST_FILE_DIR ${TESTFILE} DIRECTORY)
|
||||
set(APP_INCLUDES ${CMAKE_CURRENT_LIST_DIR}/src
|
||||
${CMAKE_CURRENT_LIST_DIR}/../../../Unity/src)
|
||||
${TEST_FILE_DIR}
|
||||
${XMOS_SANDBOX_DIR}/Unity/src
|
||||
${XMOS_SANDBOX_DIR}/lib_xud/lib_xud/src/user/class)
|
||||
|
||||
XMOS_REGISTER_APP()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user