Skip to content

Commit

Permalink
Release ThreadX regression system
Browse files Browse the repository at this point in the history
  • Loading branch information
TiejunMS committed Apr 4, 2023
1 parent ac3b6b3 commit ebeb02b
Show file tree
Hide file tree
Showing 229 changed files with 87,243 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"image": "tizho/azurertos-regression",
"runArgs": [ "--cap-add=NET_ADMIN"]
}
2 changes: 2 additions & 0 deletions scripts/build_smp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
$(dirname `realpath $0`)/../test/smp/cmake/run.sh build all
2 changes: 2 additions & 0 deletions scripts/build_tx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
$(dirname `realpath $0`)/../test/tx/cmake/run.sh build all
120 changes: 120 additions & 0 deletions scripts/cmake_bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/bin/bash

set -e

function help() {
echo "Usage: $0 [build|test] [all|<build_configuration> <build_configuration>...]"
echo "Available build_configuration:"
for build in ${build_configurations[*]}; do
echo " $build"
done
exit 1
}

function validate() {
for build in ${build_configurations[*]}; do
if [ "$1" == "$build" ]; then
return
fi
done
help
}

function generate() {
build=$1
cmake -Bbuild/$build -GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=$(dirname $(realpath $0))/../cmake/linux.cmake -DCMAKE_BUILD_TYPE=$build .
}

function build() {
cmake --build build/$1
}

function build_libs() {
cmake -Bbuild/libs -GNinja -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=$(dirname $(realpath $0))/../cmake/linux.cmake libs
cmake --build build/libs
}

function test() {
pushd build/$1
[ -z "${CTEST_PARALLEL_LEVEL}" ] && parallel="-j$2"
if [ -z "${CTEST_REPEAT_FAIL}" ];
then
repeat_fail=2
else
repeat_fail=${CTEST_REPEAT_FAIL}
fi
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}
popd
grep -E "^(\s*[0-9]+|Total)" build/$1/$1.txt >build/$1.txt
sed -i "s/\x1B\[[0-9;]*[JKmsu]//g" build/$1.txt
if [[ $1 = *"_coverage" ]]; then
./coverage.sh $1
fi
}

cd $(dirname $0)

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')
IFS=' '
read -ra build_configurations <<< "$result"

if [ $# -lt 1 ]; then
help
fi

command=$1
shift

if [ "$#" == "0" ]; then
builds=${build_configurations[0]}
elif [ "$*" == "all" ]; then
builds=${build_configurations[@]}
else
for item in $*; do
validate $item
done
builds=$*
fi

if [ "$command" == "build" ]; then
for item in $builds; do
generate $item
echo ""
done

for item in $builds; do
echo "Building $item"
build $item
echo ""
done
elif [ "$command" == "test" ]; then
cores=$(nproc)
if [ -z "${CTEST_PARALLEL_LEVEL}" ];
then
# Run builds in parallel
build_counts=$(echo $builds | wc -w)
parallel_jobs=$(($cores / $build_counts))
parallel_jobs=$(($parallel_jobs + 2))
pids=""
for item in $builds; do
echo "Testing $item"
test $item $parallel_jobs &
pids+=" $!"
done
exit_code=0
for p in $pids; do
wait $p || exit_code=$?
done
exit $exit_code
else
# Run builds in serial
for item in $builds; do
echo "Testing $item"
test $item $parallel_jobs
done
fi
elif [ "$command" == "build_libs" ]; then
build_libs
else
help
fi
3 changes: 3 additions & 0 deletions scripts/test_smp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

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

CTEST_PARALLEL_LEVEL=4 $(dirname `realpath $0`)/../test/tx/cmake/run.sh test all
2 changes: 2 additions & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tx_initialize_low_level.c
coverage_report/
76 changes: 76 additions & 0 deletions test/smp/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0057 NEW)

project(threadx_smp_test LANGUAGES C)

