Home | History | Annotate | Download | only in msgctl
      1 /*
      2  * Copyright (c) 2014 Fujitsu Ltd.
      3  * Author: Zeng Linggang <zenglg.jy (at) cn.fujitsu.com>
      4  * Copyright (c) 2018 Cyril Hrubis <chrubis (at) suse.cz>
      5  *
      6  * This program is free software; you can redistribute it and/or modify it
      7  * under the terms of version 2 of the GNU General Public License as
      8  * published by the Free Software Foundation.
      9  *
     10  * This program is distributed in the hope that it would be useful, but
     11  * WITHOUT ANY WARRANTY; without even the implied warranty of
     12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     13  *
     14  * You should have received a copy of the GNU General Public License along
     15  * with this program.
     16  */
     17 /*
     18  * DESCRIPTION
     19  *	msgctl13 - test for IPC_RMID
     20  */
     21 #include <errno.h>
     22 
     23 #include "tst_test.h"
     24 #include "tst_safe_sysv_ipc.h"
     25 #include "libnewipc.h"
     26 
     27 static void verify_msgctl(void)
     28 {
     29 	struct msqid_ds buf;
     30 	int msg_q;
     31 
     32 	msg_q = SAFE_MSGGET(IPC_PRIVATE, MSG_RW);
     33 
     34 	TEST(msgctl(msg_q, IPC_RMID, NULL));
     35 	if (TST_RET != 0) {
     36 		tst_res(TFAIL | TTERRNO, "msgctl(IPC_RMID) failed");
     37 		return;
     38 	}
     39 
     40 	tst_res(TPASS, "msgctl(IPC_RMID)");
     41 
     42 	TEST(msgctl(msg_q, IPC_STAT, &buf));
     43 	if (TST_ERR == EINVAL) {
     44 		tst_res(TPASS | TTERRNO, "msgctl(IPC_STAT)");
     45 	} else {
     46 		tst_res(TFAIL | TTERRNO,
     47 			"msgctl(IPC_STAT) returned %li", TST_RET);
     48 	}
     49 }
     50 
     51 static struct tst_test test = {
     52 	.test_all = verify_msgctl,
     53 	.needs_tmpdir = 1
     54 };
     55