msgrcv02: Add negative msgtyp tests
PATCH 1/1 msgrcv02: Add negative msgtyp tests
Test that we do not get higher message types. Also that -1 msgtyp is not misinterpreted as INT_MAX by using MSG_EXCEPT.
--- .../kernel/syscalls/ipc/msgrcv/msgrcv02.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c +12 -7
@@ -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)
Signature · 5 lines
2.33.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Richard
Quoted 2 lines
Test that we do not get higher message types. Also that -1 msgtyp is not misinterpreted as
INT_MAXby usingMSG_EXCEPT.
Other than some unnecessary spaces or empty lines, this patch looks good to me.
Best Regards
Yang Xu
Quoted 51 lines
Signed-off-by Richard Palethorpe<[email protected]>Suggested-by Cyril Hrubis<[email protected]>--- .../kernel/syscalls/ipc/msgrcv/msgrcv02.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c +12
-7@@ -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)
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 34 lines
Signed-off-by Richard Palethorpe <[email protected]>Suggested-by Cyril Hrubis <[email protected]>--- .../kernel/syscalls/ipc/msgrcv/msgrcv02.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c +3
-3@@ -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},
testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c static struct tcase { · line 59
Quoted 10 lines
testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c +6
-4- {&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}, +
I wouldn't have added this empty line. The rest of the spaces that aligns the fields looks good to me though, it's easier to read that way.
testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c static struct tcase { · line 63
Quoted 4 lines
testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c +3
-0+ {&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}, };
With the empty line removed:
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hello,
Thanks, pushed with line removed!
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp