libgpiosim: new testing library
cover libgpiosim: new testing library
This adds the library that talks to the new gpio-sim module. The module is not yet in any linux release so we'll update the kernel requirements once v5.17 is out.
The first patch adds the library and the second converts the C tests to using it.
The plan is to use it to completely rewrite the tests for v2 so I don't envision any more porting work for v1. Once we are on libgpiosim for all test frameworks in v2, we'll remove all gpio-mockup code from the project.
Bartosz Golaszewski (2):
libgpiosim: new library for controlling the gpio-sim module
tests: port C tests to libgpiosim
configure.ac | 7 +- tests/Makefile.am | 8 +- tests/gpiod-test.c | 143 +++-- tests/gpiod-test.h | 4 +- tests/gpiosim/.gitignore | 4 + tests/gpiosim/Makefile.am | 16 + tests/gpiosim/gpiosim-selftest.c | 157 +++++ tests/gpiosim/gpiosim.c | 1009 ++++++++++++++++++++++++++++++ tests/gpiosim/gpiosim.h | 64 ++ 9 files changed, 1365 insertions(+), 47 deletions(-) create mode 100644 tests/gpiosim/.gitignore create mode 100644 tests/gpiosim/Makefile.am create mode 100644 tests/gpiosim/gpiosim-selftest.c create mode 100644 tests/gpiosim/gpiosim.c create mode 100644 tests/gpiosim/gpiosim.h
Signature · 1 line
2.30.1
PATCH 1/2 libgpiosim: new library for controlling the gpio-sim module
Add a C library for controlling the gpio-sim kernel module from various libgpiod test suites. This aims at replacing the old gpio-mockup module and its user-space library - libgpio-mockup - in the project's tree.
--- configure.ac | 7 +- tests/Makefile.am | 4 +- tests/gpiosim/.gitignore | 4 + tests/gpiosim/Makefile.am | 16 + tests/gpiosim/gpiosim-selftest.c | 157 +++++ tests/gpiosim/gpiosim.c | 1009 ++++++++++++++++++++++++++++++ tests/gpiosim/gpiosim.h | 64 ++ 7 files changed, 1257 insertions(+), 4 deletions(-) create mode 100644 tests/gpiosim/.gitignore create mode 100644 tests/gpiosim/Makefile.am create mode 100644 tests/gpiosim/gpiosim-selftest.c create mode 100644 tests/gpiosim/gpiosim.c create mode 100644 tests/gpiosim/gpiosim.h
configure.ac +5 -2
@@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <[email protected]> +# SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <[email protected]> AC_PREREQ([2.69])
@@ -31,6 +31,7 @@ AC_SUBST(ABI_CXX_VERSION, [2.1.1]) # ABI version for libgpiomockup (we need this since it can be installed if we # enable install-tests). AC_SUBST(ABI_MOCKUP_VERSION, [0.1.0]) +AC_SUBST(ABI_GPIOSIM_VERSION, [0.1.0]) AC_CONFIG_AUX_DIR([autostuff]) AC_CONFIG_MACRO_DIRS([m4])
@@ -126,10 +127,11 @@ AC_DEFUN([FUNC_NOT_FOUND_TESTS], if test "x$with_tests" = xtrue then - # For libgpiomockup + # For libgpiomockup & libgpiosim AC_CHECK_FUNC([qsort], [], [FUNC_NOT_FOUND_TESTS([qsort])]) PKG_CHECK_MODULES([KMOD], [libkmod >= 18]) PKG_CHECK_MODULES([UDEV], [libudev >= 215]) + PKG_CHECK_MODULES([MOUNT], [mount >= 2.33.1]) # For core library tests PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.50])
@@ -224,6 +226,7 @@ AC_CONFIG_FILES([Makefile tools/Makefile tests/Makefile tests/mockup/Makefile + tests/gpiosim/Makefile bindings/cxx/libgpiodcxx.pc bindings/Makefile bindings/cxx/Makefile
tests/Makefile.am +2 -2
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <[email protected]> +# SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <[email protected]> -SUBDIRS = mockup +SUBDIRS = mockup gpiosim AM_CFLAGS = -I$(top_srcdir)/include/ -I$(top_srcdir)/tests/mockup/ AM_CFLAGS += -include $(top_builddir)/config.h
tests/gpiosim/.gitignore new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <[email protected]> + +gpiosim-selftest
tests/gpiosim/Makefile.am new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# SPDX-FileCopyrightText: 2021-2022 Bartosz Golaszewski <[email protected]> + +lib_LTLIBRARIES = libgpiosim.la +noinst_PROGRAMS = gpiosim-selftest + +AM_CFLAGS = -Wall -Wextra -g -fvisibility=hidden -std=gnu89 +AM_CFLAGS += -include $(top_builddir)/config.h + +libgpiosim_la_SOURCES = gpiosim.c gpiosim.h +libgpiosim_la_CFLAGS = $(AM_CFLAGS) $(KMOD_CFLAGS) $(MOUNT_CFLAGS) +libgpiosim_la_LDFLAGS = -version-info $(subst .,:,$(ABI_GPIOSIM_VERSION)) +libgpiosim_la_LDFLAGS += $(KMOD_LIBS) $(MOUNT_LIBS) + +gpiosim_selftest_SOURCES = gpiosim-selftest.c +gpiosim_selftest_LDADD = libgpiosim.la
tests/gpiosim/gpiosim-selftest.c new file +157 -0
157 lines not on this page · raw message
tests/gpiosim/gpiosim.c new file +1009 -0
1,009 lines not on this page · raw message
tests/gpiosim/gpiosim.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.30.1
PATCH 2/2 tests: port C tests to libgpiosim
In reply to Bartosz GolaszewskiThis converts the core library tests to using libgpiosim instead of libgpiod-mockup while keeping the same interface for tests.
--- tests/Makefile.am | 4 +- tests/gpiod-test.c | 143 ++++++++++++++++++++++++++++++++------------- tests/gpiod-test.h | 4 +- 3 files changed, 108 insertions(+), 43 deletions(-)
tests/Makefile.am +2 -2
@@ -3,13 +3,13 @@ SUBDIRS = mockup gpiosim -AM_CFLAGS = -I$(top_srcdir)/include/ -I$(top_srcdir)/tests/mockup/ +AM_CFLAGS = -I$(top_srcdir)/include/ -I$(top_srcdir)/tests/gpiosim/ AM_CFLAGS += -include $(top_builddir)/config.h AM_CFLAGS += -Wall -Wextra -g -std=gnu89 $(GLIB_CFLAGS) AM_CFLAGS += -DG_LOG_DOMAIN=\"gpiod-test\" AM_LDFLAGS = -pthread LDADD = $(top_builddir)/lib/libgpiod.la -LDADD += $(top_builddir)/tests/mockup/libgpiomockup.la +LDADD += $(top_builddir)/tests/gpiosim/libgpiosim.la LDADD += $(GLIB_LIBS) bin_PROGRAMS = gpiod-test
tests/gpiod-test.c +104 -39
211 lines not on this page · raw message
tests/gpiod-test.h +2 -2
@@ -1,5 +1,5 @@/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <[email protected]> */ +/* SPDX-FileCopyrightText: 2017-2022 Bartosz Golaszewski <[email protected]> */ /* * Testing framework for the core library.
@@ -50,7 +50,7 @@ enum {/* * Register a test case function. The last argument is the array of numbers -* of lines per mockup chip. +* of lines per simulated chip. */ #define GPIOD_TEST_CASE (_name, _flags, ...) \ static void _name(void); \
Signature · 1 line
2.30.1