1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (c) 2014 Fujitsu Ltd. 4 * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com> 5 * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz> 6 */ 7/* 8 * DESCRIPTION 9 * msgctl13 - test for IPC_RMID 10 */ 11#include <errno.h> 12 13#include "tst_test.h" 14#include "tst_safe_sysv_ipc.h" 15#include "libnewipc.h" 16 17static void verify_msgctl(void) 18{ 19 struct msqid_ds buf; 20 int msg_q; 21 22 msg_q = SAFE_MSGGET(IPC_PRIVATE, MSG_RW); 23 24 TEST(msgctl(msg_q, IPC_RMID, NULL)); 25 if (TST_RET != 0) { 26 tst_res(TFAIL | TTERRNO, "msgctl(IPC_RMID) failed"); 27 return; 28 } 29 30 tst_res(TPASS, "msgctl(IPC_RMID)"); 31 32 TEST(msgctl(msg_q, IPC_STAT, &buf)); 33 if (TST_ERR == EINVAL) { 34 tst_res(TPASS | TTERRNO, "msgctl(IPC_STAT)"); 35 } else { 36 tst_res(TFAIL | TTERRNO, 37 "msgctl(IPC_STAT) returned %li", TST_RET); 38 } 39} 40 41static struct tst_test test = { 42 .test_all = verify_msgctl, 43 .needs_tmpdir = 1 44}; 45