[LTP] [PATCH 1/2] Add shutdown01 test
Petr Vorel
pvorel@suse.cz
Wed Jun 5 22:24:34 CEST 2024
Hi Andrea,
...
> diff --git a/testcases/kernel/syscalls/shutdown/shutdown01.c b/testcases/kernel/syscalls/shutdown/shutdown01.c
> new file mode 100644
> index 000000000..b68b14ae8
> --- /dev/null
> +++ b/testcases/kernel/syscalls/shutdown/shutdown01.c
> @@ -0,0 +1,136 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2024 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * This test verifies the following shutdown() functionalities:
nit: here needs to be blank line to get list formatting.
> + * * 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
> + */
...
> +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?
> +
> + 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()?
> + TST_EXP_EQ_LI(send(client_sock, buff, MSGSIZE, 0), MSGSIZE);
And SAFE_SEND() here?
> +
> + 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.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Kind regards,
Petr
More information about the ltp
mailing list