Add IPC_RMID test for msgctl(2) Signed-off-by: Zeng Linggang <[email protected]> --- runtest/syscalls | 1 + runtest/syscalls-ipc | 1 + testcases/kernel/syscalls/.gitignore | 1 + testcases/kernel/syscalls/ipc/msgctl/msgctl13.c | 90 +++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 testcases/kernel/syscalls/ipc/msgctl/msgctl13.c
diff --git a/runtest/syscalls b/runtest/syscalls index 491f74e..bc73572 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -629,6 +629,7 @@ msgctl09 msgctl09 msgctl10 msgctl10 msgctl11 msgctl11 msgctl12 msgctl12 +msgctl13 msgctl13 msgget01 msgget01 msgget02 msgget02 diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc index 415357b..02b6e45 100644 --- a/runtest/syscalls-ipc +++ b/runtest/syscalls-ipc @@ -10,6 +10,7 @@ msgctl09 msgctl09 msgctl10 msgctl10 msgctl11 msgctl11 msgctl12 msgctl12 +msgctl13 msgctl13 msgget01 msgget01 msgget02 msgget02 diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore index bf37e1f..b622244 100644 --- a/testcases/kernel/syscalls/.gitignore +++ b/testcases/kernel/syscalls/.gitignore @@ -375,6 +375,7 @@ /ipc/msgctl/msgctl10 /ipc/msgctl/msgctl11 /ipc/msgctl/msgctl12 +/ipc/msgctl/msgctl13 /ipc/msgget/msgget01 /ipc/msgget/msgget02 /ipc/msgget/msgget03 diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl13.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl13.c new file mode 100644 index 0000000..caaf4ea --- /dev/null +++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl13.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2014 Fujitsu Ltd. + * Author: Zeng Linggang <[email protected]> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU General Public License along + * with this program. + */ +/* + * DESCRIPTION + * msgctl13 - test for IPC_RMID + */ + +#include <sys/types.h> +#include <sys/ipc.h> +#include <sys/msg.h> +#include <errno.h> + +#include "test.h" +#include "usctest.h" +#include "ipcmsg.h" + +char *TCID = "acct13"; +int TST_TOTAL = 1; +static void msgctl_verify(void); + +int main(int argc, char *argv[]) +{ + int lc; + char *msg; + + msg = parse_opts(argc, argv, NULL, NULL); + if (msg != NULL) + tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); + + setup(); + + for (lc = 0; TEST_LOOPING(lc); lc++) { + + tst_count = 0; + + msgctl_verify(); + } + + cleanup(); + tst_exit(); +} + +void setup(void) +{ + tst_sig(NOFORK, DEF_HANDLER, cleanup); + + TEST_PAUSE; +} + +static void msgctl_verify(void) +{ + int msg_q; + struct msqid_ds qs_buf; + + msg_q = msgget(IPC_PRIVATE, MSG_RW); + if (msg_q == -1) + tst_brkm(TBROK, cleanup, "Can't create message queue"); + + TEST(msgctl(msg_q, IPC_RMID, &qs_buf)); + + if (TEST_RETURN != 0) { + tst_resm(TFAIL, "msgctl() test IPC_RMID failed with errno: %d", + TEST_ERRNO); + return; + } + + TEST(msgget(msg_q, MSG_RW)); + if (TEST_ERRNO == ENOENT) + tst_resm(TPASS, "msgctl() test IPC_RMID succeeded"); + else + tst_resm(TFAIL, "msgctl() test IPC_RMID failed unexpectedly"); +} + +void cleanup(void) +{ + TEST_CLEANUP; +} -- 1.8.4.2 ------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
