* [LTP] [PATCH v2] msgrcv/msgrcv07.c: add MSG_EXCEPT, MSG_NOERROR flag test
[not found] <52FB25CE.7090704@cn.fujitsu.com>
@ 2014-02-12 8:06 ` Xiaoguang Wang
2014-02-19 9:21 ` Wanlong Gao
0 siblings, 1 reply; 2+ messages in thread
From: Xiaoguang Wang @ 2014-02-12 8:06 UTC (permalink / raw)
To: ltp-list
create a new case to test MSG_EXCEPT, MSG_NOERROR flag for msgrcv(2)
Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
runtest/ltplite | 1 +
runtest/stress.part3 | 1 +
runtest/syscalls | 1 +
runtest/syscalls-ipc | 1 +
testcases/kernel/syscalls/.gitignore | 1 +
testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c | 177 ++++++++++++++++++++++++
6 files changed, 182 insertions(+)
create mode 100644 testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c
diff --git a/runtest/ltplite b/runtest/ltplite
index 2f8f977..0fffa00 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -489,6 +489,7 @@ msgrcv03 msgrcv03
msgrcv04 msgrcv04
msgrcv05 msgrcv05
msgrcv06 msgrcv06
+msgrcv07 msgrcv07
msgsnd01 msgsnd01
msgsnd02 msgsnd02
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 5703d13..55e9b49 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -412,6 +412,7 @@ msgrcv03 msgrcv03
msgrcv04 msgrcv04
msgrcv05 msgrcv05
msgrcv06 msgrcv06
+msgrcv07 msgrcv07
msgsnd01 msgsnd01
msgsnd02 msgsnd02
diff --git a/runtest/syscalls b/runtest/syscalls
index 083c240..53bab14 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -642,6 +642,7 @@ msgrcv03 msgrcv03
msgrcv04 msgrcv04
msgrcv05 msgrcv05
msgrcv06 msgrcv06
+msgrcv07 msgrcv07
msgsnd01 msgsnd01
msgsnd02 msgsnd02
diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc
index 02b6e45..bd9bf30 100644
--- a/runtest/syscalls-ipc
+++ b/runtest/syscalls-ipc
@@ -23,6 +23,7 @@ msgrcv03 msgrcv03
msgrcv04 msgrcv04
msgrcv05 msgrcv05
msgrcv06 msgrcv06
+msgrcv07 msgrcv07
msgsnd01 msgsnd01
msgsnd02 msgsnd02
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index b622244..4fc27f8 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -386,6 +386,7 @@
/ipc/msgrcv/msgrcv04
/ipc/msgrcv/msgrcv05
/ipc/msgrcv/msgrcv06
+/ipc/msgrcv/msgrcv07
/ipc/msgsnd/msgsnd01
/ipc/msgsnd/msgsnd02
/ipc/msgsnd/msgsnd03
diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c
new file mode 100644
index 0000000..aac0b44
--- /dev/null
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Xiaoguang Wang <wangxg.fnst@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; if not, write the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * Description:
+ * Basic test for msgrcv(2) using MSG_EXCEPT, MSG_NOERROR
+ */
+
+#define _GNU_SOURCE
+#include <sys/wait.h>
+#include "test.h"
+#include "usctest.h"
+#include "ipcmsg.h"
+
+
+#define MSGTYPE1 1
+#define MSGTYPE2 2
+#define MSG1 "message type1"
+#define MSG2 "message type2"
+
+static void wait4child(pid_t child, char *tst_flag);
+
+static void test_msg_except(void);
+static void test_msg_noerror(void);
+
+static void (*testfunc[])(void) = { test_msg_except, test_msg_noerror };
+
+char *TCID = "msgrcv07";
+int TST_TOTAL = ARRAY_SIZE(testfunc);
+
+int main(int ac, char **av)
+{
+ int lc;
+ char *msg;
+ int i;
+
+ msg = parse_opts(ac, av, 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++)
+ (*testfunc[i])();
+ }
+
+ cleanup();
+ tst_exit();
+}
+
+void setup(void)
+{
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ TEST_PAUSE;
+}
+
+static void test_msg_except(void)
+{
+ pid_t child_pid;
+ int msgq_id;
+ MSGBUF snd_buf1 = {.mtype = MSGTYPE1, .mtext = MSG1};
+ MSGBUF snd_buf2 = {.mtype = MSGTYPE2, .mtext = MSG2};
+ MSGBUF rcv_buf;
+
+ msgq_id = msgget(IPC_PRIVATE, MSG_RW);
+ if (msgq_id == -1)
+ tst_brkm(TBROK | TERRNO, cleanup, "Can't create message queue");
+
+ if (msgsnd(msgq_id, &snd_buf1, MSGSIZE, 0) == -1)
+ tst_brkm(TBROK | TERRNO, cleanup, "Can't enqueue message");
+
+ if (msgsnd(msgq_id, &snd_buf2, MSGSIZE, 0) == -1)
+ tst_brkm(TBROK | TERRNO, cleanup, "Can't enqueue message");
+
+ child_pid = tst_fork();
+ if (child_pid == -1) {
+ tst_brkm(TBROK, cleanup, "fork failed");
+ } else if (child_pid > 0) {
+ wait4child(child_pid, "MSG_EXCEPT");
+ } else {
+ memset(&rcv_buf, 0, sizeof(rcv_buf));
+ TEST(msgrcv(msgq_id, &rcv_buf, MSGSIZE, MSGTYPE2, MSG_EXCEPT));
+ if (TEST_RETURN == -1) {
+ fprintf(stderr, "msgrcv(MSG_EXCEPT) failed\n");
+ exit(TBROK);
+ }
+ /* check the received message */
+ if (strcmp(rcv_buf.mtext, MSG1) == 0 &&
+ rcv_buf.mtype == MSGTYPE1)
+ exit(TPASS);
+ else
+ exit(TFAIL);
+ }
+
+ rm_queue(msgq_id);
+}
+
+
+static void test_msg_noerror(void)
+{
+ pid_t child_pid;
+ int msg_len, msgq_id;
+ MSGBUF snd_buf1 = {.mtype = MSGTYPE1, .mtext = MSG1};
+ MSGBUF rcv_buf;
+
+ msgq_id = msgget(IPC_PRIVATE, MSG_RW);
+ if (msgq_id == -1)
+ tst_brkm(TBROK | TERRNO, cleanup, "Can't create message queue");
+
+ if (msgsnd(msgq_id, &snd_buf1, MSGSIZE, 0) == -1)
+ tst_brkm(TBROK | TERRNO, cleanup, "Can't enqueue message");
+
+ child_pid = tst_fork();
+ if (child_pid == -1) {
+ tst_brkm(TBROK, cleanup, "fork failed");
+ } else if (child_pid > 0) {
+ wait4child(child_pid, "MSG_NOERROR");
+ } else {
+ msg_len = sizeof(MSG1) / 2;
+ memset(&rcv_buf, 0, sizeof(rcv_buf));
+
+ TEST(msgrcv(msgq_id, &rcv_buf, msg_len, MSGTYPE1, MSG_NOERROR));
+ if (TEST_RETURN == -1)
+ exit(TFAIL);
+
+ if (strncmp(rcv_buf.mtext, MSG1, msg_len) == 0 &&
+ rcv_buf.mtype == MSGTYPE1)
+ exit(TPASS);
+ exit(TFAIL);
+ }
+
+ rm_queue(msgq_id);
+}
+
+static void wait4child(pid_t child, char *tst_flag)
+{
+ int status;
+ int ret;
+
+ if (waitpid(child, &status, 0) == -1)
+ tst_resm(TBROK | TERRNO, "waitpid");
+ if (WIFEXITED(status)) {
+ ret = WEXITSTATUS(status);
+ if (ret == 0)
+ tst_resm(TPASS, "test %s success", tst_flag);
+ else if (ret == 1)
+ tst_resm(TFAIL, "test %s failed", tst_flag);
+ else
+ tst_brkm(TBROK, cleanup, "msgrcv failed unexpectedly");
+ } else {
+ tst_brkm(TBROK, cleanup, "child process terminated "
+ "abnormally. status: %d", status);
+ }
+}
+
+void cleanup(void)
+{
+ TEST_CLEANUP;
+}
--
1.8.2.1
------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH v2] msgrcv/msgrcv07.c: add MSG_EXCEPT, MSG_NOERROR flag test
2014-02-12 8:06 ` [LTP] [PATCH v2] msgrcv/msgrcv07.c: add MSG_EXCEPT, MSG_NOERROR flag test Xiaoguang Wang
@ 2014-02-19 9:21 ` Wanlong Gao
0 siblings, 0 replies; 2+ messages in thread
From: Wanlong Gao @ 2014-02-19 9:21 UTC (permalink / raw)
To: Xiaoguang Wang; +Cc: ltp-list
On 02/12/2014 04:06 PM, Xiaoguang Wang wrote:
> create a new case to test MSG_EXCEPT, MSG_NOERROR flag for msgrcv(2)
>
> Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
> ---
> runtest/ltplite | 1 +
> runtest/stress.part3 | 1 +
> runtest/syscalls | 1 +
> runtest/syscalls-ipc | 1 +
> testcases/kernel/syscalls/.gitignore | 1 +
> testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c | 177 ++++++++++++++++++++++++
> 6 files changed, 182 insertions(+)
> create mode 100644 testcases/kernel/syscalls/ipc/msgrcv/msgrcv07.c
Applied, thank you.
Wanlong Gao
------------------------------------------------------------------------------
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=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-02-19 9:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <52FB25CE.7090704@cn.fujitsu.com>
2014-02-12 8:06 ` [LTP] [PATCH v2] msgrcv/msgrcv07.c: add MSG_EXCEPT, MSG_NOERROR flag test Xiaoguang Wang
2014-02-19 9:21 ` Wanlong Gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox