Bartosz Golaszewski [Thu, 22 Jun 2017 19:11:18 +0000 (21:11 +0200)]
README: add an example of gpiomon custom output formats
In the examples section: show how to specify a custom, easily parsable
output in gpiomon.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 22 Jun 2017 18:56:36 +0000 (20:56 +0200)]
tests: gpiomon: new test case
Verify that we actually ignore events we're not watching.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 22 Jun 2017 18:42:11 +0000 (20:42 +0200)]
README: update the building section
Commit
6876721f7407 ("build: use a more standard autogen.sh") made
the supplied autogen execute ./configure unless the NOCONFIGURE
environment variable is set. Reflect that in the README file.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 21 Jun 2017 11:47:30 +0000 (13:47 +0200)]
gpiomon: simplify custom formats
Instead of replacing the format specifiers in a separate buffer, just
make use of the output stream buffering.
Also: update the gpiomon tests with some corner cases.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 21 Jun 2017 09:46:42 +0000 (11:46 +0200)]
tests: don't allocate the subprocess output buffer everytime
It's more efficient to just allocate it at testing suite's startup and
reuse it for all child processes.
While we're at it: verify that the output of subprocesses consists
of ASCII characters only.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 21 Jun 2017 08:21:44 +0000 (10:21 +0200)]
tests: gpiomon: use a different unknown custom format specifier
We previously used a character that is not interpreted by
printf()-like functions due to a bug in the testing framework.
This is now fixed, so just use %x so that we self-test the test suite
at the same time.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 21 Jun 2017 08:16:36 +0000 (10:16 +0200)]
tests: fix reading the output of subprocesses
We're currently using vasprintf() internally when reading the output
streams of terminated subprocesses. This routine interprets the buffer
as a printf() format string, so substrings like '%x' get converted
unintentionally.
Instead allocate a big enough buffer and just read the output without
any modifications.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 20 Jun 2017 18:03:33 +0000 (20:03 +0200)]
gpiomon: fix parsing of custom output formats
The '%%e' string should be printed as '%e' - the same as for printf()
format specifiers - but gpiomon prints '%%e' in this case. Fix it.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 20 Jun 2017 13:00:03 +0000 (15:00 +0200)]
configure: tests: require versions of libkmod & libudev known to work
When building tests: require libkmod and libudev versions to be at
least 18 & 215 respectively. These versions are shipped with debian
jessie and are known to work.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 20 Jun 2017 08:36:16 +0000 (10:36 +0200)]
configure: check for regex functions when building tests
Check if regexec() is available if we need to build the test suite.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 19 Jun 2017 19:26:29 +0000 (21:26 +0200)]
tests: add a FIXME comment
Reading output from child processes should be fixed at some point to
ignore printf() format specifiers.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 15 Jun 2017 07:23:13 +0000 (09:23 +0200)]
gpiomon: implement custom output formats
Add a new argument allowing the user to specify the format of the
output string printed on GPIO line events.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 15 Jun 2017 06:31:49 +0000 (08:31 +0200)]
tests: fix subprocess cleanup when dying
We need to kill the tool subprocess when bailing out during tests
everytime, not only when an error during test_tool_wait() occurs.
Also: we need to wait() for killed processes too as otherwise we may
end up calling delete_module() before the process actually stops using
gpio-mockup giving us a nasty error message from libkmod and leaving
the module in memory.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 15 Jun 2017 05:52:42 +0000 (07:52 +0200)]
tests: fix the error message when dying during test's execution
If die() or die_perr() is called during a test case, print an
additional newline character so that the error message is displayed
below the test description.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 11:52:13 +0000 (13:52 +0200)]
NEWS: updates for v0.2.1
Add release notes for libgpiod v0.2.1.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 11:07:35 +0000 (13:07 +0200)]
tests: gpiomon: more test cases
Add various test cases for gpiomon. Testing invalid input, active-low
mode, termination on signals etc.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 10:53:19 +0000 (12:53 +0200)]
gpiomon: don't ignore superfluous arguments
We don't currently support watching more than one line at a time. Bail
out if the user gives us more than two non-option arguments.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 10:44:31 +0000 (12:44 +0200)]
gpiomon: capitalize 'GPIO' in error message
Stay consistent with other error strings.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 10:22:02 +0000 (12:22 +0200)]
tests: gpiomon: check the whole output string
Add the 'event:' prefix to the regex pattern when checking the output
of gpiomon.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 08:37:56 +0000 (10:37 +0200)]
tests: gpiomon: new test cases
Add test cases verifying the --silent mode and receiving
multiple events.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 08:28:57 +0000 (10:28 +0200)]
gpiomon: fix the displayed name for falling edge events
Remove the unnecessary underscore.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 08:11:27 +0000 (10:11 +0200)]
tests: don't hardcode the chip names
Use test_chip_name() to get the name of a chip. Don't hardcode it as
it will make the tests not work if any gpiochips other than the ones
created by gpio-mockup already exist in the system.
This also fixes a couple hidden bugs, where we requested inexistent
chips in tools' command-line arguments.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 07:55:58 +0000 (09:55 +0200)]
tests: gpiomon: test a single rising edge event
Add a simple test case checking if gpiomon can receive a single rising
edge event.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 07:00:53 +0000 (09:00 +0200)]
tests: gpioget: fix potential crash
We're writing outside the values array. Fix the index.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 14 Jun 2017 05:48:00 +0000 (07:48 +0200)]
tests: chip: fix potential segfault
The automatically cleaned up string is not initialized, but if
asprintf() failed, its contents would be undefined which could lead
to a segmentation fault.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 20:04:13 +0000 (22:04 +0200)]
tests: iter: fix potential segfault
All automatically cleaned up variables must be initialized. Otherwise
we risk calling free() on an uninitialized pointer if an assertion
fails before we assign it a value.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 19:52:05 +0000 (21:52 +0200)]
tests: gpioinfo: improve test descriptions
Explain more precisely what we're actually testing.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 19:44:27 +0000 (21:44 +0200)]
tests: gpioinfo: test incorrect input
Check if gpioinfo behaves correctly if the chip for which we want the
info dumped doesn't exist.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 19:32:59 +0000 (21:32 +0200)]
tests: gpioinfo: test cases for printing info about specific chips
Add test cases checking if gpioinfo correctly dumps info if we specify
only certain chips over command-line and omits the ones we don't
request.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 19:29:16 +0000 (21:29 +0200)]
tests: new assertions
Add two new string-related assertions for tests.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 14:51:48 +0000 (16:51 +0200)]
tools: capitalize 'GPIO' in error messages
Be consistent in all error messages in gpioget & gpioset.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 14:41:29 +0000 (16:41 +0200)]
tests: gpioset: test cases for invalid arguments
Add various test cases checking the behavior of gpioset when given
invalid arguments.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 14:32:40 +0000 (16:32 +0200)]
tests: gpioset: test the --sec argument
Make sure gpioset understands the --sec argument together
with --mode=time.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 14:29:41 +0000 (16:29 +0200)]
tests: gpioset: test the --active-low flag
Duplicate the basic exit mode test but use the --active-low flag and
verify that the values are inverted.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 14:25:00 +0000 (16:25 +0200)]
tests: gpioset: test the 'time' mode
Order gpioset to wait for 100 milliseconds before exiting, then sleep
for 200 milliseconds before checking if it exited correctly.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 13:15:45 +0000 (15:15 +0200)]
tests: gpioset: test case for the 'signal' mode
Run gpioset on a set of lines, give it a couple milliseconds to
execute, then send it SIGTERM and check that it exits correctly.
Repeat for SIGINT.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 13:00:29 +0000 (15:00 +0200)]
tests: improve sigprocmask()-related error messages
When sigprocmask() fails for how=SIG_BLOCK|SIG_UNBLOCK, say explicitly
we were unable to block/unblock SIGCHLD.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 13 Jun 2017 12:58:20 +0000 (14:58 +0200)]
tests: unblock SIGCHLD after closing the signalfd
Restore the state from before running the subprocess.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 20:28:08 +0000 (22:28 +0200)]
tests: gpioset: check the 'exit' mode explicitly
Duplicate the previous 'exit' mode test but pass the mode argument
explicitly to gpioset.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 20:25:09 +0000 (22:25 +0200)]
tests: read siginfo after receiving SIGCHLD
If we don't actually read the signal info, the signals pile up after
every child process exits even if we close the sigfd.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 20:04:04 +0000 (22:04 +0200)]
tests: gpioset: test the 'wait' mode
Verify the behavior of gpioset in the 'wait' mode. Send a newline
to gpioset's standard input and check if it correctly exits.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 20:02:37 +0000 (22:02 +0200)]
tests: provide test_tool_stdin_write()
Implement a routine allowing the test code to write a formatted string
to the child process' standard input.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 19:44:13 +0000 (21:44 +0200)]
tests: gpioget: test the --active-low flag
Read all lines, change their values and re-read but this time pass
the --active-low flag to gpioget.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 19:38:04 +0000 (21:38 +0200)]
tests: add a simple test case for gpioset
Verify the 'exit' mode of gpioset.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 19:11:02 +0000 (21:11 +0200)]
tests: check reading specific lines with gpioget
Add a test case where we only read a couple GPIO line values at
specified offsets.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 19:01:10 +0000 (21:01 +0200)]
tests: new test case for gpioget
Verify that gpioget correctly bails out if the user requested to read
more GPIO lines than the number exposed by the chip.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 18:44:03 +0000 (20:44 +0200)]
tests: use calloc() where applicable
Introduce xcalloc() and use it whenever we're allocating an array
of elements.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 18:34:33 +0000 (20:34 +0200)]
tests: new test cases for gpioget
Verify the correct behavior of gpioget on invalid arguments.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 17:58:21 +0000 (19:58 +0200)]
tests: add a test case for gpioget
Add a simple test case for gpioget: read all lines at their initial
state, change the values of some of them and re-read.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 10:52:53 +0000 (12:52 +0200)]
tests: rename test_gpiotool_run()
Use the same prefix for all functions for tools testing.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 10:51:30 +0000 (12:51 +0200)]
tests: new test case for gpiodetect
Verify that we bail out if the user passes any non-option argument
to gpiodetect.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 10:46:04 +0000 (12:46 +0200)]
tests: verify the behavior of gpiofind in case of invalid arguments
Make sure we bail out with the correct error message when the user
doesn't give us exactly one GPIO line name.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 10:41:48 +0000 (12:41 +0200)]
gpiofind: tweak the error message on invalid arguments
We print the same error message in case of too many or not enough
arguments. Make the message appropriate for both cases.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 12 Jun 2017 09:01:52 +0000 (11:01 +0200)]
tests: fix a potential segfault
A string passed to test_free_str() must be allocated by malloc() or
NULL, so we need to initialize ptrn.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 11 Jun 2017 18:15:50 +0000 (20:15 +0200)]
tests: fix a memory leak
We don't free the string allocated by asprintf() in a test case for
gpioinfo. Fix it.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 11 Jun 2017 18:13:04 +0000 (20:13 +0200)]
tests: fix a test case for gpiofind
We must not hardcode the chip names. Use test_chip_name() instead.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 9 Jun 2017 15:34:05 +0000 (17:34 +0200)]
tests: add a missing assertion
asprintf() can fail. Check its return value.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 9 Jun 2017 15:29:54 +0000 (17:29 +0200)]
tests: improve the test names
Make the names of the gpiotools test cases more informative.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 9 Jun 2017 15:27:58 +0000 (17:27 +0200)]
tests: new test case for gpioinfo
Check if we correctly report exported lines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 9 Jun 2017 08:55:53 +0000 (10:55 +0200)]
tests: tweak test output
Tweak the log message header a bit: instead of having a fixed width
of the contents between the brackets in the header, fix the length of
the whole header to 8 characters.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 9 Jun 2017 07:42:04 +0000 (09:42 +0200)]
tests: add test cases for gpiofind
Verify the correct behavior of gpiofind in two cases: when it can find
a GPIO line by name and when the requested line doesn't exist.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 8 Jun 2017 13:26:24 +0000 (15:26 +0200)]
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>
Bartosz Golaszewski [Thu, 8 Jun 2017 13:20:00 +0000 (15:20 +0200)]
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>
Bartosz Golaszewski [Thu, 8 Jun 2017 13:19:01 +0000 (15:19 +0200)]
tests: add a test case for gpioinfo
Add a simple test for gpioinfo.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 8 Jun 2017 13:11:45 +0000 (15:11 +0200)]
tests: add regex handling
Add a routine allowing to check if a string contains a substring
matching against given regex pattern.
Also: add a corresponding assertion.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 8 Jun 2017 11:26:42 +0000 (13:26 +0200)]
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>
Bartosz Golaszewski [Thu, 8 Jun 2017 11:24:36 +0000 (13:24 +0200)]
tests: allow having zero gpio-mockup chips for tests
We may have tests which don't require any gpio-mockup chips to be
present. When an empty array is given as the list of chip line counts,
the gpio-mockup module will not be loaded.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 8 Jun 2017 11:06:13 +0000 (13:06 +0200)]
tests: add a simple test case for gpiodetect
Use the newly added API for subprocesses to test a simple use case
of the gpiodetect tool.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 8 Jun 2017 10:50:02 +0000 (12:50 +0200)]
tests: add infrastructure for testing the tools
Implement new routines allowing to start an external process and
retrieve its output.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Thu, 25 May 2017 14:32:50 +0000 (16:32 +0200)]
tests: new assertion
Add a new test macro which checks if given string contains a specific
substring using strstr().
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 7 Jun 2017 16:08:47 +0000 (18:08 +0200)]
README: explain what gpiod stands for
In case someone incorrectly thinks it stands for 'GPIO daemon'.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 16 May 2017 20:45:21 +0000 (22:45 +0200)]
tests: tweak test output
Say PASS instead of OK when a test is passed.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 16 May 2017 11:30:05 +0000 (13:30 +0200)]
tests: tweak the event worker
The event worker thread should only inject another line event if
pthread_cond_timedwait() returned -ETIMEDOUT. If it returned 0, then
the main thread called pthread_cond_broadcast() and either requested
the worker thread to terminate or to change the event configuration.
In both cases we should not inject an event.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 16 May 2017 09:14:45 +0000 (11:14 +0200)]
tests: only cleanup the gpio-mockup module from the main process
In preparation for adding support for subprocesses: store the pid of
the main process and use it such that we don't try to unload the
mockup module twice leading to a splat from libkmod.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 14 May 2017 14:49:47 +0000 (16:49 +0200)]
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>
Bartosz Golaszewski [Sun, 14 May 2017 14:38:57 +0000 (16:38 +0200)]
tests: rename a couple static functions
We use the 'test_' prefix to mark the testing framework API
definitions. Don't use it for static functions in gpiod-test.c.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 14 May 2017 11:37:51 +0000 (13:37 +0200)]
tests: put the printf attribute in the header for _test_print_failed()
If the printf attribute is only present next to the function's
definition, the compiler only checks the calls in the same compilation
unit.
In order to verify all the calls, annotate the declaration of
_test_print_failed() in gpiod-test.h.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 14 May 2017 11:06:40 +0000 (13:06 +0200)]
tests: make test_func private
The test callback prototype should not be used by the test code, so
prefix it with an underscore to indicate that.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 14 May 2017 09:56:19 +0000 (11:56 +0200)]
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>
Bartosz Golaszewski [Sun, 14 May 2017 09:47:06 +0000 (11:47 +0200)]
tests: use a default consumer name
We're using the same consumer name everywhere in the tests. Hide it
behind a define.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Sun, 14 May 2017 09:13:42 +0000 (11:13 +0200)]
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>
Bartosz Golaszewski [Thu, 11 May 2017 10:59:08 +0000 (12:59 +0200)]
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>
Bartosz Golaszewski [Tue, 9 May 2017 18:45:49 +0000 (20:45 +0200)]
libgpiod: start v0.3 development cycle
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 9 May 2017 17:58:30 +0000 (19:58 +0200)]
libgpiod v0.2
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 8 May 2017 16:14:42 +0000 (18:14 +0200)]
NEWS: updates for v0.2
Add release notes for libgpiod v0.2.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 8 May 2017 16:05:37 +0000 (18:05 +0200)]
NEWS: wrap lines at 80 characters
Stick to the same standards everywhere in the project.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 8 May 2017 15:01:24 +0000 (17:01 +0200)]
tests: add test cases for line events
Verify that low-level routines for line events work correctly.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 8 May 2017 14:36:53 +0000 (16:36 +0200)]
tests: fix a dmesg error message from gpio-mockup
When checking if we can load gpio-mockup, we don't pass the
gpio_mockup_ranges argument to the module. This makes probe() fail
and causes an error message to be emitted.
Pass a correct argument to gpio-mockup so that a dummy GPIO chip gets
created and no errors are displayed.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 8 May 2017 11:16:29 +0000 (13:16 +0200)]
tests: add a test case for misc line flags
Test the open drain, open source and kernel flags.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Mon, 8 May 2017 09:28:27 +0000 (11:28 +0200)]
tests: move the test case execution into a separate function
For better readability move the code executing the test case into a
separate function - between the setup and teardown routines.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 5 May 2017 17:20:28 +0000 (19:20 +0200)]
tests: add new assertion
GU_ASSERT_FALSE() checks if given statement evaluates to false.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 5 May 2017 17:07:35 +0000 (19:07 +0200)]
tests: add a test case for gpiod_line_active_state()
Verify that the active state is changed correctly depending on the
parameters of the request.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 5 May 2017 16:57:56 +0000 (18:57 +0200)]
tests: add a test case for gpiod_line_direction()
Verify that the direction is changed properly and that a correct value
is returned from gpiod_line_direction().
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 5 May 2017 15:43:06 +0000 (17:43 +0200)]
README: add some info on unit tests
Describe how to build and use the testing framework.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Fri, 5 May 2017 15:04:52 +0000 (17:04 +0200)]
libgpiod: add the NEWS file
It should have been there from the beginning but it was somehow
forgotten. Add it now - before the v0.2 release.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 2 May 2017 21:51:17 +0000 (23:51 +0200)]
tests: add a test case for gpiod_simple_event_loop()
Test a very simple use case: wait for a single event of any type.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 2 May 2017 21:50:28 +0000 (23:50 +0200)]
tests: extend the testing framework with support for event injecting
Add a routine allowing tests to specify a single event to be injected
at regular intervals.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Tue, 2 May 2017 21:58:43 +0000 (23:58 +0200)]
core: fix the return value of gpiod_simple_event_loop()
This routine should always return 0 when no errors were encountered.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 15 Mar 2017 13:50:40 +0000 (14:50 +0100)]
tests: add a test case for gpiod_line_find_by_name()
Use the newly added support for named lines and add a test case
verifying that lines can be found by name.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Bartosz Golaszewski [Wed, 15 Mar 2017 13:48:59 +0000 (14:48 +0100)]
tests: add support for named lines
If the named_lines field is true in the test description, pass an
additional module parameter to gpio-mockup to have the GPIO lines
named.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>