Bartosz Golaszewski [Wed, 7 Aug 2019 12:18:45 +0000 (14:18 +0200)]
tools: tests: restore the bats shebang in the bats source file
In commit
f52e12eafd17 ("tools: tests: run the bats script indirectly
from a shell script") we removed the bats shebang and dropped the
execute permission from the .bats test-suite file.
While the preferred method of running the gpio-tools tests is using
the helper bash script, the .bats file should still be executable on
its own. Restore the execute permissions and the shebang.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 7 Aug 2019 12:09:37 +0000 (14:09 +0200)]
tests: event: add two additional test cases for both edge events
Add two test cases explicitly verifying that watching events of both
types works correctly (in active-high and active-low modes).
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 6 Aug 2019 16:05:30 +0000 (18:05 +0200)]
bindings: cxx: use catch2 to implement a proper test-suite
Currently the only tests we have for C++ bindings are in a simple
program that makes a lot of assumptions about the environment and
doesn't even work anymore with recent kernels.
Remove it and replace it with a proper test-suite implemented using
libgpiomockup and Catch2.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 7 Aug 2019 08:51:41 +0000 (10:51 +0200)]
bindings: cxx: add a missing throw to line::event_get_fd()
If the call to gpiod_line_event_get_fd() fails, we're not actually
throwing the exception - we're only creating it on stack. Add the
missing throw keyword.
Fixes: 8078a4a2ad90 ("bindings: implement C++ bindings")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 7 Aug 2019 08:16:40 +0000 (10:16 +0200)]
tests: event: fix the active-low switch test case
Kernel commit
223ecaf140b1 ("gpiolib: fix incorrect IRQ requesting of
an active-low lineevent") fixed an issue with line events not being
inverted with the GPIOHANDLE_REQUEST_ACTIVE_LOW flag. This change has
now been released in linux v5.2.7 and the relevant test case must be
adjusted.
Convert the test case to expect a falling edge event. Since the first
pull change will be 0->1, it will be interpreted as such when the
active-low flag is used.
The minimum kernel version to run the core test-suite is now set to
v5.2.7.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 7 Aug 2019 08:01:50 +0000 (10:01 +0200)]
tests: mockup: don't fail at init-time if gpio-mockup is already loaded
The comment in gpio_mockup_new() says we can deal with gpio-mockup
already being loaded, but it's wrong - we'd actually fail in the call
to kmod_module_probe_insert_module().
Pass the KMOD_PROBE_IGNORE_LOADED flag to the insert function to fix
that.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 7 Aug 2019 07:46:41 +0000 (09:46 +0200)]
tools: tests: fix the gpiomon test case with --active-low switch
Kernel commit
223ecaf140b1 ("gpiolib: fix incorrect IRQ requesting of
an active-low lineevent") fixed an issue with line events not being
inverted with the GPIOHANDLE_REQUEST_ACTIVE_LOW flag. This change has
now been released in linux v5.2.7 and the relevant test case for
gpiomon needs to be adjusted.
Since the line going down will now be interpreted as a rising edge
event, set the pull to 1 before running gpiomon and then set it to 0
after starting it to trigger a rising edge event.
The minimum kernel version to run tests must be set to v5.2.7.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 6 Aug 2019 16:06:26 +0000 (18:06 +0200)]
tools: tests: drop the .sh extension from the testing script's name
This script requires bash, so .sh extension is not accurate. Also: it's
executable, so there's no need to indicate the interpreter in the
extension.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 6 Aug 2019 15:52:56 +0000 (17:52 +0200)]
tools: tests: pass command-line arguments to the underlying bats script
Command-line arguments need to be forwarded to the bats test-suite if
we want to control bats' execution.
Fixes: f52e12eafd17 ("tools: tests: run the bats script indirectly from a shell script")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 6 Aug 2019 15:01:53 +0000 (17:01 +0200)]
tools: tests: run the bats script indirectly from a shell script
Bats makes it very difficult to run some initial code once, perform
checks for requirements and optionally exit if they are not satisfied.
Instead of working around it in the .bats script, just create
a separate shell script that does all the initial checks and then
execs the actual bats test-suite.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 6 Aug 2019 09:52:31 +0000 (11:52 +0200)]
tests: add a test case for using misc line flags together
This adds a test case that verifies that the ACTIVE_LOW flag works
correctly when used together with OPEN_SOURCE and OPEN_DRAIN flags.
Note: a bug has been discovered in the kernel that makes the LINEINFO
ioctl() incorrectly report the direction of lines requested with
open-drain or open-source flags as 'input' if the underlying hardware
doesn't support these config options. A patch fixing it has been sent
and once it's released, the FIXME's added by this patch will be
removed.
While at it: extend the previous misc flags test with additional checks
of the reported direction, but disable the one that fails due to the
bug mentioned above.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 6 Aug 2019 12:09:18 +0000 (14:09 +0200)]
tools: tests: remove some development leftovers
Remove a leftover debugging command from the testing script that got
accidentally commited.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 5 Aug 2019 19:33:27 +0000 (21:33 +0200)]
bindings: cxx: examples: use seconds for timeout in line.event_wait()
While the event_wait() method takes ::std::chrono::nanoseconds as the
timeout argument, we don't actually need to use the same type - we can
use less fine-grained duration types. Switch to using seconds in the
gpiomoncxx example to showcase this implicit conversion.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sun, 4 Aug 2019 07:48:13 +0000 (09:48 +0200)]
tests: mockup: make sure the gpio-mockup debugfs directory is writable
The gpio-mockup library needs write permissions to make full use of
the debugfs interface. Add the W_OK flag to the call to access() when
preparing the context structure.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sun, 4 Aug 2019 08:07:57 +0000 (10:07 +0200)]
tests: mockup: add a comment explaining the kernel version definition
The library only works on newer kernels. The specific features we're
using have only available since linux v5.1.0. Add a comment explaining
this limitation to the library code.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sun, 4 Aug 2019 07:46:40 +0000 (09:46 +0200)]
tests: free the GList linking test cases once it's no longer needed
Once we registered all the test cases, the GList linking them is no
longer used. We can free it before running the test suite.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sun, 4 Aug 2019 07:43:09 +0000 (09:43 +0200)]
tests: mockup: fix a typo in comment
It should have been 'check' not 'chech'.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 3 Aug 2019 16:28:44 +0000 (18:28 +0200)]
README: update the tests section
The tests underwent significant changes recently. Reflect those in the
README file.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 3 Aug 2019 16:14:32 +0000 (18:14 +0200)]
tests: mockup: validate the chip index where applicable
In functions that take the chip index as argument: let's verify that
its value is valid i.e. it refers to an existing chip to avoid potential
segfaults.
While we're at it: delegate the validation of arguments in mockup getter
helpers to a separate routine.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 2 Aug 2019 18:40:12 +0000 (20:40 +0200)]
tests: drop manual test case links and use GList
Let's not handcode a linked list if GLib already provides us with
a robust implementation. Use GList to link the tests at registration.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 2 Aug 2019 12:22:29 +0000 (14:22 +0200)]
tests: mockup: add extern "C" to the header
The gpio-mockup support library should be usable from C++ code too.
Add extern "C" to the header.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 7 Jun 2019 12:30:57 +0000 (14:30 +0200)]
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>
Ramon Fried [Wed, 31 Jul 2019 17:38:14 +0000 (20:38 +0300)]
gpioinfo: mark kernel claimed lines as used
In case where the GPIOLINE_FLAG_KERNEL flag was set and no consumer
string is provided by the kernel, the used column was still showing
the pin as "unused" Fix that by writing "kernel".
Signed-off-by: Ramon Fried <rfried.dev@gmail.com>
[Bartosz:
- fixed indentation and alignment
- tweaked the commit message formatting]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 30 Jul 2019 11:53:13 +0000 (13:53 +0200)]
tests: setup libgpiomockup before checking the kernel version
The gpio-mockup helper library checks the kernel version itself when
creating the context object. We then check the version again (as the
minimum versions for libgpiomockup and the test-suite may differ) in
the test-suite's main function. Make sure the library runs the check
first as we don't want to tell the user the version is OK and then
fail because it isn't...
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 30 Jul 2019 11:49:49 +0000 (13:49 +0200)]
tests: fix a segfault in error path
We may all the atexit() cleanup func before the gpio_mockup context
is setup. This will result in a segfault so add an appropriate check.
Fixes: b8659e044d50 ("tests: use libgpiomockup")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 27 Jul 2019 19:50:29 +0000 (21:50 +0200)]
TODO: new task for gpiomon
Making gpiomon be able to run external processes is a common request
from users. Add it to the TODO list.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 22 Jul 2019 09:46:59 +0000 (11:46 +0200)]
tests: mockup: use KERNEL_VERSION()
There's no need to reimplement checking the kernel version. An
appropriate macro - KERNEL_VERSION() - is already provided in
linux/version.h. Use it in libgpiomockup.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 11 Jul 2019 15:24:28 +0000 (17:24 +0200)]
tests: iter: free non-mockup GPIO chips
When using gpiod_foreach_chip_noclose() we need to close any non-mockup
GPIO chip that may be present in the system. Otherwise we'll be leaking
memory.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 11 Jul 2019 09:41:21 +0000 (11:41 +0200)]
bindings: python: fix GCC8 warnings due to function pointer casting
GCC8 has added a new warning heuristic to detect invalid function
casts. This causes a lot of warnings when building libgpiod python
bindings.
Let's use Py_UNUSED where applicable to make function prototypes match
that of PyCFunction. For keyword functions, let's cast them to a
function pointer taking no arguments before casting them again to
PyCFunction. This may not be the best solution but it has to do for
the moment.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 11 Jul 2019 08:39:03 +0000 (10:39 +0200)]
tests: build: fix the name of the test executable displayed by Makefile
The test suite Makefile prints a help message after building the test
executable but the name of the program is wrong. Fix it.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 9 Jul 2019 11:02:24 +0000 (13:02 +0200)]
tests: gpio-mockup: constify num_lines
The array pointed to by num_lines is never modified so make it really
constant.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sat, 6 Jul 2019 17:31:36 +0000 (19:31 +0200)]
tests: fix a memory leak in exit path
When exiting normally we free all allocated resources (mostly to keep
valgrind quiet). The toolpath string is not being freed and pops up in
valgrind's "still reachable" category of leaks. Free this memory too
in the atexit() cleanup callback.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 5 Jul 2019 14:57:40 +0000 (16:57 +0200)]
tests: gpio-mockup: store the number of chips in gpio_mockup_probe()
We're currently not storing the number of chips in the gpio-mockup
context structure after probing the module. The value is left
initialized to 0. This leads to both a memory leak and to chip ordering
errors when running the tests at high CPU loads. This patch fixes both
issues.
Fixes: e43e46d4f79c ("tests: mockup: add a library for controlling the gpio-mockup module")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 5 Jul 2019 14:47:39 +0000 (16:47 +0200)]
tests: gpio-mockup: don't allocate the chip structure twice
We incorrectly allocate the chip structure twice: once in
gpio_mockup_probe() and then again in make_chip() which leads to a
memory leak. Remove the first instance as it's the one that's
unnecessary.
Fixes: e43e46d4f79c ("tests: mockup: add a library for controlling the gpio-mockup module")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Sun, 9 Jun 2019 09:21:57 +0000 (11:21 +0200)]
TODO: remove the task for factoring out of common testing code
We now have libgpiomockup and it's used by the core library testing
executable. Remove the task from TODO.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 7 Jun 2019 09:13:17 +0000 (11:13 +0200)]
libgpiod: start v1.5 development cycle
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 6 Jun 2019 13:18:00 +0000 (15:18 +0200)]
libgpiod v1.4
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 6 Jun 2019 13:14:22 +0000 (15:14 +0200)]
NEWS: updates for v1.4
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 3 Jun 2019 16:18:53 +0000 (18:18 +0200)]
tests: gpiomon: use test_trigger_event() to fix timing errors
Since we don't need to trigger events from a separate thread when
testing tools and we've experienced timing issues with these two
test cases, let's use the new helper for triggering of single events.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 3 Jun 2019 16:18:38 +0000 (18:18 +0200)]
tests: provide test_trigger_event()
We use a separate thread to trigger line events for library test cases
but if we're testing tools which are separate processes, we can generate
the events from the main thread. Add a simple helper for that.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 3 Jun 2019 16:17:57 +0000 (18:17 +0200)]
tests: gpiomon: tweak the timing for single event type tests
Since switching to using libgpiomockup there are some timing problems
with two gpiomon test cases. I'm not sure what the reason is and we'll
be switching to glib unit tests soon, so let's not waste time on that
and just increase the sleep time.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 13 May 2019 15:24:37 +0000 (17:24 +0200)]
tests: use libgpiomockup
Now that all the gpio-mockup support lives in a separate library we
can drop a lot of code from the testing framework.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 10 May 2019 09:43:22 +0000 (11:43 +0200)]
tests: mockup: add a library for controlling the gpio-mockup module
In order to both switch to glib unit testing framework for core
libgpiod tests as well as to cover the bindings in other languages
with proper testing while avoiding unnecessary code duplication, let's
factor out the code responsible for interaction with the gpio-mockup
module into a separate shared library.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 23 May 2019 16:25:35 +0000 (18:25 +0200)]
tests: remove make check target
Having both --enable-tests configure option and the check make target
seems redundant and confusing. Especially since the tests won't even
run without appropriate permissions for /dev/gpiochipX anyway.
Remove the check target and the --enable-install-tests option. From now
on the tests - if enabled - are built as a regular program installed to
${prefix}/bin.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 29 May 2019 15:30:53 +0000 (17:30 +0200)]
tests: fix mapping of chip numbers
After recent changes the tests stopped working when other (non mockup)
GPIO chips are present in the system. The reason for that is broken
mapping of chip numbers to chip indexes. This patch fixes it.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 17 Apr 2019 07:15:29 +0000 (09:15 +0200)]
TODO: remove the task for converting the tests for linux v5.1
The conversion of the testing framework for linux v5.1 is now done.
Remove the task from the list.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Tue, 16 Apr 2019 07:37:37 +0000 (09:37 +0200)]
tests: make linux v5.1 the minimum version to run tests
The testing framework has been adjusted for linux v5.1. It will no
longer work with older versions.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 15 Apr 2019 08:58:41 +0000 (10:58 +0200)]
tests: line: use debugfs to verify set values
Use new debugfs helpers when verifying if line values were correctly
set.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 12 Apr 2019 15:16:47 +0000 (17:16 +0200)]
tests: gpioset: make test cases work with linux v5.1
Make all gpioset test cases work with the recent changes to gpio-mockup
introduced in linux v5.1.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 12 Apr 2019 14:45:53 +0000 (16:45 +0200)]
tests: gpiomon: increase the time waiting for events
We no longer have influence over the type of generated events. We
always start with a rising edge-event and then get alternating edges.
We need to wait slightly longer to collect the events we're expecting
in one of the test cases.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 12 Apr 2019 14:37:52 +0000 (16:37 +0200)]
tests: gpioget: make test cases work with linux v5.1
Make all gpioget test cases work with the recent changes to gpio-mockup
introduced in linux v5.1.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 12 Apr 2019 08:05:30 +0000 (10:05 +0200)]
tests: event: make test cases work with linux v5.1
Make all event test cases work with the recent changes to gpio-mockup
introduced in linux v5.1.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 28 Mar 2019 13:21:45 +0000 (14:21 +0100)]
tests: ctxless: make test cases work with linux v5.1
Make all ctxless test cases work with the recent changes to gpio-mockup
introduced in linux v5.1.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 28 Mar 2019 13:14:51 +0000 (14:14 +0100)]
tests: provide test_debugfs_get/set_value() helpers
Since linux v5.1 gpio-mockup simulates pull-up/down resistors for dummy
lines. The current pull can be set using debugfs. Since we can no longer
verify if the character device interface properly sets line values, the
debugfs interface now also allows to read line values. This way we can
verify if the ABI works correctly using different code paths.
Provide functions for reading and setting values of mockup GPIO lines.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 27 Mar 2019 13:47:21 +0000 (14:47 +0100)]
tests: document the freq argument in test_set_event()
The freq argument is not documented and it's not clear what it means.
Add a brief comment.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 10 Apr 2019 14:47:19 +0000 (16:47 +0200)]
tests: fix debugfs path
Since linux v5.1 the debugfs path for gpio-mockup changed. Use the new
path both for the main directory as well as for the chip subdirectories
which no longer use the chip's label.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 27 Mar 2019 13:44:40 +0000 (14:44 +0100)]
tests: don't allow to generate events of the same type subsequently
Since linux v5.1 the state of simulated lines is tracked by the kernel
and it's no longer possible to generate two subsequent events of the
same type (e.g. two rising edge events one after another). Drop the
event_type parameter from test_set_event() and adjust all users.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Alexander Stein [Fri, 12 Apr 2019 19:18:21 +0000 (21:18 +0200)]
man: fix out of source build
Use build and source directory variables for correct paths. This
distinction is important for out of source builds.
Signed-off-by: Alexander Stein <alexander.stein@mailbox.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 1 Apr 2019 08:50:47 +0000 (10:50 +0200)]
TODO: add a list of things to implement for feature-complete
Add a document listing major features I'd like to see in libgpiod to
make it more or less complete (not including of course the support for
any potential new features that the kernel may expose in the future).
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 1 Apr 2019 13:01:53 +0000 (15:01 +0200)]
gitignore: add .swp to the list of ignored extensions
We want to ignore vim swap files. Add .swp to .gitignore.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
David Kozub [Thu, 28 Mar 2019 22:49:23 +0000 (23:49 +0100)]
bindings: cxx: make operator bool() explicit
A non-explicit operator bool() is dangerous: It allows unwanted
conversion to integral types:
gpiod::chip c;
int i = c;
This is a trivial example, but more insidious effects are possible,
e.g. with std::set<gpiod::chip>, which would use the operator bool()
to implement element comparison, thus turning such set into a set that
has at most 2 elements: An invalid (false) element and just 1 valid
element:
std::set<gpiod::chip> s;
s.emplace();
s.emplace("/dev/gpiochip0");
s.emplace("/dev/gpiochip1");
// s.size() is still 2 even if both chips were opened!
Making the operator explicit disables this.
See e.g.
https://en.cppreference.com/w/cpp/language/implicit_conversion#The_safe_bool_problem
for more info on this.
Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
David Kozub [Thu, 28 Mar 2019 23:27:28 +0000 (00:27 +0100)]
bindings: cxx: remove superfluous std::move
There is no need to use std::move on an r-value (e.g.
std::move(gpiod::chip())). Similarly, there is no need to use std::move
for returning a local variable as in:
T foo()
{
U local;
return std::move(local);
}
Not only it doesn't help, it actually inhibits named return value
optimization.
See e.g. https://isocpp.org/blog/2013/02/no-really-moving-a-return-value-is-easy-stackoverflow
Signed-off-by: David Kozub <zub@linux.fjfi.cvut.cz>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 25 Mar 2019 13:06:48 +0000 (14:06 +0100)]
libgpiod: start v1.4 development cycle
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 25 Mar 2019 09:30:26 +0000 (10:30 +0100)]
libgpiod v1.3
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 25 Mar 2019 09:25:32 +0000 (10:25 +0100)]
NEWS: updates for v1.3
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 25 Mar 2019 08:57:09 +0000 (09:57 +0100)]
build: fix cross-compilation after adding manpages
Cross-compilation is currently broken because WITH_MANPAGES is defined
conditionally. Move it out of the if/then.
Fixes: 6cbc2e57555a ("doc: add automatically generated man pages for gpio-tools")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 15 Mar 2019 14:16:53 +0000 (15:16 +0100)]
tests: look for gpio-tools in more places
Currently we only support running the test cases for gpio-tools from
the top-level source directory. Some users want to install the test
executable and run the tests from other locations (/bin, /usr/bin or
custom path).
This patch makes the test suite look in the source tree path first,
then check the directory in which the program resides and last iterate
over all directories in $PATH.
We only do that once at the beginning and then reuse the path later.
Cc: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Anders Roxell <anders.roxell@linaro.org>
Tested-by: Anders Roxell <anders.roxell@linaro.org>
Anders Roxell [Fri, 15 Mar 2019 10:01:44 +0000 (11:01 +0100)]
tests: enable installing tests to bindir
Add an enable option to configure that allows to install the testing
binary to <prefix>/bindir.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
[Bartosz: trimmed the patch to fit the new approach]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 18 Mar 2019 16:20:55 +0000 (17:20 +0100)]
gitignore: ignore patches
Add all files with the .patch extension to the list of ignored files.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 7 Mar 2019 10:15:23 +0000 (11:15 +0100)]
treewide: rearrange source directories
The src directory containing lib and tools is not necessary and will
actually cause problems if we tried to add a new component to src/
which would depend on libraries from the bindings directory because it
(bindings) already depends on src/lib.
Simplify the directory structure. Move lib and tools to the root source
directory and update all relevant files. That way we can specify the
exact build order of components from the top source Makefile.am.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 7 Mar 2019 11:10:05 +0000 (12:10 +0100)]
tools: coding style fix
Drop a stray space between '*' and get_progname().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 7 Mar 2019 10:45:47 +0000 (11:45 +0100)]
man: add template to EXTRA_DIST
Currently the man page template used by help2man is not included in the
distribution tarball. This causes build failures on systems that
actually do have help2man in which case we rebuild the man pages
locally. Add template to EXTRA_DIST.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 6 Mar 2019 16:57:32 +0000 (17:57 +0100)]
core: ctxless: arrange local variables in reverse christmas tree order
This is a cosmetic change: let's be consistent treewide and have all
local variables arranged in reverse christmas tree order.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 6 Mar 2019 15:03:34 +0000 (16:03 +0100)]
core: ctxless: bail-out if num_lines == 0
Return -1 and set errno to EINVAL if the number of lines specified in
any context-less helper is 0. This is done in addition to bailing out
when the number is higher than the maximum supported number of GPIO
lines. This fixes the segfaults that currently ocurr for num_lines == 0.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 1 Mar 2019 10:03:48 +0000 (11:03 +0100)]
README: fix the kernel version required to run tests
The kernel version required to run tests is v4.16 while README says
it's v4.11. Fix it.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Anders Roxell [Thu, 28 Feb 2019 15:35:34 +0000 (16:35 +0100)]
build: use top_builddir instead of relative paths
The only instance of using a relative path for an internal library is
in tests/Makefile.am. Use top_builddir instead.
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 28 Feb 2019 14:28:50 +0000 (15:28 +0100)]
core: drop an unnecessary pointer assignment
The whole line structure is zeroed in the line above, so there's no
need to set the fd_handle pointer to NULL.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 25 Feb 2019 09:47:08 +0000 (10:47 +0100)]
configure: check for setlinebuf() when building tools
Add setlinebuf() to the list of functions checked for when building
gpio-tools. This is now required to build gpiomon.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Martin Hundebøll [Mon, 25 Feb 2019 09:43:07 +0000 (10:43 +0100)]
gpiomon: add option to set line buffered output
Some applications call gpiomon in a sub process, in which case glibc
defaults to block buffered output on stdout. This makes the output
arrive to the calling process only when the (4kB) buffer is filled (or
when gpiomon exists), making the information obsolete and pretty much
useless.
Support such scenarios by adding a switch to configure line buffered
output on stdout. Similar switches are available in other applications
(e.g. `rsync`s --output argument).
Signed-off-by: Martin Hundebøll <martin@geanix.com>
[Bartosz:
- use setlinebuf() instead of setvbuf(),
- tweak the help string,
- move the setlinebuf() call directly into the optarg switch statement]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 25 Feb 2019 09:28:46 +0000 (10:28 +0100)]
configure: code shrink
When defining enable arguments, we don't need a full if-else spanning
multiple lines. We only care about the 'true' value, so pull the
relevant code into a single line.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Wed, 20 Feb 2019 10:30:42 +0000 (11:30 +0100)]
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>
Bartosz Golaszewski [Tue, 19 Feb 2019 16:34:39 +0000 (17:34 +0100)]
README: add a section about API documentation
Doxygen and python documentation are briefly mentioned in the BINDINGS
section but there's no word about the core C API and automatically
generated man pages.
Add a separate section to the README file describing the process of
generating html doxygen output, python help strings and man pages for
gpio-tools.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 18 Feb 2019 12:44:38 +0000 (13:44 +0100)]
doc: add automatically generated man pages for gpio-tools
Extend the build files to automatically generate man pages for
gpio-tools using help2man if it's present in the system and we're not
cross-compiling (as the built programs must be executable for help2man
to work).
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Mon, 18 Feb 2019 13:19:51 +0000 (14:19 +0100)]
doc: delete generated files on make clean
Delete the entire doc directory when running make clean.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 15 Feb 2019 15:36:00 +0000 (16:36 +0100)]
gitignore: add distribution tarballs to ignored files
Add .tar.gz files to .gitignore.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 15 Feb 2019 12:37:18 +0000 (13:37 +0100)]
bindings: python: add support for 'default_val' in Line.request()
Until now Line.request() only took 'default_vals' argument which was
passed down directly to LineBulk.request() internally. This meant that
even when requesting a single line in output mode, the default value
had to be passed in a sequence.
Add support for the 'default_val' argument which makes it possible to
specify the default value as an integer. The previous 'default_vals'
argument is still supported, but the two cannot be passed at the same
time.
Documentation for default_vals is removed, as it's now deprecated for
Line.request().
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Fri, 15 Feb 2019 12:16:57 +0000 (13:16 +0100)]
bindings: python: fix argument alignment in a function call
When breaking a line, the arguments should be aligned with the opening
bracket of the function call.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 14 Feb 2019 16:07:15 +0000 (17:07 +0100)]
tests: gpiomon: remove failing test case
Since commit
fa38869b0161 ("gpiolib: Don't support irq sharing for
userspace") in the kernel, the test case veryfing correct ignoring
of edge events is failing. It will take a while until it will be
fixed upstream so remove this test for now.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Michael Beach [Sat, 9 Feb 2019 15:06:18 +0000 (00:06 +0900)]
bindings: cxx: make bitset_cmp::operator() const
This fixes build problems with clang and libc++ and such constness is
now required by C++17 (see https://cplusplus.github.io/LWG/issue2542).
Signed-off-by: Michael Beach <michaelb@ieee.org>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Patrick Boettcher [Sun, 3 Feb 2019 12:29:14 +0000 (13:29 +0100)]
bindings: cxx: do not initialize a chip's shared_ptr with nullptr
A shared_ptr initialized with nullptr will still call the deleter which
causes a NULL-pointer dereference if we create a chip_iter when there
are no GPIO chips in the system.
Only initialize the current chip object in chip_iter if
gpiod_chip_iter_next_noclose() returned a valid pointer.
Signed-off-by: Patrick Boettcher <p@yai.se>
[Bartosz:
- tweaked the commit message
- use std::move when assigning the chip object]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Bartosz Golaszewski [Thu, 3 Jan 2019 10:46:25 +0000 (11:46 +0100)]
gpioset: extend help text
There's a common misconception about the way the character device
works. Some users expect line states to be driven as desired even
after gpioset exits. Add a note about that to the help text to avoid
further confusion.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Nov 2018 10:15:30 +0000 (11:15 +0100)]
treewide: unify naming of local variables representing return values
For integers representing simple return values of various functions
use the name 'rv' everywhere.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Gasper Zejn [Fri, 23 Feb 2018 13:51:19 +0000 (14:51 +0100)]
doc: C API documentation fixes
Fix a couple problems in doxygen documentation of the C API.
(Unfortunately no Signed-off-by tag from the submitter...)
[Bartosz: added a proper commit message]
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Nov 2018 15:43:03 +0000 (16:43 +0100)]
tests: ignore 'remove' events from udev
So far the tests have been executed on a Debian 9 machine with libudev
provided by systemd 232 - everything always worked fine. However
running them on a system with systemd 237 uncovered a bug in the
testing framework.
It turned out that on newer versions the ignored 'remove' events linger
somewhere in the pipeline and get read by subsequent test cases causing
erroneous chip naming and breaking tests.
Check the action string for udev device objects and only care about
those being added.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 9 Nov 2018 09:08:18 +0000 (10:08 +0100)]
libgpiod: start v1.3 development cycle
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 8 Nov 2018 18:36:02 +0000 (19:36 +0100)]
libgpiod v1.2
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 8 Nov 2018 18:26:31 +0000 (19:26 +0100)]
NEWS: updates for v1.2
Add release notes for libgpiod v1.2.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 7 Nov 2018 20:29:02 +0000 (21:29 +0100)]
build: check for sys/sysmacros.h in configure
We now need this header to build the core library.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 7 Nov 2018 15:55:52 +0000 (16:55 +0100)]
core: add missing include
Not including <sys/sysmacros.h> causes the following error on ARM:
core.c: In function ‘is_gpiochip_cdev’:
core.c:116:4: warning: implicit declaration of function ‘major’ [-Wimplicit-function-declaration]
major(statbuf.st_rdev), minor(statbuf.st_rdev));
^~~~~
core.c:116:28: warning: implicit declaration of function ‘minor’; did you mean ‘mknod’? [-Wimplicit-function-declaration]
major(statbuf.st_rdev), minor(statbuf.st_rdev));
^~~~~
mknod
It wasn't spotted earlier since it builds fine on x86-64. Add the
missing include.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 5 Nov 2018 02:57:17 +0000 (03:57 +0100)]
core: harden gpiod_chip_open()
Verify that the file we were asked to use is really a GPIO character
device.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>