summaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2015-08-20libusbg: tests: Add missing test casesPawel Szewczyk1-0/+38
Some test functions are not executed at all. This commit fix it. Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-08-19libusbg: tests: Add tests for gadget strings enumPawel Szewczyk1-0/+55
Test recently added functions using usbg_gadget_str enum. Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Add create function testPawel Szewczyk3-0/+60
Change-Id: I3a47f0d16b9259f09bb4ea3eeb3734a89af43019 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Add getting function attributes testsPawel Szewczyk3-0/+520
Change-Id: Ia82f5f124e7b57c2694c605ddc942513fc337645 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Add assertions for function attributesPawel Szewczyk1-0/+32
Change-Id: Idfc179ff08a0d23b73ca0f30519bbc73f6556e10 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Add creating configuration testPawel Szewczyk1-0/+44
Change-Id: I0e5c09b5664f8e15d9ba70e9a5682992341e0884 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Add framework setup for creating configPawel Szewczyk2-0/+50
Change-Id: I19b4777e9b61c7dc63c8bb0644de2a63089e6bd3 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Move initialization from for_each functions to testsPawel Szewczyk3-48/+116
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Separate safe state initialization from testsPawel Szewczyk3-90/+35
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Add macros for structures definitionsPawel Szewczyk1-109/+57
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Separate common code of gadget testingPawel Szewczyk3-74/+62
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Add wrappers for safe allocationPawel Szewczyk3-193/+85
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-07-30libusbg: tests: Use new version of cmockaPawel Szewczyk1-60/+35
Deprecated functions of cmocka are no longer used. Change-Id: If8804103492b089cf033a35d055260452553638e Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add config attributes getting and setting testPawel Szewczyk1-0/+157
Change-Id: I86e5263e11f3794aa1b999f02778dbf6ce32e572 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add simulation of configfs for config attributesPawel Szewczyk2-1/+147
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>
2015-03-06libusbg: tests: Add getting and setting config strs testPawel Szewczyk1-0/+109
Change-Id: I1c7beaf82e1df526dcd01d13c7d7857d4652fdd7 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add simulation of configfs for config stringsPawel Szewczyk2-0/+98
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>
2015-03-06libusbg: tests: Add getting binding testPawel Szewczyk1-0/+98
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-03-06libusbg: tests: Add simulation of configfs for getting bindingsPawel Szewczyk2-0/+46
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>
2015-03-06libusbg: tests: Support static binding definitionKrzysztof Opasiak1-10/+19
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>
2015-03-06libusbg: tests: Make a deep copy of date for each test caseKrzysztof Opasiak3-20/+291
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-03-06libusbg: tests: Add writable attribute to test_* structuresKrzysztof Opasiak2-0/+13
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-03-06libusbg: tests: Initialize test_function when necessaryKrzysztof Opasiak2-16/+22
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>
2015-03-06libusbg: tests: Add test_binding structurePawel Szewczyk3-13/+68
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-03-06libusbg: tests: Add getting gadget string testPawel Szewczyk1-0/+34
Change-Id: I78ab01d1ca8ff5105448d3bbf3982753cdfc01d6 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add simulation of configfs for getting gadget stringsPawel Szewczyk2-0/+53
Allows to test getting gadget strings the same way as setting them. Change-Id: I3197865955e22d3ec38f7b81f8050e95f24cdaf8 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add setting gadget strs testsPawel Szewczyk1-0/+89
Change-Id: Ia7975f0a3a2e8e2bc6bff8bcd64430a6e26d1888 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Fix coding styleKrzysztof Opasiak1-14/+36
Change-Id: I1c47e3990bbd4dbfa620fc353a6cd65898dd6a30 Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add simulation of configfs for gadget strings settingPawel Szewczyk3-0/+132
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Stop using gadget attributes strings array directlyPawel Szewczyk1-2/+2
Instead of using array exported in usbg-internal.h we use function provided by libusbg for getting string of gadget attribute Change-Id: I6430f0de2926177e5f214713778dca16c33a3f40 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Try to iterate over all gadget attributesKrzysztof Opasiak1-1/+15
Change-Id: I0fa869ecf50ead08171ee1da4b7a5326694efbdc Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Test getting strings of gadget attributesPawel Szewczyk1-0/+51
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-03-06libusbg: tests: Add udc testsPawel Szewczyk1-0/+49
Change-Id: I9725395ff5a6bac7f4edfdaa4da9bbce3a3186ff Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add states with long stringsPawel Szewczyk1-0/+72
Change-Id: I92c185449293fd9426f151687832b3bdb0c57572 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add gadget attrs get/set testsPawel Szewczyk3-0/+226
Change-Id: I5ab4262a5532e07de9e6e919e6dde5dd49da4702 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add simulation of configfs for gadget attrs get/setPawel Szewczyk2-0/+190
Before executing libusbg 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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add getting config testsPawel Szewczyk3-0/+191
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-03-06libusbg: tests: Add getting configfs path testPawel Szewczyk1-0/+90
Change-Id: Ia7d368c8749d28235a4209d5a0de90dc6878717b Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add getting functions testsPawel Szewczyk3-10/+394
Change-Id: I89296562177061559de84aa5332d8dc9347d2e13 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Use cast_to_largest_integral_type()Krzysztof Opasiak1-1/+3
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>
2015-03-06libusbg: tests: Make some functions static, some move to headerPawel Szewczyk3-39/+40
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add doxygen macros for documenting test casesPawel Szewczyk2-27/+93
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> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Remove unused variablesKrzysztof Opasiak1-3/+0
Change-Id: I4db3a1d8683867c1e969898882f0589f477ebe4c Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add guarding macros in headerPawel Szewczyk1-0/+6
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Remove unnecessary newline. Change-Id: I3db3a1d8683867c1e969898882f0589f477ebe4b Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Build tests with autotoolsPawel Szewczyk6-33/+66
Change-Id: I1438caf6806d2197bcf20a63b56e33d9243fb2a0 Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add proper path comparingPawel Szewczyk2-9/+74
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>
2015-03-06libusbg: tests: Fix tests to use correct usbg_state fieldKrzysztof Opasiak3-13/+18
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-03-06libusbg: tests: Fix tests buildKrzysztof Opasiak2-0/+10
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-03-06libusbg: tests: Remove negative buffer testPawel Szewczyk1-8/+0
Size_t is unsigned and passing -1 as buffer length makes no sense. Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Rebased onto current head. Change-Id: I18e94b152706c4ff1a4ad4e58e53f9940963d194 Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-03-06libusbg: tests: Add options parsing to running scriptPawel Szewczyk1-1/+63
Change-Id: I1658663e8b7f14b5595ef806c5fca03ae10c830d Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Signed-off-by: Stanislaw Wadas <s.wadas@samsung.com> Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>