1
0
mirror of https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git synced 2026-10-24 00:48:53 +03:00
Commit Graph

28 Commits

Author SHA1 Message Date
Bartosz Golaszewski
d30bcd7b2e tests: update library API version string tests
The version string returned by gpiod_api_version() is now stricter and
will always be of the form: x.y.z where x, y and z are unsigned integer
numbers. We no longer have to parse various suffixes so update the test
cases tree-wide.

Acked-by: Erik Wierich <erik@riscstar.com>
Link: https://lore.kernel.org/r/20250903-api-version-detach-v1-4-027ca5928518@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2025-09-09 10:24:00 +02:00
Bartosz Golaszewski
e60e38375c tests: split out reusable test code into a local static library
In order to allow the upcoming GLib and DBus bindings to reuse the test
code, let's put all common elements into reusable libtool objects and
export the relevant symbols in internal headers.

Tested-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Link: https://lore.kernel.org/r/20240812-dbus-v5-1-ead288509217@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2024-08-13 10:38:40 +02:00
Bartosz Golaszewski
f054a7099d tests: fix version parsing (again)
This time we missed the fact that the last part is optional. Fix it
treewide.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-11-03 17:17:34 +01:00
Bartosz Golaszewski
b740f64daf tests: simplify and reduce the strictness of version string regex patterns
It seems like every release there's some new problem with parsing the
version strings in tests. Let's reduce the strictness of the patterns
to avoid future test failures and accept the following version schemes:

X.Y
X.Y.Z
X.Y-devel
X.Y-rcZ

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-11 17:54:57 +02:00
Bartosz Golaszewski
7936f50218 tests: fix version regex treewide
The square bracket is in the wrong place which makes the regex not match
version strings of the form: x.y.z. Fix the pattern in core and bindings
tests.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-04-11 13:56:23 +02:00
Bartosz Golaszewski
265124bae0 tests: extend the regex matching string versions
We need to match release candidate versions too.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-02-08 14:25:17 +01:00
Bartosz Golaszewski
4c4dced3c7 core: make the library NULL-aware
Currently we almost never check the validity of pointers passed to the
core C API routines. While we cannot know if a non-NULL pointer points
to an actual object, we can at least verify that it is not NULL before
dereferencing it.

Conceptually we can think of two categories of pointers in libgpiod:

First, there are the objects we manipulate using the API. These are
normally the first arguments in any given method and they are only
instantiated inside the library and never dereferenced by the user.

They should always be valid, so passing a NULL pointer here should
always lead to a crash. Currently it will take the form of a segfault
at the moment of dereference but with this change, we make the user
program abort() with the stack trace pointing right at the offender.

The second category would be pointers to objects that are logically
parameters of methods i.e. not their first argument. Example is:
gpiod_chip_request_lines(chip, req_cfg, line_cfg) (whose logical OOP
version would be: chip->request_lines(req_cfg, line_cfg)). Here we
accept a NULL req_cfg but we'll segfault on a NULL line_cfg. For
consistency: don't crash here but instead return -1 and set errno
to EINVAL. Same everywhere else.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2023-01-06 12:46:02 +01:00
Bartosz Golaszewski
8da5c77a54 core: rename gpiod_version_string() to gpiod_api_version()
Instead of telling the user what type this function returns (they can
check it by looking at the prototype), tell them what the return value
actually represents.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
2022-12-12 09:50:47 +01:00
Bartosz Golaszewski
b7ba732e6a treewide: libgpiod v2 implementation
This commit is the result of a squash of all the commits created during
the development of libgpiod v2. This is done to preserve bisectability
of the git tree. It contains significant re-writes of the core C library
as well as C++ and python bindings. The tools have been adjusted to work
with the new API but have not undergone significant changes yet.

This commit contains the bulk of the work on libgpiod v2 but the
development continues with more changes planned.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
[Ben: fix format specifier for uint64_t]
Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
[Viresh: Fix ioctl number for gpiod_line_request_reconfigure_lines()]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
[Kent: bug fixes, improvements, better pointer contracts, type strictness]
Signed-off-by: Kent Gibson <warthog618@gmail.com>
2022-10-31 11:15:14 +01:00
Bartosz Golaszewski
154e7c5a82 licensing: relicense non-library code under GPL-2.0-or-later
LGPL-2.1 is a license meant for shared libraries. Because I didn't know
any better I used it for all files in the repository, including programs
linking against libgpiod. The standard approach for many similar projects
is to use LGPL for library code and GPL for programs (and also Makefiles
and other files containing code or configuration).

Relicense all programs, tests, makefiles and autotools files under
GPL-2.0 or later.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Kent Gibson <warthog618@gmail.com>
2021-02-18 17:42:12 +01:00
Bartosz Golaszewski
dfb707c255 licensing: make the project REUSE-compliant
In order to make the licensing situation of libgpiod clear and enable
easy reusing of the code, let's make all the files in the repository
compliant with the REUSE v3.0 specification.

