Skip to content

Commit 268e4ed

Browse files
authored
Merge pull request #25 Add regression test
Add regression test
2 parents cef8e4f + fcce06a commit 268e4ed

File tree

17 files changed

+5804
-4
lines changed

17 files changed

+5804
-4
lines changed

.devcontainer/devcontainer.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"image": "ghcr.io/tiejunms/azure_rtos_docker",
3+
4+
// Add the IDs of extensions you want installed when the container is created.
5+
"extensions": [
6+
"ms-vscode.cpptools",
7+
"ms-vscode.cmake-tools"
8+
],
9+
10+
"remoteUser": "vscode",
11+
12+
"runArgs": [ "--cap-add=NET_ADMIN"]
13+
}

.github/workflows/regression_test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This is a basic workflow that is manually triggered
2+
3+
name: regression_test
4+
5+
# Controls when the action will run. Triggers the workflow on push or pull request
6+
# events but only for the master branch
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches: [ master ]
11+
pull_request:
12+
branches: [ master ]
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# This workflow contains a single job called "linux_job"
17+
run_tests:
18+
permissions:
19+
contents: read
20+
issues: read
21+
checks: write
22+
pull-requests: write
23+
pages: write
24+
id-token: write
25+
uses: azure-rtos/threadx/.github/workflows/regression_template.yml@master

common/inc/lx_api.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* APPLICATION INTERFACE DEFINITION RELEASE */
2727
/* */
2828
/* lx_api.h PORTABLE C */
29-
/* 6.3.0 */
29+
/* 6.x */
3030
/* AUTHOR */
3131
/* */
3232
/* William E. Lamie, Microsoft Corporation */
@@ -86,6 +86,9 @@
8686
/* bitmap and obsolete count */
8787
/* cache for NOR flash, */
8888
/* resulting in version 6.3.0 */
89+
/* xx-xx-xxxx Xiuwen Cai Modified comment(s), */
90+
/* added configuration checks, */
91+
/* resulting in version 6.x */
8992
/* */
9093
/**************************************************************************/
9194

@@ -279,6 +282,19 @@ typedef unsigned long long ULONG64;
279282
#define LX_NOR_PHYSICAL_SECTOR_FREE 0xFFFFFFFF
280283

281284

285+
/* Check extended cache configurations. */
286+
#ifdef LX_NOR_DISABLE_EXTENDED_CACHE
287+
288+
#ifdef LX_NOR_ENABLE_MAPPING_BITMAP
289+
#error "To enable mapping bitmap, you need to undefine LX_NOR_DISABLE_EXTENDED_CACHE."
290+
#endif
291+
292+
#ifdef LX_NOR_ENABLE_OBSOLETE_COUNT_CACHE
293+
#error "To enable obsolete count cache, you need to undefine LX_NOR_DISABLE_EXTENDED_CACHE."
294+
#endif
295+
296+
#endif
297+
282298
/* Define NAND flash constants. */
283299

284300
#define LX_NAND_GOOD_BLOCK 0xFF

common/src/lx_nand_flash_data_page_copy.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/* FUNCTION RELEASE */
4141
/* */
4242
/* _lx_nand_flash_data_page_copy PORTABLE C */
43-
/* 6.2.1 */
43+
/* 6.x */
4444
/* AUTHOR */
4545
/* */
4646
/* Xiuwen Cai, Microsoft Corporation */
@@ -78,7 +78,11 @@
7878
/* */
7979
/* DATE NAME DESCRIPTION */
8080
/* */
81-
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
81+
/* 03-08-2023 Xiuwen Cai Initial Version 6.2.1 */
82+
/* xx-xx-xxxx Xiuwen Cai Modified comment(s), */
83+
/* fixed sequential checking */
84+
/* logic, */
85+
/* resulting in version 6.x */
8286
/* */
8387
/**************************************************************************/
8488
UINT _lx_nand_flash_data_page_copy(LX_NAND_FLASH* nand_flash, ULONG logical_sector, ULONG source_block, USHORT src_block_status,
@@ -168,7 +172,7 @@ ULONG number_of_pages;
168172
}
169173

