mirror of
https://github.com/eclipse-threadx/threadx.git
synced 2026-10-06 06:59:08 +08:00
Merge pull request #244 from azure-rtos/tizho/test
Release ThreadX regression system
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"image": "tizho/azurertos-regression",
|
||||
"runArgs": [ "--cap-add=NET_ADMIN"]
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
pr:
|
||||
- master
|
||||
|
||||
pool:
|
||||
vmImage: "ubuntu-22.04"
|
||||
|
||||
steps:
|
||||
- bash: sudo $(Build.SourcesDirectory)/scripts/install.sh
|
||||
displayName: 'Install softwares'
|
||||
env:
|
||||
INDEX_URL: $(INDEX_URL)
|
||||
|
||||
- task: Bash@3
|
||||
displayName: 'SDL check'
|
||||
inputs:
|
||||
filePath: '$(Build.SourcesDirectory)/scripts/sdl_check.sh'
|
||||
|
||||
- task: Bash@3
|
||||
displayName: 'Build SMP'
|
||||
inputs:
|
||||
filePath: '$(Build.SourcesDirectory)/scripts/build_smp.sh'
|
||||
|
||||
- task: Bash@3
|
||||
displayName: 'Test SMP'
|
||||
inputs:
|
||||
filePath: '$(Build.SourcesDirectory)/scripts/test_smp.sh'
|
||||
|
||||
- task: PublishTestResults@2
|
||||
condition: succeededOrFailed()
|
||||
displayName: 'Test SMP (PublishTestResults)'
|
||||
inputs:
|
||||
testResultsFormat: 'cTest'
|
||||
testResultsFiles: '*/Testing/**/*.xml'
|
||||
searchFolder: '$(Build.SourcesDirectory)/test/smp/cmake/build'
|
||||
testRunTitle: 'SMP-Tests'
|
||||
buildConfiguration: 'Release'
|
||||
|
||||
- task: CopyFiles@2
|
||||
condition: succeededOrFailed()
|
||||
displayName: 'Test SMP (PublishTestReports)'
|
||||
inputs:
|
||||
SourceFolder: '$(Build.SourcesDirectory)/test/smp/cmake'
|
||||
Contents: |
|
||||
build/*.txt
|
||||
build/*/Testing/**/*.xml
|
||||
coverage_report/**/*
|
||||
TargetFolder: '$(ob_outputDirectory)/test_reports_SMP'
|
||||
|
||||
- task: PublishCodeCoverageResults@1
|
||||
condition: succeededOrFailed()
|
||||
displayName: 'Test SMP (PublishCodeCoverageResults)'
|
||||
inputs:
|
||||
codeCoverageTool: 'Cobertura'
|
||||
summaryFileLocation: '$(Build.SourcesDirectory)/test/smp/cmake/coverage_report/default_build_coverage.xml'
|
||||
pathToSources: '$(Build.SourcesDirectory)/test/smp/cmake'
|
||||
reportDirectory: '$(Build.SourcesDirectory)/test/smp/cmake/coverage_report/default_build_coverage'
|
||||
@@ -0,0 +1,59 @@
|
||||
trigger:
|
||||
- master
|
||||
|
||||
pr:
|
||||
- master
|
||||
|
||||
pool:
|
||||
vmImage: "ubuntu-22.04"
|
||||
|
||||
steps:
|
||||
- bash: sudo $(Build.SourcesDirectory)/scripts/install.sh
|
||||
displayName: 'Install softwares'
|
||||
env:
|
||||
INDEX_URL: $(INDEX_URL)
|
||||
|
||||
- task: Bash@3
|
||||
displayName: 'SDL check'
|
||||
inputs:
|
||||
filePath: '$(Build.SourcesDirectory)/scripts/sdl_check.sh'
|
||||
|
||||
- task: Bash@3
|
||||
displayName: 'Build TX'
|
||||
inputs:
|
||||
filePath: '$(Build.SourcesDirectory)/scripts/build_tx.sh'
|
||||
|
||||
- task: Bash@3
|
||||
displayName: 'Test TX'
|
||||
inputs:
|
||||
filePath: '$(Build.SourcesDirectory)/scripts/test_tx.sh'
|
||||
|
||||
- task: PublishTestResults@2
|
||||
condition: succeededOrFailed()
|
||||
displayName: 'Test TX (PublishTestResults)'
|
||||
inputs:
|
||||
testResultsFormat: 'cTest'
|
||||
testResultsFiles: '*/Testing/**/*.xml'
|
||||
searchFolder: '$(Build.SourcesDirectory)/test/tx/cmake/build'
|
||||
testRunTitle: 'TX-Tests'
|
||||
buildConfiguration: 'Release'
|
||||
|
||||
- task: CopyFiles@2
|
||||
condition: succeededOrFailed()
|
||||
displayName: 'Test TX (PublishTestReports)'
|
||||
inputs:
|
||||
SourceFolder: '$(Build.SourcesDirectory)/test/tx/cmake'
|
||||
Contents: |
|
||||
build/*.txt
|
||||
build/*/Testing/**/*.xml
|
||||
coverage_report/**/*
|
||||
TargetFolder: '$(ob_outputDirectory)/test_reports_TX'
|
||||
|
||||
- task: PublishCodeCoverageResults@1
|
||||
condition: succeededOrFailed()
|
||||
displayName: 'Test TX (PublishCodeCoverageResults)'
|
||||
inputs:
|
||||
codeCoverageTool: 'Cobertura'
|
||||
summaryFileLocation: '$(Build.SourcesDirectory)/test/tx/cmake/coverage_report/default_build_coverage.xml'
|
||||
pathToSources: '$(Build.SourcesDirectory)/test/tx/cmake'
|
||||
reportDirectory: '$(Build.SourcesDirectory)/test/tx/cmake/coverage_report/default_build_coverage'
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
$(dirname `realpath $0`)/../test/smp/cmake/run.sh build all
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
$(dirname `realpath $0`)/../test/tx/cmake/run.sh build all
|
||||
Executable
+120
@@ -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
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Install necessary softwares for Ubuntu.
|
||||
|
||||
apt-get update
|
||||
apt-get install -y \
|
||||
gcc-multilib \
|
||||
git \
|
||||
g++ \
|
||||
python3-pip \
|
||||
ninja-build \
|
||||
unifdef \
|
||||
p7zip-full \
|
||||
tofrodos \
|
||||
gawk \
|
||||
cmake \
|
||||
software-properties-common
|
||||
|
||||
python3 -m pip install --upgrade pip
|
||||
pip3 install artifacts-keyring
|
||||
pip3 install gcovr==4.1 $INDEX_URL
|
||||
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
# !/bin/bash
|
||||
dir_list="common common_smp common_modules ports ports_module ports_smp samples"
|
||||
exclude_list="-path TX"
|
||||
file_list=$(find $dir_list \( $exclude_list \) -prune -o -type f -name '*.[ch]' -print)
|
||||
cd $(dirname `realpath $0`)/..
|
||||
echo "Checking for unexpected usage of memcpy..."
|
||||
echo ""
|
||||
echo "Excluding:"
|
||||
echo $exclude_list | grep -P "[^\s]*/[^\s]*" -o
|
||||
echo ""
|
||||
echo "Result:"
|
||||
grep -i "memcpy(" -i $file_list -n | grep -i "use case of .* is verified" -v
|
||||
if [ "$?" -eq "1" ];
|
||||
then
|
||||
echo "CLEAN"
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
CTEST_PARALLEL_LEVEL=4 $(dirname `realpath $0`)/../test/smp/cmake/run.sh test all
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
CTEST_PARALLEL_LEVEL=4 $(dirname `realpath $0`)/../test/tx/cmake/run.sh test all
|
||||
@@ -0,0 +1,2 @@
|
||||
tx_initialize_low_level.c
|
||||
coverage_report/
|
||||
@@ -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)
|
||||
Executable
+9
@@ -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
|
||||
@@ -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
@@ -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
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../../../scripts/cmake_bootstrap.sh
|
||||
@@ -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()
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "tx_api.h"
|
||||
|
||||
typedef unsigned int TEST_FLAG;
|
||||
TEST_FLAG threadx_byte_allocate_loop_test;
|
||||
TEST_FLAG threadx_byte_release_loop_test;
|
||||
TEST_FLAG threadx_mutex_suspension_put_test;
|
||||
TEST_FLAG threadx_mutex_suspension_priority_test;
|
||||
#ifndef TX_TIMER_PROCESS_IN_ISR
|
||||
TEST_FLAG threadx_delete_timer_thread;
|
||||
#endif
|
||||
|
||||
void abort_and_resume_byte_allocating_thread(void){}
|
||||
void abort_all_threads_suspended_on_mutex(void){}
|
||||
void suspend_lowest_priority(void){}
|
||||
#ifndef TX_TIMER_PROCESS_IN_ISR
|
||||
void delete_timer_thread(void){}
|
||||
#endif
|
||||
TEST_FLAG test_stack_analyze_flag;
|
||||
TEST_FLAG test_initialize_flag;
|
||||
TEST_FLAG test_forced_mutex_timeout;
|
||||
UINT mutex_priority_change_extension_selection;
|
||||
UINT priority_change_extension_selection;
|
||||
@@ -0,0 +1,60 @@
|
||||
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
|
||||
|
||||
# Set up the project
|
||||
project(threadx_smp
|
||||
VERSION 6.0.0
|
||||
LANGUAGES C ASM
|
||||
)
|
||||
|
||||
if(NOT DEFINED THREADX_ARCH)
|
||||
message(FATAL_ERROR "Error: THREADX_ARCH not defined")
|
||||
endif()
|
||||
if(NOT DEFINED THREADX_TOOLCHAIN)
|
||||
message(FATAL_ERROR "Error: THREADX_TOOLCHAIN not defined")
|
||||
endif()
|
||||
|
||||
set(PROJECT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../..)
|
||||
|
||||
# Define our target library and an alias for consumers
|
||||
add_library(${PROJECT_NAME})
|
||||
add_library("azrtos::${PROJECT_NAME}" ALIAS ${PROJECT_NAME})
|
||||
|
||||
# A place for generated/copied include files (no need to change)
|
||||
set(CUSTOM_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/custom_inc)
|
||||
|
||||
# Pick up the port specific variables and apply them
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ports_smp/${THREADX_ARCH}/${THREADX_TOOLCHAIN})
|
||||
|
||||
# Pick up the common stuff
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/common_smp)
|
||||
|
||||
|
||||
|
||||
|
||||
# If the user provided an override, copy it to the custom directory
|
||||
if (NOT TX_USER_FILE)
|
||||
message(STATUS "Using default tx_user.h file")
|
||||
set(TX_USER_FILE ${PROJECT_DIR}/common_smp/inc/tx_user_sample.h)
|
||||
else()
|
||||
message(STATUS "Using custom tx_user.h file from ${TX_USER_FILE}")
|
||||
endif()
|
||||
configure_file(${TX_USER_FILE} ${CUSTOM_INC_DIR}/tx_user.h COPYONLY)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
${CUSTOM_INC_DIR}
|
||||
)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "TX_INCLUDE_USER_DEFINE_FILE" )
|
||||
|
||||
# Enable a build target that produces a ZIP file of all sources
|
||||
set(CPACK_SOURCE_GENERATOR "ZIP")
|
||||
set(CPACK_SOURCE_IGNORE_FILES
|
||||
\\.git/
|
||||
\\.github/
|
||||
_build/
|
||||
\\.git
|
||||
\\.gitattributes
|
||||
\\.gitignore
|
||||
".*~$"
|
||||
)
|
||||
set(CPACK_VERBATIM_VARIABLES YES)
|
||||
include(CPack)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
||||
|
||||
set(CURRENT_DIR ${PROJECT_DIR}/ports_smp/linux/gnu)
|
||||
target_sources(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
# {{BEGIN_TARGET_SOURCES}}
|
||||
${CURRENT_DIR}/src/tx_initialize_low_level.c
|
||||
${CURRENT_DIR}/src/tx_thread_context_restore.c
|
||||
${CURRENT_DIR}/src/tx_thread_context_save.c
|
||||
${CURRENT_DIR}/src/tx_thread_interrupt_control.c
|
||||
${CURRENT_DIR}/src/tx_thread_schedule.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_core_get.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_core_preempt.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_current_state_get.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_current_thread_get.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_initialize_wait.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_low_level_initialize.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_protect.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_time_get.c
|
||||
${CURRENT_DIR}/src/tx_thread_smp_unprotect.c
|
||||
${CURRENT_DIR}/src/tx_thread_stack_build.c
|
||||
${CURRENT_DIR}/src/tx_thread_system_return.c
|
||||
${CURRENT_DIR}/src/tx_timer_interrupt.c
|
||||
|
||||
# {{END_TARGET_SOURCES}}
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
${CURRENT_DIR}/inc
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "-D_GNU_SOURCE -DTX_LINUX_DEBUG_ENABLE")
|
||||
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
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
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,185 @@
|
||||
/* This test is designed to test thread termination on a thread suspended on a block
|
||||
memory pool. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
|
||||
static TX_BLOCK_POOL pool_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_block_memory_thread_terminate_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Block Memory Thread Terminate Test.......................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Block Memory Thread Terminate Test.......................... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create block pool. */
|
||||
status = tx_block_pool_create(&pool_0, "pool 0", 100, pointer, 320);
|
||||
pointer = pointer + 320;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Block Memory Thread Terminate Test.......................... ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer_1;
|
||||
CHAR *pointer_2;
|
||||
CHAR *pointer_3;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Block Memory Thread Terminate Test.......................... ");
|
||||
|
||||
/* Allocate all blocks from the pool. */
|
||||
status = tx_block_allocate(&pool_0, (VOID **) &pointer_1, TX_NO_WAIT);
|
||||
status += tx_block_allocate(&pool_0, (VOID **) &pointer_2, TX_NO_WAIT);
|
||||
status += tx_block_allocate(&pool_0, (VOID **) &pointer_3, TX_NO_WAIT);
|
||||
|
||||
/* Increment the run counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Block memory error. */
|
||||
printf("ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Set all the memory of the blocks. */
|
||||
TX_MEMSET(pointer_1, (CHAR) 0xEF, 100);
|
||||
TX_MEMSET(pointer_2, (CHAR) 0xEF, 100);
|
||||
TX_MEMSET(pointer_3, (CHAR) 0xEF, 100);
|
||||
|
||||
|
||||
/* Let other thread suspend on block pool. */
|
||||
tx_thread_relinquish();
|
||||
|
||||
/* Terminate the other thread. */
|
||||
status = tx_thread_terminate(&thread_1);
|
||||
|
||||
/* Check status. */
|
||||
if ((status != TX_SUCCESS) || (thread_1.tx_thread_state != TX_TERMINATED) ||
|
||||
(thread_1_counter != 0))
|
||||
{
|
||||
|
||||
/* Block memory error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Release all the blocks. */
|
||||
status = tx_block_release(pointer_1);
|
||||
status += tx_block_release(pointer_2);
|
||||
status += tx_block_release(pointer_3);
|
||||
|
||||
/* Check status. */
|
||||
if ((status != TX_SUCCESS) || (thread_1.tx_thread_state != TX_TERMINATED) ||
|
||||
(thread_1_counter != 0))
|
||||
{
|
||||
|
||||
/* Block memory error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer_1;
|
||||
|
||||
|
||||
/* Attempt to get a block from the pool. */
|
||||
while(1)
|
||||
{
|
||||
|
||||
/* Allocate a block from the pool. */
|
||||
status = tx_block_allocate(&pool_0, (VOID **) &pointer_1, 10);
|
||||
|
||||
/* Determine if the allocate was successful. */
|
||||
if (status != TX_NO_MEMORY)
|
||||
return;
|
||||
|
||||
/* Set all the memory of the blocks. */
|
||||
TX_MEMSET(pointer_1, (CHAR) 0xEF, 100);
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_1_counter++;
|
||||
}
|
||||
}
|
||||
|
||||
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
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,196 @@
|
||||
/* This test is designed to test suspension timeout on a memory byte pool. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
static unsigned long thread_2_counter = 0;
|
||||
static TX_THREAD thread_2;
|
||||
|
||||
|
||||
static TX_BYTE_POOL pool_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
static void thread_2_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_byte_memory_suspension_timeout_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Byte Memory Suspension Timeout Test......................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Byte Memory Suspension Timeout Test......................... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
|
||||
status = tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Byte Memory Suspension Timeout Test......................... ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create byte pool 0. */
|
||||
status = tx_byte_pool_create(&pool_0, "pool 0", pointer, 108);
|
||||
pointer = pointer + 108;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Byte Memory Suspension Timeout Test......................... ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Byte Memory Suspension Timeout Test......................... ");
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Allocate memory from the pool. Only one block of this size will fit. */
|
||||
status = tx_byte_allocate(&pool_0, (VOID **) &pointer, 60, TX_NO_WAIT);
|
||||
|
||||
/* Check status. */
|
||||
if ((status != TX_SUCCESS) || (thread_1_counter != 0))
|
||||
{
|
||||
|
||||
/* Byte memory error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Sleep to allow the other thread to suspend and timeout on the memory
|
||||
pool once. */
|
||||
tx_thread_sleep(64);
|
||||
|
||||
/* Check the counter of the other thread. */
|
||||
if ((thread_1_counter != 6) || (thread_2_counter != 3))
|
||||
{
|
||||
|
||||
/* Block memory error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
/* Allocate memory from the pool - with timeout. */
|
||||
status = tx_byte_allocate(&pool_0, (VOID **) &pointer, 60, 10);
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_NO_MEMORY)
|
||||
return;
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_1_counter++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_2_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Delay so we get some single suspension timeouts as well. */
|
||||
tx_thread_sleep(32);
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
/* Allocate memory from the pool - with timeout. */
|
||||
status = tx_byte_allocate(&pool_0, (VOID **) &pointer, 60, 10);
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_NO_MEMORY)
|
||||
return;
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_2_counter++;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,177 @@
|
||||
/* This test is designed to test termination on thread suspended on memory byte pool. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
|
||||
static TX_BYTE_POOL pool_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_byte_memory_thread_terminate_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Byte Memory Thread Terminate Test........................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Byte Memory Thread Terminate Test........................... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create byte pools 0 and 1. */
|
||||
status = tx_byte_pool_create(&pool_0, "pool 0", pointer, 108);
|
||||
pointer = pointer + 108;
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Byte Memory Thread Terminate Test........................... ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Byte Memory Thread Terminate Test........................... ");
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Allocate memory from the pool. Only one block of this size will fit. */
|
||||
status = tx_byte_allocate(&pool_0, (VOID **) &pointer, 60, TX_NO_WAIT);
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Byte memory error. */
|
||||
printf("ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Let other thread suspend on byte pool. */
|
||||
tx_thread_relinquish();
|
||||
|
||||
/* Terminate the other thread. */
|
||||
status = tx_thread_terminate(&thread_1);
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Byte memory error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Release block back. */
|
||||
status = tx_byte_release(pointer);
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Byte memory error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Allocate memory from the pool. Only one block of this size will fit. */
|
||||
status = tx_byte_allocate(&pool_0, (VOID **) &pointer, 60, TX_NO_WAIT);
|
||||
|
||||
/* Check status. */
|
||||
if ((status != TX_SUCCESS) || (thread_1_counter != 0))
|
||||
{
|
||||
|
||||
/* Byte memory error. */
|
||||
printf("ERROR #7\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
while(1)
|
||||
{
|
||||
|
||||
/* Allocate memory from the pool. */
|
||||
status = tx_byte_allocate(&pool_0, (VOID **) &pointer, 60, TX_WAIT_FOREVER);
|
||||
|
||||
/* Should never get here! */
|
||||
if (status != TX_NO_MEMORY)
|
||||
return;
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_1_counter++;
|
||||
}
|
||||
}
|
||||
|
||||
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
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
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
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
||||
/* This test is designed to test kernel setup functionality in ThreadX. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
#include "tx_initialize.h"
|
||||
#include "tx_thread.h"
|
||||
|
||||
|
||||
TEST_FLAG test_forced_mutex_timeout;
|
||||
TEST_FLAG threadx_mutex_suspension_put_test;
|
||||
TEST_FLAG threadx_mutex_suspension_priority_test;
|
||||
TEST_FLAG threadx_byte_allocate_loop_test;
|
||||
TEST_FLAG test_initialize_flag;
|
||||
TEST_FLAG threadx_byte_release_loop_test;
|
||||
TEST_FLAG test_stack_analyze_flag;
|
||||
|
||||
|
||||
/* Define the test control global variables. */
|
||||
|
||||
ULONG test_control_return_status;
|
||||
ULONG test_control_successful_tests;
|
||||
ULONG test_control_failed_tests;
|
||||
ULONG test_control_system_errors;
|
||||
|
||||
UINT test_mutex_from_init;
|
||||
UINT test_semaphore_from_init;
|
||||
UINT test_queue_from_init;
|
||||
UINT test_event_flags_from_init;
|
||||
UINT test_byte_pool_create_init;
|
||||
UINT test_block_pool_create_init;
|
||||
UINT test_timer_create_init;
|
||||
UINT mutex_priority_change_extension_selection;
|
||||
UINT priority_change_extension_selection;
|
||||
|
||||
|
||||
__attribute__((weak)) void abort_all_threads_suspended_on_mutex(void)
|
||||
{
|
||||
}
|
||||
|
||||
__attribute__((weak)) void suspend_lowest_priority(void)
|
||||
{
|
||||
}
|
||||
|
||||
__attribute__((weak)) void abort_and_resume_byte_allocating_thread(void)
|
||||
{
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
/* Setup the ThreadX kernel. */
|
||||
_tx_initialize_kernel_setup();
|
||||
|
||||
if (_tx_thread_system_state == TX_INITIALIZE_ALMOST_DONE)
|
||||
{
|
||||
printf("Running Initialize Kernel Setup Test................................ SUCCESS!\n");
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Running Initialize Kernel Setup Test................................ ERROR!\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void test_application_define(void *first_unused_memory){}
|
||||
void tx_application_define(void *first_unused_memory){}
|
||||
|
||||
|
||||
#ifndef TX_TIMER_PROCESS_IN_ISR
|
||||
|
||||
/* Define the deletion of the system timer thread. */
|
||||
|
||||
extern TX_THREAD _tx_timer_thread;
|
||||
TEST_FLAG threadx_delete_timer_thread;
|
||||
void delete_timer_thread(void)
|
||||
{
|
||||
|
||||
_tx_thread_terminate(&_tx_timer_thread);
|
||||
_tx_thread_delete(&_tx_timer_thread);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,94 @@
|
||||
/* This test is designed to test the interrupt control service call avaialbe to the
|
||||
application. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_interrupt_control_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Interrupt Control Test...................................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT saved_interrupt_posture;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Interrupt Control Test...................................... ");
|
||||
|
||||
/* Lockout interrupts. */
|
||||
saved_interrupt_posture = tx_interrupt_control(TX_INT_DISABLE);
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Restore interrupts. */
|
||||
saved_interrupt_posture = tx_interrupt_control(saved_interrupt_posture);
|
||||
|
||||
/* Sleep to make sure interrupts now work. */
|
||||
tx_thread_sleep(2);
|
||||
|
||||
/* Check to make sure the returned interrupt type works. */
|
||||
if (saved_interrupt_posture != TX_INT_DISABLE)
|
||||
{
|
||||
|
||||
/* Interrupt control error. */
|
||||
printf("ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,194 @@
|
||||
/* This test is designed to test the mutex suspension and mutex delete with
|
||||
suspended threads. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
static unsigned long thread_2_counter = 0;
|
||||
static TX_THREAD thread_2;
|
||||
|
||||
|
||||
static TX_MUTEX mutex_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
static void thread_2_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_mutex_delete_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Delete Test........................................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Delete Test........................................... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_2, "thread 2", thread_2_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Delete Test........................................... ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create a mutex. */
|
||||
status = tx_mutex_create(&mutex_0, "mutex 0", TX_NO_INHERIT);
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Delete Test........................................... ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Mutex Delete Test........................................... ");
|
||||
|
||||
/* Increment thread 0 counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Grab the mutex so it is owned by this thread. */
|
||||
status = tx_mutex_get(&mutex_0, TX_NO_WAIT);
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Relinquish to let other threads run. */
|
||||
tx_thread_relinquish();
|
||||
|
||||
/* Other threads should now be suspended on the mutex. */
|
||||
|
||||
/* Delete the mutex to test it out! */
|
||||
status = tx_mutex_delete(&mutex_0);
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Relinquish to allow other threads to run again before we return. */
|
||||
tx_thread_relinquish();
|
||||
|
||||
/* Now check the run counter of each thread. */
|
||||
if ((thread_1_counter != 1) || (thread_2_counter != 1))
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #7\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Suspend on the mutex. */
|
||||
status = tx_mutex_get(&mutex_0, TX_WAIT_FOREVER);
|
||||
|
||||
/* Did we get the right status? */
|
||||
if (status == TX_DELETED)
|
||||
thread_1_counter++;
|
||||
}
|
||||
|
||||
|
||||
static void thread_2_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Suspend on the mutex. */
|
||||
status = tx_mutex_get(&mutex_0, TX_WAIT_FOREVER);
|
||||
|
||||
/* Did we get the right status? */
|
||||
if (status == TX_DELETED)
|
||||
thread_2_counter++;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,173 @@
|
||||
/* This test is designed to test the mutex suspension and another thread resuming the
|
||||
same priority thread by doing a mutex put. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
|
||||
static TX_MUTEX mutex_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_mutext_no_preemption_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Put with No Preemption Test........................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Put with No Preemption Test........................... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create a mutex. */
|
||||
status = tx_mutex_create(&mutex_0, "mutex 0", TX_NO_INHERIT);
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Put with No Preemption Test........................... ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Mutex Put with No Preemption Test........................... ");
|
||||
|
||||
/* Increment thread 0 counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Get the mutex. */
|
||||
status = tx_mutex_get(&mutex_0, TX_NO_WAIT);
|
||||
|
||||
/* Should be successful. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Relinquish to make the other thread suspend on the mutex. */
|
||||
tx_thread_relinquish();
|
||||
|
||||
/* Make sure the other thread has run. */
|
||||
if (thread_1_counter != 1)
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Put the mutex, this should resume the other thread
|
||||
but not preempt this thread. */
|
||||
status = tx_mutex_put(&mutex_0);
|
||||
|
||||
/* Check the status and the run counter of the other thread. */
|
||||
if ((status != TX_SUCCESS) || (thread_1_counter != 1))
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Relinquish to allow the other thread to run. */
|
||||
tx_thread_relinquish();
|
||||
|
||||
/* Make sure the other thread has run. */
|
||||
if (thread_1_counter != 2)
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #7\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
/* Increment thread run counter. */
|
||||
thread_1_counter++;
|
||||
|
||||
/* Suspend on the mutex. */
|
||||
status = tx_mutex_get(&mutex_0, TX_WAIT_FOREVER);
|
||||
|
||||
/* Did we get the right status? */
|
||||
if (status == TX_SUCCESS)
|
||||
thread_1_counter++;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
/* This test is designed to test the mutex suspension and another thread resuming the
|
||||
higher priority thread by doing a mutex put. Higher-priority thread should preempt. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
|
||||
static TX_MUTEX mutex_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_mutex_preemption_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Put with Preemption Test.............................. ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
15, 15, 100, TX_DONT_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Put with Preemption Test.............................. ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create a mutex. */
|
||||
status = tx_mutex_create(&mutex_0, "mutex 0", TX_NO_INHERIT);
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Put with Preemption Test.............................. ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Mutex Put with Preemption Test.............................. ");
|
||||
|
||||
/* Increment thread 0 counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Get the mutex. */
|
||||
status = tx_mutex_get(&mutex_0, TX_NO_WAIT);
|
||||
|
||||
/* Should be successful. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Now resume the higher priority thread to cause suspension. */
|
||||
tx_thread_resume(&thread_1);
|
||||
|
||||
/* The other thread should now be suspended on the mutex. */
|
||||
if (thread_1_counter != 1)
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Release the mutex, this should cause the other thread
|
||||
to preempt. */
|
||||
status = tx_mutex_put(&mutex_0);
|
||||
|
||||
/* Check status and run counter of other thread. */
|
||||
if ((status != TX_SUCCESS) || (thread_1_counter != 2))
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
/* Increment thread run counter. */
|
||||
thread_1_counter++;
|
||||
|
||||
/* Suspend on the mutex. */
|
||||
status = tx_mutex_get(&mutex_0, TX_WAIT_FOREVER);
|
||||
|
||||
/* Did we get the right status? */
|
||||
if (status == TX_SUCCESS)
|
||||
thread_1_counter++;
|
||||
}
|
||||
|
||||
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
@@ -0,0 +1,198 @@
|
||||
/* This test is designed to test thread terminate calls when threads are suspended on
|
||||
a mutex. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
static unsigned long thread_2_counter = 0;
|
||||
static TX_THREAD thread_2;
|
||||
|
||||
|
||||
static TX_MUTEX mutex_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
static void thread_2_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_mutex_thread_terminate_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Thread Terminate Test................................. ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Thread Terminate Test................................. ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_2, "thread 2", thread_2_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Thread Terminate Test................................. ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create a mutex. */
|
||||
status = tx_mutex_create(&mutex_0, "mutex 0", 0);
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Mutex Thread Terminate Test................................. ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Get the mutex. */
|
||||
tx_mutex_get(&mutex_0, TX_NO_WAIT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Mutex Thread Terminate Test................................. ");
|
||||
|
||||
/* Increment thread 0 counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Relinquish to let other threads run. */
|
||||
tx_thread_relinquish();
|
||||
|
||||
/* Other threads should now be suspended on the mutex. */
|
||||
if ((thread_1_counter != 1) || (thread_2_counter != 1))
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Terminate the other threads to make sure the mutex gets
|
||||
cleaned up. */
|
||||
status = tx_thread_terminate(&thread_1);
|
||||
|
||||
/* Check status and run counters of other threads. */
|
||||
if ((status != TX_SUCCESS) || (thread_1_counter != 1) || (thread_2_counter != 1))
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Terminate the other thread. */
|
||||
status = tx_thread_terminate(&thread_2);
|
||||
|
||||
/* Relinquish just to make sure. */
|
||||
tx_thread_relinquish();
|
||||
|
||||
/* Check status and run counters of other threads. */
|
||||
if ((status != TX_SUCCESS) || (thread_1_counter != 1) || (thread_2_counter != 1))
|
||||
{
|
||||
|
||||
/* Mutex error. */
|
||||
printf("ERROR #7\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
//UINT status;
|
||||
|
||||
/* Increment thread run counter. */
|
||||
thread_1_counter++;
|
||||
|
||||
/* Suspend on the mutex. */
|
||||
tx_mutex_get(&mutex_0, 33);
|
||||
|
||||
/* Should never get here! */
|
||||
thread_1_counter++;
|
||||
}
|
||||
|
||||
|
||||
static void thread_2_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
//UINT status;
|
||||
|
||||
/* Increment thread run counter. */
|
||||
thread_2_counter++;
|
||||
|
||||
/* Suspend on the mutex. */
|
||||
tx_mutex_get(&mutex_0, 44);
|
||||
|
||||
/* Should never get here! */
|
||||
thread_2_counter++;
|
||||
}
|
||||
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
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
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
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
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,183 @@
|
||||
/* This test is designed to test thread terminate when the terminated thread is suspeded
|
||||
on a queue. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
static TX_QUEUE queue_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
static void queue_notify(TX_QUEUE *queue_ptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_queue_thread_terminate_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 17, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Queue Thread Terminate Test................................. ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Queue Thread Terminate Test................................. ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create the queue. */
|
||||
status = tx_queue_create(&queue_0, "queue 0", TX_2_ULONG, pointer, 3*2*sizeof(ULONG));
|
||||
pointer = pointer + 3*2*sizeof(ULONG);
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Queue Thread Terminate Test................................. ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Setup queue send notification. */
|
||||
status = tx_queue_send_notify(&queue_0, queue_notify);
|
||||
|
||||
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Queue Thread Terminate Test................................. ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
#else
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_FEATURE_NOT_ENABLED)
|
||||
{
|
||||
|
||||
printf("Running Queue Thread Terminate Test................................. ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Queue Thread Terminate Test................................. ");
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Make sure thread 1 is suspended on the queue. */
|
||||
if (thread_1.tx_thread_state != TX_QUEUE_SUSP)
|
||||
{
|
||||
|
||||
/* Queue error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Terminate thread 1 which is suspended on queue 0. */
|
||||
status = tx_thread_terminate(&thread_1);
|
||||
|
||||
/* Check status and make sure thread 1 is terminated. */
|
||||
if ((status != TX_SUCCESS) || (thread_1.tx_thread_state != TX_TERMINATED) ||
|
||||
(thread_1_counter != 0) || (queue_0.tx_queue_suspended_count))
|
||||
{
|
||||
|
||||
/* Queue error. */
|
||||
printf("ERROR #7\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
UINT status;
|
||||
ULONG dest_message[2];
|
||||
|
||||
|
||||
/* Loop forever! */
|
||||
while(1)
|
||||
{
|
||||
|
||||
|
||||
/* Receive message from empty queue. */
|
||||
status = tx_queue_receive(&queue_0, &dest_message[0], TX_WAIT_FOREVER);
|
||||
|
||||
if (status != TX_QUEUE_EMPTY)
|
||||
break;
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_1_counter++;
|
||||
}
|
||||
}
|
||||
|
||||
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
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,179 @@
|
||||
/* This test is designed to test the semaphore suspension and another thread resuming the
|
||||
higher priority thread by doing a semaphore put. Higher-priority thread should preempt. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
|
||||
static TX_SEMAPHORE semaphore_0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
static void put_notify(TX_SEMAPHORE *semaphore_ptr)
|
||||
{
|
||||
|
||||
/* Don't need to do anything in here... */
|
||||
}
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_semaphore_preemption_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Preemption Test................................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
15, 15, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Preemption Test................................... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create a semaphore with an initial count of 0. */
|
||||
status = tx_semaphore_create(&semaphore_0, "semaphore 0", 0);
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Preemption Test................................... ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Setup the semaphore notify callback. */
|
||||
status = tx_semaphore_put_notify(&semaphore_0, put_notify);
|
||||
|
||||
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Preemption Test................................... ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
#else
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_FEATURE_NOT_ENABLED)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Preemption Test................................... ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Semaphore Preemption Test................................... ");
|
||||
|
||||
/* Increment thread 0 counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* The other thread should now be suspended on the semaphore. */
|
||||
if (thread_1_counter != 1)
|
||||
{
|
||||
|
||||
/* Semaphore error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Place an instance on the semaphore, this should cause the other thread
|
||||
to preempt. */
|
||||
status = tx_semaphore_put(&semaphore_0);
|
||||
|
||||
/* Check status and run counter of other thread. */
|
||||
if ((status != TX_SUCCESS) || (thread_1_counter != 2))
|
||||
{
|
||||
|
||||
/* Semaphore error. */
|
||||
printf("ERROR #7\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
/* Increment thread run counter. */
|
||||
thread_1_counter++;
|
||||
|
||||
/* Suspend on the semaphore. */
|
||||
status = tx_semaphore_get(&semaphore_0, TX_WAIT_FOREVER);
|
||||
|
||||
/* Did we get the right status? */
|
||||
if (status == TX_SUCCESS)
|
||||
thread_1_counter++;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,165 @@
|
||||
/* This test is designed to test the semaphore suspension and timeout functionality. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
//static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static TX_SEMAPHORE semaphore_0;
|
||||
static TX_SEMAPHORE semaphore_1;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
static void put_notify(TX_SEMAPHORE *semaphore_ptr)
|
||||
{
|
||||
|
||||
/* Don't need to do anything in here... */
|
||||
}
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_semaphore_timeout_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Suspension Timeout Test........................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Create a semaphore with an initial count of 0. */
|
||||
status = tx_semaphore_create(&semaphore_0, "semaphore 0", 0);
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Suspension Timeout Test........................... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Setup the semaphore notify callback. */
|
||||
status = tx_semaphore_put_notify(&semaphore_0, put_notify);
|
||||
|
||||
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Suspension Timeout Test........................... ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_FEATURE_NOT_ENABLED)
|
||||
{
|
||||
|
||||
printf("Running Semaphore Suspension Timeout Test........................... ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Semaphore Suspension Timeout Test........................... ");
|
||||
|
||||
#ifndef TX_DISABLE_ERROR_CHECKING
|
||||
|
||||
/* Attempt to setup semaphore notify callback on non-semaphore. */
|
||||
status = tx_semaphore_put_notify(TX_NULL, put_notify);
|
||||
|
||||
/* Check status */
|
||||
if (status != TX_SEMAPHORE_ERROR)
|
||||
{
|
||||
|
||||
/* Semaphore error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Attempt to setup semaphore notify callback on non-created semaphore. */
|
||||
semaphore_1.tx_semaphore_id = 0;
|
||||
status = tx_semaphore_put_notify(&semaphore_1, put_notify);
|
||||
|
||||
/* Check status */
|
||||
if (status != TX_SEMAPHORE_ERROR)
|
||||
{
|
||||
|
||||
/* Semaphore error. */
|
||||
printf("ERROR #6\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Sleep for 2 ticks for fresh timer. */
|
||||
tx_thread_sleep(2);
|
||||
|
||||
/* Set clock to 0. */
|
||||
tx_time_set(0);
|
||||
|
||||
/* Suspend on the semaphore. */
|
||||
status = tx_semaphore_get(&semaphore_0, 33);
|
||||
|
||||
/* Did we get the right status at the right time? */
|
||||
if ((status != TX_NO_INSTANCE) || (tx_time_get() != 33))
|
||||
{
|
||||
|
||||
/* Semaphore error. */
|
||||
printf("ERROR #7\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,145 @@
|
||||
/* Define the ThreadX SMP one thread dynamic thread exclusion test. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
|
||||
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
|
||||
static ULONG thread_0_counter;
|
||||
|
||||
|
||||
static unsigned long error = 0;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_smp_one_thread_dynamic_exclusion_test(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
0, 0, TX_NO_TIME_SLICE, TX_DONT_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
status += tx_thread_smp_core_exclude(&thread_0, 0x0); /* No exclusions! */
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running SMP One Thread Dynamic Exclusion Test....................... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
|
||||
/* Resume thread 0. */
|
||||
status = tx_thread_resume(&thread_0);
|
||||
|
||||
/* Check status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running SMP One Thread Dynamic Exclusion Test....................... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
UINT status;
|
||||
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running SMP One Thread Dynamic Exclusion Test....................... ");
|
||||
|
||||
/* Move to core 1. */
|
||||
status = tx_thread_smp_core_exclude(&thread_0, 0xD); /* Only core 1! */
|
||||
|
||||
/* Determine if the test was successful or there was an error. */
|
||||
if ((status != TX_SUCCESS) || (tx_thread_smp_core_get() != 1))
|
||||
{
|
||||
|
||||
/* Execution error. */
|
||||
printf("ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Move to core 2. */
|
||||
status = tx_thread_smp_core_exclude(&thread_0, 0xB); /* Only core 2! */
|
||||
|
||||
/* Determine if the test was successful or there was an error. */
|
||||
if ((status != TX_SUCCESS) || (tx_thread_smp_core_get() != 2))
|
||||
{
|
||||
|
||||
/* Execution error. */
|
||||
printf("ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Move to core 3. */
|
||||
status = tx_thread_smp_core_exclude(&thread_0, 0x7); /* Only core 3! */
|
||||
|
||||
/* Determine if the test was successful or there was an error. */
|
||||
if ((status != TX_SUCCESS) || (tx_thread_smp_core_get() != 3))
|
||||
{
|
||||
|
||||
/* Execution error. */
|
||||
printf("ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Move back to core 0. */
|
||||
status = tx_thread_smp_core_exclude(&thread_0, 0xE); /* Only core 0! */
|
||||
|
||||
/* Determine if the test was successful or there was an error. */
|
||||
if ((status != TX_SUCCESS) || (tx_thread_smp_core_get() != 0))
|
||||
{
|
||||
|
||||
/* Execution error. */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
|
||||
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
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
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
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
||||
/* This test is designed to see if a thread can be created with a time-slice.
|
||||
No time-slice occurs, only the processing to check for time-slicing. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_thread_basic_time_slice_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
UCHAR *memory;
|
||||
|
||||
|
||||
memory = (UCHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
memory, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 1, TX_AUTO_START);
|
||||
memory = memory + TEST_STACK_SIZE_PRINTF;
|
||||
status += tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
memory, TEST_STACK_SIZE_PRINTF,
|
||||
16, 16, 1, TX_DONT_START);
|
||||
status += tx_thread_smp_core_exclude(&thread_1, 0xF);
|
||||
status += tx_thread_resume(&thread_1);
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Thread Basic Time-Slice Test................................ ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
ULONG target_time;
|
||||
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Thread Basic Time-Slice Test................................ ");
|
||||
|
||||
/* Calculate the target running time. */
|
||||
target_time = tx_time_get() + 20;
|
||||
|
||||
/* Enter into a forever loop. */
|
||||
while(1)
|
||||
{
|
||||
|
||||
/* Increment thread 0 counter. */
|
||||
thread_0_counter++;
|
||||
|
||||
/* Determine if we are done. */
|
||||
if (tx_time_get() >= target_time)
|
||||
{
|
||||
|
||||
/* Determine if thread 1 executed. */
|
||||
if (thread_1_counter != 0)
|
||||
{
|
||||
|
||||
/* Error, thread 1 has all cores excluded so it should never run. */
|
||||
printf("ERROR #2\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/* Successful Time-slice test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
/* Loop forever. */
|
||||
while(1)
|
||||
{
|
||||
|
||||
/* Increment counter. */
|
||||
thread_1_counter++;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,140 @@
|
||||
/* This test is designed to test for preemption-threshold use during thread creation during initialization. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "tx_api.h"
|
||||
|
||||
//static unsigned long thread_0_counter = 0;
|
||||
static TX_THREAD thread_0;
|
||||
|
||||
static unsigned long thread_1_counter = 0;
|
||||
static TX_THREAD thread_1;
|
||||
|
||||
static unsigned long thread_2_counter = 0;
|
||||
static TX_THREAD thread_2;
|
||||
|
||||
|
||||
/* Define thread prototypes. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input);
|
||||
static void thread_1_entry(ULONG thread_input);
|
||||
static void thread_2_entry(ULONG thread_input);
|
||||
|
||||
|
||||
/* Prototype for test control return. */
|
||||
void test_control_return(UINT status);
|
||||
|
||||
|
||||
/* Define what the initial system looks like. */
|
||||
|
||||
#ifdef CTEST
|
||||
void test_application_define(void *first_unused_memory)
|
||||
#else
|
||||
void threadx_thread_create_preemption_threshold_application_define(void *first_unused_memory)
|
||||
#endif
|
||||
{
|
||||
|
||||
UINT status;
|
||||
CHAR *pointer;
|
||||
|
||||
|
||||
/* Put first available memory address into a character pointer. */
|
||||
pointer = (CHAR *) first_unused_memory;
|
||||
|
||||
/* Put system definition stuff in here, e.g. thread creates and other assorted
|
||||
create information. */
|
||||
|
||||
status = tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
17, 0, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Thread Create Preemption-Threshold from Init Test........... ERROR #1\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
16, 0, 100, TX_AUTO_START);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Thread Create Preemption-Threshold from Init Test........... ERROR #2\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
|
||||
pointer, TEST_STACK_SIZE_PRINTF,
|
||||
15, 0, 100, TX_DONT_START);
|
||||
status += tx_thread_resume(&thread_0);
|
||||
pointer = pointer + TEST_STACK_SIZE_PRINTF;
|
||||
|
||||
/* Check for status. */
|
||||
if (status != TX_SUCCESS)
|
||||
{
|
||||
|
||||
printf("Running Thread Create Preemption-Threshold from Init Test........... ERROR #3\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Define the test threads. */
|
||||
|
||||
static void thread_0_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
/* Inform user. */
|
||||
printf("Running Thread Create Preemption-Threshold from Init Test........... ");
|
||||
|
||||
/* If either of the other threads have run, an error is present. */
|
||||
if ((thread_1_counter) || (thread_2_counter))
|
||||
{
|
||||
|
||||
/* Test error! */
|
||||
printf("ERROR #4\n");
|
||||
test_control_return(1);
|
||||
}
|
||||
|
||||
/* Sleep for two ticks (one is insufficient to guarantee the other
|
||||
tasks will run, if this executes too close to the tick interrupt. */
|
||||
tx_thread_sleep(2);
|
||||
|
||||
|
||||
/* Now, both threads should have run. */
|
||||
if ((thread_1_counter != 1) || (thread_2_counter != 1))
|
||||
{
|
||||
|
||||
/* Test error! */
|
||||
printf("ERROR #5\n");
|
||||
test_control_return(2);
|
||||
}
|
||||
|
||||
/* Successful test. */
|
||||
printf("SUCCESS!\n");
|
||||
test_control_return(0);
|
||||
}
|
||||
|
||||
|
||||
static void thread_1_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
/* Increment this thread's counter. */
|
||||
thread_1_counter++;
|
||||
}
|
||||
|
||||
|
||||
static void thread_2_entry(ULONG thread_input)
|
||||
{
|
||||
|
||||
/* Increment the thread counter. */
|
||||
thread_2_counter++;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user