All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edward Liaw via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: kernel-team@android.com
Subject: [LTP] [PATCH] input_common.h: Add retry loop for event device
Date: Thu, 27 Feb 2025 18:05:12 +0000	[thread overview]
Message-ID: <20250227180512.355110-1-edliaw@google.com> (raw)

Android has a delay between the entry in /proc/bus/input/devices and the
path /dev/input/eventN becoming accessible.  Add a 1s retry loop to
account for this.

Signed-off-by: Edward Liaw <edliaw@google.com>
---
 testcases/kernel/input/input_common.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/input/input_common.h b/testcases/kernel/input/input_common.h
index 0ac1624b3..06fba753e 100644
--- a/testcases/kernel/input/input_common.h
+++ b/testcases/kernel/input/input_common.h
@@ -29,9 +29,12 @@ static inline int open_event_device(void)
 			memset(path, 0, sizeof(path));
 			snprintf(path, sizeof(path), "/dev/input/%s", device);
 
-			if (!access(path, F_OK)) {
-				tst_res(TINFO, "Found event device: %s", path);
-				break;
+			for (int i = 100 ; i > 0 ; i--) {
+				if (!access(path, F_OK)) {
+					tst_res(TINFO, "Found event device: %s", path);
+					break;
+				}
+				usleep(10000);
 			}
 		}
 
-- 
2.48.1.711.g2feabab25a-goog


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

             reply	other threads:[~2025-02-27 18:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 18:05 Edward Liaw via ltp [this message]
2025-02-28 11:05 ` [LTP] [PATCH] input_common.h: Add retry loop for event device 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=20250227180512.355110-1-edliaw@google.com \
    --to=ltp@lists.linux.it \
    --cc=edliaw@google.com \
    --cc=kernel-team@android.com \
    /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.