1
0
Fork 0
mirror of https://github.com/linux-usb-gadgets/libusbgx.git synced 2025-07-23 05:35:05 +03:00
Commit graph

47 commits

Author SHA1 Message Date
Krzysztof Opasiak
56355fb34d libusbgx: Add usbg_free_config_strs()
This is a first step to get rid of static buffers from usbg_config_strs.

This function should be called to release memory allocated for
configuration string.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-03-02 16:56:27 +01:00
Krzysztof Opasiak
78c45fa80f libusbgx: Get rid of static buffers from usbg_gadget_strs
Remove static buffers which limits strings length from usbg_gadget_strs.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-03-02 16:56:27 +01:00
Krzysztof Opasiak
e0e525fc58 libusbgx: Add usbg_free_gadget_strs()
This is a first step to get rid of static buffers in usbg_gadget_strs.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2017-03-02 16:54:37 +01:00
Krzysztof Opasiak
c02dbe391f libusbgx: Keep gadget strs in the same order as in device desc
Let's keep gadget strings in the same order as they appear
in USB device descriptor to avoid mistakes during structure
initialization.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-14 15:23:48 +01:00
Krzysztof Opasiak
67aaf8ea7e libusbgx: Use string name similar to USB spec
str_ser, str_prd and str_mnf are a little bit weird names
so let's replace them with names defined by USB spec.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-14 13:23:12 +01:00
Krzysztof Opasiak
4fe38766f7 libusbgx: tests: Fix indent and line length
Let's keep our lines not longer than 80 characters
and fix also indentation for function params.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-14 13:09:26 +01:00
Krzysztof Opasiak
3749ccec3d libusbgx: Remove typedefs for public structures
Let's remove typedefs from public structures to clearly
indicate users which structures can be accessed and which
should be used only as handles.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-14 13:03:26 +01:00
Krzysztof Opasiak
a23dee0c86 libusbgx: Use suitable prefix for usbg_function_type enum
Let's use USBG_ prefix for usbg_function_type enum values
to avoid users confusion.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-13 22:45:06 +01:00
Krzysztof Opasiak
d9c5a1bc49 libusbgx: Use suitable prefix for usbg_gadget_str enum
Let's use USBG_ prefix for usbg_gadget_str enum values
to avoid users confusion.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-13 22:00:26 +01:00
Krzysztof Opasiak
9be0405ed1 libusbgx: Use suitable prefix for usbg_gadget_attr enum
Let's use USBG_ prefix for usbg_gadget_attr enum values
to avoid users confusion

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2016-12-13 21:53:41 +01:00
Krzysztof Opasiak
8bc67dc065 libusbgx: tests: Update tests to use *_s() functions
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-23 00:49:03 +01:00
Krzysztof Opasiak
ec6400e101 libusbgx: tests: Port all tests to new API
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-23 00:49:03 +01:00
Pawel Szewczyk
56342defa0 libusbgx: tests: Add missing test cases
Some test functions are not executed at all. This commit fix it.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:37 +01:00
Pawel Szewczyk
2a69f0f287 libusbgx: tests: Add tests for gadget strings enum
Test recently added functions using usbg_gadget_str enum.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:37 +01:00
Pawel Szewczyk
ca8120c2aa libusbgx: tests: Add create function test
Change-Id: I3a47f0d16b9259f09bb4ea3eeb3734a89af43019
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:37 +01:00
Pawel Szewczyk
de91f03f40 libusbgx: tests: Add getting function attributes tests
Change-Id: Ia82f5f124e7b57c2694c605ddc942513fc337645
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:37 +01:00
Pawel Szewczyk
312a4ae948 libusbgx: tests: Add creating configuration test
Change-Id: I0e5c09b5664f8e15d9ba70e9a5682992341e0884
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:37 +01:00
Pawel Szewczyk
e036a3406f libusbgx: tests: Move initialization from for_each functions to tests
Instead of passing void **state as argument for for_each_* functions and
initializing state there, we make initialization first and pass initialized
state as argument for them. It looks more natural this way. This also
allows to run these functions multiple times in single test function.

