Pawel Szewczyk [Tue, 28 Apr 2015 08:51:51 +0000 (10:51 +0200)]
libusbgx: Fix mapping function type into attributes type
Type of ffs function's attribute is not PHONET, but FFS.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Stefan Agner [Fri, 24 Apr 2015 19:27:53 +0000 (21:27 +0200)]
libusbgx: print leading zero for MAC address bytes
The ethernet gadget driver requires the hex formatted MAC address
bytes with leading zero, in other words each byte needs to be two
characters in length (see get_ether_addr in u_ether.c). The libc
implementation ether_ntoa does not print leading zeros. Hence use
our own implementation which provides the format expected by the
kernel.
Signed-off-by: Stefan Agner <stefan@agner.ch>
[Rebased onto current master and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 16 Apr 2015 10:15:31 +0000 (12:15 +0200)]
libusbgx: schemes: Allow to import mass storage function
Allow to import mass storage function from gadget scheme
file. This make mass storage to be fully supported by
libusbgx.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 14:41:37 +0000 (16:41 +0200)]
libusbgx: schemes: Allow to export mass storage function
Add support for exporting mass storage function to
gadget scheme.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 09:59:01 +0000 (11:59 +0200)]
libusbgx: Add example with mass storage function
Mass storage support has been recently added to libusbgx.
This commit adds an example program which show how to create
gadget with this function.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 09:57:44 +0000 (11:57 +0200)]
libusbgx: Update example to show also mass storage function
Mass storage functions has been recently added to libusbgx
so update show-gadgets example to show also attributes of
mass storage function.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 10:53:54 +0000 (12:53 +0200)]
libusbgx: Add support for mass storage function
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 10:26:42 +0000 (12:26 +0200)]
libusbgx: Add rm callback to usbg_function
Some functions requires more complicated rm method
which will remove its sub directories. To avoid complexity
in usbg_rm_function() just add a callback which is called
there.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 10:40:23 +0000 (12:40 +0200)]
libusbgx: Add functions for reading/writing bool values
Some of function attributes on ConfigFS may be simple
boolean values so add common functions for reading
and writing them.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 09:51:12 +0000 (11:51 +0200)]
libusbgx: Rework usbg_read_buf() to accept also empty files
Some of configfs files may be empty. In that case fgets()
returns NULL but we should accept this situation and
treat it as an empty string.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 09:00:45 +0000 (11:00 +0200)]
libusbgx: Add offsetof() and container_of() macros
Add some macros which are widely used in linux
kernel and may be useful also in this library.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Mon, 13 Apr 2015 10:39:21 +0000 (12:39 +0200)]
libusbgx: Dereference pointer before switch
In each case in usbg_cleanup_function() we have
been using f_attrs->attrs. To make this shorter
and more readable add attrs pointer which is
equal to &f_attrs->attrs.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Thu, 16 Apr 2015 10:31:30 +0000 (12:31 +0200)]
libusbgx: Allow to pass usbg_init() without access to /sys/class/udc
We may would like to use this library on machine where
is no udc support (no /sys/class/udc directory) or
where we don't have sufficient rights to read udc
directory.
This commit adds support for such situation. If we are
running on such machine we will be able to pass usbg_init()
function and manage usb gadgets but we won't be able to bind
gadget to udc as we were unable to read their names.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Tue, 14 Apr 2015 12:12:35 +0000 (14:12 +0200)]
libusbgx: Fix export of phonet attributes
ifname is read only attribute so there is no need
to export it but we should return USBG_SUCCESS
value because this function has been succesfully
exported.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Pawel Szewczyk [Tue, 14 Apr 2015 09:56:53 +0000 (11:56 +0200)]
libusbgx: Don't link libusbgx with cmkocka
Cmocka is only needed for tests, no need for linking it
with library itself.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 18 Mar 2015 13:32:33 +0000 (14:32 +0100)]
libusbgx: Remove static buffers from usbg_f_ffs_attrs
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
Krzysztof Opasiak [Wed, 18 Mar 2015 12:40:11 +0000 (13:40 +0100)]
libusbgx: Remove static buffers from usbg_f_phonet_attrs
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
Krzysztof Opasiak [Wed, 18 Mar 2015 11:39:24 +0000 (12:39 +0100)]
libusbgx: Remove static buffers from usbg_f_net_attrs
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
Krzysztof Opasiak [Wed, 8 Apr 2015 13:07:49 +0000 (15:07 +0200)]
libusbgx: Introduce usbg_cleanup_function_attrs() function
We would like to eliminate static buffers from function
attributes. To achieve this we should ensure that there
is some function which free the memory allocated
in usbg_get_function_attrs()
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
Krzysztof Opasiak [Tue, 17 Mar 2015 16:28:36 +0000 (17:28 +0100)]
libusbgx: Make a use of usbg_f_attrs_type
This commit adds usbg_f_attrs_header which allows
to identify which union field is currently in use.
This allows to eliminate all switch() constructions
with list of all functions types for accessing
function attributes. Now, much more readable and
shorter enum with possible attribute types is used.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
Krzysztof Opasiak [Tue, 17 Mar 2015 16:14:32 +0000 (17:14 +0100)]
libusbgx: Add usbg_f_attrs_type enum
Currently user has to know which functions has
net attrs, which serial etc. There is a few places
where the same switch construction with list of all
function types is used.
This commit introduce enumeration which can be used
to determine set of function attribute instead of
rewriting the same enum once again.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
Krzysztof Opasiak [Tue, 17 Mar 2015 10:22:14 +0000 (11:22 +0100)]
libusbgx: Pass suitable structure to usbg_parse_function_net_attrs()
This function is desired to parse only net attrs so pass
a pointer to net attrs structure instead of generic
attrs union.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Philippe De Swert <philippedeswert@gmail.com>
Krzysztof Opasiak [Wed, 8 Apr 2015 08:08:39 +0000 (10:08 +0200)]
libusbgx: Update .gitignore for tests directory
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Dominic Sacré [Thu, 12 Mar 2015 10:50:03 +0000 (11:50 +0100)]
libusbgx: Make *_attrs and *_strs arguments const-correct
This makes it easier to use libusbgx in clean, idiomatic C++ code.
This patch changes the *_attrs and *_strs arguments only. It does not
make any assumptions regarding the const-ness of other structures
(usbg_gadget etc.), which is something that doesn't come up in typical
use cases.
Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
[Add libusbgx: to commit message.]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Dominic Sacré [Thu, 12 Mar 2015 09:38:42 +0000 (10:38 +0100)]
libusbgx: Add extern "C" linkage specification when using C++
This allows using libusbg in C++ code, without requiring users to
manually wrap the #include statement.
Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
[Add libusbgx: to commit message.]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Dominic Sacré [Thu, 12 Mar 2015 09:38:21 +0000 (10:38 +0100)]
libusbgx: Add a .gitignore file
Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
Add libusbgx: to commit message.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 18 Feb 2015 15:00:44 +0000 (16:00 +0100)]
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>
Pawel Szewczyk [Wed, 18 Feb 2015 15:00:47 +0000 (16:00 +0100)]
libusbgx: tests: Add simulation of configfs for config attributes
Config attributes can be get and set using proper pull_* and push_*
functions as setup.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Fix indent.
Change-Id: Ie168aa3f86c0a8f5e919674a816950bc0c5947ab
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Mon, 2 Mar 2015 13:37:39 +0000 (14:37 +0100)]
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>
Pawel Szewczyk [Mon, 2 Mar 2015 13:33:05 +0000 (14:33 +0100)]
libusbgx: tests: Add simulation of configfs for config strings
Allows config strings to be get from and set on virtual filesystem.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Add more documentation. Add push_config_string() function.
Change-Id: Ie04321cee9ac2a6defe0b01a650a847e1ac0a581
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 18 Feb 2015 10:51:20 +0000 (11:51 +0100)]
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>
Pawel Szewczyk [Wed, 18 Feb 2015 10:51:34 +0000 (11:51 +0100)]
libusbgx: tests: Add simulation of configfs for getting bindings
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Add asserts for gadget, config and bindings.
Change-Id: If6ce39332101826888c70790f8518876e03f8a44
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 27 Feb 2015 14:42:52 +0000 (15:42 +0100)]
libusbgx: tests: Support static binding definition
Sometimes we would like to define bindings names
other than default one. To achieve this we allocate
bindings only if they has not been allocated earlier.
Change-Id: Ifbad9b1069dd1a41d4a9f87c427c991538a8417f
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Krzysztof Opasiak [Fri, 27 Feb 2015 10:33:09 +0000 (11:33 +0100)]
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>
Krzysztof Opasiak [Thu, 26 Feb 2015 16:07:11 +0000 (17:07 +0100)]
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>
Krzysztof Opasiak [Fri, 27 Feb 2015 14:40:10 +0000 (15:40 +0100)]
libusbgx: tests: Initialize test_function when necessary
Binding structure may have some uninitialized functions
and we need to initialize it before usage.
Change-Id: I5c6f9d90f9dd1b41d8a9f80cf27cd9153ac79b7b
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Pawel Szewczyk [Wed, 25 Feb 2015 08:40:54 +0000 (09:40 +0100)]
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>
Pawel Szewczyk [Tue, 24 Feb 2015 15:02:06 +0000 (16:02 +0100)]
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>
Pawel Szewczyk [Wed, 18 Feb 2015 09:53:49 +0000 (10:53 +0100)]
libusbgx: tests: Add simulation of configfs for getting gadget strings
Allows to test getting gadget strings the same way as setting them.
Change-Id: I3197865955e22d3ec38f7b81f8050e95f24cdaf8
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 17 Feb 2015 14:04:31 +0000 (15:04 +0100)]
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>
Krzysztof Opasiak [Wed, 25 Feb 2015 15:16:51 +0000 (16:16 +0100)]
libusbgx: tests: Fix coding style
Change-Id: I1c47e3990bbd4dbfa620fc353a6cd65898dd6a30
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 24 Feb 2015 14:17:10 +0000 (15:17 +0100)]
libusbgx: tests: Add simulation of configfs for gadget strings setting
Like in testing setting gadget attributes, virtual filesystem is
prepared for setting gadget strings.
Change-Id: I0e46e3990aad4dbfa520fc333a6ca65898dd6a30
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 24 Feb 2015 14:17:18 +0000 (15:17 +0100)]
libusbgx: tests: Stop using gadget attributes strings array directly
Instead of using array exported in usbg-internal.h we use function
provided by libusbgx for getting string of gadget attribute
Change-Id: I6430f0de2926177e5f214713778dca16c33a3f40
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 25 Feb 2015 08:56:39 +0000 (09:56 +0100)]
libusbgx: tests: Try to iterate over all gadget attributes
Change-Id: I0fa869ecf50ead08171ee1da4b7a5326694efbdc
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 24 Feb 2015 12:08:11 +0000 (13:08 +0100)]
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>
Pawel Szewczyk [Mon, 24 Nov 2014 12:14:22 +0000 (13:14 +0100)]
libusbgx: tests: Update guideline changes
Change-Id: I3bc3124c1e0abec017799da84d628bf97b79737f
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Mon, 20 Oct 2014 11:18:31 +0000 (13:18 +0200)]
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>
Pawel Szewczyk [Wed, 11 Feb 2015 14:22:27 +0000 (15:22 +0100)]
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>
Pawel Szewczyk [Wed, 11 Feb 2015 15:10:38 +0000 (16:10 +0100)]
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>
Pawel Szewczyk [Thu, 12 Feb 2015 15:01:52 +0000 (16:01 +0100)]
libusbgx: tests: Add simulation of configfs for gadget attrs get/set
Before executing libusbgx functions which get and set gadget attributes,
we must prepare virtual filesystem to behave as expected.
push_* and pull_* functions take arguments similar to usbg functions
which will be called after them, e.g. push_gadget_attrs(g, a)
will prepare for calling usbg_get_gadget_attrs on gadget matching g,
where a is value passed to be read.
Change-Id: I805544dbd35a1a7f8c2e4073f9f4607d9c70bb95
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 10 Feb 2015 13:25:30 +0000 (14:25 +0100)]
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>
Pawel Szewczyk [Mon, 17 Nov 2014 12:23:40 +0000 (13:23 +0100)]
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>
Pawel Szewczyk [Wed, 11 Feb 2015 09:13:01 +0000 (10:13 +0100)]
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>
Krzysztof Opasiak [Wed, 11 Feb 2015 10:43:17 +0000 (11:43 +0100)]
libusbgx: tests: Use cast_to_largest_integral_type()
Direct cast from pointer to integer of different size
causes ugly compiler warning. To avoid this use
dedicated macro from cmocka.
Change-Id: I56f4095dd8f98c8349d02b421f02de1d61e0b2b8
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 10 Feb 2015 14:29:18 +0000 (15:29 +0100)]
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>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:21:27 +0000 (21:21 +0100)]
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>
Krzysztof Opasiak [Mon, 9 Feb 2015 09:29:59 +0000 (10:29 +0100)]
libusbgx: tests: Remove unused variables
Change-Id: I4db3a1d8683867c1e969898882f0589f477ebe4c
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 26 Nov 2014 15:19:15 +0000 (16:19 +0100)]
libusbgx: tests: Add guarding macros in header
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Remove unnecessary newline.
Change-Id: I3db3a1d8683867c1e969898882f0589f477ebe4b
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Fri, 12 Dec 2014 13:36:06 +0000 (14:36 +0100)]
libusbgx: tests: Add autotools making description to guideline
Change-Id: I82b8b5b2f792bf72586d93cc5d6987ad017be618
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:17:18 +0000 (21:17 +0100)]
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>
Pawel Szewczyk [Wed, 7 Jan 2015 15:53:06 +0000 (16:53 +0100)]
libusbgx: tests: Add proper path comparing
Multiple slashes are allowed in paths, so they cannot be compared as
simple strings.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Fix some code style issue. Move expect_path() macro
to heder file.
Change-Id: I613f9335ac665ae0e038b0493c6582a20678bd12
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 3 Feb 2015 13:16:42 +0000 (14:16 +0100)]
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>
Krzysztof Opasiak [Tue, 3 Feb 2015 13:24:56 +0000 (14:24 +0100)]
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>
Pawel Szewczyk [Wed, 7 Jan 2015 10:21:56 +0000 (11:21 +0100)]
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>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:44:45 +0000 (21:44 +0100)]
libusbgx: tests: Add options parsing to running script
Change-Id: I1658663e8b7f14b5595ef806c5fca03ae10c830d
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Signed-off-by: Stanislaw Wadas <s.wadas@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Mon, 17 Nov 2014 16:06:34 +0000 (17:06 +0100)]
libusbgx: tests: Add testing guideline
Change-Id: Ia7c2fa66a0bfa024858cde90a52ed05cbd41b12c
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 14 Nov 2014 15:14:23 +0000 (16:14 +0100)]
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>
Pawel Szewczyk [Fri, 14 Nov 2014 13:22:54 +0000 (14:22 +0100)]
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>
Pawel Szewczyk [Fri, 14 Nov 2014 14:09:47 +0000 (15:09 +0100)]
libusbgx: tests: Add assert functions for internal usbg structures
Internal usbg structures definitions are required to check if they are
correctly filled by libusbg.
Change-Id: I61d88b03d7255e6a4a6760ce5b9ad564a686c492
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 12 Nov 2014 15:54:13 +0000 (16:54 +0100)]
libusbgx: tests: Use RTLD to access original fputs()
Sometimes we would like to print something to stderr
or stdout from tests so our wrapper should use standard
fputs() definition for this function.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 9 Sep 2014 09:28:11 +0000 (11:28 +0200)]
libusbgx: tests: Add simulation of configfs for init by wrapping i/o funcs.
To separate libusbgx from configfs we simulate it by replacing i/o
functions. We can define gadgets and pass them to init and other usbg
functions through simulated file system.
Change-Id: I9d0964f13b6ef7385d32d6f0d6775fe88ff8eb17
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 6 Mar 2015 15:00:33 +0000 (16:00 +0100)]
libusbgx: Fix compilation warnings
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 11 Feb 2015 13:03:39 +0000 (14:03 +0100)]
libusbgx: Fix gadget attributes reading order
To be more consistent we read and write gadget attributes in the same order
specified by usbg_gadget_attr enum. It can make difference in testing, where
order often does matter and allows to write tests more efficient when
using wrapped filesystem operations. Also, consistency is always a good
thing.
Change-Id: Ieb3c7f81a8c0a135c47ebd358e5a87fe04766f2a
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 6 Feb 2015 15:20:19 +0000 (16:20 +0100)]
libusbgx: Add include guards to internal header
Change-Id: I4db3a1d8683867c1e969898882f0589f477ebe4b
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 3 Feb 2015 13:14:09 +0000 (14:14 +0100)]
libusbgx: Fix usbg_get_configfs_path()
Store configfs path in configfs_path attribute
and return it in usbg_get_configfs_path()
instead of returning path to usbg_gadget subsys.
Based on patch "libusbg: Fix configfs path" created by:
Pawel Szewczyk <p.szewczyk@samsung.com>
Change-Id: I49e606c9f8c5eb478ac48fc453840b9a3efdd117
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:09:24 +0000 (21:09 +0100)]
libusbgx: add --disable-gadget-schemes to configure
This commit adds --disable-gadget-schemes option to configure.
It allows to build libusbgx without libconfig.
This change does not change the API - we add instead empty functions.
The default solution is to use libconfig.
Change-Id: Ia8581fdb6368fb1877e97ee56d91d29e5128611e
Signed-off-by: Przemyslaw Kedzierski <p.kedzierski@samsung.com>
[Rebase and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 29 Oct 2014 15:15:21 +0000 (16:15 +0100)]
libusbgx: Add empty definitions of gadget schemes functions
In some cases user may want to not use gadget schemes
functionality so he should be able to remove libconfig
dependency. To be able to do this without API break
add empty definitions of gadget schemes functions which
only returns USBG_ERROR_NOT_SUPPORTED.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:07:20 +0000 (21:07 +0100)]
libusbgx: Move gadget schemes functionality to separate file
Having wholle code in one file hurts code readability.
It would be more convenient to split this large file
into a few smaller. This commits move whole functinality
related to gadget schemes to separate file.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 29 Oct 2014 14:26:12 +0000 (15:26 +0100)]
libusbgx: Extract internal header file
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Sat, 4 Oct 2014 08:27:40 +0000 (10:27 +0200)]
libusbgx: Add max and min values to enums
In some cases user of library would like to iterate over
all enum values. Depending on enum values order is not
a good idea so provide suitable min and max values to alow
doing something like:
int i;
for(i = USBG_GADGET_ATTR_MIN; i < USBG_GADGET_ATTR_MAX; ++i)
do_something_useful(i);
Moreover, ensure that function_names and gadget_attr_names
arrays has allways the same size as number of meaningful
values in related enums.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 18:48:08 +0000 (20:48 +0200)]
libusbgx: Add example how to use usbg_udc structure
This example shows how to learn what udcs are available
in system and also how to find out what gadgets are
enabled on them.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 18:44:33 +0000 (20:44 +0200)]
libusbgx: Allow to get gadget enabled on given UDC
Add usbg_get_udc_gadget() which allows user to learn
which gadget is attached to selected UDC.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 18:17:22 +0000 (20:17 +0200)]
libusbgx: Refresh gadget UDC while each usbg_get_gadget_udc()
Kernel may decide to detach our gadget in some cases.
A good example is when FFS daemon received a SIGSEGV
and all descriptors has been closed.
To avoid returning false informations to user we have
to refresh UDC attribute before returning cached pointer
to usbg_udc.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 23 Sep 2014 09:56:11 +0000 (11:56 +0200)]
libusbgx: Rework API to use usbg_udc structure
Using string as udc identifier provides a lot
of troubles. To be more consistent with rest of
API rework it to start using usbg_udc structure
instead of using char *.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 17:15:57 +0000 (19:15 +0200)]
libusbgx: Replace usbg_get_udcs() with loop
Library allows to iterate over each gadget using loop.
To be consistent with this convention add similar loop
for UDCs.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 18 Sep 2014 16:12:46 +0000 (18:12 +0200)]
libusbgx: Add udc structure
Add structure to store informations about available udcs
instead of using their names as a string.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 26 Sep 2014 15:12:57 +0000 (17:12 +0200)]
libusbgx: Don't print errno when it has not been directly set
Replace ERRORNO() macro with ERROR(). Difference betwen
them is that ERRORNO() prints also standard error string
based on errno value. This variable should not be accessed
when called function doesn't directly set it.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 26 Sep 2014 14:59:55 +0000 (16:59 +0200)]
libusbgx: Add own name to AUTHORS file.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Mon, 22 Sep 2014 10:46:22 +0000 (12:46 +0200)]
libusbgx: Make usbg_lookup_function_type() publicly available
Users of library may often receive function type as a string.
Instead of implementing parsing of such string in each program
it would be more convenient to provide such support in library.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Mon, 22 Sep 2014 10:30:03 +0000 (12:30 +0200)]
libusbgx: Return suitable error codes instead of -1
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 18 Sep 2014 15:44:48 +0000 (17:44 +0200)]
libusbgx: Allow to set all gadget attrs using one function.
Having specialized functions for each attribute may be
sometime inconvenient to use. Provide also function
whihc allows to set attribute selected by parameter.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 18 Sep 2014 12:54:22 +0000 (14:54 +0200)]
libusbgx: Simplify getting names form library structures
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Changes since v1:
Fix show-gadgets example: get attributes before dereferencing them
Reported-by: Philippe De Swert <philippe.deswert@jollamobile.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 09:49:58 +0000 (11:49 +0200)]
libusbgx: Always add '\0' at end of string
strncpy() may not append trailing '\0' so let's append
it always at end of string to avoid getting into troubles.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 18 Sep 2014 13:14:46 +0000 (15:14 +0200)]
libusbgx: fix: Remove unused variables
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 9 Sep 2014 13:24:00 +0000 (15:24 +0200)]
libusbgx: Fix off-by-one error.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 13:24:48 +0000 (15:24 +0200)]
libusbgx: doc: Fix typos in doxygen documentation
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Tony Lindgren [Sat, 20 Sep 2014 13:50:52 +0000 (15:50 +0200)]
libusbgx: Fix usbg_disable_gadget to actually clear the UDC
Currently usbg_disable_gadget() does not actually write anything
to UDC to clear it and the configured UDC name stays there.
Signed-off-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 18 Sep 2014 18:38:32 +0000 (20:38 +0200)]
libusbgx: fix: reverse comparsion to fix error
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Philippe De Swert [Tue, 16 Sep 2014 10:04:47 +0000 (13:04 +0300)]
libusbgx: Return USBG_ERROR_PATH_TOO_LONG error when it happens
Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
Acked-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 19:46:03 +0000 (20:46 +0100)]
libusbgx: Fix out-of-tree builds
The include flag should point to the source directory, not the build
directory.
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Rebased onto kopasiak/master.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>