priorities.cpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Platform Check
10 *****************************************************************************/
11 
12 #include <iostream>
13 #include <ecl/config/ecl.hpp>
14 #if defined(ECL_IS_POSIX)
15 
16 /*****************************************************************************
17 ** Includes
18 *****************************************************************************/
19 
20 #include <gtest/gtest.h>
21 #include "../../include/ecl/threads/priority.hpp"
23 
24 /*****************************************************************************
25 ** Using
26 *****************************************************************************/
27 
28 using ecl::set_priority;
30 using ecl::LowPriority;
32 using ecl::HighPriority;
39 
40 /*****************************************************************************
41 ** Tests
42 *****************************************************************************/
43 
44 TEST(PriorityTest,statistics) {
45  std::string diagnostics = ecl::print_priority_diagnostics();
46  SUCCEED();
47 }
48 
49 TEST(PriorityTest,setPosixPriorities) {
50  try {
51  set_priority(BackgroundPriority);
52  set_priority(LowPriority);
53  set_priority(NormalPriority);
54  set_priority(HighPriority);
55  set_priority(CriticalPriority);
56  SUCCEED();
57  } catch ( const StandardException &e ) {
58  // often dont have permission to higher level priorities so just warn
59  // ADD_FAILURE() << "Could not set all the non-real time priorities.";
60  std::cout << "Do not have permission for the higher level priorities." << std::endl;
61  }
62 }
63 
64 TEST(PriorityTest,setPosixRealTimePriorities) {
65  try {
66  set_priority(RealTimePriority1);
67  set_priority(RealTimePriority2);
68  set_priority(RealTimePriority3);
69  set_priority(RealTimePriority4);
70  SUCCEED();
71  } catch ( const StandardException &e ) {
72  SUCCEED();
73  // often dont have permission for real time scheduling, so just warn
74  // ADD_FAILURE() << "Could not set all the real time priorities.";
75  std::cout << "Do not have permission for real time scheduling priorities." << std::endl;
76  }
77 }
78 
79 /*****************************************************************************
80 ** Main program
81 *****************************************************************************/
82 
83 int main(int argc, char **argv) {
84 
85  testing::InitGoogleTest(&argc,argv);
86  return RUN_ALL_TESTS();
87 }
88 
89 
90 #else
91 
92 /*****************************************************************************
93 ** Alternative main
94 *****************************************************************************/
95 
96 int main(int argc, char **argv) {
97 
98  std::cout << "Currently not supported on your platform." << std::endl;
99 }
100 
101 #endif /* ECL_IS_POSIX */
102 
TEST(TypeTests, fundamentals)
int main(int argc, char **argv)
Definition: priorities.cpp:96


ecl_threads
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:44