[LTP] [PATCH] input_common.h: Add retry loop for event device
Edward Liaw
edliaw@google.com
Thu Feb 27 19:05:12 CET 2025
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
More information about the ltp
mailing list