]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Fix rfkill testing with updated kernel
authorJouni Malinen <jouni@codeaurora.org>
Fri, 15 Jan 2021 16:10:34 +0000 (18:10 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 15 Jan 2021 16:10:34 +0000 (18:10 +0200)
Kernel commit 14486c82612a ("rfkill: add a reason to the HW rfkill
state") added an extra byte to the end of the rfkill events and that
confused the read loop here since python tried to buffer the results
from multiple read() calls into the local buffer that then delivered the
extra octets in consecutive events. Fix this by disabling buffering for
these reads.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
tests/hwsim/rfkill.py

index f08cf50c5dfba2404e774f7aa4c75205ddeb29f0..72b2527feaa8a5ee0dd1065289f429f504af6842 100755 (executable)
@@ -126,7 +126,7 @@ class RFKill(object):
     @classmethod
     def list(cls):
         res = []
-        rfk = open('/dev/rfkill', 'rb')
+        rfk = open('/dev/rfkill', 'rb', buffering=0)
         fd = rfk.fileno()
         flgs = fcntl.fcntl(fd, fcntl.F_GETFL)
         fcntl.fcntl(fd, fcntl.F_SETFL, flgs | os.O_NONBLOCK)