diff mbox series

[kms-tests] tests: Add a plane formats test

Message ID 20190616234153.26423-1-laurent.pinchart@ideasonboard.com (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series [kms-tests] tests: Add a plane formats test | expand

Commit Message

Laurent Pinchart June 16, 2019, 11:41 p.m. UTC
Add a new test script that tests all formats supported by planes.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 tests/kms-test-formats.py | 63 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100755 tests/kms-test-formats.py

Comments

Kieran Bingham June 18, 2019, 9:41 p.m. UTC | #1
Hi Laurent,

On 17/06/2019 00:41, Laurent Pinchart wrote:
> Add a new test script that tests all formats supported by planes.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Seems reasonable to me.

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> ---
>  tests/kms-test-formats.py | 63 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
>  create mode 100755 tests/kms-test-formats.py
> 
> diff --git a/tests/kms-test-formats.py b/tests/kms-test-formats.py
> new file mode 100755
> index 000000000000..ae89bb542485
> --- /dev/null
> +++ b/tests/kms-test-formats.py
> @@ -0,0 +1,63 @@
> +#!/usr/bin/python3
> +
> +import kmstest
> +import pykms
> +import time
> +
> +class FormatsTest(kmstest.KMSTest):
> +    """Test all available plane formats."""
> +
> +    def main(self):
> +        self.start("plane formats")
> +
> +        # Find a CRTC with a connected connector and at least one plane
> +        for connector in self.card.connectors:
> +            if not connector.connected():
> +                self.skip("unconnected connector")
> +                continue
> +
> +            try:
> +                mode = connector.get_default_mode()
> +            except ValueError:
> +                continue
> +
> +            crtcs = connector.get_possible_crtcs()
> +            for crtc in crtcs:
> +                if crtc.primary_plane:
> +                    break
> +            else:
> +                crtc = None
> +
> +            if crtc:
> +                break
> +
> +        else:
> +            self.skip("no CRTC available with connector")
> +            return
> +
> +        self.logger.log("Testing connector %s, CRTC %u, mode %s" % \
> +              (connector.fullname, crtc.id, mode.name))
> +
> +        for format in crtc.primary_plane.formats:
> +            self.logger.log("Testing format %s" % format)
> +
> +            # Create a frame buffer
> +            try:
> +                fb = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, format)
> +            except ValueError:
> +                continue
> +
> +            pykms.draw_test_pattern(fb)
> +
> +            # Set the mode with a primary plane
> +            ret = self.atomic_crtc_mode_set(crtc, connector, mode, fb)
> +            if ret < 0:
> +                self.fail("atomic mode set failed with %d" % ret)
> +                continue
> +
> +            self.run(3)
> +
> +        self.atomic_crtc_disable(crtc)
> +        self.success()
> +
> +FormatsTest().execute()
>
diff mbox series

Patch

diff --git a/tests/kms-test-formats.py b/tests/kms-test-formats.py
new file mode 100755
index 000000000000..ae89bb542485
--- /dev/null
+++ b/tests/kms-test-formats.py
@@ -0,0 +1,63 @@ 
+#!/usr/bin/python3
+
+import kmstest
+import pykms
+import time
+
+class FormatsTest(kmstest.KMSTest):
+    """Test all available plane formats."""
+
+    def main(self):
+        self.start("plane formats")
+
+        # Find a CRTC with a connected connector and at least one plane
+        for connector in self.card.connectors:
+            if not connector.connected():
+                self.skip("unconnected connector")
+                continue
+
+            try:
+                mode = connector.get_default_mode()
+            except ValueError:
+                continue
+
+            crtcs = connector.get_possible_crtcs()
+            for crtc in crtcs:
+                if crtc.primary_plane:
+                    break
+            else:
+                crtc = None
+
+            if crtc:
+                break
+
+        else:
+            self.skip("no CRTC available with connector")
+            return
+
+        self.logger.log("Testing connector %s, CRTC %u, mode %s" % \
+              (connector.fullname, crtc.id, mode.name))
+
+        for format in crtc.primary_plane.formats:
+            self.logger.log("Testing format %s" % format)
+
+            # Create a frame buffer
+            try:
+                fb = pykms.DumbFramebuffer(self.card, mode.hdisplay, mode.vdisplay, format)
+            except ValueError:
+                continue
+
+            pykms.draw_test_pattern(fb)
+
+            # Set the mode with a primary plane
+            ret = self.atomic_crtc_mode_set(crtc, connector, mode, fb)
+            if ret < 0:
+                self.fail("atomic mode set failed with %d" % ret)
+                continue
+
+            self.run(3)
+
+        self.atomic_crtc_disable(crtc)
+        self.success()
+
+FormatsTest().execute()