In order to achieve that:
  - put all used licenses into a separate LICENSES/ directory
  - add SPDX license identifiers to all files that were missing them with
    regular text files being licensed under CC-BY-SA-4.0, while files
    containing code and configuration are licensed under GPL-2.0-or-later
  - replace custom copyright texts with SPDX-FileCopyrightText
  - update the gpio.h kernel uAPI header with the upstream version where
    the SDPX license identifier was fixed to use 'GPL-2.0-only' variant
    instead of the deprecated 'GPL-2.0'

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Kent Gibson <warthog618@gmail.com>
2021-02-18 17:42:08 +01:00
Bartosz Golaszewski
6f8700e0bd tests: misc: fix the version string test case
The current development version is v1.6-devel. The '-' character is
there to differentiate between the "main" version part and the extra
suffix.

The existing test case for the version string is now failing because
we used '.' previously for the extra version suffix. Fix it by extending
the regex pattern.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2020-02-03 11:19:07 +01:00
Bartosz Golaszewski
9c5a6f31eb tests: use GLib for library test cases and bats for gpio-tools
This replaces the custom hand-crafted testing suite with well-known
open-source tools while keeping the same coverage. The core library
is now tested using the GLib unit testing framework. The gpio-tools
are now tested in bash using the bats testing system instead of being
invoked from a C program.

This simplifies and shrinks the testing code and makes it less prone
to bugs.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-08-01 17:31:31 +02:00
Bartosz Golaszewski
937ded4dbc treewide: order includes alphabetically
Unify the header includes by ordering them alphabetically and always
having local headers in a second group below the global ones (separated
by a newline).

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
2019-02-21 09:38:57 +01:00
Bartosz Golaszewski
0a9faf3abf license: use C++-style comments for SPDX headers in source files
Follow the linux kernel licensing style and only use C-style comments
in C headers.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-04-04 13:19:05 +02:00
Bartosz Golaszewski
b59666510f tests: use SPDX license identifier
Use the SPDX license identifier for LGPLv2.1 or later in source files
of the testing framework.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-03-04 10:38:50 +01:00
Bartosz Golaszewski
0704bcdbbf all: update the copyright notice
All these files have been updated in 2018.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-13 23:16:31 +01:00
Bartosz Golaszewski
7df216bf4d all: modify the license preamble in files
This project contains both a library and executables so it's better to
use an umbrella term "This program ..." than "This library ..." in all
the source files.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2018-01-10 01:50:36 +01:00
SZ Lin
7d61309458 all: make license type consistent between source files and COPYING file
The license type of COPYING file is "LGPL-2.1+", but it is declared
as "LGPL-2.1" in the preamble of source files.

This patch fixes license type inconsistency issue in each source file.

Signed-off-by: SZ Lin <sz.lin@moxa.com>
[Bartosz: tweaked the commit message]
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-12-01 18:43:54 +01:00
Bartosz Golaszewski
091d36e360 libgpiod: unify the header comments
Make the header comment look the same in every file. Move additional
descriptions of files' contents below the header.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-12 17:22:09 +02:00
Bartosz Golaszewski
cc0b3fac72 core: kill custom error handling
The libgpiod-specific error codes are not really necessary and can be
easily replaced with regular libc error numbers defined in errno.h.

Remove all routines and definitions dealing with error numbers and
switch to using errnos in the library code.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-07-06 11:11:36 +02:00
Bartosz Golaszewski
190555c3bc tests: improve the version string test
Use the recently introduced regex matching function to verify that
the version string has a correct format.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-06-08 15:26:24 +02:00
Bartosz Golaszewski
be302e2ce5 tests: don't request gpio-mockup chips for the version string test
Change the line sizes list into an empty array.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-06-08 15:20:00 +02:00
Bartosz Golaszewski
a84f8b945d tests: request 0 chips for the error handling test case
We now support having no gpio-mockup chips for test cases. Update the
error handling test.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-06-08 13:32:14 +02:00
Bartosz Golaszewski
96a17a0501 tests: convert named_lines into a general 'flags' field
We currently have the boolean 'named_lines' field in the test
description structure. Convert it to an integer in order to allow
passing multiple test switches in the future.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-05-14 16:55:27 +02:00
Bartosz Golaszewski
86a94bf1e1 tests: change the test API prefix
The gu_ prefix stood for gpiod unit, but it's no longer valid. These
definitions are not visible outside of the tests subdirectory, so
there's no need for a unique prefix. Just start all symbols with test_
or TEST_.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-05-14 13:26:48 +02:00
Bartosz Golaszewski
2f5d950907 tests: rename gpiod-unit to gpiod-test
The testing framework will be reused for all kinds of tests. Also: the
tests we have are not really separated, but use external components so
calling them unit tests is wrong anyway.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-05-14 13:18:39 +02:00
Bartosz Golaszewski
715791a3a3 tests: remove the unit subdirectory
Initially we planned to have different subdirectories for different
kinds of tests (unit, tools etc.) but since it was decided that we'll
reuse the already existing framework for all tests (in order to avoid
having to reimplement the same functionality) we can get rid of the
unit subdirectory.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
2017-05-14 13:09:36 +02:00