shutdown testing suite
cover shutdown testing suite
This testing suite is meant to test shutdown() syscall functionalities. The current LTP version uses shutdown() inside many tests, but none of them is specifically running unit tests for it.
This suite comes with both unit tests for shutdown() flags and error codes.
---
Andrea Cervesato (2):
Add shutdown01 test
Add shutdown02 test
runtest/syscalls | 3 + testcases/kernel/syscalls/shutdown/.gitignore | 2 + testcases/kernel/syscalls/shutdown/Makefile | 7 ++ testcases/kernel/syscalls/shutdown/shutdown01.c | 136 ++++++++++++++++++++++++ testcases/kernel/syscalls/shutdown/shutdown02.c | 75 +++++++++++++ 5 files changed, 223 insertions(+)
---
base-commit: 0358f7a2788eed0cbff7f8519b1a0f7f89d36c13
change-id: 20240524-shutdown-c8d7580e916a
Best regards,
Signature · 5 lines
Andrea Cervesato <[email protected]> -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/2 Add shutdown01 test
From: Andrea Cervesato <[email protected]>
This test verifies the following shutdown() functionalities:
* SHUT_RD should enable send() ops but disable recv() ops
* SHUT_WR should enable recv() ops but disable send() ops
* SHUT_RDWR should disable both recv() and send() ops
--- runtest/syscalls | 2 + testcases/kernel/syscalls/shutdown/.gitignore | 1 + testcases/kernel/syscalls/shutdown/Makefile | 7 ++ testcases/kernel/syscalls/shutdown/shutdown01.c | 136 ++++++++++++++++++++++++ 4 files changed, 146 insertions(+)
runtest/syscalls +2 -0
@@ -1465,6 +1465,8 @@ shmget04 shmget04 shmget05 shmget05 shmget06 shmget06 +shutdown01 shutdown01 + sigaction01 sigaction01 sigaction02 sigaction02
testcases/kernel/syscalls/shutdown/.gitignore new file +1 -0
@@ -0,0 +1 @@ +shutdown01
testcases/kernel/syscalls/shutdown/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/shutdown/shutdown01.c new file +136 -0
136 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/2] Add shutdown01 test
Hi Andrea,
...
Quoted 6 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +0
-0
testcases/kernel/syscalls/shutdown/shutdown01.c line 9
Quoted 9 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +9
-0@@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* [Description] +* +* This test verifies the following shutdown() functionalities:
nit: here needs to be blank line to get list formatting.
Quoted 4 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +4
-0+* * SHUT_RD should enable send() ops but disable recv() ops +* * SHUT_WR should enable recv() ops but disable send() ops +* * SHUT_RDWR should disable both recv() and send() ops +*/
...
testcases/kernel/syscalls/shutdown/shutdown01.c line 65
Quoted 4 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +4
-0+static void test_shutdown_recv (void ) +{ +int client_sock; +char buff[MSGSIZE ] = {0 };
Wouldn't it be better to send some data?
Or is it not important, we use guarded buffers?
testcases/kernel/syscalls/shutdown/shutdown01.c line 72
Quoted 7 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +7
-0+ + client_sock =start_test (); + +tst_res (TINFO ,"Testing SHUT_RD flag" ); + +TST_EXP_PASS (shutdown (client_sock,SHUT_RD )); +TST_EXP_EQ_LI (recv (client_sock, buff,MSGSIZE ,0 ),0 );
Interesting, I would expect failure ("If how is SHUT_RD, further receptions will be disallowed.")
And maybe use SAFE_RECV()?
testcases/kernel/syscalls/shutdown/shutdown01.c line 73
Quoted 1 line
testcases/kernel/syscalls/shutdown/shutdown01.c new file +1
-0+TST_EXP_EQ_LI (send (client_sock, buff,MSGSIZE ,0 ),MSGSIZE );
And SAFE_SEND() here?
testcases/kernel/syscalls/shutdown/shutdown01.c line 77
Quoted 4 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +4
-0+ +SAFE_CLOSE (client_sock); +TST_CHECKPOINT_WAKE (0 ); +}
nit: I would also use struct tcase and .tcnt, because all 3 tests are nearly identical.
Otherwise LGTM.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/2] Add shutdown01 test
Hi!
Quoted 24 lines · Petr Vorel
Hi Andrea,
...
Quoted 6 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +0
-0testcases/kernel/syscalls/shutdown/shutdown01.c line 9
Quoted 9 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +9
-0@@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2024 SUSE LLC Andrea Cervesato <[email protected]> +*/ + +/*\ +* [Description] +* +* This test verifies the following shutdown() functionalities: nit: here needs to be blank line to get list formatting.
testcases/kernel/syscalls/shutdown/shutdown01.c line 13
Quoted 4 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +4
-0+* * SHUT_RD should enable send() ops but disable recv() ops +* * SHUT_WR should enable recv() ops but disable send() ops +* * SHUT_RDWR should disable both recv() and send() ops +*/
Quoted 7 lines
...
testcases/kernel/syscalls/shutdown/shutdown01.c line 65
Quoted 4 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +4
-0+static void test_shutdown_recv (void ) +{ +int client_sock; +char buff[MSGSIZE ] = {0 };Wouldn't it be better to send some data?
Or is it not important, we use guarded buffers?
In this case, data is not really important because we need to test if send/recv are disabled after shutdown().
Quoted 22 lines
testcases/kernel/syscalls/shutdown/shutdown01.c line 72
Quoted 8 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +7
-0+ + client_sock =start_test (); + +tst_res (TINFO ,"Testing SHUT_RD flag" ); + +TST_EXP_PASS (shutdown (client_sock,SHUT_RD )); +TST_EXP_EQ_LI (recv (client_sock, buff,MSGSIZE ,0 ),0 );Interesting, I would expect failure ("If how is
SHUT_RD, further receptions will be disallowed.")And maybe use
SAFE_RECV()?testcases/kernel/syscalls/shutdown/shutdown01.c line 73
Quoted 1 line
testcases/kernel/syscalls/shutdown/shutdown01.c new file +1
-0+TST_EXP_EQ_LI (send (client_sock, buff,MSGSIZE ,0 ),MSGSIZE );And
SAFE_SEND()here?testcases/kernel/syscalls/shutdown/shutdown01.c line 77
Quoted 4 lines
testcases/kernel/syscalls/shutdown/shutdown01.c new file +4
-0+ +SAFE_CLOSE (client_sock); +TST_CHECKPOINT_WAKE (0 ); +}nit: I would also use struct tcase and .tcnt, because all 3 tests are nearly identical.
Quoted 6 lines
Otherwise LGTM.
Reviewed-by Petr Vorel <[email protected]>Kind regards,
Petr
I will fix the rest.
Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/2 Add shutdown02 test
In reply to Andrea CervesatoFrom: Andrea Cervesato <[email protected]>
This test verifies the following shutdown() errors:
* EBADF sockfd is not a valid file descriptor
* EINVAL An invalid value was specified in how
* ENOTCONN The specified socket is not connected
* ENOTSOCK The file descriptor sockfd does not refer to a socket
--- runtest/syscalls | 1 + testcases/kernel/syscalls/shutdown/.gitignore | 1 + testcases/kernel/syscalls/shutdown/shutdown02.c | 75 +++++++++++++++++++++++++ 3 files changed, 77 insertions(+)
runtest/syscalls +1 -0
@@ -1466,6 +1466,7 @@ shmget05 shmget05 shmget06 shmget06 shutdown01 shutdown01 +shutdown02 shutdown02 sigaction01 sigaction01 sigaction02 sigaction02
testcases/kernel/syscalls/shutdown/.gitignore +1 -0
@@ -1 +1,2 @@ shutdown01 +shutdown02
testcases/kernel/syscalls/shutdown/shutdown02.c new file +75 -0
75 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp