@@ -113,3 +113,43 @@ TEST_F(SchedulerTests, TimeoutClearAddTask) {
113113
114114 EXPECT_EQ (Scheduler::active_task_count_, 1 );
115115}
116+
117+ static volatile int connecting_execs{0 };
118+ static volatile int operational_execs{0 };
119+ static volatile int fault_execs{0 };
120+ void connecting_cyclic (){
121+ connecting_execs++;
122+ }
123+ void operational_cyclic (){
124+ operational_execs++;
125+ }
126+ void fault_cyclic (){
127+ fault_execs++;
128+ }
129+ TEST_F (SchedulerTests, TaskDe_ReRegistration) {
130+ uint8_t connecting_task = Scheduler::register_task (10 , &connecting_cyclic);
131+ uint8_t operational_task = 0 ;
132+ uint8_t fault_task = 0 ;
133+ Scheduler::start ();
134+
135+ constexpr int NUM_TICKS = 100 ;
136+ for (int i = 0 ; i < NUM_TICKS; i++) {
137+ TIM2_BASE->CNT ++;
138+ if (i == 21 ){
139+ Scheduler::unregister_task (connecting_task);
140+ operational_task = Scheduler::register_task (10 ,operational_cyclic);
141+ }
142+ if (i == 45 ){
143+ Scheduler::unregister_task (operational_task);
144+ fault_task = Scheduler::register_task (10 ,fault_cyclic);
145+ }
146+ if ( i == 70 ){
147+ Scheduler::unregister_task (fault_task);
148+ i = 100 ; // finish test
149+ }
150+ Scheduler::update ();
151+ }
152+ EXPECT_EQ (connecting_execs, 2 );
153+ EXPECT_EQ (operational_execs, 2 );
154+ EXPECT_EQ (fault_execs, 2 );
155+ }
0 commit comments