summaryrefslogtreecommitdiff
path: root/tests/kmstest.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/kmstest.py')
-rwxr-xr-xtests/kmstest.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/kmstest.py b/tests/kmstest.py
index 177110e..960c27f 100755
--- a/tests/kmstest.py
+++ b/tests/kmstest.py
@@ -168,17 +168,21 @@ class CRCReader(object):
def __init__(self, crtc):
self.pipe = crtc.idx
+ self.ctrl = -1
+ self.dir = -1
+ self.data = -1
# Hardcode the device minor to 0 as the KMSTest constructor opens the
# default card object.
self.dir = os.open(f'/sys/kernel/debug/dri/0/crtc-{self.pipe}/crc', 0)
self.ctrl = os.open('control', os.O_WRONLY, dir_fd = self.dir)
- self.data = -1
def __del__(self):
self.stop()
- os.close(self.ctrl)
- os.close(self.dir)
+ if self.ctrl != -1:
+ os.close(self.ctrl)
+ if self.dir != -1:
+ os.close(self.dir)
def start(self, source):
os.write(self.ctrl, source.encode('ascii'))