Home | History | Annotate | Download | only in sem_destroy
      1 /*
      2     Copyright (c) 2003, Intel Corporation. All rights reserved.
      3     Created by:  majid.awad REMOVE-THIS AT intel DOT com
      4     This file is licensed under the GPL license.  For the full content
      5     of this license, see the COPYING file at the top level of this
      6     source tree.
      7  */
      8 
      9 /*
     10  * This test case verify the unamed semaphore is destroyed by calling
     11  * sem_destroy to return 0 on successful call.
     12 */
     13 
     14 #include <sys/types.h>
     15 #include <stdio.h>
     16 #include <errno.h>
     17 #include <unistd.h>
     18 #include <semaphore.h>
     19 #include <sys/stat.h>
     20 #include <fcntl.h>
     21 #include "posixtest.h"
     22 
     23 #define TEST "4-1"
     24 #define FUNCTION "sem_destroy"
     25 #define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
     26 
     27 int main(void)
     28 {
     29 	sem_t mysemp;
     30 
     31 	if (sem_init(&mysemp, 0, 0) == -1) {
     32 		perror(ERROR_PREFIX "sem_init");
     33 		return PTS_UNRESOLVED;
     34 	}
     35 
     36 	if (sem_destroy(&mysemp) == 0) {
     37 		puts("TEST PASSED");
     38 		return PTS_PASS;
     39 	} else {
     40 		puts("TEST FAILED: couldn't destroy sempahore.");
     41 		return PTS_FAIL;
     42 	}
     43 }
     44