msgctl/msgctl12.c: add new tests

Add new tests for msgctl(2):
IPC_INFO
MSG_INFO
MSG_STAT

Signed-off-by: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
diff --git a/runtest/syscalls b/runtest/syscalls
index 496bcba..d173c24 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -628,6 +628,7 @@
 msgctl09 msgctl09
 msgctl10 msgctl10
 msgctl11 msgctl11
+msgctl12 msgctl12
 
 msgget01 msgget01
 msgget02 msgget02
diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc
index f57a96e..415357b 100644
--- a/runtest/syscalls-ipc
+++ b/runtest/syscalls-ipc
@@ -9,6 +9,7 @@
 msgctl09 msgctl09
 msgctl10 msgctl10
 msgctl11 msgctl11
+msgctl12 msgctl12
 
 msgget01 msgget01
 msgget02 msgget02
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 1caf8e3..bf37e1f 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -374,6 +374,7 @@
 /ipc/msgctl/msgctl09
 /ipc/msgctl/msgctl10
 /ipc/msgctl/msgctl11
+/ipc/msgctl/msgctl12
 /ipc/msgget/msgget01
 /ipc/msgget/msgget02
 /ipc/msgget/msgget03
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl12.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl12.c
new file mode 100644
index 0000000..d3a2850
--- /dev/null
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl12.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
+ *
+ * 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
+ *	msgctl12 - test for IPC_INFO MSG_INFO and MSG_STAT.
+ */
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <errno.h>
+
+#include "test.h"
+#include "usctest.h"
+#include "ipcmsg.h"
+
+static int msg_q;
+static int index_q;
+static struct msginfo msginfo_buf;
+static struct msqid_ds msgqid_buf;
+
+static struct test_case_t {
+	int *queue_id;
+	int ipc_cmd;
+	char *name;
+	void *buf;
+} test_cases[] = {
+	{&msg_q, IPC_INFO, "IPC_INFO", &msginfo_buf},
+	{&msg_q, MSG_INFO, "MSG_INFO", &msginfo_buf},
+	{&index_q, MSG_STAT, "MSG_STAT", &msgqid_buf},
+};
+
+char *TCID = "msgctl12";
+int TST_TOTAL = ARRAY_SIZE(test_cases);
+
+int main(int argc, char *argv[])
+{
+	int lc;
+	char *msg;
+	int i;
+
+	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;
+
+		for (i = 0; i < TST_TOTAL; i++) {
+
+			TEST(msgctl(*test_cases[i].queue_id,
+				    test_cases[i].ipc_cmd, test_cases[i].buf));
+
+			if (TEST_RETURN == -1) {
+				tst_resm(TFAIL,
+					 "msgctl() test %s failed with errno: "
+					 "%d", test_cases[i].name, TEST_ERRNO);
+			} else {
+				tst_resm(TPASS, "msgctl() test %s succeeded",
+					 test_cases[i].name);
+			}
+		}
+	}
+
+	cleanup();
+	tst_exit();
+}
+
+void setup(void)
+{
+	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+	TEST_PAUSE;
+
+	msg_q = msgget(IPC_PRIVATE, MSG_RW);
+	if (msg_q < 0)
+		tst_brkm(TBROK, cleanup, "Can't create message queue");
+
+	index_q = msgctl(msg_q, IPC_INFO, (struct msqid_ds *)&msginfo_buf);
+	if (index_q < 0)
+		tst_brkm(TBROK, cleanup, "Can't create message queue");
+}
+
+void cleanup(void)
+{
+	rm_queue(msg_q);
+
+	TEST_CLEANUP;
+}