Release ThreadX regression system

This commit is contained in:
Tiejun Zhou
2023-04-04 09:40:54 +00:00
parent ac3b6b326c
commit ebeb02b958
229 changed files with 87243 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
cmake_policy(SET CMP0054 NEW)
cmake_policy(SET CMP0057 NEW)
project(threadx_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_REGRESSION_TEST
-DTEST_STACK_SIZE_PRINTF=4096
${${CMAKE_BUILD_TYPE}})
add_link_options(-m32)
enable_testing()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../../.. threadx)
add_subdirectory(regression)
add_subdirectory(samples)
# Coverage
if(CMAKE_BUILD_TYPE MATCHES ".*_coverage")
target_compile_options(threadx PRIVATE -fprofile-arcs -ftest-coverage)
target_link_options(threadx PRIVATE -fprofile-arcs -ftest-coverage)
endif()
target_compile_options(
threadx
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)
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
set -e
cd $(dirname $0)
mkdir -p coverage_report/$1
gcovr --object-directory=build/$1/threadx/CMakeFiles/threadx.dir/common/src -r build/$1 -f ../../../common/src --xml-pretty --output coverage_report/$1.xml
gcovr --object-directory=build/$1/threadx/CMakeFiles/threadx.dir/common/src -r build/$1 -f ../../../common/src --html --html-details --output coverage_report/$1/index.html
+121
View File
@@ -0,0 +1,121 @@
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_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)
target_compile_definitions(test_utility PUBLIC CTEST BATCH_TEST
TEST_STACK_SIZE_PRINTF=4096)
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
View File
@@ -0,0 +1,10 @@
#!/bin/bash
dst=$(dirname $0)/../../regression/tx_initialize_low_level.c
src=$(dirname $0)/../../../../ports/linux/gnu/src/tx_initialize_low_level.c
line=`sed -n '/_tx_linux_timer_interrupt/=' $src | tail -n 1`
sed "${line}iVOID test_interrupt_dispatch(VOID);" $src > tmp1
line=`sed -n '/_tx_timer_interrupt/=' $src | tail -n 1`
sed "${line}itest_interrupt_dispatch();" tmp1 > $dst
rm tmp1
+1
View File
@@ -0,0 +1 @@
../../../tools/cmake_bootstrap.sh
+15
View File
@@ -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/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)
endforeach()
+20
View File
@@ -0,0 +1,20 @@
#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;
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,81 @@
/* 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;
__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,167 @@
/* 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;
ULONG now;
/* 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? */
now = tx_time_get();
if ((status != TX_NO_INSTANCE) || (now != 33))
{
/* Semaphore error. */
printf("ERROR #7, now = %lu\n", now);
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,73 @@
/* 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;
/* 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_thread_basic_time_slice_application_define(void *first_unused_memory)
#endif
{
UINT status;
/* 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,
first_unused_memory, TEST_STACK_SIZE_PRINTF,
16, 16, 1, TX_AUTO_START);
/* 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)
{
/* Inform user. */
printf("Running Thread Basic Time-Slice Test................................ ");
/* Enter into a forever loop. */
while(1)
{
/* Increment thread 0 counter. */
thread_0_counter++;
/* Determine if we are done. */
if (tx_time_get() > 18)
{
/* Successful Time-slice test. */
printf("SUCCESS!\n");
test_control_return(0);
}
}
}
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
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,184 @@
/* This test is designed to test multiple threads sleeping for 33 ticks. */
#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 unsigned long thread_3_counter = 0;
static TX_THREAD thread_3;
/* 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);
static void thread_3_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_multiple_sleep_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, 3, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Multiple Thread Sleep for 33 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, 3, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Multiple Thread Sleep for 33 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, 3, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Multiple Thread Sleep for 33 Test.................... ERROR #3\n");
test_control_return(1);
}
status = tx_thread_create(&thread_3, "thread 3", thread_3_entry, 1,
pointer, TEST_STACK_SIZE_PRINTF,
15, 15, 3, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Multiple Thread Sleep for 33 Test.................... ERROR #4\n");
test_control_return(1);
}
}
/* Define the test threads. */
static void thread_0_entry(ULONG thread_input)
{
/* Enter into a forever loop. */
while(1)
{
/* Increment thread 0 counter. */
thread_0_counter++;
/* Sleep for a couple ticks. */
tx_thread_sleep(33);
}
}
static void thread_1_entry(ULONG thread_input)
{
/* Enter into a forever loop. */
while(1)
{
/* Increment thread 1 counter. */
thread_1_counter++;
/* Sleep for a couple ticks. */
tx_thread_sleep(33);
}
}
static void thread_2_entry(ULONG thread_input)
{
/* Enter into a forever loop. */
while(1)
{
/* Increment thread 0 counter. */
thread_2_counter++;
/* Sleep for a couple ticks. */
tx_thread_sleep(33);
}
}
static void thread_3_entry(ULONG thread_input)
{
/* Inform user. */
printf("Running Thread Multiple Thread Sleep for 33 Test.................... ");
/* Clear the tick count. */
tx_time_set(0);
/* Sleep for 100 ticks (+1 in case tick before threads 0,1,2 have run). */
tx_thread_sleep(101);
/* Determine if the sleep was accurate. */
if ((thread_0_counter == 4) && (thread_1_counter == 4) &&
(thread_2_counter == 4))
{
/* Successful Multiple Sleep test. */
printf("SUCCESS!\n");
test_control_return(0);
}
else
{
/* Thread Multiple Sleep error. */
printf("ERROR #5\n");
test_control_return(1);
}
}
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,193 @@
/* This test is designed to see if multiple threads can be created and relinquish control between them. */
#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 unsigned long thread_3_counter = 0;
static TX_THREAD thread_3;
/* 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);
static void thread_3_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_relinquish_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. */
/* Create thread 0. */
status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 0,
pointer, TEST_STACK_SIZE_PRINTF,
16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Relinquish Test...................................... ERROR #1\n");
test_control_return(1);
}
/* Create thread 1. */
status = tx_thread_create(&thread_1, "thread 1", thread_1_entry, 1,
pointer, TEST_STACK_SIZE_PRINTF,
16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Relinquish Test...................................... ERROR #2\n");
test_control_return(1);
}
/* Create thread 2. */
status = tx_thread_create(&thread_2, "thread 2", thread_2_entry, 2,
pointer, TEST_STACK_SIZE_PRINTF,
16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Relinquish Test...................................... ERROR #3\n");
test_control_return(1);
}
/* Create thread 3. */
status = tx_thread_create(&thread_3, "thread 3", thread_3_entry, 3,
pointer, TEST_STACK_SIZE_PRINTF,
16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Relinquish Test...................................... ERROR #4\n");
test_control_return(1);
}
}
/* Define the test threads. */
static void thread_0_entry(ULONG thread_input)
{
/* Check for correct input value and execution of other threads. */
if ((thread_input != 0) || (thread_1_counter) || (thread_2_counter) ||
(thread_3_counter))
return;
/* Increment thread 0 counter. */
thread_0_counter++;
/* Relinquish to other thread(s). */
tx_thread_relinquish();
}
static void thread_1_entry(ULONG thread_input)
{
/* Check for correct input value and execution of other threads. */
if ((thread_input != 1) || (thread_0_counter != 1) || (thread_2_counter) ||
(thread_3_counter))
return;
/* Increment thread 1 counter. */
thread_1_counter++;
/* Relinquish to other thread(s). */
tx_thread_relinquish();
}
static void thread_2_entry(ULONG thread_input)
{
/* Check for correct input value and execution of other threads. */
if ((thread_input != 2) || (thread_0_counter != 1) || (thread_1_counter != 1) ||
(thread_3_counter))
return;
/* Increment thread 2 counter. */
thread_2_counter++;
/* Relinquish to other thread(s). */
tx_thread_relinquish();
}
static void thread_3_entry(ULONG thread_input)
{
/* Inform user. */
printf("Running Thread Relinquish Test...................................... ");
/* Check for correct input value and execution of other threads. */
if ((thread_input != 3) || (thread_0_counter != 1) || (thread_1_counter != 1) ||
(thread_2_counter != 1) || (thread_0.tx_thread_state != TX_READY) ||
(thread_1.tx_thread_state != TX_READY) || (thread_2.tx_thread_state != TX_READY))
return;
/* Increment thread 3 counter. */
thread_3_counter++;
/* Immediate response relinquish. */
tx_thread_relinquish();
/* All other threads should be completed now. */
if ((thread_0.tx_thread_state != TX_COMPLETED) || (thread_1.tx_thread_state != TX_COMPLETED) ||
(thread_2.tx_thread_state != TX_COMPLETED))
{
/* Thread Relinquish error. */
printf("ERROR #5\n");
test_control_return(1);
}
/* Execute immediate response relinquish. */
tx_thread_relinquish();
/* Successful thread relinquish test. */
printf("SUCCESS!\n");
test_control_return(0);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,92 @@
/* This test is designed to test a simple sleep for 18 ticks, with something in the
remaining field of the thread control block. */
#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_thread_simple_sleep_non_clear_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;
/* Place a 1 in the thread control block to simulate a control block created in
random memory. */
thread_0.tx_thread_timer.tx_timer_internal_re_initialize_ticks = 1;
/* 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, 3, TX_AUTO_START);
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Sleep with non-zero TX_THREAD........................ ERROR #1\n");
test_control_return(1);
}
}
/* Define the test threads. */
static void thread_0_entry(ULONG thread_input)
{
ULONG now;
/* Inform user. */
printf("Running Thread Sleep with non-zero TX_THREAD........................ ");
/* Clear the tick count. */
tx_time_set(0);
/* Sleep for 18 ticks. */
tx_thread_sleep(9);
tx_thread_sleep(9);
/* Determine if the sleep was accurate. */
now = tx_time_get();
if ((now == 18) ||
(now == 19))
{
/* Successful Simple Sleep test. */
printf("SUCCESS!\n");
test_control_return(0);
}
else
{
/* Thread Simple Sleep error. */
printf("ERROR #2, now = %lu\n", now);
test_control_return(1);
}
}
@@ -0,0 +1,87 @@
/* This test is designed to test a simple sleep for 18 ticks. */
#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_thread_simple_sleep_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, 3, TX_AUTO_START);
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Simple Sleep for 18 Ticks Test....................... ERROR #1\n");
test_control_return(1);
}
}
/* Define the test threads. */
static void thread_0_entry(ULONG thread_input)
{
ULONG now;
/* Inform user. */
printf("Running Thread Simple Sleep for 18 Ticks Test....................... ");
/* Clear the tick count. */
tx_time_set(0);
/* Sleep for 18 ticks. */
tx_thread_sleep(18);
/* Determine if the sleep was accurate. */
now = tx_time_get();
if ((now == 18) ||
(now == 19))
{
/* Successful Simple Sleep test. */
printf("SUCCESS!\n");
test_control_return(0);
}
else
{
/* Thread Simple Sleep error. */
printf("ERROR #2, now = %lu\n", now);
test_control_return(1);
}
}
@@ -0,0 +1,116 @@
/* This test is designed to see if a thread can successfully suspend itself in a single
thread system. This also tests a thread created that is not automatically enabled. */
#include <stdio.h>
#include "tx_api.h"
static unsigned long thread_0_counter = 0;
static TX_THREAD thread_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_simple_supsend_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, TX_NO_TIME_SLICE, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Simple Suspend 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, TX_NO_TIME_SLICE, TX_DONT_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Simple Suspend Test.................................. ERROR #2\n");
test_control_return(1);
}
}
/* Define the test thread. */
static void thread_0_entry(ULONG thread_input)
{
UINT status;
/* Resume the test control thread. */
status = tx_thread_resume(&thread_1);
/* Check status. */
if (status != TX_SUCCESS)
return;
/* Increment thread 0 counter. */
thread_0_counter++;
/* Suspend the running thread. */
tx_thread_suspend(&thread_0);
}
static void thread_1_entry(ULONG thread_input)
{
/* Inform user. */
printf("Running Thread Simple Suspend Test.................................. ");
/* The other thread should be in a suspended state now. */
if ((thread_0.tx_thread_state != TX_SUSPENDED) || (thread_0_counter != 1))
{
/* Thread Suspend error. */
printf("ERROR #3\n");
test_control_return(1);
}
else
{
/* Successful Thread Suspend test. */
printf("SUCCESS!\n");
test_control_return(0);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,187 @@
/* This test is designed to test thread termination of a thread in a sleep condition. */
#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 unsigned long thread_1_enter = 0;
static unsigned long thread_1_exit = 0;
static TX_THREAD thread_1;
extern UINT _tx_thread_preempt_disable;
/* 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 entry_exit_notify(TX_THREAD *thread_ptr, UINT type)
{
/* Check for the appropriate thread. */
if (thread_ptr != &thread_1)
return;
/* Check for type. */
if (type == TX_THREAD_ENTRY)
thread_1_enter++;
else if (type == TX_THREAD_EXIT)
thread_1_exit++;
}
/* Define what the initial system looks like. */
#ifdef CTEST
void test_application_define(void *first_unused_memory)
#else
void threadx_thread_sleep_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 Thread Suspend 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,
18, 18, 100, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Suspend Terminate Test............................... ERROR #2\n");
test_control_return(1);
}
/* Setup the notify call to test that logic. */
status += tx_thread_entry_exit_notify(&thread_1, entry_exit_notify);
#ifndef TX_DISABLE_NOTIFY_CALLBACKS
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Suspend Terminate Test............................... ERROR #3\n");
test_control_return(1);
}
#else
/* Check for status. */
if (status != TX_FEATURE_NOT_ENABLED)
{
printf("Running Thread Suspend Terminate 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 Thread Suspend Terminate Test............................... ");
/* Increment run counter. */
thread_0_counter++;
/* Sleep to allow lower-priority thread 1 to run. */
tx_thread_sleep(5);
/* Now terminate thread 1. */
status = tx_thread_terminate(&thread_1);
/* Check status. */
if ((status != TX_SUCCESS) || (thread_1_counter != 1) || (_tx_thread_preempt_disable))
{
/* Terminate error. */
printf("ERROR #5\n");
test_control_return(1);
}
/* Now try to suspend a terminated thread. */
status = tx_thread_suspend(&thread_1);
/* Check status. */
if (status != TX_SUSPEND_ERROR)
{
/* Suspend 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;
while(1)
{
/* Increment run counter. */
thread_1_counter++;
/* Suspend thread 1. */
status = tx_thread_sleep(100);
/* Check status. */
if (status != TX_SUCCESS)
{
thread_1_counter = 0; /* Make an error! */
return;
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,149 @@
/* This test is designed to test the change time-slice service call. */
#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;
extern unsigned long _tx_timer_time_slice;
/* 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_time_slice_change_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 Thread Time-Slice Change 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,
22, 22, 200, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Time-Slice Change Test............................... ERROR #2\n");
test_control_return(1);
}
}
/* Define the test threads. */
static void thread_0_entry(ULONG thread_input)
{
UINT status;
ULONG old_time_slice = 0;
/* Inform user. */
printf("Running Thread Time-Slice Change Test............................... ");
/* Increment thread 0 counter. */
thread_0_counter++;
/* Change the time-slice of other thread. */
status = tx_thread_time_slice_change(&thread_1, 33, &old_time_slice);
/* Check status and the time sice of specified thread. */
if ((status != TX_SUCCESS) || (old_time_slice != 200) || (thread_1.tx_thread_new_time_slice != 33))
{
/* Thread error. */
printf("ERROR #3\n");
test_control_return(1);
}
/* Sleep to get a fresh timer. */
tx_thread_sleep(1);
/* Change the time-slice of this thread. */
status = tx_thread_time_slice_change(&thread_0, 66, &old_time_slice);
/* Check status and the time sice of specified thread. */
if ((status != TX_SUCCESS) || (old_time_slice != 100) || (thread_0.tx_thread_new_time_slice != 66) ||
(_tx_timer_time_slice != 66))
{
/* Thread error. */
printf("ERROR #4\n");
test_control_return(1);
}
/* Change the time-slice of this thread. */
status = tx_thread_time_slice_change(&thread_1, 2, &old_time_slice);
/* Sleep for 8 ticks just to allow thread 1 to run and time-slice with no other thread ready. */
tx_thread_sleep(8);
if (status != TX_SUCCESS)
{
/* Thread error. */
printf("ERROR #5\n");
test_control_return(1);
}
else
{
/* Successful test. */
printf("SUCCESS!\n");
test_control_return(0);
}
}
static void thread_1_entry(ULONG thread_input)
{
while(1)
{
/* Identify. */
tx_thread_identify();
/* Increment the thread counter. */
thread_1_counter++;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,138 @@
/* This test is designed to test thread wait abort. */
#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_wait_abort_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, TX_NO_TIME_SLICE, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Wait Abort 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, TX_NO_TIME_SLICE, TX_DONT_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Thread Wait Abort 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 Thread Wait Abort Test...................................... ");
/* Let other thread run. */
tx_thread_resume(&thread_1);
/* Make sure thread 1 is sleeping. */
if (thread_1.tx_thread_state != TX_SLEEP)
{
/* Thread error. */
printf("ERROR #3\n");
test_control_return(1);
}
/* At this point, call tx_thread_wait_abort to abort the sleep in thread1. */
status = tx_thread_wait_abort(&thread_1);
/* Check for status. */
if ((status != TX_SUCCESS) || (thread_1.tx_thread_state != TX_SUSPENDED))
{
/* Thread error. */
printf("ERROR #4\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;
/* Sleep for a long long time. */
status = tx_thread_sleep(1000000000);
/* Check for the proper status. */
if (status != TX_WAIT_ABORTED)
{
/* Thread error. */
printf("ERROR #5\n");
test_control_return(1);
}
/* Increment the thread counter. */
thread_1_counter++;
/* Suspend self. */
tx_thread_suspend(&thread_1);
}
@@ -0,0 +1,107 @@
/* This test is designed to test simple tx_time_get and set services. */
#include <stdio.h>
#include "tx_api.h"
static unsigned long thread_0_counter = 0;
static TX_THREAD thread_0;
/* Prototype for test control return. */
void test_control_return(UINT status);
/* Define thread prototypes. */
static void thread_0_entry(ULONG thread_input);
/* Define what the initial system looks like. */
#ifdef CTEST
void test_application_define(void *first_unused_memory)
#else
void threadx_time_get_set_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, 3, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Time Simple Get/Set Test.................................... ERROR #1\n");
test_control_return(1);
}
}
/* Define the test threads. */
static void thread_0_entry(ULONG thread_input)
{
ULONG current_time;
/* Inform user. */
printf("Running Time Simple Get/Set Test.................................... ");
/* Increment thread 0 counter. */
thread_0_counter++;
/* Sleep for 1 tick to get a fresh timer. */
tx_thread_sleep(1);
/* Set time to 0. */
tx_time_set(0);
/* Sleep for a couple ticks. */
tx_thread_sleep(35);
/* Pickup the current time. */
current_time = tx_time_get();
/* Check Current time. It should be 35. */
if (current_time != 35)
{
/* System time error. */
printf("ERROR #2\n");
test_control_return(1);
}
/* Set the new time. */
tx_time_set(7);
/* Check the new time. */
if (tx_time_get() != 7)
{
/* System time error. */
printf("ERROR #3\n");
test_control_return(1);
}
else
{
/* Successful time 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
@@ -0,0 +1,186 @@
/* This test is designed to test the accuracy of three free running timers. */
#include <stdio.h>
#include "tx_api.h"
//static unsigned long thread_0_counter = 0;
static TX_THREAD thread_0;
static unsigned long timer_0_counter = 0;
static TX_TIMER timer_0;
static unsigned long timer_1_counter = 0;
static TX_TIMER timer_1;
static unsigned long timer_2_counter = 0;
static TX_TIMER timer_2;
/* Define prototypes. */
static void thread_0_entry(ULONG thread_input);
static void timer_0_expiration(ULONG timer_input);
static void timer_1_expiration(ULONG timer_input);
static void timer_2_expiration(ULONG timer_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_timer_multiple_accuracy_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, 3, TX_AUTO_START);
pointer = pointer + TEST_STACK_SIZE_PRINTF;
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Timer Multiple Timer Accuracy Test.......................... ERROR #1\n");
test_control_return(1);
}
status = tx_timer_create(&timer_0, "timer 0", timer_0_expiration, 0x1234,
1, 1, TX_NO_ACTIVATE);
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Timer Multiple Timer Accuracy Test.......................... ERROR #2\n");
test_control_return(1);
}
status = tx_timer_create(&timer_1, "timer 1", timer_1_expiration, 0x1234,
2, 2, TX_NO_ACTIVATE);
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Timer Multiple Timer Accuracy Test.......................... ERROR #3\n");
test_control_return(1);
}
status = tx_timer_create(&timer_2, "timer 2", timer_2_expiration, 0x1234,
3, 3, TX_NO_ACTIVATE);
/* Check for status. */
if (status != TX_SUCCESS)
{
printf("Running Timer Multiple Timer Accuracy 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 Timer Multiple Timer Accuracy Test.......................... ");
/* Sleep to get a fresh timer. */
tx_thread_sleep(1);
/* Activate all the timers. */
status = tx_timer_activate(&timer_0);
/* Check status. */
if (status != TX_SUCCESS)
{
/* Application timer error. */
printf("ERROR #5\n");
test_control_return(1);
}
status = tx_timer_activate(&timer_1);
/* Check status. */
if (status != TX_SUCCESS)
{
/* Application timer error. */
printf("ERROR #6\n");
test_control_return(1);
}
status = tx_timer_activate(&timer_2);
/* Check status. */
if (status != TX_SUCCESS)
{
/* Application timer error. */
printf("ERROR #7\n");
test_control_return(1);
}
/* Sleep for a some ticks. */
tx_thread_sleep(300);
/* Insure that each timer ran twice. */
if ((timer_0_counter != 300) || (timer_1_counter != 150) ||
(timer_2_counter != 100))
{
/* Application timer error. */
printf("ERROR #8\n");
test_control_return(1);
}
else
{
/* Successful timer test. */
printf("SUCCESS!\n");
test_control_return(0);
}
}
static void timer_0_expiration(ULONG timer_input)
{
/* Process timer expiration. */
timer_0_counter++;
}
static void timer_1_expiration(ULONG timer_input)
{
/* Process timer expiration. */
timer_1_counter++;
}
static void timer_2_expiration(ULONG timer_input)
{
/* Process timer expiration. */
timer_2_counter++;
}

Some files were not shown because too many files have changed in this diff Show More