All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Jinseok Kim <always.starving0@gmail.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2 1/2] poll: add basic POLLHUP semantics test
Date: Tue, 24 Feb 2026 16:31:38 +0100	[thread overview]
Message-ID: <aZ3EWrWQCy7LeSTa@yuki.lan> (raw)
In-Reply-To: <20260221134014.37652-1-always.starving0@gmail.com>

Hi!
> Add a basic poll() test to verify that POLLHUP is reported when the
> peer end of a pipe is closed.
> 
> The test creates a pipe, closes the write end, and polls the read end
> for POLLIN events. poll() is expected to return successfully and set
> POLLHUP in revents.
> 
> This covers basic poll() lifecycle semantics that were not previously
> tested.
> 
> Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
> ---
>  testcases/kernel/syscalls/poll/poll03.c | 62 +++++++++++++++++++++++++

This is missing runtest entry in runtest/syscalls file.

> +void verify_pollhup(void)
> +{
> +	struct pollfd pfd = {
> +		.fd = fds[0], .events = POLLIN,
> +	};
> +
> +	SAFE_CLOSE(fds[1]);

Doesn't this fail the test on a second iteration? Have you tried to run
the test with -i 2?

The fd should be closed only once in the setup.

> +	TEST(poll(&pfd, 1, -1));
> +
> +	if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "poll() failed");
> +		return;
> +	}
> +
> +	if (TST_RET != 1) {
> +		tst_res(TFAIL, "Unexpected poll() return value %ld", TST_RET);
> +		return;
> +	}
> +
> +	TST_EXP_EXPR(pfd.revents & POLLHUP);
> +	TST_EXP_EXPR((pfd.revents & ~POLLHUP) == 0);
> +
> +	tst_res(TPASS, "poll() reported POLLHUP");
> +}
> +
> +static void setup(void)
> +{
> +	SAFE_PIPE(fds);
> +}
> +
> +static void cleanup(void)
> +{
> +	if (fds[0] > 0)
> +		SAFE_CLOSE(fds[0]);
> +
> +	if (fds[1] > 0)
> +		SAFE_CLOSE(fds[1]);
> +}
> +
> +static struct tst_test test = {
> +	.setup = setup,
> +	.cleanup = cleanup,
> +	.test_all = verify_pollhup,
> +};
> --
> 2.43.0

-- 
Cyril Hrubis
chrubis@suse.cz

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

  parent reply	other threads:[~2026-02-24 15:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19 16:36 [LTP] [PATCH 1/2] poll: add basic POLLHUP semantics test Jinseok Kim
2026-02-19 16:36 ` [LTP] [PATCH 2/2] poll: add test for POLLNVAL on invalid fd Jinseok Kim
2026-02-20 10:05   ` Cyril Hrubis
2026-02-21 13:33     ` [LTP] [PATCH v2 1/2] poll: add basic POLLHUP semantics test Jinseok Kim
2026-02-21 13:40     ` Jinseok Kim
2026-02-21 13:40       ` [LTP] [PATCH v2 2/2] poll: add test for POLLNVAL on invalid fd Jinseok Kim
2026-02-24 15:36         ` Cyril Hrubis
2026-02-24 17:15           ` [LTP] [PATCH v3 1/2] poll: add basic POLLHUP semantics test Jinseok Kim
2026-02-24 17:15             ` [LTP] [PATCH v3 2/2] poll: add test for POLLNVAL on invalid fd Jinseok Kim
2026-02-25 10:36               ` Cyril Hrubis
2026-02-25 10:37             ` [LTP] [PATCH v3 1/2] poll: add basic POLLHUP semantics test Cyril Hrubis
2026-02-25 11:28               ` [LTP] [PATCH v4 " Jinseok Kim
2026-02-25 11:28                 ` [LTP] [PATCH v4 2/2] poll: add test for POLLNVAL on invalid fd Jinseok Kim
2026-02-25 11:34                   ` Andrea Cervesato via ltp
2026-02-25 11:34                 ` [LTP] [PATCH v4 1/2] poll: add basic POLLHUP semantics test Andrea Cervesato via ltp
2026-02-25 11:39             ` [LTP] [PATCH v3 " Andrea Cervesato
2026-02-24 15:31       ` Cyril Hrubis [this message]
2026-02-24 17:02         ` [LTP] [PATCH v2 " Jinseok Kim
2026-02-20  9:51 ` [LTP] [PATCH " Cyril Hrubis

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=aZ3EWrWQCy7LeSTa@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=always.starving0@gmail.com \
    --cc=ltp@lists.linux.it \
    /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.