test_manual_semaphores.c
Go to the documentation of this file.
00001 
00026 #include <stdio.h>
00027 #include <string.h>
00028 #include "sr_communications/ipc/semaphores.h"
00029 
00030 //#define DEFAULT_SEMFILE        AD_CORE_OUTPUTDIR "communications/ipc/semfile.tests"
00031 #define DEFAULT_SEMFILE        "/tmp/communications/ipc/semfile.tests"
00032 
00033 #define TRUE 1
00034 #define FALSE 0
00035 
00036 int main(int argc, char **argv)
00037 {
00038     key_t semKey;
00039     int semID;
00040     char semFile[128];
00041 
00042     strcpy(semFile, DEFAULT_SEMFILE);
00043 
00044     if (createKey(&semKey, semFile) < 0) {
00045         perror("Error cretaing semaphore Key.\n");
00046         return (-1);
00047     }
00048     printf("Key created.\n");
00049 
00050     if (getSemID(semKey, &semID) < 0) {
00051         perror("Error in getSemID.\n");
00052         return (-2);
00053     }
00054     printf("getSemID successful\n");
00055 
00056     if (waitSem(semID) < 0) {
00057         perror("Error in waitSem.\n");
00058         return -3;
00059     }
00060     printf("waitSem successful\n");
00061 
00062     if (freeSem(semID) < 0) {
00063         perror("Error in freeSem().\n");
00064         return -4;
00065     }
00066     printf("freeSem successful\n");
00067 
00068     if (rmSem(semID) < 0) {
00069         perror("Error in rmSem().\n");
00070     }
00071     printf("rmSem successful\n");
00072 
00073     return 0;
00074 }


sr_communications
Author(s): Raul Perula-Martinez , Victor Gonzalez
autogenerated on Wed Aug 26 2015 16:26:47