msgstress04: make sure not pass IPC_PRIVATE to msgget
PATCH 1/1 msgstress04: make sure not pass IPC_PRIVATE to msgget
From: Kai Kang <[email protected]>
It fails to run case msgstress04:
$ ./msgstress04 -n 1 -c 1 -l 1
It only inits the first MSGMNI members of keyarray. So if argument off of function dotest_iteration is greater than MSGMNI, the argument key passed to function dotest() will be IPC_PRIVATE(0) which will finally pass to syscall msgget(), then cause case fails.
Make sure get the value for key from the initialized members of keyarray.
--- testcases/kernel/syscalls/ipc/msgstress/msgstress04.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +1 -1
@@ -198,7 +198,7 @@ static void dotest_iteration(int off)memset (pidarray,0 ,sizeof (pidarray));for (i =0 ; i < nprocs; i++) { - key = keyarray[off + i]; + key = keyarray[(off + i) %MSGMNI ];if ((pid =FORK_OR_VFORK ()) <0 ) tst_brkm(TFAIL, cleanup,
Signature · 1 line
2.17.0
PATCH 1/1 msgstress04: make sure not pass IPC_PRIVATE to msgget
----- Original Message -----
Quoted 24 lines
From: Kai Kang <[email protected]>
It fails to run case msgstress04:
$ ./msgstress04 -n 1 -c 1 -l 1It only inits the first MSGMNI members of keyarray. So if argument off of function
dotest_iterationis greater than MSGMNI, the argument key passed to functiondotest()will beIPC_PRIVATE(0)which will finally pass to syscallmsgget(), then cause case fails.Make sure get the value for key from the initialized members of keyarray.
Signed-off-by Kai Kang <[email protected]>--- testcases/kernel/syscalls/ipc/msgstress/msgstress04.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +0
-0
testcases/kernel/syscalls/ipc/msgstress/msgstress04.c static void dotest_iteration(int off) · line 201
Quoted 5 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +1
-1@@ -198,7 +198,7 @@ static void dotest_iteration(int off)memset (pidarray,0 ,sizeof (pidarray));for (i =0 ; i < nprocs; i++) { - key = keyarray[off + i]; + key = keyarray[(off + i) %MSGMNI ];
Hi,
Isn't this going to pick same key over and over again?
Say maxnprocs is '1', and MSGMNI is 10000:
dotest_iteration(i*(10000 / 1));
will become:
key = keyarray[(10000 + 0) % 10000];
key = keyarray[(20000 + 0) % 10000];
key = keyarray[(30000 + 0) % 10000];
...
If test intention is to exercise queues for all keys, shouldn't we fix main() instead?
testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +2 -2
@@ -176,11 +176,11 @@ int main(int argc, char **argv) }else {for (i =0 ; i < (MSGMNI / maxnprocs); i++) { nprocs = maxnprocs; -dotest_iteration (i*(MSGMNI / maxnprocs)); +dotest_iteration (i * maxnprocs); } nprocs =MSGMNI % maxnprocs; -dotest_iteration (i*(MSGMNI / maxnprocs)); +dotest_iteration (i * maxnprocs); }tst_resm (TPASS ,"Test ran successfully!" );
Regards,
Jan
Quoted 10 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +0
-1if ((pid =FORK_OR_VFORK ()) <0 ) tst_brkm(TFAIL, cleanup, --2.17.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 msgstress04: make sure not pass IPC_PRIVATE to msgget
Quoted 36 lines · Jan Stancek
----- Original Message -----
Quoted 24 lines
From: Kai Kang <[email protected]>
It fails to run case msgstress04:
$ ./msgstress04 -n 1 -c 1 -l 1It only inits the first MSGMNI members of keyarray. So if argument off of function
dotest_iterationis greater than MSGMNI, the argument key passed to functiondotest()will beIPC_PRIVATE(0)which will finally pass to syscallmsgget(), then cause case fails.Make sure get the value for key from the initialized members of keyarray.
Signed-off-by Kai Kang <[email protected]>--- testcases/kernel/syscalls/ipc/msgstress/msgstress04.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +0
-0testcases/kernel/syscalls/ipc/msgstress/msgstress04.c static void dotest_iteration(int off) · line 201
Quoted 5 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +1
-1@@ -198,7 +198,7 @@ static void dotest_iteration(int off)memset (pidarray,0 ,sizeof (pidarray));for (i =0 ; i < nprocs; i++) { - key = keyarray[off + i]; + key = keyarray[(off + i) %MSGMNI ];Hi,
Isn't this going to pick same key over and over again?
Say maxnprocs is '1', and MSGMNI is 10000:
Quoted 8 lines
dotest_iteration(i*(10000 / 1)); will become: key = keyarray[(10000 + 0) % 10000]; key = keyarray[(20000 + 0) % 10000]; key = keyarray[(30000 + 0) % 10000]; ...If test intention is to exercise queues for all keys, shouldn't we fix
main()instead?
Yes, you're right. Thanks for comment. V2 will be sent.
--Kai
Quoted 33 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +2
-2@@ -176,11 +176,11 @@ int main(int argc, char **argv) }else {for (i =0 ; i < (MSGMNI / maxnprocs); i++) { nprocs = maxnprocs; -dotest_iteration (i*(MSGMNI / maxnprocs)); +dotest_iteration (i * maxnprocs); } nprocs =MSGMNI % maxnprocs; -dotest_iteration (i*(MSGMNI / maxnprocs)); +dotest_iteration (i * maxnprocs); }tst_resm (TPASS ,"Test ran successfully!" );Regards,
JanQuoted 10 lines
testcases/kernel/syscalls/ipc/msgstress/msgstress04.c +0
-1if ((pid =FORK_OR_VFORK ()) <0 ) tst_brkm(TFAIL, cleanup, --2.17.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Regards, Neil | Kai Kang