Commit Graph

294 Commits (5108e34ce848a980d1edd64d7bafcba32d639a06)

Author SHA1 Message Date
The Gitter Badger 5108e34ce8 Add Gitter badge 2020-07-13 21:16:53 +00:00
nirenjan f963991161 Save PID in libx52_device structure
This will support a parser interface which will parse the HID report
from the X52, but given that the device has different PIDs, the parser
will need to behave differently depending on the PID.
2020-07-04 23:29:25 -07:00
nirenjan 945ddc63a3 Update for release 0.2.1 2020-06-28 13:31:25 -07:00
nirenjan 729bbcaf90 Rename CLI tests from libx52 to x52cli 2020-06-28 12:01:14 -07:00
nirenjan 4311c020a0 Merge branch 'cmocka-tests' 2020-06-28 11:49:39 -07:00
nirenjan c40847b833 Add clock tests to verify PDT/PST/UTC 2020-06-28 11:32:19 -07:00
nirenjan 3981b873e0 Add date format tests 2020-06-28 08:57:23 -07:00
nirenjan 87ad48a37f Cleanup generated test formatting 2020-06-28 08:57:01 -07:00
nirenjan 7b423f4ea0 Update libx52_set_led_state to use check_feature 2020-06-28 08:35:14 -07:00
nirenjan efd984ef63 Parse and add setup_hook and fields
This change allows updates to the dev structure for individual test
cases. This defines the "setup_hook" array, and "fields" map, at both
the test group level and at the individual test case level, with the
ones at the test case level overriding any parent level fields and/or
hooks.

The primary use case for this is to add new test definitions that would
not be setup correctly by the default infrastructure, such as testing
the LED function for the non-Pro X52, or setting up clock tests for
local timezone, etc.
2020-06-28 08:24:49 -07:00
nirenjan 108b7e2522 Add cmocka to OSX build 2020-06-27 22:20:40 -07:00
nirenjan 681a8e8aa1 Change libx52 mock tests to use preprocessor overrides
Prior to this change, libx52 tests needed a linker that supported the
--wrap argument. This is not available on OSX, and therefore, we had to
disable the unit tests on non-Linux systems.

Since we needed to rebuild the libx52 library anyway for the test, it is
simpler to just define libusb_control_transfer to point to our mock
function. This allows us to verify libx52 on all supported platforms.
2020-06-27 22:04:56 -07:00
nirenjan 57cda79320 Add specifications for Saitek X52
[skip ci]
2020-06-21 08:49:14 -07:00
nirenjan 8388f3308e Reword configure warning on non-Linux hosts 2020-06-21 08:48:44 -07:00
nirenjan c4696f6055 Add clock time tests 2020-06-17 18:52:07 -07:00
nirenjan 34b023b1fa Add cmocka to Travis CI builds on Ubuntu 2020-06-17 16:18:06 -07:00
nirenjan e9167b4c20 Disable cmocka tests on non-Linux hosts 2020-06-17 16:00:25 -07:00
nirenjan 3afe999fe8 Ensure generated sources are not packaged in distribution 2020-06-17 15:12:01 -07:00
nirenjan 9f37cde784 Add generated tests to verify libx52 functionality
This change adds a suite of tests in JSON format using a Python script
to generate the cmocka based test program. Because we need to wrap some
of libusb functionality, we need to rebuild and relink the libx52
sources with the -Wl,--wrap option.
2020-06-17 15:06:19 -07:00
nirenjan bf9b1bdfbd Remove manual tests in favor of cmocka
Prior to this change, we needed to add a manual override function to
mock the vendor command. Given that cmocka has built-in support for
mocking functions, it's better to use that instead.

This change simply removes the manual override and any tests that rely
on it.
2020-06-16 17:33:15 -07:00
nirenjan f0ed2f39e3 Set minimum version of Python to 3.5
On Xenial, the version of Python 3 is 3.5. Restricting the version to
3.6 or newer causes the Travis CI build to break on Xenial.
2020-06-16 15:39:31 -07:00
nirenjan c4acd0ce49 Update makefiles to use Python 3
Prior to this change, generation of the character lookup table could use
Python 2 or Python 3, depending on what the first instance of python in
the PATH pointed to.  On most systems, python is a symbolic link to
python2.7. However, given that Python 2 is EOL, it makes sense to switch
the code to use Python 3 now, rather than later.

This change updates the requirements to use Python 3.6 or later, and
updates the Makefile to invoke the script with the detected python
binary, rather than relying on the shebang to use the system Python.
2020-06-16 15:17:53 -07:00
nirenjan 3eaee7b8f4 Reduce duplicate code in libx52 test code 2020-06-14 00:07:40 -07:00
nirenjan e1915bc734 Update paths of scripts to allow building on BSD
Prior to this change, the assumption in all shell and Python scripts was
that the Bash interpreter would always be available at `/bin/bash`, and
Python would always be available at `/usr/bin/python`. However, on a VM
running FreeBSD, installing bash and python using the pkg command
installs them under /usr/local/bin.

This change updates the paths to use /usr/bin/env in the shebang. While
this is not a standard path either, it is more likely to be available at
this location.

This change also updates the find command in common_infra.sh to use
`-perm -+x` in lieu of `-executable`, which is not a condition defined
by POSIX. This allows running the tests on BSD.
2020-06-12 23:26:51 -07:00
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