[LTP] [PATCH v2] input_common.h: Add retry loop for event device

Edward Liaw edliaw@google.com
Fri Feb 28 19:48:34 CET 2025


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

Signed-off-by: Edward Liaw <edliaw@google.com>
---
 testcases/kernel/input/input_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/input/input_common.h b/testcases/kernel/input/input_common.h
index 0ac1624b3..5b1755771 100644
--- a/testcases/kernel/input/input_common.h
+++ b/testcases/kernel/input/input_common.h
@@ -29,7 +29,7 @@ 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)) {
+			if (!TST_RETRY_FUNC(access(path, F_OK), TST_RETVAL_EQ0)) {
 				tst_res(TINFO, "Found event device: %s", path);
 				break;
 			}
-- 
2.48.1.711.g2feabab25a-goog



More information about the ltp mailing list