mirror of
https://github.com/eclipse-threadx/levelx.git
synced 2026-09-14 04:06:00 +08:00
Add test files
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
threadx
|
||||
filex
|
||||
coverage_report
|
||||
.run.sh
|
||||
@@ -0,0 +1,128 @@
|
||||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
|
||||
project(levelx_test LANGUAGES C)
|
||||
|
||||
# Set build configurations
|
||||
set(BUILD_CONFIGURATIONS default_build_coverage
|
||||
free_sector_verify_build
|
||||
full_build
|
||||
standalone_build
|
||||
standalone_free_sector_verify_build
|
||||
standalone_full_build
|
||||
new_driver_interface_build
|
||||
nor_obsolete_cache_build
|
||||
nor_mapping_cache_build
|
||||
nor_obsolete_mapping_cache_build)
|
||||
set(CMAKE_CONFIGURATION_TYPES
|
||||
${BUILD_CONFIGURATIONS}
|
||||
CACHE STRING "list of supported configuration types" FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
${CMAKE_CONFIGURATION_TYPES})
|
||||
list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE)
|
||||
if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST
|
||||
CMAKE_CONFIGURATION_TYPES)))
|
||||
set(CMAKE_BUILD_TYPE
|
||||
"${BUILD_TYPE}"
|
||||
CACHE STRING "Build Type of the project" FORCE)
|
||||
endif()
|
||||
|
||||
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
||||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||
set(FX_FAULT_TOLERANT_DEFINITIONS
|
||||
-DFX_ENABLE_FAULT_TOLERANT -DFX_UPDATE_FILE_SIZE_ON_ALLOCATE
|
||||
-DFX_FAULT_TOLERANT_TRANSACTION_FAIL_FUNCTION)
|
||||
set(default_build_coverage "")
|
||||
set(free_sector_verify_build -DLX_FREE_SECTOR_DATA_VERIFY)
|
||||
set(full_build -DLX_FREE_SECTOR_DATA_VERIFY
|
||||
-DLX_DIRECT_READ
|
||||
-DLX_NAND_FLASH_DIRECT_MAPPING_CACHE
|
||||
-DLX_NOR_DISABLE_EXTENDED_CACHE
|
||||
-DLX_THREAD_SAFE_ENABLE)
|
||||
# For Standalone builds LX_STANADLONE_ENABLE is defined in line 61
|
||||
set(standalone_build -DLX_STANDALONE_ENABLE)
|
||||
set(standalone_free_sector_verify_build -DLX_STANDALONE_ENABLE ${free_sector_verify_build})
|
||||
set(standalone_full_build -DLX_STANDALONE_ENABLE ${full_build})
|
||||
set(new_driver_interface_build -DLX_NOR_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
|
||||
-DLX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE)
|
||||
set(nor_obsolete_cache_build -DLX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
|
||||
set(nor_mapping_cache_build -DLX_NOR_ENABLE_MAPPING_BITMAP)
|
||||
set(nor_obsolete_mapping_cache_build -DLX_NOR_ENABLE_MAPPING_BITMAP
|
||||
-DLX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
|
||||
|
||||
add_compile_options(
|
||||
-m32
|
||||
-std=c99
|
||||
-ggdb
|
||||
-g3
|
||||
-gdwarf-2
|
||||
-fdiagnostics-color
|
||||
-Werror
|
||||
${${CMAKE_BUILD_TYPE}})
|
||||
add_link_options(-m32)
|
||||
|
||||
enable_testing()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "standalone.*")
|
||||
set(LX_STANDALONE_ENABLE
|
||||
ON
|
||||
CACHE BOOL "LevelX standalone enabled(No Azure RTOS ThreadX)" FORCE)
|
||||
set(FX_STANDALONE_ENABLE
|
||||
ON
|
||||
CACHE BOOL "FileX standalone enabled(No Azure RTOS ThreadX)" FORCE)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../.. levelx)
|
||||
add_subdirectory(regression)
|
||||
add_subdirectory(samples)
|
||||
|
||||
# Coverage
|
||||
if(CMAKE_BUILD_TYPE MATCHES ".*_coverage")
|
||||
target_compile_options(levelx PRIVATE -fprofile-arcs -ftest-coverage)
|
||||
target_link_options(levelx PRIVATE -fprofile-arcs -ftest-coverage)
|
||||
endif()
|
||||
|
||||
|
||||
# Build ThreadX library once
|
||||
execute_process(COMMAND ${CMAKE_CURRENT_LIST_DIR}/run.sh build_libs)
|
||||
add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_LIST_DIR}/run.sh
|
||||
build_libs)
|
||||
add_dependencies(levelx build_libs)
|
||||
target_include_directories(levelx PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc)
|
||||
if(NOT LX_STANDALONE_ENABLE)
|
||||
add_library(threadx SHARED IMPORTED GLOBAL)
|
||||
add_library("azrtos::threadx" ALIAS threadx)
|
||||
set_target_properties(
|
||||
threadx PROPERTIES IMPORTED_LOCATION
|
||||
${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so)
|
||||
add_library(filex SHARED IMPORTED GLOBAL)
|
||||
add_library("azrtos::filex" ALIAS filex)
|
||||
set_target_properties(filex PROPERTIES IMPORTED_LOCATION
|
||||
${CMAKE_BINARY_DIR}/../libs/filex/libfilex.so)
|
||||
else()
|
||||
get_filename_component(
|
||||
externals ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE)
|
||||
add_subdirectory(${externals}/filex filex)
|
||||
add_library("azrtos::filex" ALIAS filex)
|
||||
endif()
|
||||
|
||||
target_compile_options(
|
||||
levelx
|
||||
PRIVATE -Werror
|
||||
-Wall
|
||||
-Wextra
|
||||
-pedantic
|
||||
-fmessage-length=0
|
||||
-fsigned-char
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
-Wunused
|
||||
-Wuninitialized
|
||||
-Wmissing-declarations
|
||||
-Wconversion
|
||||
-Wpointer-arith
|
||||
-Wshadow
|
||||
-Wlogical-op
|
||||
-Waggregate-return
|
||||
-Wfloat-equal)
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
mkdir -p coverage_report/$1
|
||||
gcovr --object-directory=build/$1/levelx/CMakeFiles/levelx.dir/common/src -r ../../common/src --xml-pretty --output coverage_report/$1.xml
|
||||
gcovr --object-directory=build/$1/levelx/CMakeFiles/levelx.dir/common/src -r ../../common/src --html --html-details --output coverage_report/$1/index.html
|
||||
@@ -0,0 +1,38 @@
|
||||
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
|
||||
|
||||
project(libs LANGUAGES C)
|
||||
|
||||
if($ENV{ENABLE_64})
|
||||
message(STATUS "Building for 64bit")
|
||||
else()
|
||||
add_compile_options(-m32)
|
||||
add_link_options(-m32)
|
||||
message(STATUS "Building for 32bit")
|
||||
endif()
|
||||
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
|
||||
|
||||
get_filename_component(
|
||||
externals ${CMAKE_CURRENT_SOURCE_DIR}/.. ABSOLUTE)
|
||||
|
||||
if(NOT LX_STANDALONE_ENABLE)
|
||||
add_subdirectory(${externals}/threadx threadx)
|
||||
endif()
|
||||
add_subdirectory(${externals}/filex filex)
|
||||
target_compile_options(threadx PRIVATE -DTX_ENABLE_EVENT_TRACE)
|
||||
if(NOT DEFINED ENV{ENABLE_IDLE})
|
||||
target_compile_options(threadx PRIVATE -DTX_LINUX_NO_IDLE_ENABLE)
|
||||
endif()
|
||||
|
||||
|
||||
if((NOT LX_STANDALONE_ENABLE) OR (NOT FX_STANDALONE_ENABLE))
|
||||
foreach(lib threadx filex)
|
||||
get_target_property(dirs ${lib} INCLUDE_DIRECTORIES)
|
||||
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/inc)
|
||||
foreach(dir ${dirs})
|
||||
file(GLOB header_files ${dir}/*.h)
|
||||
foreach(header_file ${header_files})
|
||||
execute_process(COMMAND ln -sf ${header_file} ${CMAKE_BINARY_DIR}/inc)
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif()
|
||||
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
|
||||
project(regression_test LANGUAGES C)
|
||||
|
||||
set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../regression)
|
||||
|
||||
set(regression_test_cases
|
||||
${SOURCE_DIR}/levelx_nand_flash_test.c
|
||||
${SOURCE_DIR}/levelx_nor_flash_test.c
|
||||
${SOURCE_DIR}/levelx_nor_flash_test_cache.c)
|
||||
|
||||
foreach(test_case ${regression_test_cases} ${regression_test_cases_exfat})
|
||||
get_filename_component(test_name ${test_case} NAME_WE)
|
||||
add_executable(${test_name} ${test_case})
|
||||
target_link_libraries(${test_name} PRIVATE azrtos::filex)
|
||||
target_link_libraries(${test_name} PRIVATE azrtos::levelx)
|
||||
target_compile_definitions(${test_name} PRIVATE BATCH_TEST)
|
||||
add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name})
|
||||
endforeach()
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
# if threadx repo does not exist, clone it
|
||||
[ -d threadx ] || git clone https://github.com/azure-rtos/threadx.git --depth 1
|
||||
[ -d filex ] || git clone https://github.com/azure-rtos/filex.git --depth 1
|
||||
[ -f .run.sh ] || ln -sf threadx/scripts/cmake_bootstrap.sh .run.sh
|
||||
./.run.sh $*
|
||||
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
|
||||
project(samples LANGUAGES C)
|
||||
|
||||
set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../samples)
|
||||
|
||||
set(sample_files
|
||||
${SOURCE_DIR}/demo_filex_nand_flash.c
|
||||
${SOURCE_DIR}/demo_filex_nor_flash.c)
|
||||
|
||||
foreach(sample_file ${sample_files})
|
||||
get_filename_component(sample_file_name ${sample_file} NAME_WE)
|
||||
add_executable(${sample_file_name} ${sample_file})
|
||||
target_link_libraries(${sample_file_name} PRIVATE azrtos::filex)
|
||||
target_link_libraries(${sample_file_name} PRIVATE azrtos::levelx)
|
||||
endforeach()
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user