Commit Graph

292 Commits (945ddc63a35f89214ff3efa9cb319bc869c52247)

Author SHA1 Message Date
nirenjan 85d2fc3522 Update libx52 version to reflect fix 2020-06-06 18:34:32 -07:00
nirenjan af49ce6500 Fix daylight savings offset calculation bug
This commit changes the local timezone calculation to use tm.tm_gmtoff,
and falling back to calculating it manually from the output of strftime
when tm_gmtoff is not a member of struct tm.

This also fixes the tests so that they are no longer expected to fail.

Fixes #20.
2020-06-06 17:48:17 -07:00
nirenjan f5145de36b Force _GNU_SOURCE in libusbx52 2020-06-06 17:26:43 -07:00
nirenjan 4f22983739 Revert "Enable compiling libx52 with weak symbol binding"
The hope was that I could compile some tests that would override
libx52_vendor_command, and run those on OSX to bypass the skipped tests
that used x52cli. However, a Travis-CI run indicated that the compiler
on OSX doesn't support weak symbols, which renders the point moot.
2020-06-06 17:05:17 -07:00
nirenjan 5b7afa6ae1 Add ax_sys_weak_alias.m4 2020-06-06 16:39:33 -07:00
nirenjan 780d9b4da4 Reduce variable scope as suggested by code inspector 2020-06-06 16:35:24 -07:00
nirenjan 95bc71859b Enable compiling libx52 with weak symbol binding
This change allows exporting libx52_vendor_command as a weak symbol,
thereby allowing it to be overridden by a test runner to validate that
the library is indeed behaving as per the spec.

Because this is something that may not be necessarily desirable on a
production environment, add a configure time flag to disable building
with weak symbols. This will also disable any tests that may rely on
libx52_vendor_command being a weak function.
2020-06-06 16:24:31 -07:00
nirenjan 01e815fc3b Add link to Github in Doxygen generated output 2020-06-06 08:54:59 -07:00
nirenjan 99bfb7d36a Disable dot in Doxyfile 2020-06-06 08:54:12 -07:00
nirenjan 1188bea444 Use TAP for tests
Prior to this change, the tests were using the automake simple test
harness. The limitation was that for each set of test cases (e.g.
timezone tests), even if one test failed, it would report every test in
that set as failed. Migrating to TAP allows fine-grained reporting on
every single test case, and allows better investigation into checking
which individual tests failed.

This change also updates the timezone tests to explicitly mark the ones
that check when the timezone is Pacific Daylight Time as expected to
fail. It also updates the clock tests to improve the formatting of the
test case identifier.
2020-06-06 08:33:30 -07:00
nirenjan 758d1d05d2 Update gitignore with Doxygen man output directory 2020-06-06 08:16:52 -07:00
nirenjan bac20b410d Hide libx52 internal symbols
Prior to this change, all symbols were being exported in the generated
library. This change adds libtool directives to only export the public
symbols in libx52.
2020-06-06 07:41:13 -07:00
nirenjan 89c233e244 Update translation template after source update 2020-06-06 07:40:55 -07:00
nirenjan 88f02bc5da Add _GNU_SOURCE to all files
If configured with CFLAGS=-std=c99, then quite a few warnings are
raised, as well as a couple of errors. By forcing the system to use
_GNU_SOURCE, we can allow the compilation to succeed even if using a
user defined C standard.
2020-06-05 16:37:20 -07:00
nirenjan 543aec85b1 Add config header to all C files 2020-06-05 15:19:56 -07:00
nirenjan 011bb737af Update libusbx52 to address code-inspector violations
This change addresses the code inspector violations reported in
https://frontend.code-inspector.com/analysis/result/8899/550515
2020-06-04 17:03:02 -07:00
nirenjan 8e77d6f09b Correct type of loop variable
If `-Wpedantic` is given as part of CFLAGS, this flags a warning stating
that `int` and `size_t` are of different sizes. This simply changes the
type of `i` to `size_t` to match the output of `strlen`.
2020-06-04 15:48:57 -07:00
nirenjan b6ebdef7ef Handle time out of range in libx52_set_clock
Prior to this change, the assumption was that localtime/gmtime would
never fail, regardless of the time value provided to it. However,
testing on an Ubuntu 20.04 machine revealed that the representable
range of time_t was about 56 bits, values that exceed a 56 bit
representation would cause localtime/gmtime to return a NULL pointer.

