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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>