1/*
2 * Copyright (c) 2002, Intel Corporation. All rights reserved.
3 * Created by:  geoffrey.r.gustafson 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 *  mq_close test case that attempts to open a new message queue,
11 *  close the message queue and verify that mq_close returns 0.
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 "posixtest.h"
21
22#define TEST "1-1"
23#define FUNCTION "mq_close"
24
25int main()
26{
27	char qname[50];
28	mqd_t queue;
29
30	sprintf(qname, "/" FUNCTION "_" TEST "_%d", getpid());
31
32	queue = mq_open(qname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
33	if (queue == (mqd_t)-1) {
34		perror("mq_open() did not return success");
35		return PTS_UNRESOLVED;
36	}
37
38	if (mq_close(queue) != 0) {
39		printf("Test FAILED\n");
40		return PTS_FAIL;
41	}
42
43	if (mq_unlink(qname) != 0) {
44		perror("mq_unlink() did not return success");
45		return PTS_UNRESOLVED;
46	}
47
48	printf("Test PASSED\n");
49	return PTS_PASS;
50}
51