170174
/* Check if the pages in destination block is still sequential. */
171-
if ((destination_page) != (logical_sector + i % nand_flash -> lx_nand_flash_pages_per_block))
175+
if (destination_page != ((logical_sector + i) % nand_flash -> lx_nand_flash_pages_per_block))
172176
{
173177
/* Mark the block status as non sequential. */
174178
dest_block_status |= LX_NAND_BLOCK_STATUS_NON_SEQUENTIAL;

scripts/build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
$(dirname `realpath $0`)/../test/cmake/run.sh build all

scripts/install.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
#
3+
4+
# Remove large folder
5+
rm -rf /opt/hostedtoolcache
6+
7+
# Install necessary softwares for Ubuntu.
8+
9+
sudo apt-get update
10+
sudo apt-get install -y \
11+
gcc-multilib \
12+
git \
13+
g++ \
14+
python3-pip \
15+
ninja-build \
16+
unifdef \
17+
p7zip-full \
18+
tofrodos \
19+
gawk \
20+
software-properties-common
21+
22+
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
23+
CODENAME=$(lsb_release -c | cut -f2 -d':' | sed 's/\t//')
24+
apt-add-repository "deb https://apt.kitware.com/ubuntu/ $CODENAME main"
25+
26+
python3 -m pip install --upgrade pip
27+
pip3 install gcovr==4.1
28+
pip install --upgrade cmake

scripts/test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
$(dirname `realpath $0`)/../test/cmake/run.sh test all

test/cmake/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
threadx
2+
filex
3+
coverage_report
4+
.run.sh

test/cmake/CMakeLists.txt

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2+
cmake_policy(SET CMP0054 NEW)
3+
cmake_policy(SET CMP0057 NEW)
4+
5+
project(levelx_test LANGUAGES C)
6+
7+
# Set build configurations
8+
set(BUILD_CONFIGURATIONS default_build_coverage
9+
free_sector_verify_build
10+
full_build
11+
standalone_build
12+
standalone_free_sector_verify_build
13+
standalone_full_build
14+
new_driver_interface_build
15+
nor_obsolete_cache_build
16+
nor_mapping_cache_build
17+
nor_obsolete_mapping_cache_build)
18+
set(CMAKE_CONFIGURATION_TYPES
19+
${BUILD_CONFIGURATIONS}
20+
CACHE STRING "list of supported configuration types" FORCE)
21+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
22+
${CMAKE_CONFIGURATION_TYPES})
23+
list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE)
24+
if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST
25+
CMAKE_CONFIGURATION_TYPES)))
26+
set(CMAKE_BUILD_TYPE
27+
"${BUILD_TYPE}"
28+
CACHE STRING "Build Type of the project" FORCE)
29+
endif()
30+
31+
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
32+
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
33+
set(FX_FAULT_TOLERANT_DEFINITIONS
34+
-DFX_ENABLE_FAULT_TOLERANT -DFX_UPDATE_FILE_SIZE_ON_ALLOCATE
35+
-DFX_FAULT_TOLERANT_TRANSACTION_FAIL_FUNCTION)
36+
set(default_build_coverage "")
37+
set(free_sector_verify_build -DLX_FREE_SECTOR_DATA_VERIFY)
38+
set(full_build -DLX_FREE_SECTOR_DATA_VERIFY
39+
-DLX_DIRECT_READ
40+
-DLX_NAND_FLASH_DIRECT_MAPPING_CACHE
41+
-DLX_NOR_DISABLE_EXTENDED_CACHE
42+
-DLX_THREAD_SAFE_ENABLE)
43+
# For Standalone builds LX_STANADLONE_ENABLE is defined in line 61
44+
set(standalone_build -DLX_STANDALONE_ENABLE)
45+
set(standalone_free_sector_verify_build -DLX_STANDALONE_ENABLE ${free_sector_verify_build})
46+
set(standalone_full_build -DLX_STANDALONE_ENABLE ${full_build})
47+
set(new_driver_interface_build -DLX_NOR_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE
48+
-DLX_NAND_ENABLE_CONTROL_BLOCK_FOR_DRIVER_INTERFACE)
49+
set(nor_obsolete_cache_build -DLX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
50+
set(nor_mapping_cache_build -DLX_NOR_ENABLE_MAPPING_BITMAP)
51+
set(nor_obsolete_mapping_cache_build -DLX_NOR_ENABLE_MAPPING_BITMAP
52+
-DLX_NOR_ENABLE_OBSOLETE_COUNT_CACHE)
53+
54+
add_compile_options(
55+
-m32
56+
-std=c99
57+
-ggdb
58+
-g3
59+
-gdwarf-2
60+
-fdiagnostics-color
61+
-Werror
62+
${${CMAKE_BUILD_TYPE}})
63+
add_link_options(-m32)
64+
65+
enable_testing()
66+
67+
if(CMAKE_BUILD_TYPE MATCHES "standalone.*")
68+
set(LX_STANDALONE_ENABLE
69+
ON
70+
CACHE BOOL "LevelX standalone enabled(No Azure RTOS ThreadX)" FORCE)
71+
set(FX_STANDALONE_ENABLE
72+
ON
73+
CACHE BOOL "FileX standalone enabled(No Azure RTOS ThreadX)" FORCE)
74+
endif()
75+
76+
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../.. levelx)
77+
add_subdirectory(regression)
78+
add_subdirectory(samples)
79+
80+
# Coverage
81+
if(CMAKE_BUILD_TYPE MATCHES ".*_coverage")
82+
target_compile_options(levelx PRIVATE -fprofile-arcs -ftest-coverage)
83+
target_link_options(levelx PRIVATE -fprofile-arcs -ftest-coverage)
84+
endif()
85+
86+
87+
# Build ThreadX library once
88+
execute_process(COMMAND ${CMAKE_CURRENT_LIST_DIR}/run.sh build_libs)
89+
add_custom_target(build_libs ALL COMMAND ${CMAKE_CURRENT_LIST_DIR}/run.sh
90+
build_libs)
91+
add_dependencies(levelx build_libs)
92+
target_include_directories(levelx PUBLIC ${CMAKE_BINARY_DIR}/../libs/inc)
93+
if(NOT LX_STANDALONE_ENABLE)
94+
add_library(threadx SHARED IMPORTED GLOBAL)
95+
add_library("azrtos::threadx" ALIAS threadx)
96+
set_target_properties(
97+
threadx PROPERTIES IMPORTED_LOCATION
98+
${CMAKE_BINARY_DIR}/../libs/threadx/libthreadx.so)
99+
add_library(filex SHARED IMPORTED GLOBAL)
100+
add_library("azrtos::filex" ALIAS filex)
101+
set_target_properties(filex PROPERTIES IMPORTED_LOCATION
102+
${CMAKE_BINARY_DIR}/../libs/filex/libfilex.so)
103+
else()
104+
get_filename_component(
105+
externals ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE)
106+
add_subdirectory(${externals}/filex filex)
107+
add_library("azrtos::filex" ALIAS filex)
108+
endif()
109+
110+
target_compile_options(
111+
levelx
112+
PRIVATE -Werror
113+
-Wall
114+
-Wextra
115+
-pedantic
116+
-fmessage-length=0
117+
-fsigned-char
118+
-ffunction-sections
119+
-fdata-sections
120+
-Wunused
121+
-Wuninitialized
122+
-Wmissing-declarations
123+
-Wconversion
124+
-Wpointer-arith
125+
-Wshadow
126+
-Wlogical-op
127+
-Waggregate-return
128+
-Wfloat-equal)

