@@ -59,6 +59,12 @@ void increment_with_murder(counter_t* counter) {
5959 (*counter)++;
6060}
6161
62+ void self_terminate (Thread *self) {
63+ self->terminate ();
64+ // Code should not get here
65+ TEST_ASSERT (0 );
66+ }
67+
6268// Tests that spawn tasks in different configurations
6369template <void (*F)(counter_t *)>
6470void test_single_thread () {
@@ -97,6 +103,13 @@ void test_serial_threads() {
97103 TEST_ASSERT_EQUAL (counter, N);
98104}
99105
106+ void test_self_terminate () {
107+ Thread *thread = new Thread (osPriorityNormal, STACK_SIZE);
108+ thread->start (thread, self_terminate);
109+ thread->join ();
110+ delete thread;
111+ }
112+
100113utest::v1::status_t test_setup (const size_t number_of_cases) {
101114 GREENTEA_SETUP (40 , " default_auto" );
102115 return verbose_test_setup_handler (number_of_cases);
@@ -123,6 +136,8 @@ Case cases[] = {
123136 Case (" Testing single thread with murder" , test_single_thread<increment_with_murder>),
124137 Case (" Testing parallel threads with murder" , test_parallel_threads<3 , increment_with_murder>),
125138 Case (" Testing serial threads with murder" , test_serial_threads<10 , increment_with_murder>),
139+
140+ Case (" Testing thread self terminate" , test_self_terminate),
126141};
127142
128143Specification specification (test_setup, cases);
0 commit comments