diff mbox series

[libgpiod,2/6] tests: remove line bulk test cases

Message ID 20210309132639.29069-3-brgl@bgdev.pl
State New
Headers show
Series treewide: another bunch of cleanups for v2.0 | expand

Commit Message

Bartosz Golaszewski March 9, 2021, 1:26 p.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

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      |  43 --------
 bindings/python/tests/gpiod_py_test.py |  15 ---
 tests/Makefile.am                      |   1 -
 tests/tests-bulk.c                     | 145 -------------------------
 4 files changed, 204 deletions(-)
 delete mode 100644 tests/tests-bulk.c
diff mbox series

Patch

diff --git a/bindings/cxx/tests/tests-line.cpp b/bindings/cxx/tests/tests-line.cpp
index c1ad8d2..648012a 100644
--- a/bindings/cxx/tests/tests-line.cpp
+++ b/bindings/cxx/tests/tests-line.cpp
@@ -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 });
diff --git a/bindings/python/tests/gpiod_py_test.py b/bindings/python/tests/gpiod_py_test.py
index c8ee85b..b7c30de 100755
--- a/bindings/python/tests/gpiod_py_test.py
+++ b/bindings/python/tests/gpiod_py_test.py
@@ -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
 #
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 49aa215..43b215e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index ad08f2d..0000000
--- a/tests/tests-bulk.c
+++ /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);
-}