test/cmake/coverage.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd $(dirname $0)
6+
mkdir -p coverage_report/$1
7+
gcovr --object-directory=build/$1/levelx/CMakeFiles/levelx.dir/common/src -r ../../common/src --xml-pretty --output coverage_report/$1.xml
8+
gcovr --object-directory=build/$1/levelx/CMakeFiles/levelx.dir/common/src -r ../../common/src --html --html-details --output coverage_report/$1/index.html

test/cmake/libs/CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2+
3+
project(libs LANGUAGES C)
4+
5+
if($ENV{ENABLE_64})
6+
message(STATUS "Building for 64bit")
7+
else()
8+
add_compile_options(-m32)
9+
add_link_options(-m32)
10+
message(STATUS "Building for 32bit")
11+
endif()
12+
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
13+
14+
get_filename_component(
15+
externals ${CMAKE_CURRENT_SOURCE_DIR}/.. ABSOLUTE)
16+
17+
if(NOT LX_STANDALONE_ENABLE)
18+
add_subdirectory(${externals}/threadx threadx)
19+
endif()
20+
add_subdirectory(${externals}/filex filex)
21+
target_compile_options(threadx PRIVATE -DTX_ENABLE_EVENT_TRACE)
22+
if(NOT DEFINED ENV{ENABLE_IDLE})
23+
target_compile_options(threadx PRIVATE -DTX_LINUX_NO_IDLE_ENABLE)
24+
endif()
25+
26+
27+
if((NOT LX_STANDALONE_ENABLE) OR (NOT FX_STANDALONE_ENABLE))
28+
foreach(lib threadx filex)
29+
get_target_property(dirs ${lib} INCLUDE_DIRECTORIES)
30+
execute_process(COMMAND mkdir -p ${CMAKE_BINARY_DIR}/inc)
31+
foreach(dir ${dirs})
32+
file(GLOB header_files ${dir}/*.h)
33+
foreach(header_file ${header_files})
34+
execute_process(COMMAND ln -sf ${header_file} ${CMAKE_BINARY_DIR}/inc)
35+
endforeach()
36+
endforeach()
37+
endforeach()
38+
endif()

test/cmake/regression/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
2+
cmake_policy(SET CMP0057 NEW)
3+
4+
project(regression_test LANGUAGES C)
5+
6+
set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../regression)
7+
8+
set(regression_test_cases
9+
${SOURCE_DIR}/levelx_nand_flash_test.c
10+
${SOURCE_DIR}/levelx_nor_flash_test.c
11+
${SOURCE_DIR}/levelx_nor_flash_test_cache.c)
12+
13+
foreach(test_case ${regression_test_cases} ${regression_test_cases_exfat})
14+
get_filename_component(test_name ${test_case} NAME_WE)
15+
add_executable(${test_name} ${test_case})
16+
target_link_libraries(${test_name} PRIVATE azrtos::filex)
17+
target_link_libraries(${test_name} PRIVATE azrtos::levelx)
18+
target_compile_definitions(${test_name} PRIVATE BATCH_TEST)
19+
add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name})
20+
endforeach()

test/cmake/run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
cd $(dirname $0)
4+
5+
# if threadx repo does not exist, clone it
6+
[ -d threadx ] || git clone https://github.com/azure-rtos/threadx.git --depth 1
7+
[ -d filex ] || git clone https://github.com/azure-rtos/filex.git --depth 1
8+
[ -f .run.sh ] || ln -sf threadx/scripts/cmake_bootstrap.sh .run.sh
9+
./.run.sh $*

test/cmake/samples/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
2+
cmake_policy(SET CMP0057 NEW)
3+
4+
project(samples LANGUAGES C)
5+
6+
set(SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../samples)
7+
8+
set(sample_files
9+
${SOURCE_DIR}/demo_filex_nand_flash.c
10+
${SOURCE_DIR}/demo_filex_nor_flash.c)
11+
12+
foreach(sample_file ${sample_files})
13+
get_filename_component(sample_file_name ${sample_file} NAME_WE)
14+
add_executable(${sample_file_name} ${sample_file})
15+
target_link_libraries(${sample_file_name} PRIVATE azrtos::filex)
16+
target_link_libraries(${sample_file_name} PRIVATE azrtos::levelx)
17+
endforeach()

0 commit comments

Comments
 (0)