# Set build configurations
set(BUILD_CONFIGURATIONS default_build_coverage
disable_notify_callbacks_build stack_checking_build
trace_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(default_build_coverage "")
set(disable_notify_callbacks_build -DTX_DISABLE_NOTIFY_CALLBACKS)
set(stack_checking_build -DTX_ENABLE_STACK_CHECKING)
set(trace_build -DTX_ENABLE_EVENT_TRACE)

add_compile_options(
-m32
-std=c99
-ggdb
-g3
-gdwarf-2
-fdiagnostics-color
# -Werror
-DTX_THREAD_SMP_ONLY_CORE_0_DEFAULT
-DTX_SMP_NOT_POSSIBLE
-DTX_REGRESSION_TEST
-DTEST_STACK_SIZE_PRINTF=4096
${${CMAKE_BUILD_TYPE}})
add_link_options(-m32)

enable_testing()

add_subdirectory(threadx_smp)
add_subdirectory(regression)
add_subdirectory(samples)

# Coverage
if(CMAKE_BUILD_TYPE MATCHES ".*_coverage")
target_compile_options(threadx_smp PRIVATE -fprofile-arcs -ftest-coverage)
target_link_options(threadx_smp PRIVATE -fprofile-arcs -ftest-coverage)
endif()

target_compile_options(
threadx_smp
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)
9 changes: 9 additions & 0 deletions test/smp/cmake/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

set -e

cd $(dirname $0)
threadx_smp=$(realpath ../../../common_smp/src)
mkdir -p coverage_report/$1
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
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
133 changes: 133 additions & 0 deletions test/smp/cmake/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
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}/threadx_block_memory_basic_test.c
${SOURCE_DIR}/threadx_block_memory_error_detection_test.c
${SOURCE_DIR}/threadx_block_memory_information_test.c
${SOURCE_DIR}/threadx_block_memory_prioritize_test.c
${SOURCE_DIR}/threadx_block_memory_suspension_test.c
${SOURCE_DIR}/threadx_block_memory_suspension_timeout_test.c
${SOURCE_DIR}/threadx_block_memory_thread_terminate_test.c
${SOURCE_DIR}/threadx_byte_memory_basic_test.c
${SOURCE_DIR}/threadx_byte_memory_information_test.c
${SOURCE_DIR}/threadx_byte_memory_prioritize_test.c
${SOURCE_DIR}/threadx_byte_memory_suspension_test.c
${SOURCE_DIR}/threadx_byte_memory_suspension_timeout_test.c
${SOURCE_DIR}/threadx_byte_memory_thread_contention_test.c
${SOURCE_DIR}/threadx_byte_memory_thread_terminate_test.c
${SOURCE_DIR}/threadx_event_flag_basic_test.c
${SOURCE_DIR}/threadx_event_flag_information_test.c
${SOURCE_DIR}/threadx_event_flag_isr_set_clear_test.c
${SOURCE_DIR}/threadx_event_flag_isr_wait_abort_test.c
${SOURCE_DIR}/threadx_event_flag_single_thread_terminate_test.c
${SOURCE_DIR}/threadx_event_flag_suspension_consume_test.c
${SOURCE_DIR}/threadx_event_flag_suspension_different_bits_consume_test.c
${SOURCE_DIR}/threadx_event_flag_suspension_different_bits_test.c
${SOURCE_DIR}/threadx_event_flag_suspension_test.c
${SOURCE_DIR}/threadx_event_flag_suspension_timeout_test.c
${SOURCE_DIR}/threadx_event_flag_thread_terminate_test.c
${SOURCE_DIR}/threadx_interrupt_control_test.c
${SOURCE_DIR}/threadx_mutex_basic_test.c
${SOURCE_DIR}/threadx_mutex_delete_test.c
${SOURCE_DIR}/threadx_mutex_information_test.c
${SOURCE_DIR}/threadx_mutex_nested_priority_inheritance_test.c
${SOURCE_DIR}/threadx_mutex_no_preemption_test.c
${SOURCE_DIR}/threadx_mutex_preemption_test.c
${SOURCE_DIR}/threadx_mutex_priority_inheritance_test.c
${SOURCE_DIR}/threadx_mutex_proritize_test.c
${SOURCE_DIR}/threadx_mutex_suspension_timeout_test.c
${SOURCE_DIR}/threadx_mutex_thread_terminate_test.c
${SOURCE_DIR}/threadx_queue_basic_eight_word_test.c
${SOURCE_DIR}/threadx_queue_basic_four_word_test.c
${SOURCE_DIR}/threadx_queue_basic_one_word_test.c
${SOURCE_DIR}/threadx_queue_basic_sixteen_word_test.c
${SOURCE_DIR}/threadx_queue_basic_two_word_test.c
${SOURCE_DIR}/threadx_queue_empty_suspension_test.c
${SOURCE_DIR}/threadx_queue_flush_no_suspension_test.c
${SOURCE_DIR}/threadx_queue_flush_test.c
${SOURCE_DIR}/threadx_queue_front_send_test.c
${SOURCE_DIR}/threadx_queue_full_suspension_test.c
${SOURCE_DIR}/threadx_queue_information_test.c
${SOURCE_DIR}/threadx_queue_prioritize.c
${SOURCE_DIR}/threadx_queue_suspension_timeout_test.c
${SOURCE_DIR}/threadx_queue_thread_terminate_test.c
${SOURCE_DIR}/threadx_semaphore_basic_test.c
${SOURCE_DIR}/threadx_semaphore_ceiling_put_test.c
${SOURCE_DIR}/threadx_semaphore_delete_test.c
${SOURCE_DIR}/threadx_semaphore_information_test.c
${SOURCE_DIR}/threadx_semaphore_non_preemption_test.c
${SOURCE_DIR}/threadx_semaphore_preemption_test.c
${SOURCE_DIR}/threadx_semaphore_prioritize.c
${SOURCE_DIR}/threadx_semaphore_thread_terminate_test.c
${SOURCE_DIR}/threadx_semaphore_timeout_test.c
${SOURCE_DIR}/threadx_smp_multiple_threads_one_core_test.c
${SOURCE_DIR}/threadx_smp_non_trivial_scheduling_test.c
${SOURCE_DIR}/threadx_smp_one_thread_dynamic_exclusion_test.c
${SOURCE_DIR}/threadx_smp_preemption_threshold_test.c
${SOURCE_DIR}/threadx_smp_random_resume_suspend_exclusion_pt_test.c
${SOURCE_DIR}/threadx_smp_random_resume_suspend_exclusion_test.c
${SOURCE_DIR}/threadx_smp_random_resume_suspend_test.c
${SOURCE_DIR}/threadx_smp_rebalance_exclusion_test.c
${SOURCE_DIR}/threadx_smp_relinquish_test.c
${SOURCE_DIR}/threadx_smp_resume_suspend_accending_order_test.c
${SOURCE_DIR}/threadx_smp_resume_suspend_decending_order_test.c
${SOURCE_DIR}/threadx_smp_time_slice_test.c
${SOURCE_DIR}/threadx_smp_two_threads_one_core_test.c
${SOURCE_DIR}/threadx_thread_basic_execution_test.c
${SOURCE_DIR}/threadx_thread_basic_time_slice_test.c
${SOURCE_DIR}/threadx_thread_completed_test.c
${SOURCE_DIR}/threadx_thread_create_preemption_threshold_test.c
${SOURCE_DIR}/threadx_thread_delayed_suspension_test.c
${SOURCE_DIR}/threadx_thread_information_test.c
${SOURCE_DIR}/threadx_thread_multi_level_preemption_threshold_test.c
${SOURCE_DIR}/threadx_thread_multiple_non_current_test.c
${SOURCE_DIR}/threadx_thread_multiple_sleep_test.c
${SOURCE_DIR}/threadx_thread_multiple_suspension_test.c
${SOURCE_DIR}/threadx_thread_multiple_time_slice_test.c
${SOURCE_DIR}/threadx_thread_preemptable_suspension_test.c
${SOURCE_DIR}/threadx_thread_preemption_change_test.c
${SOURCE_DIR}/threadx_thread_priority_change.c
${SOURCE_DIR}/threadx_thread_relinquish_test.c
${SOURCE_DIR}/threadx_thread_reset_test.c
${SOURCE_DIR}/threadx_thread_simple_sleep_non_clear_test.c
${SOURCE_DIR}/threadx_thread_simple_sleep_test.c
${SOURCE_DIR}/threadx_thread_simple_suspend_test.c
${SOURCE_DIR}/threadx_thread_sleep_for_100ticks_test.c
${SOURCE_DIR}/threadx_thread_sleep_terminate_test.c
${SOURCE_DIR}/threadx_thread_stack_checking_test.c
${SOURCE_DIR}/threadx_thread_terminate_delete_test.c
${SOURCE_DIR}/threadx_thread_time_slice_change_test.c
${SOURCE_DIR}/threadx_thread_wait_abort_and_isr_test.c
${SOURCE_DIR}/threadx_thread_wait_abort_test.c
${SOURCE_DIR}/threadx_time_get_set_test.c
${SOURCE_DIR}/threadx_timer_activate_deactivate_test.c
${SOURCE_DIR}/threadx_timer_deactivate_accuracy_test.c
${SOURCE_DIR}/threadx_timer_information_test.c
${SOURCE_DIR}/threadx_timer_large_timer_accuracy_test.c
${SOURCE_DIR}/threadx_timer_multiple_accuracy_test.c
${SOURCE_DIR}/threadx_timer_multiple_test.c
${SOURCE_DIR}/threadx_timer_simple_test.c
${SOURCE_DIR}/threadx_trace_basic_test.c
${SOURCE_DIR}/threadx_initialize_kernel_setup_test.c)