Change-Id: If84bbedf374f1f0ebf70315cea950dcd2e527d18
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:37 +01:00
Pawel Szewczyk
0e199f2f24 libusbgx: tests: Separate safe state initialization from tests
Test functions usually need to initialize usbg state before testing.
However, initialization may fail, causing test to finish immediatelly,
running teardown function.

This commit add function which takes care of state pointer when
initializing.

Change-Id: I797e56ac3cda67e871c6c4fbd2184220b05068f6
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Pawel Szewczyk
5185f1aa82 libusbgx: tests: Add macros for structures definitions
To avoid defining the same or similar values multiple times, we can define
data by proper macros.

Change-Id: I8fa5fd02c76f16a1b9d65a33482a6cd1caa16b70
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Pawel Szewczyk
9549829a45 libusbgx: tests: Separate common code of gadget testing
Most gadget tests run the same initialization and loop through all
gadgets, performing single operation on them and checking results.
Common code is now separated to for_each_test_gadget function.

Change-Id: I0a1870487aa0c25153c96e57da5501e1bccb8132
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Pawel Szewczyk
718b86e50f libusbgx: tests: Add wrappers for safe allocation
Every allocation here requires checking if it was successful and
storing it on queue to be freed later. Now it can all be done by single
function call.

Change-Id: I06c0099d0b44cb030b6ab8e338ccd58e078a92ac
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Pawel Szewczyk
cc4e00b0b3 libusbgx: tests: Use new version of cmocka
Deprecated functions of cmocka are no longer used.

Change-Id: If8804103492b089cf033a35d055260452553638e
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:36 +01:00
Pawel Szewczyk
d17722045a libusbgx: tests: Add config attributes getting and setting test
Change-Id: I86e5263e11f3794aa1b999f02778dbf6ce32e572
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:35 +01:00
Pawel Szewczyk
9ba53ec609 libusbgx: tests: Add getting and setting config strs test
Change-Id: I1c7beaf82e1df526dcd01d13c7d7857d4652fdd7
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:35 +01:00
Pawel Szewczyk
78e83b64ad libusbgx: tests: Add getting binding test
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>

Fix coding style.

Change-Id: I1ae18bc2393067cd0735ab812ec720e900ef3161
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:35 +01:00
Krzysztof Opasiak
03606d9238 libusbgx: tests: Make a deep copy of date for each test case
Each test case should use own copy of test_* structures.
To achieve this we do a deep copy of structures which has
not been marked as writable.

Change-Id: I1f1a949059dd1a41d4a9f80ca27c391533a59a7f
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
2015-12-22 21:45:34 +01:00
Krzysztof Opasiak
64ef96ef91 libusbgx: tests: Add writable attribute to test_* structures
Reusing the same structures for many tests is wrong for
security reasons. Some of test cases already allocates
own copy of test structures. This commit adds a field
which indicates if given structure has been allocated
for test case or if it is global structure and should
not be changed.

Change-Id: I8a1f9b9059dd1a41d4a9f80c427c991533f7ab9a
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
3e80a0fec6 libusbgx: tests: Add test_binding structure
Using the same type for binding and function (and assuming that binding
has the same name as its target function) was not an elegant solution.
It is fixed by adding separate structure and use it in test setups.

To save old, convinient way of defining bindings by list of functions,
additional field in test binding is provided and prepare_state generate
bindings based on it.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>

s/binded/bound

Change-Id: I8a1f9b9059dd1a41d4a9f80c427c991533a74b7e
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
2209249876 libusbgx: tests: Add getting gadget string test
Change-Id: I78ab01d1ca8ff5105448d3bbf3982753cdfc01d6
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
2060c87f13 libusbgx: tests: Add setting gadget strs tests
Change-Id: Ia7975f0a3a2e8e2bc6bff8bcd64430a6e26d1888
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Krzysztof Opasiak
a7d8b8739e libusbgx: tests: Try to iterate over all gadget attributes
Change-Id: I0fa869ecf50ead08171ee1da4b7a5326694efbdc
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
8df248e8b6 libusbgx: tests: Test getting strings of gadget attributes
Simply check if valid strings are returned

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>

