Skip to content

Commit ebeb02b

Browse files
committed
Release ThreadX regression system
1 parent ac3b6b3 commit ebeb02b

File tree

229 files changed

+87243
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

229 files changed

+87243
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"image": "tizho/azurertos-regression",
3+
"runArgs": [ "--cap-add=NET_ADMIN"]
4+
}

scripts/build_smp.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/smp/cmake/run.sh build all

scripts/build_tx.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/tx/cmake/run.sh build all

scripts/cmake_bootstrap.sh

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
function help() {
6+
echo "Usage: $0 [build|test] [all|<build_configuration> <build_configuration>...]"
7+
echo "Available build_configuration:"
8+
for build in ${build_configurations[*]}; do
9+
echo " $build"
10+
done
11+
exit 1
12+
}
13+
14+
function validate() {
15+
for build in ${build_configurations[*]}; do
16+
if [ "$1" == "$build" ]; then
17+
return
18+
fi
19+
done
20+
help
21+
}
22+
23+
function generate() {
24+
build=$1
25+
cmake -Bbuild/$build -GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=$(dirname $(realpath $0))/../cmake/linux.cmake -DCMAKE_BUILD_TYPE=$build .
26+
}
27+
28+
function build() {
29+
cmake --build build/$1
30+
}
31+
32+
function build_libs() {
33+
cmake -Bbuild/libs -GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=$(dirname $(realpath $0))/../cmake/linux.cmake libs
34+
cmake --build build/libs
35+
}
36+
37+
function test() {
38+
pushd build/$1
39+
[ -z "${CTEST_PARALLEL_LEVEL}" ] && parallel="-j$2"
40+
if [ -z "${CTEST_REPEAT_FAIL}" ];
41+
then
42+
repeat_fail=2
43+
else
44+
repeat_fail=${CTEST_REPEAT_FAIL}
45+
fi
46+
ctest $parallel --timeout 1000 -O $1.txt -T test --no-compress-output --test-output-size-passed 4194304 --test-output-size-failed 4194304 --output-on-failure --repeat until-pass:${repeat_fail}
47+
popd
48+
grep -E "^(\s*[0-9]+|Total)" build/$1/$1.txt >build/$1.txt
49+
sed -i "s/\x1B\[[0-9;]*[JKmsu]//g" build/$1.txt
50+
if [[ $1 = *"_coverage" ]]; then
51+
./coverage.sh $1
52+
fi
53+
}
54+
55+
cd $(dirname $0)
56+
57+
result=$(sed -n "/(BUILD_CONFIGURATIONS/,/)/p" CMakeLists.txt|sed ':label;N;s/\n/ /;b label'|grep -Pzo "[a-zA-Z0-9_]*build[a-zA-Z0-9_]*\s*"| tr -d '\0')
58+
IFS=' '
59+
read -ra build_configurations <<< "$result"
60+
61+
if [ $# -lt 1 ]; then
62+
help
63+
fi
64+
65+
command=$1
66+
shift
67+
68+
if [ "$#" == "0" ]; then
69+
builds=${build_configurations[0]}
70+
elif [ "$*" == "all" ]; then
71+
builds=${build_configurations[@]}
72+
else
73+
for item in $*; do
74+
validate $item
75+
done
76+
builds=$*
77+
fi
78+
79+
if [ "$command" == "build" ]; then
80+
for item in $builds; do
81+
generate $item
82+
echo ""
83+
done
84+
85+
for item in $builds; do
86+
echo "Building $item"
87+
build $item
88+
echo ""
89+
done
90+
elif [ "$command" == "test" ]; then
91+
cores=$(nproc)
92+
if [ -z "${CTEST_PARALLEL_LEVEL}" ];
93+
then
94+
# Run builds in parallel
95+
build_counts=$(echo $builds | wc -w)
96+
parallel_jobs=$(($cores / $build_counts))
97+
parallel_jobs=$(($parallel_jobs + 2))
98+
pids=""
99+
for item in $builds; do
100+
echo "Testing $item"
101+
test $item $parallel_jobs &
102+
pids+=" $!"
103+
done
104+
exit_code=0
105+
for p in $pids; do
106+
wait $p || exit_code=$?
107+
done
108+
exit $exit_code
109+
else
110+
# Run builds in serial
111+
for item in $builds; do
112+
echo "Testing $item"
113+
test $item $parallel_jobs
114+
done
115+
fi
116+
elif [ "$command" == "build_libs" ]; then
117+
build_libs
118+
else
119+
help
120+
fi

scripts/test_smp.sh

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

scripts/test_tx.sh

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

test/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tx_initialize_low_level.c
2+
coverage_report/

test/smp/cmake/CMakeLists.txt

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2+
cmake_policy(SET CMP0054 NEW)
3+
cmake_policy(SET CMP0057 NEW)
4+
5+
project(threadx_smp_test LANGUAGES C)
6+
7+
# Set build configurations
8+
set(BUILD_CONFIGURATIONS default_build_coverage
9+
disable_notify_callbacks_build stack_checking_build
10+
trace_build)
11+
set(CMAKE_CONFIGURATION_TYPES
12+
${BUILD_CONFIGURATIONS}
13+
CACHE STRING "list of supported configuration types" FORCE)
14+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
15+
${CMAKE_CONFIGURATION_TYPES})
16+
list(GET CMAKE_CONFIGURATION_TYPES 0 BUILD_TYPE)
17+
if((NOT CMAKE_BUILD_TYPE) OR (NOT ("${CMAKE_BUILD_TYPE}" IN_LIST
18+
CMAKE_CONFIGURATION_TYPES)))
19+
set(CMAKE_BUILD_TYPE
20+
"${BUILD_TYPE}"
21+
CACHE STRING "Build Type of the project" FORCE)
22+
endif()
23+
24+
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
25+
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")
26+
set(default_build_coverage "")
27+
set(disable_notify_callbacks_build -DTX_DISABLE_NOTIFY_CALLBACKS)
28+
set(stack_checking_build -DTX_ENABLE_STACK_CHECKING)
29+
set(trace_build -DTX_ENABLE_EVENT_TRACE)
30+
31+
add_compile_options(
32+
-m32
33+
-std=c99
34+
-ggdb
35+
-g3
36+
-gdwarf-2
37+
-fdiagnostics-color
38+
# -Werror
39+
-DTX_THREAD_SMP_ONLY_CORE_0_DEFAULT
40+
-DTX_SMP_NOT_POSSIBLE
41+
-DTX_REGRESSION_TEST
42+
-DTEST_STACK_SIZE_PRINTF=4096
43+
${${CMAKE_BUILD_TYPE}})
44+
add_link_options(-m32)
45+
46+
enable_testing()
47+
48+
add_subdirectory(threadx_smp)
49+
add_subdirectory(regression)
50+
add_subdirectory(samples)
51+
52+
# Coverage
53+
if(CMAKE_BUILD_TYPE MATCHES ".*_coverage")
54+
target_compile_options(threadx_smp PRIVATE -fprofile-arcs -ftest-coverage)
55+
target_link_options(threadx_smp PRIVATE -fprofile-arcs -ftest-coverage)
56+
endif()
57+
58+
target_compile_options(
59+
threadx_smp
60+
PRIVATE # -Werror
61+
-Wall
62+
-Wextra
63+
-pedantic
64+
-fmessage-length=0
65+
-fsigned-char
66+
-ffunction-sections
67+
-fdata-sections
68+
-Wunused
69+
-Wuninitialized
70+
-Wmissing-declarations
71+
-Wconversion
72+
-Wpointer-arith
73+
# -Wshadow
74+
-Wlogical-op
75+
-Waggregate-return
76+
-Wfloat-equal)

