Commit Graph

570 Commits (cpp)

Author SHA1 Message Date
nirenjan 21a5da3c70 Update POT with new source line numbers 2020-06-12 23:16:33 -07:00
nirenjan f754533a67 Update gettext.h to fix warnings when compiling with --disable-nls
With the introduction of AX_COMPILE_FLAGS in configure.ac, building with
--disable-nls in configuration raises additional warnings.

This change updates gettext.h in order to address those warnings.
2020-06-12 22:05:28 -07:00
nirenjan 16a7801e59 Update offset tests to use common test infrastructure.
Prior to the introduction of common test infrastructure, the offset test
was using an undocumented function in libx52 to validate the timezone
offset calculations.

This change allows us to hide that undocumented function and not have to
expose internal functionality in order to perform testing.
2020-06-12 17:18:04 -07:00
nirenjan 02165a8712 Fix comparision issue in test_common.c
Prior to this change, the comparision loop ran until it found a zero
value in either the index or the value field, rather than looping until
both were zero.

This change fixes that bug, and also adds additional debug functions to
print the expected and observed values.
2020-06-12 17:09:09 -07:00
nirenjan 8b49b91267 Enable -Werror in compiler flags 2020-06-11 23:39:28 -07:00
nirenjan dbacc27164 libusbx52: Clean up compiler warnings 2020-06-11 23:39:28 -07:00
nirenjan 1e2dd5699f libx52util: Clean up compiler warnings 2020-06-11 23:39:28 -07:00
nirenjan 3b8b98e74c libx52: Clean up compiler warnings 2020-06-11 23:39:28 -07:00
nirenjan 65c889827a x52cli: Clean up compiler warnings 2020-06-11 23:39:28 -07:00
nirenjan 09eb7d31e8 x52test: Clean up compiler warnings 2020-06-11 23:39:28 -07:00
nirenjan 37162510ac Enable additional compiler warnings
This change adds additional compiler warnings as detected by the
autoconf archive. Because the code is susceptible to these additional
warnings, disable treating warnings as errors for now, until we can fix
the warnings.
2020-06-11 23:38:44 -07:00
nirenjan fffb0bb69e Add test cases for blink and shift functionality 2020-06-11 22:29:59 -07:00
nirenjan 49d162fa07 Return result from _x52_vendor_command 2020-06-11 16:44:41 -07:00
nirenjan 1efcaf8970 Remove unnecessary pass statement 2020-06-11 16:04:12 -07:00
nirenjan 071162a907 Replace backticks with $(...) in test scripts 2020-06-11 16:03:16 -07:00
nirenjan c96ba7fec4 Add test cases for LEDs
This change adds tests for setting the X52Pro LEDs using the new x52
test infrastructure. This should be used in addition to the x52cli based
test suite.
2020-06-11 15:07:27 -07:00
nirenjan 92b0eb584f Allow overriding the vendor command functionality
This change allows for a test framework to override the functionality of
libx52_vendor_command. By doing so, it can build tests that change the
libx52_device structure, and therefore, not need to rely on libusbx52 to
get the commands written.

This allows for tests that can be built and run on other OSes as well,
since the libusbx52 based tests cannot run on OSX and have not been
tested on BSD systems.
2020-06-10 17:04:24 -07:00
nirenjan 2cb3474861 Add test case for offset calculation 2020-06-09 15:29:26 -07:00
nirenjan 4d93df1d58 Break offset calculation out into a separate function
This change will allow for a test program to verify that the offset
computation is valid.
2020-06-09 14:43:59 -07:00
nirenjan c9ffb415c8 Move opening from environment into separate function 2020-06-09 14:31:20 -07:00
nirenjan d53e56c491 Use $(...) instead of `...` in test scripts 2020-06-08 23:55:27 -07:00
nirenjan 23a980e250 Cleanup spurious whitespace 2020-06-08 23:52:27 -07:00
nirenjan 5715b19326 Reduce libx52_update function complexity
With the introduction of automatic code review tools, libx52_update was
found to be "too complex". This change simply breaks out the switch
cases into a set of functions indexed through a lookup table.
2020-06-08 22:59:41 -07:00
nirenjan e70a1b74e9 libx52: create separate group for connection functions 2020-06-08 17:31:32 -07:00
nirenjan 2d46b395a1 Add libx52_is_connected function 2020-06-08 17:22:33 -07:00
nirenjan 0cf977b751 Automatically close open handle when no device detected
Prior to this change, libx52_vendor_command would leave the device
handle untouched, even if the joystick was disconnected.

This change will force applications to reconnect to the joystick after
they encounter such a failure.
2020-06-08 16:23:11 -07:00
nirenjan cdd5e773e2 Update Changelog.md 2020-06-07 02:30:14 -07:00
nirenjan 88d57958f9 Remove daylight savings offset bug from documentation 2020-06-07 02:26:32 -07:00
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