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 verifies the sem_post returns 0 on successful call. 11 */ 12 13 14#include <stdio.h> 15#include <errno.h> 16#include <unistd.h> 17#include <semaphore.h> 18#include <sys/stat.h> 19#include <fcntl.h> 20#include "posixtest.h" 21 22 23#define TEST "4-1" 24#define FUNCTION "sem_post" 25#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": " 26 27 28 29int main() { 30 sem_t *mysemp; 31 char semname[50]; 32 33 sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid()); 34 35 /* Initial value of Semaphore is 0 */ 36 mysemp = sem_open(semname, O_CREAT, 0777, 0); 37 if( mysemp == SEM_FAILED || mysemp == NULL ) { 38 perror(ERROR_PREFIX "sem_open"); 39 return PTS_UNRESOLVED; 40 } 41 42 if( sem_post(mysemp) == 0 ) { 43 puts("TEST PASSED"); 44 sem_close(mysemp); 45 sem_unlink(semname); 46 return PTS_PASS; 47 } else { 48 puts("TEST FAILED: value of sem_post is not returning zero"); 49 return PTS_FAIL; 50 } 51 printf("This code should not be executed.\n"); 52 return PTS_UNRESOLVED; 53} 54 55