add_custom_command(
OUTPUT ${SOURCE_DIR}/tx_initialize_low_level.c
COMMAND bash ${CMAKE_CURRENT_LIST_DIR}/generate_test_file.sh
COMMENT "Generating tx_initialize_low_level.c for test")

add_library(test_utility ${SOURCE_DIR}/tx_initialize_low_level.c
${SOURCE_DIR}/testcontrol.c)
target_link_libraries(test_utility PUBLIC azrtos::threadx_smp)
target_compile_definitions(test_utility PUBLIC CTEST BATCH_TEST)

foreach(test_case ${regression_test_cases})
get_filename_component(test_name ${test_case} NAME_WE)
add_executable(${test_name} ${test_case})
target_link_libraries(${test_name} PRIVATE test_utility)
add_test(${CMAKE_BUILD_TYPE}::${test_name} ${test_name})
endforeach()
10 changes: 10 additions & 0 deletions test/smp/cmake/regression/generate_test_file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

dst=$(dirname $0)/../../regression/tx_initialize_low_level.c
src=$(dirname $0)/../../../../ports_smp/linux/gnu/src/tx_initialize_low_level.c

line=`sed -n '/_tx_linux_timer_interrupt/=' $src | tail -n 1`
sed "${line}iVOID test_interrupt_dispatch(VOID);" $src > tmp1
line=`sed -n '/_tx_timer_interrupt/=' $src | tail -n 1`
sed "${line}itest_interrupt_dispatch();" tmp1 > $dst
rm tmp1
1 change: 1 addition & 0 deletions test/smp/cmake/run.sh
15 changes: 15 additions & 0 deletions test/smp/cmake/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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}/../../../../ports_smp/linux/gnu/example_build)

set(sample_files
${SOURCE_DIR}/sample_threadx.c)

foreach(sample_file ${sample_files})
get_filename_component(sample_file_name ${sample_file} NAME_WE)
add_executable(${sample_file_name} ${sample_file} ${CMAKE_CURRENT_LIST_DIR}/fake.c)
target_link_libraries(${sample_file_name} PRIVATE azrtos::threadx_smp)
endforeach()
Loading

0 comments on commit ebeb02b

Please sign in to comment.