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() returns an error if creation is not requested and
11 * name does not refer to an already existing message queue.
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 "posixtest.h"
22
23#define NAMESIZE 50
24
25int main()
26{
27        char qname[NAMESIZE];
28        mqd_t queue;
29
30        sprintf(qname, "/mq_open_3-1_%d", getpid());
31
32        queue = mq_open(qname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
33        if (queue != (mqd_t)-1) {
34		printf("mq_open() did not return error\n");
35		printf("Test FAILED\n");
36		mq_close(queue);
37		mq_unlink(qname);
38		return PTS_FAIL;
39        }
40
41        printf("Test PASSED\n");
42        return PTS_PASS;
43}
44
45