summaryrefslogtreecommitdiff
path: root/tests/kmstest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/kmstest.py')
-rwxr-xr-xtests/kmstest.py60
1 files changed, 30 insertions, 30 deletions
diff --git a/tests/kmstest.py b/tests/kmstest.py
index 949bb20..708e699 100755
--- a/tests/kmstest.py
+++ b/tests/kmstest.py
@@ -63,23 +63,23 @@ class EventLoop(selectors.DefaultSelector):
class KernelLogMessage(object):
def __init__(self, msg):
- pos = msg.find(";")
+ pos = msg.find(';')
header = msg[:pos]
msg = msg[pos+1:]
- facility, sequence, timestamp, *other = header.split(",")
+ facility, sequence, timestamp, *other = header.split(',')
self.facility = int(facility)
self.sequence = int(sequence)
self.timestamp = int(timestamp) / 1000000.
- msg = msg.split("\n")
+ msg = msg.split('\n')
self.msg = msg[0]
self.tags = {}
try:
tags = msg[1:-1]
for tag in tags:
- tag = tag.strip().split("=")
+ tag = tag.strip().split('=')
self.tags[tag[0]] = tag[1]
except:
pass
@@ -87,7 +87,7 @@ class KernelLogMessage(object):
class KernelLogReader(object):
def __init__(self):
- self.kmsg = os.open("/dev/kmsg", 0)
+ self.kmsg = os.open('/dev/kmsg', 0)
flags = fcntl.fcntl(self.kmsg, fcntl.F_GETFL)
fcntl.fcntl(self.kmsg, fcntl.F_SETFL, flags | os.O_NONBLOCK)
os.lseek(self.kmsg, 0, os.SEEK_END)
@@ -100,7 +100,7 @@ class KernelLogReader(object):
while True:
try:
msg = os.read(self.kmsg, 8191)
- msg = msg.decode("utf-8")
+ msg = msg.decode('utf-8')
except OSError as e:
if e.errno == errno.EAGAIN:
break
@@ -113,7 +113,7 @@ class KernelLogReader(object):
class Logger(object):
def __init__(self, name):
- self.logfile = open("%s.log" % name, "w")
+ self.logfile = open('%s.log' % name, 'w')
self._kmsg = KernelLogReader()
def __del__(self):
@@ -129,7 +129,7 @@ class Logger(object):
def event(self):
kmsgs = self._kmsg.read()
for msg in kmsgs:
- self.logfile.write("K [%6f] %s\n" % (msg.timestamp, msg.msg))
+ self.logfile.write('K [%6f] %s\n' % (msg.timestamp, msg.msg))
self.logfile.flush()
@property
@@ -146,13 +146,13 @@ class Logger(object):
self.event()
now = time.clock_gettime(time.CLOCK_MONOTONIC)
- self.logfile.write("U [%6f] %s\n" % (now, msg))
+ self.logfile.write('U [%6f] %s\n' % (now, msg))
self.logfile.flush()
class CRC(object):
def __init__(self, crc):
- if crc.startswith("XXXXXXXXXX"):
+ if crc.startswith('XXXXXXXXXX'):
self.frame = None
else:
self.frame = int(crc[:10], 16)
@@ -171,8 +171,8 @@ class CRCReader(object):
# Hardcode the device minor to 0 as the KMSTest constructor opens the
# default card object.
- self.dir = os.open("/sys/kernel/debug/dri/0/crtc-%u/crc" % self.pipe, 0)
- self.ctrl = os.open("control", os.O_WRONLY, dir_fd = self.dir)
+ self.dir = os.open('/sys/kernel/debug/dri/0/crtc-%u/crc' % self.pipe, 0)
+ self.ctrl = os.open('control', os.O_WRONLY, dir_fd = self.dir)
self.data = -1
def __del__(self):
@@ -181,8 +181,8 @@ class CRCReader(object):
os.close(self.dir)
def start(self, source):
- os.write(self.ctrl, source.encode("ascii"))
- self.data = os.open("data", os.O_RDONLY, dir_fd = self.dir)
+ os.write(self.ctrl, source.encode('ascii'))
+ self.data = os.open('data', os.O_RDONLY, dir_fd = self.dir)
def stop(self):
if self.data != -1:
@@ -194,7 +194,7 @@ class CRCReader(object):
while len(crcs) < num_entries:
try:
crc = os.read(self.data, CRCReader.MAX_LINE_LEN)
- crc = crc.decode("ascii")
+ crc = crc.decode('ascii')
except OSError as e:
if e.errno == errno.EAGAIN:
break
@@ -211,7 +211,7 @@ class Dist(object):
self.y = y
def __repr__(self):
- return "(%d,%d)" % (self.x, self.y)
+ return '(%d,%d)' % (self.x, self.y)
class Point(object):
@@ -220,7 +220,7 @@ class Point(object):
self.y = y
def __repr__(self):
- return "(%d,%d)" % (self.x, self.y)
+ return '(%d,%d)' % (self.x, self.y)
def move(self, distance):
self.x += distance.x
@@ -233,7 +233,7 @@ class Size(object):
self.height = height
def __repr__(self):
- return "%ux%u" % (self.width, self.height)
+ return '%ux%u' % (self.width, self.height)
class Rect(object):
@@ -244,7 +244,7 @@ class Rect(object):
self.height = height
def __repr__(self):
- return "(%d,%d)/%ux%u" % (self.left, self.top, self.width, self.height)
+ return '(%d,%d)/%ux%u' % (self.left, self.top, self.width, self.height)
def isEmpty(self):
"""Check if the rectangle has a zero width or height"""
@@ -387,7 +387,7 @@ class KMSTest(object):
def atomic_plane_disable(self, plane, sync=True):
req = AtomicRequest(self)
- req.add(plane, { "FB_ID": 0, 'CRTC_ID': 0 })
+ req.add(plane, { 'FB_ID': 0, 'CRTC_ID': 0 })
if sync:
return req.commit_sync()
@@ -397,7 +397,7 @@ class KMSTest(object):
def atomic_planes_disable(self, sync=True):
req = AtomicRequest(self)
for plane in self.card.planes:
- req.add(plane, { "FB_ID": 0, 'CRTC_ID': 0 })
+ req.add(plane, { 'FB_ID': 0, 'CRTC_ID': 0 })
if sync:
return req.commit_sync()
@@ -462,32 +462,32 @@ class KMSTest(object):
def start(self, name):
"""Start a test."""
self.test_name = name
- self.logger.log("Testing %s" % name)
- sys.stdout.write("Testing %s: " % name)
+ self.logger.log('Testing %s' % name)
+ sys.stdout.write('Testing %s: ' % name)
sys.stdout.flush()
def progress(self, current, maximum):
- sys.stdout.write("\rTesting %s: %u/%u" % (self.test_name, current, maximum))
+ sys.stdout.write('\rTesting %s: %u/%u' % (self.test_name, current, maximum))
sys.stdout.flush()
def fail(self, reason):
"""Complete a test with failure."""
- self.logger.log("Test failed. Reason: %s" % reason)
+ self.logger.log('Test failed. Reason: %s' % reason)
self.logger.flush()
- sys.stdout.write("\rTesting %s: FAIL\n" % self.test_name)
+ sys.stdout.write('\rTesting %s: FAIL\n' % self.test_name)
sys.stdout.flush()
def skip(self, reason):
"""Complete a test with skip."""
- self.logger.log("Test skipped. Reason: %s" % reason)
+ self.logger.log('Test skipped. Reason: %s' % reason)
self.logger.flush()
- sys.stdout.write("SKIP\n")
+ sys.stdout.write('SKIP\n')
sys.stdout.flush()
def success(self):
"""Complete a test with success."""
- self.logger.log("Test completed successfully")
+ self.logger.log('Test completed successfully')
self.logger.flush()
- sys.stdout.write("\rTesting %s: SUCCESS\n" % self.test_name)
+ sys.stdout.write('\rTesting %s: SUCCESS\n' % self.test_name)
sys.stdout.flush()