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 
ecl::RealTimePriority2
@ RealTimePriority2
Definition: priority_common.hpp:51
ecl::HighPriority
@ HighPriority
Definition: priority_common.hpp:48
TEST
TEST(TypeTests, fundamentals)
ecl::LowPriority
@ LowPriority
Definition: priority_common.hpp:46
ecl::StandardException
ecl::CriticalPriority
@ CriticalPriority
Definition: priority_common.hpp:49
standard_exception.hpp
ecl::NormalPriority
@ NormalPriority
Definition: priority_common.hpp:47
ecl::RealTimePriority1
@ RealTimePriority1
Definition: priority_common.hpp:50
ecl::RealTimePriority3
@ RealTimePriority3
Definition: priority_common.hpp:52
main
int main(int argc, char **argv)
Definition: priorities.cpp:96
ecl::BackgroundPriority
@ BackgroundPriority
Definition: priority_common.hpp:45
ecl::RealTimePriority4
@ RealTimePriority4
Definition: priority_common.hpp:53


ecl_threads
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:43