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/*
10   sem_open test case that attempts to open a new semaphoree, and the
11   return value is not NULL
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 "1-2"
24#define FUNCTION "sem_open"
25#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
26
27
28int main()
29{
30	sem_t   *mysemp;
31	char semname[50];
32
33	sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
34
35	mysemp = sem_open(semname, O_CREAT, 0777, 1);
36
37	/* Checking if mysemp has a value returned. From sem_open */
38
39	if ( &mysemp != NULL)
40	{
41		puts("TEST PASSED");
42		sem_close(mysemp);
43		sem_unlink(semname);
44		return PTS_PASS;
45	}
46	else
47	{
48		puts("TEST FAILED");
49		return PTS_FAIL;
50	}
51}
52