1*84d9c625SLionel Sambuc /* $NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $ */
211be35a1SLionel Sambuc
311be35a1SLionel Sambuc /*-
411be35a1SLionel Sambuc * Copyright (c) 2011 The NetBSD Foundation, Inc.
511be35a1SLionel Sambuc * All rights reserved.
611be35a1SLionel Sambuc *
711be35a1SLionel Sambuc * This code is derived from software contributed to The NetBSD Foundation
811be35a1SLionel Sambuc * by Jukka Ruohonen.
911be35a1SLionel Sambuc *
1011be35a1SLionel Sambuc * Redistribution and use in source and binary forms, with or without
1111be35a1SLionel Sambuc * modification, are permitted provided that the following conditions
1211be35a1SLionel Sambuc * are met:
1311be35a1SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
1411be35a1SLionel Sambuc * notice, this list of conditions and the following disclaimer.
1511be35a1SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
1611be35a1SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
1711be35a1SLionel Sambuc * documentation and/or other materials provided with the distribution.
1811be35a1SLionel Sambuc *
1911be35a1SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2011be35a1SLionel Sambuc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2111be35a1SLionel Sambuc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2211be35a1SLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2311be35a1SLionel Sambuc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2411be35a1SLionel Sambuc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2511be35a1SLionel Sambuc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2611be35a1SLionel Sambuc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2711be35a1SLionel Sambuc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2811be35a1SLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2911be35a1SLionel Sambuc * POSSIBILITY OF SUCH DAMAGE.
3011be35a1SLionel Sambuc */
3111be35a1SLionel Sambuc #include <sys/cdefs.h>
32*84d9c625SLionel Sambuc __RCSID("$NetBSD: t_msgrcv.c,v 1.3 2013/07/24 11:44:10 skrll Exp $");
3311be35a1SLionel Sambuc
3411be35a1SLionel Sambuc #include <sys/msg.h>
3511be35a1SLionel Sambuc #include <sys/stat.h>
3611be35a1SLionel Sambuc #include <sys/sysctl.h>
3711be35a1SLionel Sambuc #include <sys/wait.h>
3811be35a1SLionel Sambuc
3911be35a1SLionel Sambuc #include <atf-c.h>
4011be35a1SLionel Sambuc #include <errno.h>
4111be35a1SLionel Sambuc #include <pwd.h>
4211be35a1SLionel Sambuc #include <signal.h>
4311be35a1SLionel Sambuc #include <stdio.h>
4411be35a1SLionel Sambuc #include <stdlib.h>
4511be35a1SLionel Sambuc #include <string.h>
4611be35a1SLionel Sambuc #include <sysexits.h>
4711be35a1SLionel Sambuc #include <time.h>
4811be35a1SLionel Sambuc #include <unistd.h>
4911be35a1SLionel Sambuc
5011be35a1SLionel Sambuc #define MSG_KEY 1234
5111be35a1SLionel Sambuc #define MSG_MTYPE_1 0x41
5211be35a1SLionel Sambuc #define MSG_MTYPE_2 0x42
5311be35a1SLionel Sambuc #define MSG_MTYPE_3 0x43
54*84d9c625SLionel Sambuc #define MSG_LEN 3
5511be35a1SLionel Sambuc
5611be35a1SLionel Sambuc struct msg {
5711be35a1SLionel Sambuc long mtype;
58*84d9c625SLionel Sambuc char buf[MSG_LEN];
5911be35a1SLionel Sambuc };
6011be35a1SLionel Sambuc
6111be35a1SLionel Sambuc static void clean(void);
6211be35a1SLionel Sambuc
6311be35a1SLionel Sambuc static void
clean(void)6411be35a1SLionel Sambuc clean(void)
6511be35a1SLionel Sambuc {
6611be35a1SLionel Sambuc int id;
6711be35a1SLionel Sambuc
6811be35a1SLionel Sambuc if ((id = msgget(MSG_KEY, 0)) != -1)
6911be35a1SLionel Sambuc (void)msgctl(id, IPC_RMID, 0);
7011be35a1SLionel Sambuc }
7111be35a1SLionel Sambuc
7211be35a1SLionel Sambuc ATF_TC_WITH_CLEANUP(msgrcv_basic);
ATF_TC_HEAD(msgrcv_basic,tc)7311be35a1SLionel Sambuc ATF_TC_HEAD(msgrcv_basic, tc)
7411be35a1SLionel Sambuc {
7511be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "A basic test of msgrcv(2)");
7611be35a1SLionel Sambuc }
7711be35a1SLionel Sambuc
ATF_TC_BODY(msgrcv_basic,tc)7811be35a1SLionel Sambuc ATF_TC_BODY(msgrcv_basic, tc)
7911be35a1SLionel Sambuc {
8011be35a1SLionel Sambuc struct msg msg1 = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
8111be35a1SLionel Sambuc struct msg msg2 = { MSG_MTYPE_1, { 'x', 'y', 'z' } };
8211be35a1SLionel Sambuc int id;
8311be35a1SLionel Sambuc
8411be35a1SLionel Sambuc id = msgget(MSG_KEY, IPC_CREAT | 0600);
8511be35a1SLionel Sambuc ATF_REQUIRE(id != -1);
8611be35a1SLionel Sambuc
87*84d9c625SLionel Sambuc (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
88*84d9c625SLionel Sambuc (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT);
8911be35a1SLionel Sambuc
9011be35a1SLionel Sambuc ATF_CHECK(msg1.buf[0] == msg2.buf[0]);
9111be35a1SLionel Sambuc ATF_CHECK(msg1.buf[1] == msg2.buf[1]);
9211be35a1SLionel Sambuc ATF_CHECK(msg1.buf[2] == msg2.buf[2]);
9311be35a1SLionel Sambuc
9411be35a1SLionel Sambuc ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
9511be35a1SLionel Sambuc }
9611be35a1SLionel Sambuc
ATF_TC_CLEANUP(msgrcv_basic,tc)9711be35a1SLionel Sambuc ATF_TC_CLEANUP(msgrcv_basic, tc)
9811be35a1SLionel Sambuc {
9911be35a1SLionel Sambuc clean();
10011be35a1SLionel Sambuc }
10111be35a1SLionel Sambuc
10211be35a1SLionel Sambuc ATF_TC_WITH_CLEANUP(msgrcv_block);
ATF_TC_HEAD(msgrcv_block,tc)10311be35a1SLionel Sambuc ATF_TC_HEAD(msgrcv_block, tc)
10411be35a1SLionel Sambuc {
10511be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "Test that msgrcv(2) blocks");
10611be35a1SLionel Sambuc }
10711be35a1SLionel Sambuc
ATF_TC_BODY(msgrcv_block,tc)10811be35a1SLionel Sambuc ATF_TC_BODY(msgrcv_block, tc)
10911be35a1SLionel Sambuc {
11011be35a1SLionel Sambuc struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
11111be35a1SLionel Sambuc int id, sta;
11211be35a1SLionel Sambuc pid_t pid;
11311be35a1SLionel Sambuc
11411be35a1SLionel Sambuc id = msgget(MSG_KEY, IPC_CREAT | 0600);
11511be35a1SLionel Sambuc ATF_REQUIRE(id != -1);
11611be35a1SLionel Sambuc
11711be35a1SLionel Sambuc pid = fork();
11811be35a1SLionel Sambuc ATF_REQUIRE(pid >= 0);
11911be35a1SLionel Sambuc
12011be35a1SLionel Sambuc if (pid == 0) {
12111be35a1SLionel Sambuc
122*84d9c625SLionel Sambuc if (msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1, 0) < 0)
12311be35a1SLionel Sambuc _exit(EXIT_FAILURE);
12411be35a1SLionel Sambuc
12511be35a1SLionel Sambuc _exit(EXIT_SUCCESS);
12611be35a1SLionel Sambuc }
12711be35a1SLionel Sambuc
12811be35a1SLionel Sambuc /*
12911be35a1SLionel Sambuc * Below msgsnd(2) should unblock the child,
13011be35a1SLionel Sambuc * and hence kill(2) should fail with ESRCH.
13111be35a1SLionel Sambuc */
13211be35a1SLionel Sambuc (void)sleep(1);
133*84d9c625SLionel Sambuc (void)msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT);
13411be35a1SLionel Sambuc (void)sleep(1);
13511be35a1SLionel Sambuc (void)kill(pid, SIGKILL);
13611be35a1SLionel Sambuc (void)wait(&sta);
13711be35a1SLionel Sambuc
13811be35a1SLionel Sambuc if (WIFEXITED(sta) == 0 || WIFSIGNALED(sta) != 0)
13911be35a1SLionel Sambuc atf_tc_fail("msgrcv(2) did not block");
14011be35a1SLionel Sambuc
14111be35a1SLionel Sambuc ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
14211be35a1SLionel Sambuc }
14311be35a1SLionel Sambuc
ATF_TC_CLEANUP(msgrcv_block,tc)14411be35a1SLionel Sambuc ATF_TC_CLEANUP(msgrcv_block, tc)
14511be35a1SLionel Sambuc {
14611be35a1SLionel Sambuc clean();
14711be35a1SLionel Sambuc }
14811be35a1SLionel Sambuc
14911be35a1SLionel Sambuc ATF_TC_WITH_CLEANUP(msgrcv_err);
ATF_TC_HEAD(msgrcv_err,tc)15011be35a1SLionel Sambuc ATF_TC_HEAD(msgrcv_err, tc)
15111be35a1SLionel Sambuc {
15211be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "Test errors from msgrcv(2)");
15311be35a1SLionel Sambuc }
15411be35a1SLionel Sambuc
ATF_TC_BODY(msgrcv_err,tc)15511be35a1SLionel Sambuc ATF_TC_BODY(msgrcv_err, tc)
15611be35a1SLionel Sambuc {
15711be35a1SLionel Sambuc struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
15811be35a1SLionel Sambuc int id, r = 0;
15911be35a1SLionel Sambuc
16011be35a1SLionel Sambuc id = msgget(MSG_KEY, IPC_CREAT | 0600);
16111be35a1SLionel Sambuc ATF_REQUIRE(id != -1);
16211be35a1SLionel Sambuc
16311be35a1SLionel Sambuc errno = 0;
16411be35a1SLionel Sambuc
16511be35a1SLionel Sambuc ATF_REQUIRE_ERRNO(ENOMSG, msgrcv(id, &msg,
166*84d9c625SLionel Sambuc MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
16711be35a1SLionel Sambuc
168*84d9c625SLionel Sambuc ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
16911be35a1SLionel Sambuc
17011be35a1SLionel Sambuc errno = 0;
17111be35a1SLionel Sambuc
17211be35a1SLionel Sambuc ATF_REQUIRE_ERRNO(EFAULT, msgrcv(id, (void *)-1,
173*84d9c625SLionel Sambuc MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
17411be35a1SLionel Sambuc
17511be35a1SLionel Sambuc errno = 0;
17611be35a1SLionel Sambuc
17711be35a1SLionel Sambuc ATF_REQUIRE_ERRNO(EINVAL, msgrcv(-1, &msg,
178*84d9c625SLionel Sambuc MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT) == -1);
17911be35a1SLionel Sambuc
18011be35a1SLionel Sambuc errno = 0;
18111be35a1SLionel Sambuc
18211be35a1SLionel Sambuc ATF_REQUIRE_ERRNO(EINVAL, msgrcv(-1, &msg,
18311be35a1SLionel Sambuc SSIZE_MAX, MSG_MTYPE_1, IPC_NOWAIT) == -1);
18411be35a1SLionel Sambuc
185*84d9c625SLionel Sambuc ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
18611be35a1SLionel Sambuc
18711be35a1SLionel Sambuc errno = 0;
18811be35a1SLionel Sambuc
18911be35a1SLionel Sambuc ATF_REQUIRE_ERRNO(E2BIG, msgrcv(id, &r,
190*84d9c625SLionel Sambuc MSG_LEN - 1, MSG_MTYPE_1, IPC_NOWAIT) == -1);
19111be35a1SLionel Sambuc
19211be35a1SLionel Sambuc ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
19311be35a1SLionel Sambuc }
19411be35a1SLionel Sambuc
ATF_TC_CLEANUP(msgrcv_err,tc)19511be35a1SLionel Sambuc ATF_TC_CLEANUP(msgrcv_err, tc)
19611be35a1SLionel Sambuc {
19711be35a1SLionel Sambuc clean();
19811be35a1SLionel Sambuc }
19911be35a1SLionel Sambuc
20011be35a1SLionel Sambuc
20111be35a1SLionel Sambuc ATF_TC_WITH_CLEANUP(msgrcv_mtype);
ATF_TC_HEAD(msgrcv_mtype,tc)20211be35a1SLionel Sambuc ATF_TC_HEAD(msgrcv_mtype, tc)
20311be35a1SLionel Sambuc {
20411be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "Test message types with msgrcv(2)");
20511be35a1SLionel Sambuc }
20611be35a1SLionel Sambuc
ATF_TC_BODY(msgrcv_mtype,tc)20711be35a1SLionel Sambuc ATF_TC_BODY(msgrcv_mtype, tc)
20811be35a1SLionel Sambuc {
20911be35a1SLionel Sambuc struct msg msg1 = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
21011be35a1SLionel Sambuc struct msg msg2 = { MSG_MTYPE_3, { 'x', 'y', 'z' } };
21111be35a1SLionel Sambuc int id;
21211be35a1SLionel Sambuc
21311be35a1SLionel Sambuc id = msgget(MSG_KEY, IPC_CREAT | 0600);
21411be35a1SLionel Sambuc ATF_REQUIRE(id != -1);
21511be35a1SLionel Sambuc
216*84d9c625SLionel Sambuc (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
217*84d9c625SLionel Sambuc (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_2, IPC_NOWAIT);
21811be35a1SLionel Sambuc
21911be35a1SLionel Sambuc ATF_CHECK(msg1.buf[0] != msg2.buf[0]); /* Different mtype. */
22011be35a1SLionel Sambuc ATF_CHECK(msg1.buf[1] != msg2.buf[1]);
22111be35a1SLionel Sambuc ATF_CHECK(msg1.buf[2] != msg2.buf[2]);
22211be35a1SLionel Sambuc
223*84d9c625SLionel Sambuc (void)msgrcv(id, &msg2, MSG_LEN, MSG_MTYPE_1, IPC_NOWAIT);
22411be35a1SLionel Sambuc
22511be35a1SLionel Sambuc ATF_CHECK(msg1.buf[0] == msg2.buf[0]); /* Same mtype. */
22611be35a1SLionel Sambuc ATF_CHECK(msg1.buf[1] == msg2.buf[1]);
22711be35a1SLionel Sambuc ATF_CHECK(msg1.buf[2] == msg2.buf[2]);
22811be35a1SLionel Sambuc
22911be35a1SLionel Sambuc ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
23011be35a1SLionel Sambuc }
23111be35a1SLionel Sambuc
ATF_TC_CLEANUP(msgrcv_mtype,tc)23211be35a1SLionel Sambuc ATF_TC_CLEANUP(msgrcv_mtype, tc)
23311be35a1SLionel Sambuc {
23411be35a1SLionel Sambuc clean();
23511be35a1SLionel Sambuc }
23611be35a1SLionel Sambuc
23711be35a1SLionel Sambuc ATF_TC_WITH_CLEANUP(msgrcv_nonblock);
ATF_TC_HEAD(msgrcv_nonblock,tc)23811be35a1SLionel Sambuc ATF_TC_HEAD(msgrcv_nonblock, tc)
23911be35a1SLionel Sambuc {
24011be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "Test msgrcv(2) with IPC_NOWAIT");
24111be35a1SLionel Sambuc atf_tc_set_md_var(tc, "timeout", "10");
24211be35a1SLionel Sambuc }
24311be35a1SLionel Sambuc
ATF_TC_BODY(msgrcv_nonblock,tc)24411be35a1SLionel Sambuc ATF_TC_BODY(msgrcv_nonblock, tc)
24511be35a1SLionel Sambuc {
24611be35a1SLionel Sambuc struct msg msg = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
24711be35a1SLionel Sambuc const ssize_t n = 10;
24811be35a1SLionel Sambuc int id, sta;
24911be35a1SLionel Sambuc ssize_t i;
25011be35a1SLionel Sambuc pid_t pid;
25111be35a1SLionel Sambuc
25211be35a1SLionel Sambuc id = msgget(MSG_KEY, IPC_CREAT | 0600);
25311be35a1SLionel Sambuc ATF_REQUIRE(id != -1);
25411be35a1SLionel Sambuc
25511be35a1SLionel Sambuc for (i = 0; i < n; i++) {
25611be35a1SLionel Sambuc
257*84d9c625SLionel Sambuc ATF_REQUIRE(msgsnd(id, &msg, MSG_LEN, IPC_NOWAIT) == 0);
25811be35a1SLionel Sambuc }
25911be35a1SLionel Sambuc
26011be35a1SLionel Sambuc pid = fork();
26111be35a1SLionel Sambuc ATF_REQUIRE(pid >= 0);
26211be35a1SLionel Sambuc
26311be35a1SLionel Sambuc if (pid == 0) {
26411be35a1SLionel Sambuc
26511be35a1SLionel Sambuc while (i != 0) {
26611be35a1SLionel Sambuc
267*84d9c625SLionel Sambuc if (msgrcv(id, &msg, MSG_LEN, MSG_MTYPE_1,
268*84d9c625SLionel Sambuc IPC_NOWAIT) == -1)
26911be35a1SLionel Sambuc _exit(EXIT_FAILURE);
27011be35a1SLionel Sambuc
27111be35a1SLionel Sambuc i--;
27211be35a1SLionel Sambuc }
27311be35a1SLionel Sambuc
27411be35a1SLionel Sambuc _exit(EXIT_SUCCESS);
27511be35a1SLionel Sambuc }
27611be35a1SLionel Sambuc
27711be35a1SLionel Sambuc (void)sleep(2);
27811be35a1SLionel Sambuc (void)kill(pid, SIGKILL);
27911be35a1SLionel Sambuc (void)wait(&sta);
28011be35a1SLionel Sambuc
28111be35a1SLionel Sambuc if (WIFSIGNALED(sta) != 0 || WTERMSIG(sta) == SIGKILL)
28211be35a1SLionel Sambuc atf_tc_fail("msgrcv(2) blocked with IPC_NOWAIT");
28311be35a1SLionel Sambuc
28411be35a1SLionel Sambuc if (WIFEXITED(sta) == 0 && WEXITSTATUS(sta) != EXIT_SUCCESS)
28511be35a1SLionel Sambuc atf_tc_fail("msgrcv(2) failed");
28611be35a1SLionel Sambuc
28711be35a1SLionel Sambuc ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
28811be35a1SLionel Sambuc }
28911be35a1SLionel Sambuc
ATF_TC_CLEANUP(msgrcv_nonblock,tc)29011be35a1SLionel Sambuc ATF_TC_CLEANUP(msgrcv_nonblock, tc)
29111be35a1SLionel Sambuc {
29211be35a1SLionel Sambuc clean();
29311be35a1SLionel Sambuc }
29411be35a1SLionel Sambuc
29511be35a1SLionel Sambuc ATF_TC_WITH_CLEANUP(msgrcv_truncate);
ATF_TC_HEAD(msgrcv_truncate,tc)29611be35a1SLionel Sambuc ATF_TC_HEAD(msgrcv_truncate, tc)
29711be35a1SLionel Sambuc {
29811be35a1SLionel Sambuc atf_tc_set_md_var(tc, "descr", "Test msgrcv(2) with MSG_NOERROR");
29911be35a1SLionel Sambuc }
30011be35a1SLionel Sambuc
ATF_TC_BODY(msgrcv_truncate,tc)30111be35a1SLionel Sambuc ATF_TC_BODY(msgrcv_truncate, tc)
30211be35a1SLionel Sambuc {
303*84d9c625SLionel Sambuc #define MSG_SMALLLEN 2
30411be35a1SLionel Sambuc struct msgsmall {
30511be35a1SLionel Sambuc long mtype;
306*84d9c625SLionel Sambuc char buf[MSG_SMALLLEN];
30711be35a1SLionel Sambuc };
30811be35a1SLionel Sambuc
30911be35a1SLionel Sambuc struct msg msg1 = { MSG_MTYPE_1, { 'a', 'b', 'c' } };
31011be35a1SLionel Sambuc struct msgsmall msg2 = { MSG_MTYPE_1, { 'x', 'y' } };
31111be35a1SLionel Sambuc int id;
31211be35a1SLionel Sambuc
31311be35a1SLionel Sambuc id = msgget(MSG_KEY, IPC_CREAT | 0600);
31411be35a1SLionel Sambuc ATF_REQUIRE(id != -1);
31511be35a1SLionel Sambuc
316*84d9c625SLionel Sambuc (void)msgsnd(id, &msg1, MSG_LEN, IPC_NOWAIT);
317*84d9c625SLionel Sambuc (void)msgrcv(id, &msg2, MSG_SMALLLEN,
31811be35a1SLionel Sambuc MSG_MTYPE_1, IPC_NOWAIT | MSG_NOERROR);
31911be35a1SLionel Sambuc
32011be35a1SLionel Sambuc ATF_CHECK(msg1.buf[0] == msg2.buf[0]);
32111be35a1SLionel Sambuc ATF_CHECK(msg1.buf[1] == msg2.buf[1]);
32211be35a1SLionel Sambuc
32311be35a1SLionel Sambuc ATF_REQUIRE(msgctl(id, IPC_RMID, 0) == 0);
32411be35a1SLionel Sambuc }
32511be35a1SLionel Sambuc
ATF_TC_CLEANUP(msgrcv_truncate,tc)32611be35a1SLionel Sambuc ATF_TC_CLEANUP(msgrcv_truncate, tc)
32711be35a1SLionel Sambuc {
32811be35a1SLionel Sambuc clean();
32911be35a1SLionel Sambuc }
33011be35a1SLionel Sambuc
ATF_TP_ADD_TCS(tp)33111be35a1SLionel Sambuc ATF_TP_ADD_TCS(tp)
33211be35a1SLionel Sambuc {
33311be35a1SLionel Sambuc
33411be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, msgrcv_basic);
33511be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, msgrcv_block);
33611be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, msgrcv_err);
33711be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, msgrcv_mtype);
33811be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, msgrcv_nonblock);
33911be35a1SLionel Sambuc ATF_TP_ADD_TC(tp, msgrcv_truncate);
34011be35a1SLionel Sambuc
34111be35a1SLionel Sambuc return atf_no_error();
34211be35a1SLionel Sambuc }
343