1/* 2 Copyright (c) 2002-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 open_sem test case that attempts to open a new semaphore, 10 with the maximum VALUE allowed. 11 */ 12 13#include <sys/types.h> 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 <limits.h> 21#include "posixtest.h" 22 23#define TEST "5-1" 24#define FUNCTION "sem_open" 25 26int main(void) 27{ 28 sem_t *mysemp; 29 char semname[50]; 30 int counter = SEM_VALUE_MAX; 31 32 if (counter >= INT_MAX) { 33 return PTS_PASS; 34 } 35 36 sprintf(semname, "/" FUNCTION "_" TEST "_%d", getpid()); 37 38 ++counter; 39 mysemp = sem_open(semname, O_CREAT, 0444, counter); 40 if ((mysemp == SEM_FAILED) && (errno == EINVAL)) { 41 puts("TEST PASSED"); 42 sem_unlink(semname); 43 return PTS_PASS; 44 } else { 45 puts("TEST FAILED"); 46 return PTS_FAIL; 47 } 48} 49