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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>