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