Explorar el Código

Individual unit tests fixes

Anatoli Arkhipenko hace 5 meses
padre
commit
89c93c20e4

+ 7 - 3
src/TaskScheduler.h

@@ -469,6 +469,10 @@ StatusRequest::StatusRequest()
 {
     iCount = 0;
     iStatus = 0;
+#ifdef _TASK_TIMEOUT
+    iTimeout = 0;
+    iStarttime = 0;
+#endif  //  #ifdef _TASK_TIMEOUT
 }
 
 void StatusRequest::setWaiting(unsigned int aCount) { 
@@ -1629,9 +1633,9 @@ bool Scheduler::execute() {
                 if ( iCurrent->iStatus.waiting ) {
 
 #ifdef _TASK_TICKLESS
-    // if there is a task waiting on a status request we are obligated to run continously
-    // because event can trigger at any point at time. 
-    nrd |= _TASK_NEXTRUN_IMMEDIATE; // immediate
+                    // if there is a task waiting on a status request we are obligated to run continously
+                    // because event can trigger at any point at time. 
+                    nrd |= _TASK_NEXTRUN_IMMEDIATE; // immediate
 #endif
 
 #ifdef _TASK_TIMEOUT

+ 4 - 3
tests/test-scheduler-advanced-features.cpp

@@ -564,6 +564,7 @@ TEST_F(AdvancedSchedulerTest, TaskWaitForStatusRequest) {
 
     EXPECT_TRUE(sr.isPending());
     ts.execute();
+    EXPECT_TRUE(sr.isPending());
     EXPECT_EQ(advanced_callback_counter, 0);
 
     // Complete the status request
@@ -600,21 +601,21 @@ TEST_F(AdvancedSchedulerTest, TaskWaitForDelayedStatusRequest) {
     advanced_callback_counter = 0;
 
     // Create task with delayed wait (should wait for delay even though SR is complete)
-    Task delayed_waiter(500, 1, &consumer_callback, &ts);
+    Task delayed_waiter(50, 1, &consumer_callback, &ts);
     delayed_waiter.waitForDelayed(&sr, 500, 1); // 500ms delay
 
     // Task should be enabled
     EXPECT_TRUE(delayed_waiter.isEnabled());
 
     // Should not execute immediately despite completed StatusRequest
-    delay(50);
+    delay(500);
     EXPECT_TRUE(sr.isPending());
     ts.execute();
     EXPECT_EQ(advanced_callback_counter, 0);
 
     sr.signalComplete(); // Complete SR
     EXPECT_FALSE(sr.isPending());
-    
+
     // The task will be scheduled to run after the delay
     bool success = runAdvancedSchedulerUntil(ts, []() { return false; }, 200); // Wait up to 1000ms
     EXPECT_FALSE(success); 

+ 2 - 2
tests/test-scheduler-basic-thorough.cpp

@@ -1139,7 +1139,7 @@ TEST_F(SchedulerThoroughTest, TaskIterationState) {
 
     // Note: Testing iteration state requires access during callback execution
     // This test verifies the task completes its iterations properly
-    success = runSchedulerUntil(ts, []() { return true; }, 1000);
+    success = runSchedulerUntil(ts, []() { return false; }, 1000);
     // EXPECT_TRUE(success);
     EXPECT_EQ(callback_counter, 3);
     EXPECT_FALSE(task.isEnabled()); // Should auto-disable after 3 iterations
@@ -1803,7 +1803,7 @@ TEST_F(SchedulerThoroughTest, ComplexTaskLifecycle) {
     EXPECT_TRUE(task.isEnabled());
 
     // Run all iterations
-    bool success = runSchedulerUntil(ts, []() { return true; }, 1000);
+    bool success = runSchedulerUntil(ts, []() { return false; }, 1000);
     // EXPECT_TRUE(success);
     EXPECT_EQ(callback_counter, 3);
     EXPECT_EQ(task.getRunCounter(), 3);