Cheetah Software  1.0
test_periodic_tasks.cpp File Reference
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "Utilities/PeriodicTask.h"
+ Include dependency graph for test_periodic_tasks.cpp:

Go to the source code of this file.

Classes

class  TestPeriodicTask
 

Functions

void inc_scount ()
 
 TEST (PeriodicTask, test1)
 

Variables

static int scount = 0
 

Function Documentation

void inc_scount ( )

Definition at line 26 of file test_periodic_tasks.cpp.

References scount.

26 { scount++; }
static int scount

+ Here is the caller graph for this function:

TEST ( PeriodicTask  ,
test1   
)

Definition at line 28 of file test_periodic_tasks.cpp.

References TestPeriodicTask::_cleanedUp, TestPeriodicTask::_counter, TestPeriodicTask::_init, TestPeriodicTask::_slow, f(), inc_scount(), scount, PeriodicTask::start(), and PeriodicTaskManager::stopAll().

28  {
29  PeriodicTaskManager taskManager;
30  TestPeriodicTask task1(&taskManager, 0.01f, "test-task-1");
31  TestPeriodicTask task2(&taskManager, 0.02f, "test-task-2");
32 
33  task1.start();
34  task2.start();
35 
36  for (int i = 0; i < 10; i++) {
37  // taskManager.printStatus();
38  usleep(50000);
39  }
40 
41  task1.start();
42  task1.start();
43 
44  EXPECT_TRUE(task2._counter > 0);
45  EXPECT_TRUE(task2._init);
46  EXPECT_FALSE(task2._cleanedUp);
47 
48  EXPECT_TRUE(task2._counter > 0);
49  EXPECT_TRUE(task2._init);
50  EXPECT_FALSE(task2._cleanedUp);
51 
52  taskManager.stopAll();
53 
54  TestPeriodicTask task3(&taskManager, .01f, "slow-task");
55  task3._slow = true;
56  task3.start();
57 
58  for (int i = 0; i < 10; i++) {
59  // taskManager.printStatus();
60  usleep(50000);
61  }
62 
63  taskManager.stopAll();
64  taskManager.stopAll();
65 
66  PeriodicFunction pf(&taskManager, 0.01f, "func-test", &inc_scount);
67  pf.start();
68 
69  usleep(100000);
70  EXPECT_TRUE(scount > 0);
71  printf("scount = %d\n", scount);
72 
73  // taskManager.stopAll(); test destructors cleaning things up instead
74 }
static int scount
void inc_scount()
MX f(const MX &x, const MX &u)

+ Here is the call graph for this function:

Variable Documentation

int scount = 0
static

Definition at line 24 of file test_periodic_tasks.cpp.