[libgpiod][PATCH 1/3] bindings: python: tests: extend reconfiguration tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A number of the corner cases for reconfiguration are untested, including
 - using None for default settings
 - missing settings for some lines
 - jumbled line ordering relative to the request
 - extra settings for non-requested lines

Add tests for these corner cases.

Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx>
---
 bindings/python/tests/tests_line_request.py | 50 +++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/bindings/python/tests/tests_line_request.py b/bindings/python/tests/tests_line_request.py
index f99b93d..2f375d6 100644
--- a/bindings/python/tests/tests_line_request.py
+++ b/bindings/python/tests/tests_line_request.py
@@ -490,6 +490,56 @@ class ReconfigureRequestedLines(TestCase):
         info = self.chip.get_line_info(2)
         self.assertEqual(info.direction, Direction.INPUT)
 
+    def test_reconfigure_by_misordered_offsets(self):
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.OUTPUT)
+        self.req.reconfigure_lines(
+            {(6, 0, 3, 2): gpiod.LineSettings(direction=Direction.INPUT)}
+        )
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.INPUT)
+
+    def test_reconfigure_by_misordered_names(self):
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.OUTPUT)
+        self.req.reconfigure_lines(
+            {(0, "baz", 2, "foo"): gpiod.LineSettings(direction=Direction.INPUT)}
+        )
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.INPUT)
+
+    def test_reconfigure_with_default(self):
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.OUTPUT)
+        self.req.reconfigure_lines({
+            0: gpiod.LineSettings(direction=Direction.INPUT),
+            2: None,
+            ("baz", "foo"): gpiod.LineSettings(direction=Direction.INPUT)
+        })
+        info = self.chip.get_line_info(0)
+        self.assertEqual(info.direction, Direction.INPUT)
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.OUTPUT)
+
+    def test_reconfigure_missing_offsets(self):
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.OUTPUT)
+        self.req.reconfigure_lines(
+                {(6, 0): gpiod.LineSettings(direction=Direction.INPUT)}
+            )
+        info = self.chip.get_line_info(0)
+        self.assertEqual(info.direction, Direction.INPUT)
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.OUTPUT)
+
+    def test_reconfigure_extra_offsets(self):
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.OUTPUT)
+        self.req.reconfigure_lines(
+            {(0, 2, 3, 6, 5): gpiod.LineSettings(direction=Direction.INPUT)}
+            )
+        info = self.chip.get_line_info(2)
+        self.assertEqual(info.direction, Direction.INPUT)
 
 class ReleasedLineRequestCannotBeUsed(TestCase):
     def test_using_released_line_request(self):
-- 
2.39.2





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux