priorities.cpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Platform Check
00010 *****************************************************************************/
00011 
00012 #include <iostream>
00013 #include <ecl/config/ecl.hpp>
00014 #if defined(ECL_IS_POSIX)
00015 
00016 /*****************************************************************************
00017 ** Includes
00018 *****************************************************************************/
00019 
00020 #include <gtest/gtest.h>
00021 #include "../../include/ecl/threads/priority.hpp"
00022 #include <ecl/exceptions/standard_exception.hpp>
00023 
00024 /*****************************************************************************
00025 ** Using
00026 *****************************************************************************/
00027 
00028 using ecl::set_priority;
00029 using ecl::BackgroundPriority;
00030 using ecl::LowPriority;
00031 using ecl::NormalPriority;
00032 using ecl::HighPriority;
00033 using ecl::CriticalPriority;
00034 using ecl::RealTimePriority4;
00035 using ecl::RealTimePriority3;
00036 using ecl::RealTimePriority2;
00037 using ecl::RealTimePriority1;
00038 using ecl::StandardException;
00039 
00040 /*****************************************************************************
00041 ** Tests
00042 *****************************************************************************/
00043 
00044 TEST(PriorityTest,statistics) {
00045         std::string diagnostics = ecl::print_priority_diagnostics();
00046         SUCCEED();
00047 }
00048 
00049 TEST(PriorityTest,setPosixPriorities) {
00050         try {
00051                 set_priority(BackgroundPriority);
00052                 set_priority(LowPriority);
00053                 set_priority(NormalPriority);
00054                 set_priority(HighPriority);
00055                 set_priority(CriticalPriority);
00056                 SUCCEED();
00057         } catch ( const StandardException &e ) {
00058         // often dont have permission to higher level priorities so just warn
00059                 // ADD_FAILURE() << "Could not set all the non-real time priorities.";
00060         std::cout << "Do not have permission for the higher level priorities." << std::endl;
00061         }
00062 }
00063 
00064 TEST(PriorityTest,setPosixRealTimePriorities) {
00065         try {
00066                 set_priority(RealTimePriority1);
00067                 set_priority(RealTimePriority2);
00068                 set_priority(RealTimePriority3);
00069                 set_priority(RealTimePriority4);
00070                 SUCCEED();
00071         } catch ( const StandardException &e ) {
00072                 SUCCEED();
00073             // often dont have permission for real time scheduling, so just warn
00074             // ADD_FAILURE() << "Could not set all the real time priorities.";
00075             std::cout << "Do not have permission for real time scheduling priorities." << std::endl;
00076         }
00077 }
00078 
00079 /*****************************************************************************
00080 ** Main program
00081 *****************************************************************************/
00082 
00083 int main(int argc, char **argv) {
00084 
00085     testing::InitGoogleTest(&argc,argv);
00086     return RUN_ALL_TESTS();
00087 }
00088 
00089 
00090 #else
00091 
00092 /*****************************************************************************
00093 ** Alternative main
00094 *****************************************************************************/
00095 
00096 int main(int argc, char **argv) {
00097 
00098         std::cout << "Currently not supported on your platform." << std::endl;
00099 }
00100 
00101 #endif /* ECL_IS_POSIX */
00102 


ecl_threads
Author(s): Daniel Stonier
autogenerated on Mon Jul 3 2017 02:22:01