diff options
Diffstat (limited to 'test/tx/regression/threadx_thread_basic_execution_test.c')
| -rw-r--r-- | test/tx/regression/threadx_thread_basic_execution_test.c | 212 |
1 files changed, 106 insertions, 106 deletions
diff --git a/test/tx/regression/threadx_thread_basic_execution_test.c b/test/tx/regression/threadx_thread_basic_execution_test.c index 7a5ae864..9949eac8 100644 --- a/test/tx/regression/threadx_thread_basic_execution_test.c +++ b/test/tx/regression/threadx_thread_basic_execution_test.c @@ -1,5 +1,5 @@ -/* This test is designed to see if one thread can be created and executed. - It thread_0_entry is hit, then the thread was successfully scheduled. +/* This test is designed to see if one thread can be created and executed. + It thread_0_entry is hit, then the thread was successfully scheduled. On success, thread_0_counter gets incremented. */ #include <stdio.h> @@ -56,10 +56,10 @@ static unsigned long isr_executed = 0; static void thread_0_entry(ULONG task_input); -UINT _txe_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr, +UINT _txe_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr, VOID (*entry_function)(ULONG), ULONG entry_input, - VOID *stack_start, ULONG stack_size, - UINT priority, UINT preempt_threshold, + VOID *stack_start, ULONG stack_size, + UINT priority, UINT preempt_threshold, ULONG time_slice, UINT auto_start, UINT thread_control_block_size); #ifndef TX_INLINE_THREAD_RESUME_SUSPEND @@ -92,8 +92,8 @@ CHAR *pointer; /* Attempt to create a thread from a timer. */ pointer = (CHAR *) 0x3000; - status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 16, TX_NO_TIME_SLICE, TX_DONT_START); /* Check for status. */ @@ -137,8 +137,8 @@ ULONG old_time_slice; /* Attempt to create a thread from a timer. */ pointer = (CHAR *) not_used_stack; - status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 16, TX_NO_TIME_SLICE, TX_DONT_START); /* Check for status. */ @@ -151,7 +151,7 @@ ULONG old_time_slice; /* Attempt to delete a thread from an ISR. */ status = tx_thread_delete(&thread_0); - + /* Check for status. */ if (status != TX_CALLER_ERROR) { @@ -162,7 +162,7 @@ ULONG old_time_slice; /* Attempt to change preemption from an ISR. */ status = tx_thread_preemption_change(&thread_0, 1, &old_value); - + /* Check for status. */ if (status != TX_CALLER_ERROR) { @@ -173,7 +173,7 @@ ULONG old_time_slice; /* Attempt to change priority from an ISR. */ status = tx_thread_priority_change(&thread_0, 1, &old_value); - + /* Check for status. */ if (status != TX_CALLER_ERROR) { @@ -235,7 +235,7 @@ ULONG old_time_slice; static void test_isr1(void) { - + UINT status; TX_THREAD *current_thread; @@ -247,31 +247,31 @@ TX_THREAD *current_thread; /* Pickup the current thread. */ current_thread = tx_thread_identify(); - + /* Determine if the condition is present. */ if ((current_thread == &thread_4) && (_tx_thread_preempt_disable) && (thread_4.tx_thread_state == TX_READY)) { - /* Suspend the currently running thread 4 with the preemption-threshold flag set to ensure tx_thread_suspend from an ISR works + /* Suspend the currently running thread 4 with the preemption-threshold flag set to ensure tx_thread_suspend from an ISR works in this case. */ status = tx_thread_suspend(&thread_4); - + /* Check for error. */ if (status != TX_SUCCESS) { - + /* Set error flag. */ error++; } /* Resume thread 4. */ tx_thread_resume(&thread_4); - + /* Indicate the test case has been found. */ test_case_found = TX_TRUE; - } + } } - + #endif #endif @@ -299,30 +299,30 @@ TX_THREAD fake_thread; /* Setup a pointer. */ pointer = (CHAR *) first_unused_memory; - + /* Adjust it forward just to make sure there is some space for the test below. */ pointer = pointer + 200; /* 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, + + 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; - + #ifndef TX_INLINE_THREAD_RESUME_SUSPEND #ifndef TX_NOT_INTERRUPTABLE - status += tx_thread_create(&thread_4, "thread 4", thread_4_entry, 4, - pointer, TEST_STACK_SIZE_PRINTF, + status += tx_thread_create(&thread_4, "thread 4", thread_4_entry, 4, + pointer, TEST_STACK_SIZE_PRINTF, 15, 15, TX_NO_TIME_SLICE, TX_DONT_START); pointer = pointer + TEST_STACK_SIZE_PRINTF; - + #endif -#endif - - +#endif + + /* Check for status. */ if (status != TX_SUCCESS) { @@ -331,7 +331,7 @@ TX_THREAD fake_thread; test_control_return(1); } - + #ifndef TX_NOT_INTERRUPTABLE /* Now setup a fake thread to generate the other NULL pointer test in the cleanup routines. */ @@ -370,7 +370,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Setup test thread to make sure _tx_thread_wait_abort can handle a NULL cleanup. */ test_thread.tx_thread_state = TX_IO_DRIVER; - test_thread.tx_thread_suspend_cleanup = TX_NULL; + test_thread.tx_thread_suspend_cleanup = TX_NULL; test_thread.tx_thread_timer.tx_timer_internal_list_head = TX_NULL; test_thread.tx_thread_suspending = TX_TRUE; test_thread.tx_thread_delayed_suspend = TX_TRUE; @@ -382,7 +382,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Setup test thread to make sure _tx_thread_timeout can handle a NULL cleanup. */ test_thread.tx_thread_state = TX_IO_DRIVER; - test_thread.tx_thread_suspend_cleanup = TX_NULL; + test_thread.tx_thread_suspend_cleanup = TX_NULL; test_thread.tx_thread_timer.tx_timer_internal_list_head = TX_NULL; test_thread.tx_thread_suspending = TX_TRUE; test_thread.tx_thread_delayed_suspend = TX_TRUE; @@ -392,12 +392,12 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); temp_mutex_release = _tx_thread_mutex_release; _tx_thread_mutex_release = TX_NULL; test_thread.tx_thread_state = TX_TERMINATED; - test_thread.tx_thread_suspend_cleanup = TX_NULL; + test_thread.tx_thread_suspend_cleanup = TX_NULL; test_thread.tx_thread_timer.tx_timer_internal_list_head = TX_NULL; test_thread.tx_thread_suspending = TX_TRUE; test_thread.tx_thread_timer.tx_timer_internal_list_head = TX_NULL; test_thread.tx_thread_delayed_suspend = TX_TRUE; - status = _tx_thread_terminate(&test_thread); + status = _tx_thread_terminate(&test_thread); _tx_thread_mutex_release = temp_mutex_release; /* Recover Mutex release pointer. */ /* Perform thread memory test. */ @@ -407,10 +407,10 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); thread_memory.second_middle= 0x61718191; thread_memory.next_to_last = 0x99aabbcc; thread_memory.last = 0xddeeff00; - + /* Create the thread. */ - status += tx_thread_create(&thread_memory.thread_block, "thread memory", thread_0_entry, 1, - &thread_memory.stack[0], (2048*sizeof(ULONG))/sizeof(ULONG), + status += tx_thread_create(&thread_memory.thread_block, "thread memory", thread_0_entry, 1, + &thread_memory.stack[0], (2048*sizeof(ULONG))/sizeof(ULONG), 16, 16, TX_NO_TIME_SLICE, TX_DONT_START); tx_thread_delete(&thread_memory.thread_block); @@ -423,7 +423,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); (thread_memory.next_to_last != 0x99aabbcc) || (thread_memory.last != 0xddeeff00)) { - + /* Memory overwrite error. */ printf("ERROR #2\n"); test_control_return(1); @@ -435,8 +435,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread with a null pointer. */ pointer = (CHAR *) not_used_stack; - status = tx_thread_create(TX_NULL, "thread 0", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(TX_NULL, "thread 0", thread_0_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 16, TX_NO_TIME_SLICE, TX_AUTO_START); /* Check for status. */ @@ -449,8 +449,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread with a bad control block size. */ pointer = (CHAR *) not_used_stack; - status = _txe_thread_create(&thread_3, "thread 3", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = _txe_thread_create(&thread_3, "thread 3", thread_0_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 16, TX_NO_TIME_SLICE, TX_AUTO_START, (sizeof(TX_THREAD)+1)); /* Check for status. */ @@ -463,8 +463,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread with a NULL entry function. */ pointer = (CHAR *) not_used_stack; - status = tx_thread_create(&thread_3, "thread 3", TX_NULL, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_3, "thread 3", TX_NULL, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 16, TX_NO_TIME_SLICE, TX_AUTO_START); /* Check for status. */ @@ -477,8 +477,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread that has already been created. */ pointer = (CHAR *) not_used_stack; - status = tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + 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); /* Check for status. */ @@ -490,8 +490,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); } /* Attempt to create a thread with an overlapping stack. */ - status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, - thread_0.tx_thread_stack_ptr, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, + thread_0.tx_thread_stack_ptr, TEST_STACK_SIZE_PRINTF, 16, 16, TX_NO_TIME_SLICE, TX_AUTO_START); /* Check for status. */ @@ -505,8 +505,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread with another variation of an overlapping stack. */ pointer = thread_0.tx_thread_stack_start; pointer = pointer - 20; - status = tx_thread_create(&thread_1, "thread 1", TX_NULL, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_1, "thread 1", TX_NULL, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 16, TX_NO_TIME_SLICE, TX_AUTO_START); /* Check for status. */ @@ -519,8 +519,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread an extra small stack. */ pointer = (CHAR *) not_used_stack; - status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, - pointer, 1, + status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, + pointer, 1, 16, 16, TX_NO_TIME_SLICE, TX_AUTO_START); /* Check for status. */ @@ -533,8 +533,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread with an invalid thread priority. */ pointer = (CHAR *) not_used_stack; - status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 5000, 5000, TX_NO_TIME_SLICE, TX_AUTO_START); /* Check for status. */ @@ -547,8 +547,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread with an invalid preemption-threshold. */ pointer = (CHAR *) not_used_stack; - status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 17, TX_NO_TIME_SLICE, TX_AUTO_START); /* Check for status. */ @@ -561,8 +561,8 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to create a thread with an invalid auto start. */ pointer = (CHAR *) not_used_stack; - status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, - pointer, TEST_STACK_SIZE_PRINTF, + status = tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1, + pointer, TEST_STACK_SIZE_PRINTF, 16, 16, TX_NO_TIME_SLICE, 3456); /* Check for status. */ @@ -598,7 +598,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to register a entry/exit callback on a non-thread. */ status = tx_thread_entry_exit_notify(TX_NULL, TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -610,7 +610,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to register a entry/exit callback on a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_entry_exit_notify(&thread_2, TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -621,7 +621,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to get info on a non-thread. */ status = tx_thread_info_get(TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -633,7 +633,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to get info on a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_info_get(&thread_2, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -644,7 +644,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to change preemption of a non-thread. */ status = tx_thread_preemption_change(TX_NULL, 1, TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -652,11 +652,11 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #19\n"); test_control_return(1); } - + /* Attempt to change preemption of a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_preemption_change(&thread_2, 1, TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -667,7 +667,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to change preemption with a NULL return value. */ status = tx_thread_preemption_change(&thread_0, 1, TX_NULL); - + /* Check for status. */ if (status != TX_PTR_ERROR) { @@ -675,10 +675,10 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #21\n"); test_control_return(1); } - + /* Attempt to change preemption with a bad threshold value. */ status = tx_thread_preemption_change(&thread_0, 17, &old_value); - + /* Check for status. */ if (status != TX_THRESH_ERROR) { @@ -690,7 +690,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to change priority of a non-thread. */ status = tx_thread_priority_change(TX_NULL, 1, TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -698,11 +698,11 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #23\n"); test_control_return(1); } - + /* Attempt to change priority of a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_priority_change(&thread_2, 1, TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -713,7 +713,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt to change priority with a NULL return value. */ status = tx_thread_priority_change(&thread_0, 1, TX_NULL); - + /* Check for status. */ if (status != TX_PTR_ERROR) { @@ -721,10 +721,10 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #25\n"); test_control_return(1); } - + /* Attempt to change priority with a bad priority value. */ status = tx_thread_priority_change(&thread_0, 2046, &old_value); - + /* Check for status. */ if (status != TX_PRIORITY_ERROR) { @@ -769,7 +769,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt a thread resume with a NULL pointer. */ status = tx_thread_resume(TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -777,11 +777,11 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #30\n"); test_control_return(1); } - + /* Attempt a thread resume on a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_resume(&thread_2); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -792,7 +792,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt a thread suspend with a NULL pointer. */ status = tx_thread_suspend(TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -800,11 +800,11 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #32\n"); test_control_return(1); } - + /* Attempt a thread suspend on a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_suspend(&thread_2); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -815,7 +815,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt a thread termiante with a NULL pointer. */ status = tx_thread_terminate(TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -823,11 +823,11 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #34\n"); test_control_return(1); } - + /* Attempt a thread terminate on a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_terminate(&thread_2); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -838,7 +838,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt a thread time-slice chagne with a NULL pointer. */ status = tx_thread_time_slice_change(TX_NULL, 1, &old_time_slice); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -846,11 +846,11 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #36\n"); test_control_return(1); } - + /* Attempt a thread time-slice change on a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_time_slice_change(&thread_2, 1, &old_time_slice); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -861,7 +861,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt a thread time-slice change with a null return pointer. */ status = tx_thread_time_slice_change(&thread_0, 1, TX_NULL); - + /* Check for status. */ if (status != TX_PTR_ERROR) { @@ -872,7 +872,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Attempt a thread wait abort with a NULL pointer. */ status = tx_thread_wait_abort(TX_NULL); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -880,11 +880,11 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); printf("ERROR #39\n"); test_control_return(1); } - + /* Attempt a thread wait abort on a non-created thread. */ thread_2.tx_thread_id = 0; status = tx_thread_wait_abort(&thread_2); - + /* Check for status. */ if (status != TX_THREAD_ERROR) { @@ -908,7 +908,7 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* Test for error. */ if ((error) || (timer_executed != 1) || (isr_executed != 1)) { - + /* Thread error. */ printf("ERROR #41\n"); test_control_return(1); @@ -921,25 +921,25 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); /* At this point setup the ISR. */ test_isr_dispatch = test_isr1; - + /* Resume thread 4. */ - tx_thread_resume(&thread_4); - + tx_thread_resume(&thread_4); + /* Clear the ISR. */ - test_isr_dispatch = TX_NULL; - + test_isr_dispatch = TX_NULL; + /* Now check for an error. */ if ((error) || (test_case_found == TX_FALSE)) { - + /* Basic execution error. */ printf("ERROR #42\n"); test_control_return(1); } - + +#endif #endif -#endif - + /* Successful test. */ printf("SUCCESS!\n"); test_control_return(0); @@ -952,13 +952,13 @@ VOID (*temp_mutex_release)(TX_THREAD *thread_ptr); static void thread_4_entry(ULONG thread_input) { -TX_INTERRUPT_SAVE_AREA +TX_INTERRUPT_SAVE_AREA /* Loop until we achieve as suspend request while inside of the tx_thread_resume API. */ while (test_case_found == TX_FALSE) { - + /* Temporarily disable preemption for the test. */ TX_DISABLE _tx_thread_preempt_disable++; @@ -966,7 +966,7 @@ TX_INTERRUPT_SAVE_AREA /* Increment the run counter for this test. */ thread_4_counter++; - + TX_DISABLE _tx_thread_preempt_disable--; TX_RESTORE @@ -974,6 +974,6 @@ TX_INTERRUPT_SAVE_AREA } #endif -#endif +#endif |
