Initial import of t_shmat.
[pcca-tests.git] / mqueue.h / t_mq_open_close.c
CommitLineData
322a3d9c
SK
1/*
2 * Copyright (c) 2009, Stathis Kamperis
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
17 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
18 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
24 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
70975016 28#include <assert.h>
f2b0b8eb
SK
29#include <fcntl.h>
30#include <mqueue.h>
31#include <stdio.h>
32#include <stdlib.h>
33#include <unistd.h>
34
322a3d9c 35#define MQNAME "/t_mq_openclose"
f2b0b8eb
SK
36
37int main(void)
38{
39 mqd_t md;
40
41 /* Create a message queue for write only with default parameters. */
9335f425 42 md = mq_open(MQNAME, O_CREAT | O_EXCL | O_WRONLY, 0777, NULL);
8c99d793 43 assert(md != (mqd_t)-1);
f2b0b8eb
SK
44
45 /* Disassociate with message queue. */
46 assert(mq_close(md) != -1);
47
9335f425
SK
48 /* Remove the message queue from the system. */
49 assert(mq_unlink(MQNAME) != -1);
50
51 printf("passed\n");
52
f2b0b8eb
SK
53 return (EXIT_SUCCESS);
54}