All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: Richard Palethorpe <rpalethorpe@suse.com>
Subject: [LTP] [PATCH] msgrcv02: Add negative msgtyp tests
Date: Tue, 12 Oct 2021 10:28:58 +0100	[thread overview]
Message-ID: <20211012092858.29992-1-rpalethorpe@suse.com> (raw)

Test that we do not get higher message types. Also that -1 msgtyp is not
misinterpreted as INT_MAX by using MSG_EXCEPT.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
Suggested-by: Cyril Hrubis <chrubis@suse.cz>
---
 .../kernel/syscalls/ipc/msgrcv/msgrcv02.c     | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
index cfb7d7446..fba6a5289 100644
--- a/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
+++ b/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
@@ -21,6 +21,8 @@
  *   msgflg and no message of the requested type existed on the message queue.
  */
 
+#define _GNU_SOURCE
+
 #include <string.h>
 #include <sys/wait.h>
 #include <sys/msg.h>
@@ -38,7 +40,7 @@ struct passwd *pw;
 static struct buf {
 	long type;
 	char mtext[MSGSIZE];
-} rcv_buf, snd_buf = {MSGTYPE, "hello"};
+} rcv_buf, snd_buf = {2, "hello"};
 
 static struct tcase {
 	int *id;
@@ -49,12 +51,15 @@ static struct tcase {
 	int exp_user;
 	int exp_err;
 } tcases[] = {
-	{&queue_id, &rcv_buf, 4, 1, 0, 0, E2BIG},
-	{&queue_id, &rcv_buf, MSGSIZE, 1, 0, 1, EACCES},
-	{&queue_id, NULL, MSGSIZE, 1, 0, 0, EFAULT},
-	{&bad_id, &rcv_buf, MSGSIZE, 1, 0, 0, EINVAL},
-	{&queue_id, &rcv_buf, -1, 1, 0, 0, EINVAL},
-	{&queue_id, &rcv_buf, MSGSIZE, 2, IPC_NOWAIT, 0, ENOMSG},
+	{&queue_id, &rcv_buf, MSGSIZE - 1, 2, 0, 0, E2BIG},
+	{&queue_id, &rcv_buf, MSGSIZE,     2, 0, 1, EACCES},
+	{&queue_id, NULL,     MSGSIZE,     2, 0, 0, EFAULT},
+	{&bad_id,   &rcv_buf, MSGSIZE,     2, 0, 0, EINVAL},
+	{&queue_id, &rcv_buf, -1,          2, 0, 0, EINVAL},
+
+	{&queue_id, &rcv_buf, MSGSIZE,  3, IPC_NOWAIT,              0, ENOMSG},
+	{&queue_id, &rcv_buf, MSGSIZE, -1, IPC_NOWAIT,              0, ENOMSG},
+	{&queue_id, &rcv_buf, MSGSIZE, -1, IPC_NOWAIT | MSG_EXCEPT, 0, ENOMSG},
 };
 
 static void verify_msgrcv(struct tcase *tc)
-- 
2.33.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2021-10-12  9:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-12  9:28 Richard Palethorpe via ltp [this message]
2021-10-13  8:24 ` [LTP] [PATCH] msgrcv02: Add negative msgtyp tests xuyang2018.jy
2021-10-13 10:06 ` Cyril Hrubis
2021-10-13 11:32   ` Richard Palethorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211012092858.29992-1-rpalethorpe@suse.com \
    --to=ltp@lists.linux.it \
    --cc=rpalethorpe@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.