All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-gpio@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: [libgpiod][PATCH 2/6] tests: remove line bulk test cases
Date: Tue,  9 Mar 2021 14:26:35 +0100	[thread overview]
Message-ID: <20210309132639.29069-3-brgl@bgdev.pl> (raw)
In-Reply-To: <20210309132639.29069-1-brgl@bgdev.pl>

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 --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);
-}
-- 
2.30.1


  parent reply	other threads:[~2021-03-09 13:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 13:26 [libgpiod][PATCH 0/6] treewide: another bunch of cleanups for v2.0 Bartosz Golaszewski
2021-03-09 13:26 ` [libgpiod][PATCH 1/6] treewide: simplify line lookup Bartosz Golaszewski
2021-03-09 13:26 ` Bartosz Golaszewski [this message]
2021-03-09 13:26 ` [libgpiod][PATCH 3/6] core: switch to reference counting for gpio chip objects Bartosz Golaszewski
2021-03-09 13:26 ` [libgpiod][PATCH 4/6] treewide: remove is_requested() and is_free() Bartosz Golaszewski
2021-03-09 13:26 ` [libgpiod][PATCH 5/6] treewide: kill line updating Bartosz Golaszewski
2021-03-09 13:26 ` [libgpiod][PATCH 6/6] core: hide the GPIOD_API symbol Bartosz Golaszewski
2021-03-09 15:07   ` Andy Shevchenko
2021-03-09 15:18     ` Bartosz Golaszewski
2021-03-09 15:28       ` Andy Shevchenko
2021-03-17 10:25 ` [libgpiod][PATCH 0/6] treewide: another bunch of cleanups for v2.0 Bartosz Golaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210309132639.29069-3-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.