1/*
2 * Copyright (c) 2003, Intel Corporation. All rights reserved.
3 * Created by:  julie.n.fleischer 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 * Test that mq_open() fails with ENOENT if the named message queue does
11 * not yet exist, but O_CREAT is not set.
12 */
13
14#include <stdio.h>
15#include <mqueue.h>
16#include <fcntl.h>
17#include <sys/stat.h>
18#include <sys/types.h>
19#include <unistd.h>
20#include <string.h>
21#include <errno.h>
22#include "posixtest.h"
23
24#define NAMESIZE 50
25
26int main()
27{
28        char qname[NAMESIZE];
29        mqd_t queue;
30
31        sprintf(qname, "/mq_open_29-1_%d", getpid());
32
33        queue = mq_open(qname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
34        if (queue != (mqd_t)-1) {
35                printf("mq_open() did not return mqd_t - on error\n");
36		printf("Test FAILED\n");
37		mq_close(queue);
38		mq_unlink(qname);
39                return PTS_FAIL;
40        }
41
42	if (errno != ENOENT) {
43		printf("errno != ENOENT\n");
44		printf("Test FAILED\n");
45		mq_close(queue);
46		mq_unlink(qname);
47                return PTS_FAIL;
48	}
49
50        printf("Test PASSED\n");
51        return PTS_PASS;
52}
53
54