diff options
author | Pawel Szewczyk <p.szewczyk@samsung.com> | 2015-05-28 12:31:17 +0200 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-07-30 15:56:37 +0200 |
commit | 2458818f33eba80674bb806ec5e2c1a6ed94318c (patch) | |
tree | bb50a7db13df5e0f8c2ecc25f7efe00345044cd2 | |
parent | 60558e475177e62d546860edd8468f4bde577e67 (diff) | |
download | libusbg-2458818f33eba80674bb806ec5e2c1a6ed94318c.tar.gz libusbg-2458818f33eba80674bb806ec5e2c1a6ed94318c.tar.bz2 libusbg-2458818f33eba80674bb806ec5e2c1a6ed94318c.zip |
libusbg: tests: Add creating configuration test
Change-Id: I0e5c09b5664f8e15d9ba70e9a5682992341e0884
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
-rw-r--r-- | tests/test.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/test.c b/tests/test.c index 4e4783b..7c19198 100644 --- a/tests/test.c +++ b/tests/test.c @@ -1475,6 +1475,42 @@ static void test_set_config_attrs(void **state) } /** + * @brieg Test creating config + * @details Start with empty gadgets, add all functions from given state + * @param[in, out] state Pointer to pointer to correctly initialized test state, + * will point to usbg state when finished. + */ +static void test_create_config(void **state) +{ + usbg_state *s = NULL; + usbg_gadget *g = NULL; + usbg_config *c = NULL; + struct test_state *ts; + struct test_state *empty; + struct test_gadget *tg; + struct test_config *tc; + + ts = (struct test_state *)(*state); + *state = NULL; + + empty = build_empty_gadget_state(ts); + + init_with_state(empty, &s); + *state = s; + + for (tg = ts->gadgets; tg->name; tg++) { + g = usbg_get_gadget(s, tg->name); + assert_non_null(g); + for (tc = tg->configs; tc->label; tc++) { + pull_create_config(tc); + usbg_create_config(g, tc->id, tc->label, + tc->attrs, tc->strs, &c); + assert_config_equal(c, tc); + } + } +} + +/** * * @brief cleanup usbg state */ @@ -1931,6 +1967,14 @@ static struct CMUnitTest tests[] = { */ USBG_TEST_TS("test_set_config_attrs_random", test_set_config_attrs, setup_random_config_attrs_state), + /** + * @usbg_test + * @test_desc{test_create_config_random, + * Create config with random attributes + * usbg_create_config} + */ + USBG_TEST_TS("test_create_config_random", + test_create_config, setup_random_config_attrs_state), #ifndef DOXYGEN }; |