tests: remove line bulk test cases
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Wed, 20 Jan 2021 10:27:20 +0000 (11:27 +0100)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 18 Mar 2021 08:34:15 +0000 (09:34 +0100)
Together with the removal of line objects, we'll entirely drop the
line bulk concept. In order to avoid having to update tests that will
soon be unneeded when introducing further changes, let's remove line
bulk test cases already.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
bindings/cxx/tests/tests-line.cpp
bindings/python/tests/gpiod_py_test.py
tests/Makefile.am
tests/tests-bulk.c [deleted file]

index c1ad8d2f07e741a2e6b3e2cfeb32e77b64ce2077..648012a10f8d055c728fbbef7db1227f6229b721 100644 (file)
@@ -153,49 +153,6 @@ TEST_CASE("Line information can be correctly retrieved", "[line]")
        }
 }
 
-TEST_CASE("Line bulk object works correctly", "[line][bulk]")
-{
-       mockup::probe_guard mockup_chips({ 8 }, mockup::FLAG_NAMED_LINES);
-       ::gpiod::chip chip(mockup::instance().chip_path(0));
-
-       SECTION("lines can be added, accessed and cleared")
-       {
-               ::gpiod::line_bulk lines;
-
-               REQUIRE(lines.empty());
-
-               lines.append(chip.get_line(0));
-               lines.append(chip.get_line(1));
-               lines.append(chip.get_line(2));
-
-               REQUIRE(lines.size() == 3);
-               REQUIRE(lines.get(1).name() == "gpio-mockup-A-1");
-               REQUIRE(lines[2].name() == "gpio-mockup-A-2");
-
-               lines.clear();
-
-               REQUIRE(lines.empty());
-       }
-
-       SECTION("bulk iterator works")
-       {
-               auto lines = chip.get_all_lines();
-               unsigned int count = 0;
-
-               for (auto& it: lines)
-                       REQUIRE(it.offset() == count++);
-
-               REQUIRE(count == chip.num_lines());
-       }
-
-       SECTION("accessing lines out of range throws exception")
-       {
-               auto lines = chip.get_all_lines();
-
-               REQUIRE_THROWS_AS(lines.get(11), ::std::out_of_range);
-       }
-}
-
 TEST_CASE("Line values can be set and read", "[line]")
 {
        mockup::probe_guard mockup_chips({ 8 });
index c8ee85b23bf53190b899ceec1b6e6b569107c8d0..b7c30ded62fbb0ee6fd3ea1469e938ba05f6f0dc 100755 (executable)
@@ -670,21 +670,6 @@ class LineIterator(MockupTestCase):
 
             self.assertEqual(count, chip.num_lines())
 
-class LineBulkIter(MockupTestCase):
-
-    chip_sizes = ( 4, )
-
-    def test_line_bulk_iterator(self):
-        with gpiod.Chip(mockup.chip_path(0)) as chip:
-            lines = chip.get_all_lines()
-            count = 0
-
-            for line in lines:
-                self.assertEqual(line.offset(), count)
-                count += 1
-
-            self.assertEqual(count, chip.num_lines())
-
 #
 # Event test cases
 #
index 49aa215dced6f23654ba19456a00c40855fbda67..43b215e12a86847f3ce8ff2dd632de40a0d7af38 100644 (file)
@@ -17,7 +17,6 @@ bin_PROGRAMS = gpiod-test
 gpiod_test_SOURCES =                   \
                gpiod-test.c            \
                gpiod-test.h            \
-               tests-bulk.c            \
                tests-chip.c            \
                tests-event.c           \
                tests-line.c            \
diff --git a/tests/tests-bulk.c b/tests/tests-bulk.c
deleted file mode 100644 (file)
index ad08f2d..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
-
-#include <errno.h>
-
-#include "gpiod-test.h"
-
-#define GPIOD_TEST_GROUP "bulk"
-
-GPIOD_TEST_CASE(alloc_zero_lines, 0, { 1 })
-{
-       struct gpiod_line_bulk *bulk;
-
-       bulk = gpiod_line_bulk_new(0);
-       g_assert_null(bulk);
-       g_assert_cmpint(errno, ==, EINVAL);
-}
-
-GPIOD_TEST_CASE(add_too_many_lines, 0, { 8 })
-{
-       g_autoptr(gpiod_line_bulk_struct) bulk = NULL;
-       g_autoptr(gpiod_chip_struct) chip = NULL;
-       struct gpiod_line *lineA, *lineB, *lineC;
-       gint ret;
-
-       chip = gpiod_chip_open(gpiod_test_chip_path(0));
-       g_assert_nonnull(chip);
-       gpiod_test_return_if_failed();
-
-       bulk = gpiod_line_bulk_new(2);
-       g_assert_nonnull(bulk);
-       gpiod_test_return_if_failed();
-
-       lineA = gpiod_chip_get_line(chip, 0);
-       lineB = gpiod_chip_get_line(chip, 1);
-       lineC = gpiod_chip_get_line(chip, 2);
-       g_assert_nonnull(lineA);
-       g_assert_nonnull(lineB);
-       g_assert_nonnull(lineC);
-       gpiod_test_return_if_failed();
-
-       ret = gpiod_line_bulk_add_line(bulk, lineA);
-       g_assert_cmpint(ret, ==, 0);
-       ret = gpiod_line_bulk_add_line(bulk, lineB);
-       g_assert_cmpint(ret, ==, 0);
-       ret = gpiod_line_bulk_add_line(bulk, lineC);
-       g_assert_cmpint(ret, ==, -1);
-       g_assert_cmpint(errno, ==, EINVAL);
-}
-
-GPIOD_TEST_CASE(add_lines_from_different_chips, 0, { 8, 8 })
-{
-       g_autoptr(gpiod_line_bulk_struct) bulk = NULL;
-       g_autoptr(gpiod_chip_struct) chipA = NULL;
-       g_autoptr(gpiod_chip_struct) chipB = NULL;
-       struct gpiod_line *lineA, *lineB;
-       gint ret;
-
-       chipA = gpiod_chip_open(gpiod_test_chip_path(0));
-       chipB = gpiod_chip_open(gpiod_test_chip_path(1));
-       g_assert_nonnull(chipA);
-       g_assert_nonnull(chipB);
-       gpiod_test_return_if_failed();
-
-       bulk = gpiod_line_bulk_new(4);
-       g_assert_nonnull(bulk);
-       gpiod_test_return_if_failed();
-
-       lineA = gpiod_chip_get_line(chipA, 0);
-       lineB = gpiod_chip_get_line(chipB, 0);
-       g_assert_nonnull(lineA);
-       g_assert_nonnull(lineB);
-       gpiod_test_return_if_failed();
-
-       ret = gpiod_line_bulk_add_line(bulk, lineA);
-       g_assert_cmpint(ret, ==, 0);
-       ret = gpiod_line_bulk_add_line(bulk, lineB);
-       g_assert_cmpint(ret, ==, -1);
-       g_assert_cmpint(errno, ==, EINVAL);
-}
-
-static const gchar *const bulk_foreach_line_names[] = {
-       "gpio-mockup-A-0",
-       "gpio-mockup-A-1",
-       "gpio-mockup-A-2",
-       "gpio-mockup-A-3"
-};
-
-static int bulk_foreach_callback_all(struct gpiod_line *line, void *data)
-{
-       gint *i = data;
-
-       g_assert_cmpstr(gpiod_line_name(line), ==,
-                       bulk_foreach_line_names[(*i)++]);
-
-       return GPIOD_LINE_BULK_CB_NEXT;
-}
-
-static int bulk_foreach_callback_stop(struct gpiod_line *line, void *data)
-{
-       gint *i = data;
-
-       g_assert_cmpstr(gpiod_line_name(line), ==,
-                       bulk_foreach_line_names[(*i)++]);
-       if (*i == 2)
-               return GPIOD_LINE_BULK_CB_STOP;
-
-       return GPIOD_LINE_BULK_CB_NEXT;
-}
-
-GPIOD_TEST_CASE(foreach_all_lines, GPIOD_TEST_FLAG_NAMED_LINES, { 4 })
-{
-       g_autoptr(gpiod_line_bulk_struct) bulk = NULL;
-       g_autoptr(gpiod_chip_struct) chip = NULL;
-       gint i = 0;
-
-       chip = gpiod_chip_open(gpiod_test_chip_path(0));
-       g_assert_nonnull(chip);
-       gpiod_test_return_if_failed();
-
-       bulk = gpiod_chip_get_all_lines(chip);
-       g_assert_nonnull(bulk);
-       gpiod_test_return_if_failed();
-
-       gpiod_line_bulk_foreach_line(bulk, bulk_foreach_callback_all, &i);
-       gpiod_test_return_if_failed();
-}
-
-GPIOD_TEST_CASE(foreach_two_lines, GPIOD_TEST_FLAG_NAMED_LINES, { 8 })
-{
-       g_autoptr(gpiod_line_bulk_struct) bulk = NULL;
-       g_autoptr(gpiod_chip_struct) chip = NULL;
-       gint i = 0;
-
-       chip = gpiod_chip_open(gpiod_test_chip_path(0));
-       g_assert_nonnull(chip);
-       gpiod_test_return_if_failed();
-
-       bulk = gpiod_chip_get_all_lines(chip);
-       g_assert_nonnull(bulk);
-       gpiod_test_return_if_failed();
-
-       gpiod_line_bulk_foreach_line(bulk, bulk_foreach_callback_stop, &i);
-       g_assert_cmpint(i, ==, 2);
-}