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

Edward Liaw edliaw@google.com
Tue Mar 4 01:59:43 CET 2025


On Mon, Mar 3, 2025 at 10:34 AM Edward Liaw <edliaw@google.com> wrote:

>
>
> On Mon, Mar 3, 2025 at 1:35 AM Li Wang <liwang@redhat.com> wrote:
>
>>
>>
>> On Sat, Mar 1, 2025 at 2:49 AM Edward Liaw via ltp <ltp@lists.linux.it>
>> wrote:
>>
>>> 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.
>>>
>>
>> Did you count for how long it takes to entry? The default time
>> TST_RETRY_FUNC
>> is backoff 1 second, if that time is not enough, you can consider the
>> completed
>> version TST_RETRY_FN_EXP_BACKOFF for setting more seconds.
>>
>> Anyway, this looks good.
>> Reviewed-by: Li Wang <liwang@redhat.com>
>>
>
> Yeah, 1 sec should be more than enough for Android; the delay has so far
> been on the order of microseconds.
>
Sorry, milliseconds* not microseconds.
>
>
>>
>>
>>>
>>> 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
>>>
>>>
>>> --
>>> Mailing list info: https://lists.linux.it/listinfo/ltp
>>>
>>>
>>
>> --
>> Regards,
>> Li Wang
>>
>


More information about the ltp mailing list