From: Cyril Hrubis <chrubis@suse.cz>
To: Avinesh Kumar <avinesh.kumar@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3] uevent02: Make wait_for_uevents() order-independent
Date: Tue, 15 Sep 2026 12:53:51 +0200 [thread overview]
Message-ID: <aqkjv-oIgNgHYROA@yuki.lan> (raw)
In-Reply-To: <20260907194422.414746-1-avinesh.kumar@suse.com>
Hi!
> static inline void wait_for_uevents(int fd, const struct uevent_desc *const uevents[])
> {
> - int i = 0;
> + int i, cnt = 0, remaining;
> +
> + while (uevents[cnt])
> + cnt++;
> +
> + uint8_t matched[cnt];
> +
> + memset(matched, 0, sizeof(matched));
>
> - while (1) {
> + remaining = cnt;
> +
> + while (remaining) {
> int len;
> char buf[4096];
>
> @@ -136,11 +155,15 @@ static inline void wait_for_uevents(int fd, const struct uevent_desc *const ueve
>
> print_uevent(buf, len);
>
> - if (uevent_match(buf, len, uevents[i])) {
> - tst_res(TPASS, "Got expected UEVENT");
> - if (!uevents[++i]) {
> - close(fd);
> - return;
> + for (i = 0; i < cnt; i++) {
> + if (matched[i])
> + continue;
> +
> + if (uevent_match(buf, len, uevents[i])) {
> + tst_res(TPASS, "Got expected UEVENT");
> + matched[i] = 1;
> + remaining--;
> + break;
> }
> }
> }
Unfortunately this is not yet ready either. The problem is that this
relaxes the conditions for uevent01.c and uevent03.c too, since these
two tests does not inforce any order after this change.
Well techically for uevent01.c the order does not matter, since the two
events for attach/detach are the same, as the event only reports
"change".
But uevent03.c is exactly the same patter, sequence of add and remove
events. Hence we have to enforce at least partial order. I would however
enforce the full order unless we are told otherwise. So maybe we need
two different wait_for_uevents() helpers one that would keep the order
and one that would match events in any order. And we should use the
order enforcing one in the uevent01 and uevent03.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-09-15 10:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 17:14 [LTP] [PATCH] uevent02: Make wait_for_uevents() order-independent Avinesh Kumar via ltp
2026-08-25 17:36 ` [LTP] " linuxtestproject.agent
2026-08-28 15:26 ` [LTP] [PATCH v2] " Avinesh Kumar via ltp
2026-08-28 21:09 ` [LTP] " linuxtestproject.agent
2026-09-03 13:25 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
2026-09-03 14:42 ` Cyril Hrubis
2026-09-07 19:44 ` [LTP] [PATCH v3] " Avinesh Kumar via ltp
2026-09-07 22:01 ` [LTP] " linuxtestproject.agent
2026-09-15 10:53 ` Cyril Hrubis [this message]
2026-09-15 11:37 ` [LTP] [PATCH v4] uevents: introduce wait_for_uevents_unordered() Avinesh Kumar via ltp
2026-09-15 12:36 ` Petr Vorel
2026-09-15 12:43 ` Cyril Hrubis
2026-09-15 12:55 ` Petr Vorel
2026-09-15 12:41 ` 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=aqkjv-oIgNgHYROA@yuki.lan \
--to=chrubis@suse.cz \
--cc=avinesh.kumar@suse.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.