This change replaces the use of localtime/gmtime with their
corresponding thread-safe variants, and checks the return value against
NULL. If it matches a NULL value, then it will return an error and not
update the clocks.
2020-06-04 15:34:03 -07:00
nirenjan cdc6a594e4 Add contribution guidelines 2020-06-02 17:20:03 -07:00
nirenjan dbfe26f709 Update issue templates 2020-06-02 17:18:00 -07:00
nirenjan a7d5b7e34d Update issue templates 2020-06-02 17:12:45 -07:00
nirenjan cb96d297ab Create INSTALL.md
[skip ci]
2020-06-02 16:36:01 -07:00
nirenjan c2c852cee1 Add faketime to Travis packages list
This change adds the faketime package when building on Linux. faketime
is needed for the timezone tests.
2020-06-02 15:03:26 -07:00
nirenjan 79bd8466c1 Add test suite for timezone tests
Previously, when testing the clock command of x52cli, we had forced the
system timezone to UTC. As a result, the offset calculations for clocks
2 and 3 were never computed and always resulted in 0, which hid the bug
when the local time and local standard time did not match (#20).

This commit adds a test case that uses faketime to test setting the
clock to local (Pacific Time) and verifying that the offsets are
computed correctly. Given that the bug is still present as of this
commit, add the test suite to XFAIL_TESTS as well, so that it doesn't
break the CI build.
2020-06-02 14:48:46 -07:00
nirenjan 7ae5cad0cc Clear warning when linking x52test_log_actions
Prior to this change, we were linking the log_actions program against
the stub library, since we needed to use the logging capabilities in the
stub library to save the expected values to a file for the test harness
to use. However, doing so gives us the following warning:

*** Warning: Linking the executable x52test_log_actions against the loadable module
*** libusbx52.so is not portable!

Since we don't really need to have dynamic linking in this case, simply
including the stub library source into the log_actions program sources
list is sufficient, and bypasses this warning.
2020-06-02 07:50:51 -07:00
nirenjan a43cbc83a5 Add libx52_set_clock bug (#20) to documentation 2020-06-01 17:45:33 -07:00
nirenjan 57f7758dd1 x52test: Check device type during reset
Prior to this change, x52test would always assume that the device was an
X52Pro when resetting the device state. This change fixes that
assumption by checking the feature flags, since only the X52Pro has LED
support.

This change also updates the translation files due to the automatic
update because of line numbers being changed.
2020-06-01 00:10:01 -07:00
nirenjan e7d14d7b53 x52test: Cleanup if successful or cancelled
Commit be1f7e0 fixed the error handling, but missed this line. The
original behavior was to restore the X52 LED and MFD state after
completing all the tests, or if the user cancelled the tests using
Ctrl-C.

This commit fixes that regression, so that it will preserve the state
only if it encountered an error during the test, not if it was
cancelled.
2020-05-31 23:57:03 -07:00
nirenjan a16b1822aa Delete obsolete man pages
Prior to this change, a separate copy of the man pages for the libx52
functions was being maintained since I couldn't get Doxygen to work
properly at the time (I don't remember, it's been over 5 years).

The man pages are out of date and don't match up with the current
version of libx52, and haven't been for some time. Now that we have
functional documentation generated via Doxygen, it is time to get rid of
the obsolete stuff.

This change deletes the entire man folder, and doesn't change anything
else, since it was self-contained.

[skip ci]
2020-05-31 15:50:59 -07:00
nirenjan 127ab10995 Update Doxygen documentation
This change cleans up the documentation and adds examples for some
functions.
2020-05-31 08:45:34 -07:00
nirenjan 2db24e8759 Add udev rules to distribution
Prior to this change, a user had to manually install their own udev
rules on Linux if they wanted to access the joystick without having to
run as root. The most common usecase was on systems based on Debian,
where the user would be a member of the plugdev group, and they would
create their own rule to allow members of the group to write to the
joystick.

This change adds a validated udev rule to the distribution, so if the
user compiles from source and does a make install, the rule to allow
plugdev group members to access the joystick is installed.
2020-05-30 16:38:58 -07:00
nirenjan e5ce827d7e Update installation instructions in README 2020-05-30 16:38:27 -07:00
nirenjan b0a07fe364 Ensure that doxygen docs are removed on uninstall 2020-05-30 16:36:55 -07:00
nirenjan a711f0a882 Remove consolidated API documentation page
This change ensures that there is a separate link to all libx52.h
documentation. As a result, there is no longer a need to manually
maintain a list of functions, structs, enums, etc. This also updates
the main page to link directly to the documented files, rather than
to the API page.
2020-05-28 16:27:44 -07:00
nirenjan 7889124217 Update readme [skip ci] 2020-05-28 15:40:46 -07:00
nirenjan f9be0b3172 Move x52cli documentation into Doxygen
Prior to this change, the x52cli man page was a manually created file
that was out of date with the source. Rather than update that file, and
maintain a separate document for the HTML sources, it makes sense to
consolidate both the HTML and manpage documentation to a Doxygen page
block within the source and update the Doxyfile to generate man pages as
well.

This change also removes the obsolete manually maintained manpage, and
falls back to Doxygen to build and install the manpage.
2020-05-28 15:31:08 -07:00
nirenjan 374fd94fcd Update gitignore list with additional generated files [skip ci] 2020-05-26 16:33:58 -07:00
nirenjan c86e3f027a Add install rule for Doxygen generated docs 2020-05-26 16:16:54 -07:00
nirenjan 973348e537 Add Stale bot integration
This change enables the Probot stale issues bot to automatically close
inactive issues.

[skip ci]
2020-05-25 23:39:10 -07:00
nirenjan 491e5dffeb Format silent rules for doxygen generation
This change changes the silent rule for doxygen docs to show `DXGEN`
instead of just `GEN`.
2020-05-25 01:25:53 -07:00
nirenjan aff5576106 Disable doxygen MAN generation 2020-05-25 01:25:45 -07:00
nirenjan d9ae8d4b79 Add connect/disconnect methods to libx52
Prior to this change, libx52_init needed a supported joystick to be
plugged in, otherwise it would fail with LIBX52_ERROR_NO_DEVICE. This
change modifies the behavior so that libx52_init would still succeed,
but the application should call libx52_connect to make sure that the
device handle is valid. libx52_init still tries to connect to the
joystick, but absence is no longer treated as a failure.

This change also modifies x52cli to check that the joystick is actually
connected before calling the individual handlers. Because libx52_init no
longer fails if the joystick is absent, we need to rely on the return
code from libx52_connect.
2020-05-23 02:18:40 -07:00
nirenjan 93f1091b95 Ignore additional generated files
[skip ci]
2020-05-22 23:32:17 -07:00
nirenjan 6dc5d51461 Commit automatic changes to PO files
The previous commit to restore the test order in x52test did not fix the
order in the PO files, which got automatically modified when `make
update-po` ran. This commit restores those changes.
2020-05-22 23:26:48 -07:00
nirenjan dfdf6468bc Update Doxygen documentation
This updates the Doxygen documentation so that the generated
documentation is more readable and accessible to users of libx52
2020-05-22 18:05:07 -07:00
nirenjan fd6afde59c Update libx52 soname to 2.2.0 2020-05-22 16:02:59 -07:00
nirenjan 132b72f562 Ignore generated .mo files
This change cleans up a few of the dummy translations in xx_PL using the
open source [Poedit](https://www.poedit.net) editor. Since the editor
also generates the corresponding .mo file, it makes sense to add .mo as
an ignored extension.

[skip ci]
2020-05-22 13:36:53 -07:00
nirenjan d89cce807b Add check for LED support in x52test
This commit uses the new `libx52_check_feature` API to check if the
device supports LED control. If not, it prints an error message and
exits the LED tests gracefully.

This also reverts commit 45f009ac90, which
had moved the LED tests to the end. Since this is no longer necessary,
it is moved back to avoid any issues with anything that may have relied
on the old order.
2020-05-22 11:15:27 -07:00
nirenjan 482943e7a3 Add feature check method to libx52
This change allows applications to query if the connected device
supports the requested feature. This is so that applications like
x52test can skip test routines that aren't supported, instead of bailing
out of the loop.
2020-05-22 10:39:47 -07:00
nirenjan 0b6bc8f074 Clear the structure memory on exiting libx52 2020-05-22 10:33:33 -07:00