15 #include <gtest/gtest.h>    18 #include "../../include/ecl/ipc/semaphore.hpp"    19 #include "../../include/ecl/ipc/shared_memory.hpp"    21 #ifdef ECL_HAS_SEMAPHORES    28 using ecl::SharedMemory;
    53 class SemaphoreTimedData {
    56         void initialise() { value[0] = 1.0; value[1] = 2.0; };
    67 using ecl::ipc::tests::SemaphoreTimedData;
    81 TEST(SemaphoreTimedTests,access) {
    83     string sm_name(
"shared_memory");
    84     string sem_name(
"shared_semaphore");
    97             SharedMemory<SemaphoreTimedData> sm(sm_name);
    98             Semaphore semaphore(sem_name);
   100             bool result = semaphore.trylock(timeout);
   101             EXPECT_FALSE(result);
   107                 if ( (result = semaphore.trylock(timeout)) ) {
   117             std::cout << e.
what() << std::endl;
   122         std::cerr << 
"Failed to fork" << std::endl;
   131             SharedMemory<SemaphoreTimedData> sm(sm_name);
   132             Semaphore semaphore(sem_name);
   133             SemaphoreTimedData *data = sm.data();
   135             data->value[0] = 1.3;
   136             data->value[1] = 2.3;
   137             EXPECT_EQ(1.3,data->value[0]);
   138             EXPECT_EQ(2.3,data->value[1]);
   147             std::cout << e.
what() << std::endl;
   156 int main(
int argc, 
char **argv) {
   158     std::cout << std::endl;
   159     std::cout << 
"What you should see:" << std::endl;
   160     std::cout << 
"  - Process forks" << std::endl;
   161     std::cout << 
"  - Parent creates shared memory." << std::endl;
   162     std::cout << 
"  - Parent locks a semaphore and enters shared memory for 2 seconds." << std::endl;
   163     std::cout << 
"  - Child waits one second and tries lock for 750ms." << std::endl;
   164     std::cout << 
"  - Child fails and again tries lock for 750ms." << std::endl;
   165     std::cout << 
"  - Child succeeds in locking.." << std::endl;
   166     std::cout << std::endl;
   168     testing::InitGoogleTest(&argc,argv);
   169     return RUN_ALL_TESTS();
   178 int main(
int argc, 
char **argv) {
   179     std::cout << std::endl;
   180     std::cout << 
"Semaphores are not supported on this platform (or ecl is just lacking)." << std::endl;
   181     std::cout << std::endl;
 int main(int argc, char **argv)
Embedded control libraries. 
const char * what() const 
TEST(TypeTests, fundamentals)