diff options
author | Pawel Szewczyk <p.szewczyk@samsung.com> | 2014-11-17 13:23:40 +0100 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-03-06 16:12:07 +0100 |
commit | 1e74257ced26d1c0bb9e423446a79fac681b9917 (patch) | |
tree | 673d291ee24725bf55383ef7aee023c6c4df095b /tests | |
parent | 364655dd837c91f0a63712d47eeafd3833598b6d (diff) | |
download | libusbg-1e74257ced26d1c0bb9e423446a79fac681b9917.tar.gz libusbg-1e74257ced26d1c0bb9e423446a79fac681b9917.tar.bz2 libusbg-1e74257ced26d1c0bb9e423446a79fac681b9917.zip |
libusbg: tests: Add getting configfs path test
Change-Id: Ia7d368c8749d28235a4209d5a0de90dc6878717b
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.c | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/test.c b/tests/test.c index d335947..516d68f 100644 --- a/tests/test.c +++ b/tests/test.c @@ -686,6 +686,72 @@ static void test_get_function_instance_len(void **state) } /** + * @brief Tests getting configfs path from usbg state + * @param[in,out] state Pointer to pointer to correctly initialized test state. + * When finished, it contains pointer to usbg_state which should be cleaned. + */ +static void test_get_configfs_path(void **state) +{ + usbg_state *s = NULL; + struct test_state *st; + const char *path; + + st = (struct test_state *)(*state); + *state = NULL; + + init_with_state(st, &s); + *state = s; + + path = usbg_get_configfs_path(s); + assert_path_equal(path, st->configfs_path); +} + +/** + * @brief Tests getting configfs path length from usbg state + * @param[in,out] state Pointer to pointer to correctly initialized test state. + * When finished, it contains pointer to usbg_state which should be cleaned. + */ +static void test_get_configfs_path_len(void **state) +{ + usbg_state *s = NULL; + struct test_state *st; + int ret, len; + + st = (struct test_state *)(*state); + *state = NULL; + + init_with_state(st, &s); + *state = s; + + ret = usbg_get_configfs_path_len(s); + len = strlen(st->configfs_path); + assert_int_equal(ret, len); +} + +/** + * @brief Tests copying configfs path into buffer + * @param[in,out] state Pointer to pointer to correctly initialized test state. + * When finished, it contains pointer to usbg_state which should be cleaned. + */ +static void test_cpy_configfs_path(void **state) +{ + usbg_state *s = NULL; + struct test_state *st; + char path[PATH_MAX]; + int ret; + + st = (struct test_state *)(*state); + *state = NULL; + + init_with_state(st, &s); + *state = s; + + ret = usbg_cpy_configfs_path(s, path, PATH_MAX); + assert_int_equal(ret, USBG_SUCCESS); + assert_path_equal(path, st->configfs_path); +} + +/** * @brief cleanup usbg state */ static void teardown_state(void **state) @@ -893,6 +959,30 @@ static UnitTest tests[] = { * usbg_get_function_type_str} */ unit_test(test_get_function_type_str_fail), + /** + * @usbg_test + * @test_desc{test_get_configfs_path_simple, + * heck if simple configfs path was returned correctly, + * usbg_get_configfs_path} + */ + USBG_TEST_TS("test_get_configfs_path_simple", + test_get_configfs_path, setup_simple_state), + /** + * @usbg_test + * @test_desc{test_get_configfs_path_len, + * Check if configfs path length is correctly calculated, + * usbg_get_configfs_path_len} + */ + USBG_TEST_TS("test_get_configfs_path_len_simple", + test_get_configfs_path_len, setup_simple_state), + /** + * @usbg_test + * @test_desc{test_cpy_configfs_path_simple, + * Copy simple configfs path into buffer and compare with original, + * usbg_cpy_configfs_path} + */ + USBG_TEST_TS("test_cpy_configfs_path_simple", + test_cpy_configfs_path, setup_simple_state), #ifndef DOXYGEN }; |