@@ -59,6 +59,12 @@ void increment_with_murder(counter_t* counter) {
59
59
(*counter)++;
60
60
}
61
61
62
+ void self_terminate (Thread *self) {
63
+ self->terminate ();
64
+ // Code should not get here
65
+ TEST_ASSERT (0 );
66
+ }
67
+
62
68
// Tests that spawn tasks in different configurations
63
69
template <void (*F)(counter_t *)>
64
70
void test_single_thread () {
@@ -97,6 +103,13 @@ void test_serial_threads() {
97
103
TEST_ASSERT_EQUAL (counter, N);
98
104
}
99
105
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
+
100
113
utest::v1::status_t test_setup (const size_t number_of_cases) {
101
114
GREENTEA_SETUP (40 , " default_auto" );
102
115
return verbose_test_setup_handler (number_of_cases);
@@ -123,6 +136,8 @@ Case cases[] = {
123
136
Case (" Testing single thread with murder" , test_single_thread<increment_with_murder>),
124
137
Case (" Testing parallel threads with murder" , test_parallel_threads<3 , increment_with_murder>),
125
138
Case (" Testing serial threads with murder" , test_serial_threads<10 , increment_with_murder>),
139
+
140
+ Case (" Testing thread self terminate" , test_self_terminate),
126
141
};
127
142
128
143
Specification specification (test_setup, cases);
0 commit comments