From 2d6009586815a2e862932b8607bceb34f7706460 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 26 Aug 1997 19:24:22 +0000 Subject: Patches from Chris Johns to clean up test. --- testsuites/libtests/rtems++/Init.cc | 18 ++++-------------- testsuites/libtests/rtems++/System.h | 18 ++++++++++++++++++ testsuites/libtests/rtems++/Task1.cc | 31 ++++++++++++++++++++++++++++--- testsuites/libtests/rtems++/Task2.cc | 2 +- testsuites/libtests/rtems++/Task3.cc | 2 +- 5 files changed, 52 insertions(+), 19 deletions(-) (limited to 'testsuites/libtests') diff --git a/testsuites/libtests/rtems++/Init.cc b/testsuites/libtests/rtems++/Init.cc index c995a3de10..edffed05e9 100644 --- a/testsuites/libtests/rtems++/Init.cc +++ b/testsuites/libtests/rtems++/Init.cc @@ -25,15 +25,13 @@ #define TEST_INIT #include "System.h" +// make global so it lasts past the Init task's stack's life time +Task1 task_1; + rtems_task Init(rtems_task_argument ) { puts( "\n\n*** RTEMS++ TEST ***" ); - rtemsEvent end_me("INIT"); - Task1 task_1; - - task_1.set_end_event(end_me); - printf( "INIT - Task.create() - " ); task_1.create("TA1 ", 0, RTEMS_MINIMUM_STACK_SIZE); printf("%s\n", task_1.last_status_string()); @@ -54,15 +52,7 @@ rtems_task Init(rtems_task_argument ) task_1.start(0xDEADDEAD); printf("%s\n", task_1.last_status_string()); - // block waiting for any event - rtems_event_set out; - - // wait for task1 to tell me to finish - end_me.receive(RTEMS_SIGNAL_0, out); - - task_1.destroy(); - - printf("*** END OF RTEMS++ TEST ***"); + printf("INIT - Destroy it's self\n"); // needs to be in C, no C++ object owns the Init task rtems_status_code status = rtems_task_delete( RTEMS_SELF ); diff --git a/testsuites/libtests/rtems++/System.h b/testsuites/libtests/rtems++/System.h index 5e11e59238..dad9c8dca0 100644 --- a/testsuites/libtests/rtems++/System.h +++ b/testsuites/libtests/rtems++/System.h @@ -39,6 +39,10 @@ class Task1 { rtemsEvent end_init; + rtemsEvent end_init; + + rtemsEvent end_init; + void print_mode(rtems_mode mode, rtems_mode mask); void screen1(void); @@ -48,8 +52,10 @@ class Task1 void screen5(void); void screen6(void); + void set_end_event(rtemsEvent& end_event) { end_init = end_event; } protected: virtual void body(rtems_task_argument argument); + void set_end_event(rtemsEvent& end_event) { end_init = end_event; } public: void set_end_event(rtemsEvent& end_event) { end_init = end_event; } @@ -72,6 +78,18 @@ public: class Task3 : public rtemsTask { +}; + +class EndTask + : public rtemsTask +{ +protected: + virtual void body(rtems_task_argument argument); + +public: + EndTask(const char* name, + const rtems_task_priority initial_priority, + const rtems_unsigned32 stack_size); void screen6(void); protected: diff --git a/testsuites/libtests/rtems++/Task1.cc b/testsuites/libtests/rtems++/Task1.cc index c6212c8c26..5dbd4d7ea9 100644 --- a/testsuites/libtests/rtems++/Task1.cc +++ b/testsuites/libtests/rtems++/Task1.cc @@ -23,6 +23,7 @@ * $Id$ */ +#include #include #include "System.h" @@ -54,10 +55,20 @@ void Task1::body(rtems_task_argument argument) rtems_test_pause_and_screen_number(6); screen6(); - rtems_test_pause_and_screen_number(7); - // causes init to delete me and itself - end_init.send(RTEMS_SIGNAL_0); + // do not call exit(0) from this thread as this object is static + // the static destructor call delete the task which is calling exit + // so exit never completes + + EndTask end_task("ENDT", (rtems_task_priority) 1, RTEMS_MINIMUM_STACK_SIZE * 6); + end_task.start(0); + + rtemsEvent block_me; + rtems_event_set out; + + block_me.receive(RTEMS_SIGNAL_0, out); + + printf("**** TASK 1 did not block ????\n"); } void Task1::screen1(void) @@ -655,3 +666,17 @@ void Task1::print_mode(rtems_mode mode, rtems_mode mask) printf("INTMASK=%i", mode & RTEMS_INTERRUPT_MASK); } + +EndTask::EndTask(const char* name, + const rtems_task_priority initial_priority, + const rtems_unsigned32 stack_size) + : rtemsTask(name, initial_priority, stack_size, RTEMS_NO_PREEMPT) +{ +} + +void EndTask::body(rtems_task_argument ) +{ + printf("*** END OF RTEMS++ TEST ***\n"); + exit(0); +} + diff --git a/testsuites/libtests/rtems++/Task2.cc b/testsuites/libtests/rtems++/Task2.cc index ab8c3cb78e..2052efdd57 100644 --- a/testsuites/libtests/rtems++/Task2.cc +++ b/testsuites/libtests/rtems++/Task2.cc @@ -32,7 +32,7 @@ void Task2::body(rtems_task_argument ) { screen4(); - printf("%s - destory itself\n", name_string()); + printf("%s - destroy itself\n", name_string()); destroy(); } diff --git a/testsuites/libtests/rtems++/Task3.cc b/testsuites/libtests/rtems++/Task3.cc index 3d3060d398..ab28f3130d 100644 --- a/testsuites/libtests/rtems++/Task3.cc +++ b/testsuites/libtests/rtems++/Task3.cc @@ -32,7 +32,7 @@ void Task3::body(rtems_task_argument ) { screen6(); - printf("%s - destory itself\n", name_string()); + printf("%s - destroy itself\n", name_string()); destroy(); } -- cgit v1.2.3