tests: Fix rfkill testing with updated kernel

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>
This commit is contained in:
Jouni Malinen 2021-01-15 18:10:34 +02:00 committed by Jouni Malinen
parent 8f58972942
commit f34493f2a8

View file

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