Use USBG_GADGET_ATTR_MIN - 1 instead of just -1.

Change-Id: I0f3869eaf50ead08171ee1da4b7a5326694efb2c
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
895d7cef49 libusbgx: tests: Add udc tests
Change-Id: I9725395ff5a6bac7f4edfdaa4da9bbce3a3186ff
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
623f89071c libusbgx: tests: Add states with long strings
Change-Id: I92c185449293fd9426f151687832b3bdb0c57572
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
aaebacf25e libusbgx: tests: Add gadget attrs get/set tests
Change-Id: I5ab4262a5532e07de9e6e919e6dde5dd49da4702
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
a9e608e101 libusbgx: tests: Add getting config tests
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>

Remove unused variable in for_each_test_config().

Change-Id: I6dd8dc33639dff2d3322c6098a43c69beb8a7ef6
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
7115cced5b libusbgx: tests: Add getting configfs path test
Change-Id: Ia7d368c8749d28235a4209d5a0de90dc6878717b
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
30dfcc89fa libusbgx: tests: Add getting functions tests
Change-Id: I89296562177061559de84aa5332d8dc9347d2e13
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Pawel Szewczyk
be767ffc0f libusbgx: tests: Make some functions static, some move to header
init_with_state is also used by functions in usbg-test.c, so was declared
globaly in header. Other functions from test.c is not used outside and
we can make them static.

Change-Id: I56f4095dd8f98c8349d02b421f02de1d61e0b2b7
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:34 +01:00
Krzysztof Opasiak
3133e4c2d3 libusbgx: tests: Add doxygen macros for documenting test cases
Also proceed doxygen config file with autoconf now. Autoconf copy .in file,
substituting found variable values. It allows to specify what documentation
should be build by configure script.

Change-Id: I00cae61aefcc5b6444b0afc0dfe73c5973de34a9
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Rebase and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:33 +01:00
Krzysztof Opasiak
6dbd9775a8 libusbgx: tests: Build tests with autotools
Change-Id: I1438caf6806d2197bcf20a63b56e33d9243fb2a0
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description and rebase]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:29 +01:00
Krzysztof Opasiak
c3c2223d44 libusbgx: tests: Fix tests to use correct usbg_state field
Due to recent changes in usbg_state, lets
introduce configfs_path field in state test_state
structure and fill it.

Since now path field should not be filled as it's
filled by prepare_state() function and generates
subsystem path using given configfs path.

Change-Id: I50e606c9f8c5eb478ac48fc453840b9a3efdd117
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:29 +01:00
Krzysztof Opasiak
aaae83f680 libusbgx: tests: Fix tests build
Due to adding configure flags which allows to disable
libconfig dependency introduce a temporary fix which should
be removed when we will build tests with autotools.

Change-Id: I51f606c9f8c5eb478ac48fc453840b9a3efdd117
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:45:29 +01:00
Pawel Szewczyk
773a80429c libusbgx: tests: Remove negative buffer test
Size_t is unsigned and passing -1 as buffer length makes no sense.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Rebase and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:44:57 +01:00
Krzysztof Opasiak
5b4eb3c5de libusbgx: tests: Allow to skip some tests
In some cases we may want to mark some tests as skipped.
Doing this in code requires recompilation after each change.
This patch extends the tests framework and allows to create
configuration file and mark some tests as skipped (for example
using # and comment some test and run them always from the
same binary file.

We use stdin/stdout for reading/writing configuration
because we are wrapping filesystem operations in our
mock framework (usbg-io-wrappers). To keep our mock
framework as simple as we can we use those standard
streams which are forrwarded by framework to original
implementations of those functions.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:43:24 +01:00
Pawel Szewczyk
4628580af9 libusbgx: tests: Add init and getting gadgets tests
Change-Id: I4c872a76bf59b8eaababfdf4bbb1804d4008f8de
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>

Make two macros (generic and specific) for defining test
cases instead of hardcoding everything in one macro.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 21:41:58 +01:00