test/smp/cmake/coverage.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd $(dirname $0)
6+
threadx_smp=$(realpath ../../../common_smp/src)
7+
mkdir -p coverage_report/$1
8+
gcovr --object-directory=build/$1/threadx_smp/CMakeFiles/threadx_smp.dir/$threadx_smp -r build/$1 -f ../../../common_smp/src --xml-pretty --output coverage_report/$1.xml
9+
gcovr --object-directory=build/$1/threadx_smp/CMakeFiles/threadx_smp.dir/$threadx_smp -r build/$1 -f ../../../common_smp/src --html --html-details --output coverage_report/$1/index.html
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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}/threadx_block_memory_basic_test.c
10+
${SOURCE_DIR}/threadx_block_memory_error_detection_test.c
11+
${SOURCE_DIR}/threadx_block_memory_information_test.c
12+
${SOURCE_DIR}/threadx_block_memory_prioritize_test.c
13+
${SOURCE_DIR}/threadx_block_memory_suspension_test.c
14+
${SOURCE_DIR}/threadx_block_memory_suspension_timeout_test.c
15+
${SOURCE_DIR}/threadx_block_memory_thread_terminate_test.c
16+
${SOURCE_DIR}/threadx_byte_memory_basic_test.c
17+
${SOURCE_DIR}/threadx_byte_memory_information_test.c
18+
${SOURCE_DIR}/threadx_byte_memory_prioritize_test.c
19+
${SOURCE_DIR}/threadx_byte_memory_suspension_test.c
20+
${SOURCE_DIR}/threadx_byte_memory_suspension_timeout_test.c
21+
${SOURCE_DIR}/threadx_byte_memory_thread_contention_test.c
22+
${SOURCE_DIR}/threadx_byte_memory_thread_terminate_test.c
23+
${SOURCE_DIR}/threadx_event_flag_basic_test.c
24+
${SOURCE_DIR}/threadx_event_flag_information_test.c
25+
${SOURCE_DIR}/threadx_event_flag_isr_set_clear_test.c
26+
${SOURCE_DIR}/threadx_event_flag_isr_wait_abort_test.c
27+
${SOURCE_DIR}/threadx_event_flag_single_thread_terminate_test.c
28+
${SOURCE_DIR}/threadx_event_flag_suspension_consume_test.c
29+
${SOURCE_DIR}/threadx_event_flag_suspension_different_bits_consume_test.c
30+
${SOURCE_DIR}/threadx_event_flag_suspension_different_bits_test.c
31+
${SOURCE_DIR}/threadx_event_flag_suspension_test.c
32+
${SOURCE_DIR}/threadx_event_flag_suspension_timeout_test.c
33+
${SOURCE_DIR}/threadx_event_flag_thread_terminate_test.c
34+
${SOURCE_DIR}/threadx_interrupt_control_test.c
35+
${SOURCE_DIR}/threadx_mutex_basic_test.c
36+
${SOURCE_DIR}/threadx_mutex_delete_test.c
37+
${SOURCE_DIR}/threadx_mutex_information_test.c
38+
${SOURCE_DIR}/threadx_mutex_nested_priority_inheritance_test.c
39+
${SOURCE_DIR}/threadx_mutex_no_preemption_test.c
40+
${SOURCE_DIR}/threadx_mutex_preemption_test.c
41+
${SOURCE_DIR}/threadx_mutex_priority_inheritance_test.c
42+
${SOURCE_DIR}/threadx_mutex_proritize_test.c
43+
${SOURCE_DIR}/threadx_mutex_suspension_timeout_test.c
44+
${SOURCE_DIR}/threadx_mutex_thread_terminate_test.c
45+
${SOURCE_DIR}/threadx_queue_basic_eight_word_test.c
46+
${SOURCE_DIR}/threadx_queue_basic_four_word_test.c
47+
${SOURCE_DIR}/threadx_queue_basic_one_word_test.c
48+
${SOURCE_DIR}/threadx_queue_basic_sixteen_word_test.c
49+
${SOURCE_DIR}/threadx_queue_basic_two_word_test.c
50+
${SOURCE_DIR}/threadx_queue_empty_suspension_test.c
51+
${SOURCE_DIR}/threadx_queue_flush_no_suspension_test.c
52+
${SOURCE_DIR}/threadx_queue_flush_test.c
53+
${SOURCE_DIR}/threadx_queue_front_send_test.c
54+
${SOURCE_DIR}/threadx_queue_full_suspension_test.c
55+
${SOURCE_DIR}/threadx_queue_information_test.c
56+
${SOURCE_DIR}/threadx_queue_prioritize.c
57+
${SOURCE_DIR}/threadx_queue_suspension_timeout_test.c
58+
${SOURCE_DIR}/threadx_queue_thread_terminate_test.c
59+
${SOURCE_DIR}/threadx_semaphore_basic_test.c
60+
${SOURCE_DIR}/threadx_semaphore_ceiling_put_test.c
61+
${SOURCE_DIR}/threadx_semaphore_delete_test.c
62+
${SOURCE_DIR}/threadx_semaphore_information_test.c
63+
${SOURCE_DIR}/threadx_semaphore_non_preemption_test.c
64+
${SOURCE_DIR}/threadx_semaphore_preemption_test.c
65+
${SOURCE_DIR}/threadx_semaphore_prioritize.c
66+
${SOURCE_DIR}/threadx_semaphore_thread_terminate_test.c
67+
${SOURCE_DIR}/threadx_semaphore_timeout_test.c
68+
${SOURCE_DIR}/threadx_smp_multiple_threads_one_core_test.c
69+
${SOURCE_DIR}/threadx_smp_non_trivial_scheduling_test.c
70+
${SOURCE_DIR}/threadx_smp_one_thread_dynamic_exclusion_test.c
71+
${SOURCE_DIR}/threadx_smp_preemption_threshold_test.c
72+
${SOURCE_DIR}/threadx_smp_random_resume_suspend_exclusion_pt_test.c
73+
${SOURCE_DIR}/threadx_smp_random_resume_suspend_exclusion_test.c
74+
${SOURCE_DIR}/threadx_smp_random_resume_suspend_test.c
75+
${SOURCE_DIR}/threadx_smp_rebalance_exclusion_test.c
76+
${SOURCE_DIR}/threadx_smp_relinquish_test.c
77+
${SOURCE_DIR}/threadx_smp_resume_suspend_accending_order_test.c
78+
${SOURCE_DIR}/threadx_smp_resume_suspend_decending_order_test.c
79+
${SOURCE_DIR}/threadx_smp_time_slice_test.c
80+
${SOURCE_DIR}/threadx_smp_two_threads_one_core_test.c
81+
${SOURCE_DIR}/threadx_thread_basic_execution_test.c
82+
${SOURCE_DIR}/threadx_thread_basic_time_slice_test.c
83+
${SOURCE_DIR}/threadx_thread_completed_test.c
84+
${SOURCE_DIR}/threadx_thread_create_preemption_threshold_test.c
85+
${SOURCE_DIR}/threadx_thread_delayed_suspension_test.c
86+
${SOURCE_DIR}/threadx_thread_information_test.c
87+
${SOURCE_DIR}/threadx_thread_multi_level_preemption_threshold_test.c
88+
${SOURCE_DIR}/threadx_thread_multiple_non_current_test.c
89+
${SOURCE_DIR}/threadx_thread_multiple_sleep_test.c
90+
${SOURCE_DIR}/threadx_thread_multiple_suspension_test.c
91+
${SOURCE_DIR}/threadx_thread_multiple_time_slice_test.c
92+
${SOURCE_DIR}/threadx_thread_preemptable_suspension_test.c
93+
${SOURCE_DIR}/threadx_thread_preemption_change_test.c
94+
${SOURCE_DIR}/threadx_thread_priority_change.c
95+
${SOURCE_DIR}/threadx_thread_relinquish_test.c
96+
${SOURCE_DIR}/threadx_thread_reset_test.c
97+
${SOURCE_DIR}/threadx_thread_simple_sleep_non_clear_test.c
98+
${SOURCE_DIR}/threadx_thread_simple_sleep_test.c
99+
${SOURCE_DIR}/threadx_thread_simple_suspend_test.c
100+
${SOURCE_DIR}/threadx_thread_sleep_for_100ticks_test.c
101+
${SOURCE_DIR}/threadx_thread_sleep_terminate_test.c
102+
${SOURCE_DIR}/threadx_thread_stack_checking_test.c
103+
${SOURCE_DIR}/threadx_thread_terminate_delete_test.c
104+
${SOURCE_DIR}/threadx_thread_time_slice_change_test.c
105+
${SOURCE_DIR}/threadx_thread_wait_abort_and_isr_test.c
106+
${SOURCE_DIR}/threadx_thread_wait_abort_test.c
107+
${SOURCE_DIR}/threadx_time_get_set_test.c
108+
${SOURCE_DIR}/threadx_timer_activate_deactivate_test.c
109+
${SOURCE_DIR}/threadx_timer_deactivate_accuracy_test.c
110+
${SOURCE_DIR}/threadx_timer_information_test.c
111+
${SOURCE_DIR}/threadx_timer_large_timer_accuracy_test.c
112+
${SOURCE_DIR}/threadx_timer_multiple_accuracy_test.c
113+
${SOURCE_DIR}/threadx_timer_multiple_test.c
114+
${SOURCE_DIR}/threadx_timer_simple_test.c
115+
${SOURCE_DIR}/threadx_trace_basic_test.c
116+
${SOURCE_DIR}/threadx_initialize_kernel_setup_test.c)
117+
118+
add_custom_command(
119+
OUTPUT ${SOURCE_DIR}/tx_initialize_low_level.c
120+
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_test_file.sh
121+
COMMENT "Generating tx_initialize_low_level.c for test")
122+
123+
add_library(test_utility ${SOURCE_DIR}/tx_initialize_low_level.c
124+
${SOURCE_DIR}/testcontrol.c)
125+
target_link_libraries(test_utility PUBLIC azrtos::threadx_smp)
126+
target_compile_definitions(test_utility PUBLIC CTEST BATCH_TEST)
127+
128+
foreach(test_case ${regression_test_cases})
129+
get_filename_component(test_name ${test_case} NAME_WE)
130+
add_executable(${test_name} ${test_case})
131+
target_link_libraries(${test_name} PRIVATE test_utility)
132+
add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name})
133+
endforeach()

0 commit comments

Comments
 (0)