1 /* This test is designed to see if one thread can be created and executed.
2    It thread_0_entry is hit, then the thread was successfully scheduled.
3    On success, thread_0_counter gets incremented.  */
4 
5 #include   <stdio.h>
6 #include   "tx_api.h"
7 #include   "tx_block_pool.h"
8 #include   "tx_byte_pool.h"
9 #include   "tx_event_flags.h"
10 #include   "tx_mutex.h"
11 #include   "tx_queue.h"
12 #include   "tx_semaphore.h"
13 #include   "tx_thread.h"
14 
15 
16 typedef struct THREAD_MEMORY_TEST_STRUCT
17 {
18     ULONG       first;
19     ULONG       second;
20     TX_THREAD   thread_block;
21     ULONG       first_middle;
22     ULONG       second_middle;
23     ULONG       stack[2048/sizeof(ULONG)];
24     ULONG       next_to_last;
25     ULONG       last;
26 
27 } THREAD_MEMORY_TEST;
28 
29 static  THREAD_MEMORY_TEST   thread_memory;
30 
31 
32 
33 /* Define the ISR dispatch.  */
34 
35 extern VOID    (*test_isr_dispatch)(void);
36 
37 
38 static unsigned long   thread_0_counter =  0;
39 static TX_THREAD       thread_0;
40 static TX_THREAD       thread_1;
41 static TX_THREAD       thread_2;
42 static TX_THREAD       thread_3;
43 static TX_THREAD       test_thread;
44 
45 static TX_TIMER        timer_0;
46 
47 
48 static UCHAR           not_used_stack[TEST_STACK_SIZE_PRINTF];
49 
50 static unsigned long error =  0;
51 static unsigned long timer_executed =  0;
52 static unsigned long isr_executed =  0;
53 
54 
55 /* Define task prototypes.  */
56 
57 static void    thread_0_entry(ULONG task_input);
58 
59 UINT        _txe_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr,
60                 VOID (*entry_function)(ULONG), ULONG entry_input,
61                 VOID *stack_start, ULONG stack_size,
62                 UINT priority, UINT preempt_threshold,
63                 ULONG time_slice, UINT auto_start, UINT thread_control_block_size);
64 
65 
66 /* Prototype for test control return.  */
67 
68 void  test_control_return(UINT status);
69 
70 
71 /* Define the timer for this test.  */
72 
timer_entry(ULONG i)73 static void    timer_entry(ULONG i)
74 {
75 
76 #ifndef TX_DISABLE_ERROR_CHECKING
77 
78 UINT    status;
79 CHAR    *pointer;
80 
81     /* Attempt to create a thread from a timer.  */
82     pointer =  (CHAR *) 0x3000;
83     status =  tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1,
84             pointer, TEST_STACK_SIZE_PRINTF,
85             16, 16, TX_NO_TIME_SLICE, TX_DONT_START);
86 
87     /* Check for status.  */
88     if (status != TX_CALLER_ERROR)
89     {
90 
91         /* Error!  */
92         error++;
93     }
94 
95     /* Attempt a thread reset from a timer.  */
96     status =  tx_thread_reset(&thread_0);
97 
98     /* Check for status.  */
99     if (status != TX_CALLER_ERROR)
100     {
101 
102         /* Error!  */
103         error++;
104     }
105 
106     timer_executed =  1;
107 #endif
108 }
109 
110 /* Define the ISR dispatch routine.  */
111 
test_isr(void)112 static void    test_isr(void)
113 {
114 
115 #ifndef TX_DISABLE_ERROR_CHECKING
116 
117 CHAR    *pointer;
118 UINT    status;
119 UINT    old_value;
120 ULONG   old_time_slice;
121 
122 
123     /* Call tx_thread_relinquish from ISR to make sure the error checking discards the call.  */
124     tx_thread_relinquish();
125 
126     /* Attempt to create a thread from a timer.  */
127     pointer =  (CHAR *) not_used_stack;
128     status =  tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1,
129             pointer, TEST_STACK_SIZE_PRINTF,
130             16, 16, TX_NO_TIME_SLICE, TX_DONT_START);
131 
132     /* Check for status.  */
133     if (status != TX_CALLER_ERROR)
134     {
135 
136         /* Error!  */
137         error++;
138     }
139 
140     /* Attempt to delete a thread from an ISR.  */
141     status =  tx_thread_delete(&thread_0);
142 
143     /* Check for status.  */
144     if (status != TX_CALLER_ERROR)
145     {
146 
147         /* Error!  */
148         error++;
149     }
150 
151     /* Attempt to change preemption from an ISR.  */
152     status =  tx_thread_preemption_change(&thread_0, 1, &old_value);
153 
154     /* Check for status.  */
155     if (status != TX_CALLER_ERROR)
156     {
157 
158         /* Error!  */
159         error++;
160     }
161 
162     /* Attempt to change priority from an ISR.  */
163     status =  tx_thread_priority_change(&thread_0, 1, &old_value);
164 
165     /* Check for status.  */
166     if (status != TX_CALLER_ERROR)
167     {
168 
169         /* Error!  */
170         error++;
171     }
172 
173     /* Attempt a thread reset from an ISR.  */
174     status =  tx_thread_reset(&thread_0);
175 
176     /* Check for status.  */
177     if (status != TX_CALLER_ERROR)
178     {
179 
180         /* Error!  */
181         error++;
182     }
183 
184     /* Attempt a thread terminate from an ISR.  */
185     status =  tx_thread_terminate(&thread_0);
186 
187     /* Check for status.  */
188     if (status != TX_CALLER_ERROR)
189     {
190 
191         /* Error!  */
192         error++;
193     }
194 
195     /* Attempt a thread time slice change from an ISR.  */
196     status =  tx_thread_time_slice_change(&thread_0, 1, &old_time_slice);
197 
198     /* Check for status.  */
199     if (status != TX_CALLER_ERROR)
200     {
201 
202         /* Error!  */
203         error++;
204     }
205 
206     isr_executed =  1;
207 #endif
208 
209     /* Test thread sleep call from ISR.  */
210     status =  tx_thread_sleep(11);
211 
212     /* Check for status.  */
213     if (status != TX_CALLER_ERROR)
214     {
215 
216         /* Error!  */
217         error++;
218     }
219 }
220 
221 #if 0
222 static void    test_thread_entry(ULONG thread_input)
223 {
224     /* Do nothing here!  */
225 }
226 #endif
227 
228 /* Define what the initial system looks like.  */
229 
230 #ifdef CTEST
test_application_define(void * first_unused_memory)231 void test_application_define(void *first_unused_memory)
232 #else
233 void    threadx_thread_basic_execution_application_define(void *first_unused_memory)
234 #endif
235 {
236 
237 INT         status;
238 CHAR        *pointer;
239 TX_THREAD   fake_thread;
240 
241 
242     /* Setup a pointer.  */
243     pointer =  (CHAR *) first_unused_memory;
244 
245     /* Adjust it forward just to make sure there is some space for the test below.  */
246     pointer =  pointer + 200;
247 
248     /* Put system definition stuff in here, e.g. thread creates and other assorted
249        create information.  */
250 
251     status =  tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
252             pointer, TEST_STACK_SIZE_PRINTF,
253             16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
254 
255     /* Check for status.  */
256     if (status != TX_SUCCESS)
257     {
258 
259         printf("Running Thread Basic Execution Test................................. ERROR #1\n");
260         test_control_return(1);
261     }
262 
263 #ifndef TX_NOT_INTERRUPTABLE
264 
265     /* Now setup a fake thread to generate the other NULL pointer test in the cleanup routines.  */
266     fake_thread.tx_thread_suspend_control_block =  TX_NULL;
267     _tx_semaphore_cleanup(&fake_thread, 0);
268     _tx_queue_cleanup(&fake_thread, 0);
269     _tx_mutex_cleanup(&fake_thread, 0);
270     _tx_event_flags_cleanup(&fake_thread, 0);
271     _tx_byte_pool_cleanup(&fake_thread, 0);
272     _tx_block_pool_cleanup(&fake_thread, 0);
273 #endif
274 }
275 
276 
277 
278 /* Define the test threads.  */
279 
thread_0_entry(ULONG thread_input)280 static void    thread_0_entry(ULONG thread_input)
281 {
282 
283 #ifndef TX_DISABLE_ERROR_CHECKING
284 UINT    status;
285 CHAR    *pointer;
286 UINT    old_value;
287 ULONG   old_time_slice;
288 #endif
289 
290 VOID            (*temp_mutex_release)(TX_THREAD *thread_ptr);
291 
292 
293     /* Increment thread 0 counter.  */
294     thread_0_counter++;
295 
296     /* Inform user of success getting to this test.  */
297     printf("Running Thread Basic Execution Test................................. ");
298 
299     /* Setup test thread to make sure _tx_thread_wait_abort can handle a NULL cleanup.  */
300     test_thread.tx_thread_state =                              TX_IO_DRIVER;
301     test_thread.tx_thread_suspend_cleanup =                    TX_NULL;
302     test_thread.tx_thread_timer.tx_timer_internal_list_head =  TX_NULL;
303     test_thread.tx_thread_suspending =                         TX_TRUE;
304     test_thread.tx_thread_delayed_suspend =                    TX_TRUE;
305     if(_tx_thread_wait_abort(&test_thread) != TX_WAIT_ABORT_ERROR)
306     {
307         printf("ERROR #XX\n");
308         test_control_return(1);
309     }
310 
311     /* Setup test thread to make sure _tx_thread_timeout can handle a NULL cleanup.  */
312     test_thread.tx_thread_state =                              TX_IO_DRIVER;
313     test_thread.tx_thread_suspend_cleanup =                    TX_NULL;
314     test_thread.tx_thread_timer.tx_timer_internal_list_head =  TX_NULL;
315     test_thread.tx_thread_suspending =                         TX_TRUE;
316     test_thread.tx_thread_delayed_suspend =                    TX_TRUE;
317     _tx_thread_timeout((ULONG) &test_thread);
318 
319     /* Setup test thread to make sure _tx_thread_terminate can handle a NULL mutex release function pointer.  */
320     temp_mutex_release =  _tx_thread_mutex_release;
321     _tx_thread_mutex_release =  TX_NULL;
322     test_thread.tx_thread_state =                              TX_TERMINATED;
323     test_thread.tx_thread_suspend_cleanup =                    TX_NULL;
324     test_thread.tx_thread_timer.tx_timer_internal_list_head =  TX_NULL;
325     test_thread.tx_thread_suspending =                         TX_TRUE;
326     test_thread.tx_thread_timer.tx_timer_internal_list_head =  TX_NULL;
327     test_thread.tx_thread_delayed_suspend =                    TX_TRUE;
328     status =  _tx_thread_terminate(&test_thread);
329     _tx_thread_mutex_release =  temp_mutex_release;     /* Recover Mutex release pointer.  */
330 
331     /* Perform thread memory test.  */
332     thread_memory.first =        0x11223344;
333     thread_memory.second =       0x55667788;
334     thread_memory.first_middle = 0x21314151;
335     thread_memory.second_middle= 0x61718191;
336     thread_memory.next_to_last = 0x99aabbcc;
337     thread_memory.last =         0xddeeff00;
338 
339     /* Create the thread.  */
340     status +=  tx_thread_create(&thread_memory.thread_block, "thread memory", thread_0_entry, 1,
341             &thread_memory.stack[0], (2048*sizeof(ULONG))/sizeof(ULONG),
342             16, 16, TX_NO_TIME_SLICE, TX_DONT_START);
343     tx_thread_delete(&thread_memory.thread_block);
344 
345     /* Check for status.  */
346     if ((status != TX_SUCCESS) ||
347         (thread_memory.first != 0x11223344) ||
348         (thread_memory.second != 0x55667788) ||
349         (thread_memory.first_middle != 0x21314151) ||
350         (thread_memory.second_middle != 0x61718191) ||
351         (thread_memory.next_to_last != 0x99aabbcc) ||
352         (thread_memory.last != 0xddeeff00))
353     {
354 
355         /* Memory overwrite error.  */
356         printf("ERROR #2\n");
357         test_control_return(1);
358     }
359 
360 
361 
362 #ifndef TX_DISABLE_ERROR_CHECKING
363 
364     /* Attempt to create a thread with a null pointer.  */
365     pointer =  (CHAR *) not_used_stack;
366     status =  tx_thread_create(TX_NULL, "thread 0", thread_0_entry, 1,
367             pointer, TEST_STACK_SIZE_PRINTF,
368             16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
369 
370     /* Check for status.  */
371     if (status != TX_THREAD_ERROR)
372     {
373 
374         printf("ERROR #3\n");
375         test_control_return(1);
376     }
377 
378     /* Attempt to create a thread with a bad control block size.  */
379     pointer =  (CHAR *) not_used_stack;
380     status =  _txe_thread_create(&thread_3, "thread 3", thread_0_entry, 1,
381             pointer, TEST_STACK_SIZE_PRINTF,
382             16, 16, TX_NO_TIME_SLICE, TX_AUTO_START, (sizeof(TX_THREAD)+1));
383 
384     /* Check for status.  */
385     if (status != TX_THREAD_ERROR)
386     {
387 
388         printf("ERROR #4\n");
389         test_control_return(1);
390     }
391 
392     /* Attempt to create a thread with a NULL entry function.  */
393     pointer =  (CHAR *) not_used_stack;
394     status =  tx_thread_create(&thread_3, "thread 3", TX_NULL, 1,
395             pointer, TEST_STACK_SIZE_PRINTF,
396             16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
397 
398     /* Check for status.  */
399     if (status != TX_PTR_ERROR)
400     {
401 
402         printf("ERROR #5\n");
403         test_control_return(1);
404     }
405 
406     /* Attempt to create a thread that has already been created.  */
407     pointer =  (CHAR *) not_used_stack;
408     status =  tx_thread_create(&thread_0, "thread 0", thread_0_entry, 1,
409             pointer, TEST_STACK_SIZE_PRINTF,
410             16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
411 
412     /* Check for status.  */
413     if (status != TX_THREAD_ERROR)
414     {
415 
416         printf("ERROR #6\n");
417         test_control_return(1);
418     }
419 
420     /* Attempt to create a thread with an overlapping stack.  */
421     status =  tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1,
422             thread_0.tx_thread_stack_ptr, TEST_STACK_SIZE_PRINTF,
423             16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
424 
425     /* Check for status.  */
426     if (status != TX_PTR_ERROR)
427     {
428 
429         printf("ERROR #7\n");
430         test_control_return(1);
431     }
432 
433     /* Attempt to create a thread with another variation of an overlapping stack.  */
434     pointer =  thread_0.tx_thread_stack_start;
435     pointer =  pointer - 20;
436     status =  tx_thread_create(&thread_1, "thread 1", TX_NULL, 1,
437             pointer, TEST_STACK_SIZE_PRINTF,
438             16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
439 
440     /* Check for status.  */
441     if (status != TX_PTR_ERROR)
442     {
443 
444         printf("ERROR #8\n");
445         test_control_return(1);
446     }
447 
448     /* Attempt to create a thread an extra small stack.  */
449     pointer =  (CHAR *) not_used_stack;
450     status =  tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1,
451             pointer, 1,
452             16, 16, TX_NO_TIME_SLICE, TX_AUTO_START);
453 
454     /* Check for status.  */
455     if (status != TX_SIZE_ERROR)
456     {
457 
458         printf("ERROR #9\n");
459         test_control_return(1);
460     }
461 
462     /* Attempt to create a thread with an invalid thread priority.  */
463     pointer =  (CHAR *) not_used_stack;
464     status =  tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1,
465             pointer, TEST_STACK_SIZE_PRINTF,
466             5000, 5000, TX_NO_TIME_SLICE, TX_AUTO_START);
467 
468     /* Check for status.  */
469     if (status != TX_PRIORITY_ERROR)
470     {
471 
472         printf("ERROR #10\n");
473         test_control_return(1);
474     }
475 
476     /* Attempt to create a thread with an invalid preemption-threshold.  */
477     pointer =  (CHAR *) not_used_stack;
478     status =  tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1,
479             pointer, TEST_STACK_SIZE_PRINTF,
480             16, 17, TX_NO_TIME_SLICE, TX_AUTO_START);
481 
482     /* Check for status.  */
483     if (status != TX_THRESH_ERROR)
484     {
485 
486         printf("ERROR #11\n");
487         test_control_return(1);
488     }
489 
490     /* Attempt to create a thread with an invalid auto start.  */
491     pointer =  (CHAR *) not_used_stack;
492     status =  tx_thread_create(&thread_1, "thread 1", thread_0_entry, 1,
493             pointer, TEST_STACK_SIZE_PRINTF,
494             16, 16, TX_NO_TIME_SLICE, 3456);
495 
496     /* Check for status.  */
497     if (status != TX_START_ERROR)
498     {
499 
500         printf("ERROR #12\n");
501         test_control_return(1);
502     }
503 
504     /* Attempt to delete a non-thread.  */
505     status =  tx_thread_delete(TX_NULL);
506 
507     /* Check for status.  */
508     if (status != TX_THREAD_ERROR)
509     {
510 
511         printf("ERROR #13\n");
512         test_control_return(1);
513     }
514 
515     /* Attempt to delete a non-created thread.  */
516     thread_2.tx_thread_id =  0;
517     status =  tx_thread_delete(&thread_2);
518 
519     /* Check for status.  */
520     if (status != TX_THREAD_ERROR)
521     {
522 
523         printf("ERROR #14\n");
524         test_control_return(1);
525     }
526 
527     /* Attempt to register a entry/exit callback on a non-thread.  */
528     status =  tx_thread_entry_exit_notify(TX_NULL, TX_NULL);
529 
530     /* Check for status.  */
531     if (status != TX_THREAD_ERROR)
532     {
533 
534         printf("ERROR #15\n");
535         test_control_return(1);
536     }
537 
538     /* Attempt to register a entry/exit callback on a non-created thread.  */
539     thread_2.tx_thread_id =  0;
540     status =  tx_thread_entry_exit_notify(&thread_2, TX_NULL);
541 
542     /* Check for status.  */
543     if (status != TX_THREAD_ERROR)
544     {
545 
546         printf("ERROR #16\n");
547         test_control_return(1);
548     }
549 
550     /* Attempt to get info on a non-thread.  */
551     status =  tx_thread_info_get(TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL);
552 
553     /* Check for status.  */
554     if (status != TX_THREAD_ERROR)
555     {
556 
557         printf("ERROR #17\n");
558         test_control_return(1);
559     }
560 
561     /* Attempt to get info on a non-created thread.  */
562     thread_2.tx_thread_id =  0;
563     status =  tx_thread_info_get(&thread_2, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL, TX_NULL);
564 
565     /* Check for status.  */
566     if (status != TX_THREAD_ERROR)
567     {
568 
569         printf("ERROR #18\n");
570         test_control_return(1);
571     }
572 
573     /* Attempt to change preemption of a non-thread.  */
574     status =  tx_thread_preemption_change(TX_NULL, 1, TX_NULL);
575 
576     /* Check for status.  */
577     if (status != TX_THREAD_ERROR)
578     {
579 
580         printf("ERROR #19\n");
581         test_control_return(1);
582     }
583 
584     /* Attempt to change preemption of a non-created thread.  */
585     thread_2.tx_thread_id =  0;
586     status =  tx_thread_preemption_change(&thread_2, 1, TX_NULL);
587 
588     /* Check for status.  */
589     if (status != TX_THREAD_ERROR)
590     {
591 
592         printf("ERROR #20\n");
593         test_control_return(1);
594     }
595 
596     /* Attempt to change preemption with a NULL return value.  */
597     status =  tx_thread_preemption_change(&thread_0, 1, TX_NULL);
598 
599     /* Check for status.  */
600     if (status != TX_PTR_ERROR)
601     {
602 
603         printf("ERROR #21\n");
604         test_control_return(1);
605     }
606 
607     /* Attempt to change preemption with a bad threshold value.  */
608     status =  tx_thread_preemption_change(&thread_0, 17, &old_value);
609 
610     /* Check for status.  */
611     if (status != TX_THRESH_ERROR)
612     {
613 
614         printf("ERROR #22\n");
615         test_control_return(1);
616     }
617 
618 
619     /* Attempt to change priority of a non-thread.  */
620     status =  tx_thread_priority_change(TX_NULL, 1, TX_NULL);
621 
622     /* Check for status.  */
623     if (status != TX_THREAD_ERROR)
624     {
625 
626         printf("ERROR #23\n");
627         test_control_return(1);
628     }
629 
630     /* Attempt to change priority of a non-created thread.  */
631     thread_2.tx_thread_id =  0;
632     status =  tx_thread_priority_change(&thread_2, 1, TX_NULL);
633 
634     /* Check for status.  */
635     if (status != TX_THREAD_ERROR)
636     {
637 
638         printf("ERROR #24\n");
639         test_control_return(1);
640     }
641 
642     /* Attempt to change priority with a NULL return value.  */
643     status =  tx_thread_priority_change(&thread_0, 1, TX_NULL);
644 
645     /* Check for status.  */
646     if (status != TX_PTR_ERROR)
647     {
648 
649         printf("ERROR #25\n");
650         test_control_return(1);
651     }
652 
653     /* Attempt to change priority with a bad priority value.  */
654     status =  tx_thread_priority_change(&thread_0, 2046, &old_value);
655 
656     /* Check for status.  */
657     if (status != TX_PRIORITY_ERROR)
658     {
659 
660         printf("ERROR #26\n");
661         test_control_return(1);
662     }
663 
664     /* Attempt a thread reset for a non-thread.  */
665     status =  tx_thread_reset(TX_NULL);
666 
667     /* Check for status.  */
668     if (status != TX_THREAD_ERROR)
669     {
670 
671         printf("ERROR #27\n");
672         test_control_return(1);
673     }
674 
675     /* Attempt a thread reset from same thread.  */
676     status =  tx_thread_reset(&thread_0);
677 
678     /* Check for status.  */
679     if (status != TX_NOT_DONE)
680     {
681 
682         printf("ERROR #28\n");
683         test_control_return(1);
684     }
685 
686     /* Attempt a thread reset for a non-created thread.  */
687     thread_2.tx_thread_id =  0;
688     status =  tx_thread_reset(&thread_2);
689 
690     /* Check for status.  */
691     if (status != TX_THREAD_ERROR)
692     {
693 
694         printf("ERROR #29\n");
695         test_control_return(1);
696     }
697 
698     /* Attempt a thread resume with a NULL pointer.  */
699     status = tx_thread_resume(TX_NULL);
700 
701     /* Check for status.  */
702     if (status != TX_THREAD_ERROR)
703     {
704 
705         printf("ERROR #30\n");
706         test_control_return(1);
707     }
708 
709     /* Attempt a thread resume on a non-created thread.  */
710     thread_2.tx_thread_id =  0;
711     status = tx_thread_resume(&thread_2);
712 
713     /* Check for status.  */
714     if (status != TX_THREAD_ERROR)
715     {
716 
717         printf("ERROR #31\n");
718         test_control_return(1);
719     }
720 
721     /* Attempt a thread suspend with a NULL pointer.  */
722     status = tx_thread_suspend(TX_NULL);
723 
724     /* Check for status.  */
725     if (status != TX_THREAD_ERROR)
726     {
727 
728         printf("ERROR #32\n");
729         test_control_return(1);
730     }
731 
732     /* Attempt a thread suspend on a non-created thread.  */
733     thread_2.tx_thread_id =  0;
734     status = tx_thread_suspend(&thread_2);
735 
736     /* Check for status.  */
737     if (status != TX_THREAD_ERROR)
738     {
739 
740         printf("ERROR #33\n");
741         test_control_return(1);
742     }
743 
744     /* Attempt a thread termiante with a NULL pointer.  */
745     status = tx_thread_terminate(TX_NULL);
746 
747     /* Check for status.  */
748     if (status != TX_THREAD_ERROR)
749     {
750 
751         printf("ERROR #34\n");
752         test_control_return(1);
753     }
754 
755     /* Attempt a thread terminate on a non-created thread.  */
756     thread_2.tx_thread_id =  0;
757     status = tx_thread_terminate(&thread_2);
758 
759     /* Check for status.  */
760     if (status != TX_THREAD_ERROR)
761     {
762 
763         printf("ERROR #35\n");
764         test_control_return(1);
765     }
766 
767     /* Attempt a thread time-slice chagne with a NULL pointer.  */
768     status = tx_thread_time_slice_change(TX_NULL, 1, &old_time_slice);
769 
770     /* Check for status.  */
771     if (status != TX_THREAD_ERROR)
772     {
773 
774         printf("ERROR #36\n");
775         test_control_return(1);
776     }
777 
778     /* Attempt a thread time-slice change on a non-created thread.  */
779     thread_2.tx_thread_id =  0;
780     status = tx_thread_time_slice_change(&thread_2, 1, &old_time_slice);
781 
782     /* Check for status.  */
783     if (status != TX_THREAD_ERROR)
784     {
785 
786         printf("ERROR #37\n");
787         test_control_return(1);
788     }
789 
790     /* Attempt a thread time-slice change with a null return pointer.  */
791     status = tx_thread_time_slice_change(&thread_0, 1, TX_NULL);
792 
793     /* Check for status.  */
794     if (status != TX_PTR_ERROR)
795     {
796 
797         printf("ERROR #38\n");
798         test_control_return(1);
799     }
800 
801     /* Attempt a thread wait abort with a NULL pointer.  */
802     status = tx_thread_wait_abort(TX_NULL);
803 
804     /* Check for status.  */
805     if (status != TX_THREAD_ERROR)
806     {
807 
808         printf("ERROR #39\n");
809         test_control_return(1);
810     }
811 
812     /* Attempt a thread wait abort on a non-created thread.  */
813     thread_2.tx_thread_id =  0;
814     status = tx_thread_wait_abort(&thread_2);
815 
816     /* Check for status.  */
817     if (status != TX_THREAD_ERROR)
818     {
819 
820         printf("ERROR #40\n");
821         test_control_return(1);
822     }
823 
824     /* Create a timer for the test.  */
825     tx_timer_create(&timer_0, "timer 0", timer_entry, 0, 1, 1, TX_AUTO_ACTIVATE);
826 
827     /* Setup the ISR.  */
828     test_isr_dispatch =  test_isr;
829 
830     /* Sleep for a bit...  */
831     tx_thread_sleep(3);
832 
833     /* Clear the ISR.  */
834     test_isr_dispatch =  TX_NULL;
835 
836     /* Test for error.  */
837     if ((error) || (timer_executed != 1) || (isr_executed != 1))
838     {
839 
840         /* Thread error.  */
841         printf("ERROR #41\n");
842         test_control_return(1);
843     }
844 
845 #endif
846 
847     /* Check status.  */
848     if (error)
849     {
850 
851         /* Block memory error.  */
852         printf("ERROR #42\n");
853         test_control_return(1);
854     }
855     else
856     {
857 
858         /* Successful test.  */
859         printf("SUCCESS!\n");
860         test_control_return(0);
861     }
862 
863 }
864