summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2016-12-14 13:09:26 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2016-12-14 13:09:26 +0100
commit4fe38766f7c48c2e05e6e62013f822001fcee494 (patch)
treebf47f029b25371ac9255ebbf8a75a98bd0cc8e6c
parent3749ccec3d73284b869d458e4832616adfae31e3 (diff)
downloadlibusbg-4fe38766f7c48c2e05e6e62013f822001fcee494.tar.gz
libusbg-4fe38766f7c48c2e05e6e62013f822001fcee494.tar.bz2
libusbg-4fe38766f7c48c2e05e6e62013f822001fcee494.zip
libusbgx: tests: Fix indent and line length
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>
-rw-r--r--tests/test.c90
-rw-r--r--tests/usbg-test.c69
-rw-r--r--tests/usbg-test.h9
3 files changed, 108 insertions, 60 deletions
diff --git a/tests/test.c b/tests/test.c
index 33760b0..0063d55 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -190,7 +190,8 @@ static struct test_gadget all_funcs_gadgets[] = {
};
static struct test_gadget long_udc_gadgets[] = {
- GADGET("long_udc_gadgets", long_usbg_string, simple_confs, simple_funcs),
+ GADGET("long_udc_gadgets", long_usbg_string,
+ simple_confs, simple_funcs),
TEST_GADGET_LIST_END
};
@@ -238,16 +239,20 @@ struct test_gadget_strs_data {
/**
* @brief Simple state
*/
-static struct test_state simple_state = STATE("config", simple_gadgets, simple_udcs);
+static struct test_state simple_state =
+ STATE("config", simple_gadgets, simple_udcs);
/**
* @brief State with all functions avaible
*/
-static struct test_state all_funcs_state = STATE("all_funcs_configfs", all_funcs_gadgets, simple_udcs);
+static struct test_state all_funcs_state =
+ STATE("all_funcs_configfs", all_funcs_gadgets, simple_udcs);
-static struct test_state long_path_state = STATE(long_path_str, simple_gadgets, simple_udcs);
+static struct test_state long_path_state =
+ STATE(long_path_str, simple_gadgets, simple_udcs);
-static struct test_state long_udc_state = STATE("simple_path", long_udc_gadgets, long_udcs);
+static struct test_state long_udc_state =
+ STATE("simple_path", long_udc_gadgets, long_udcs);
static struct usbg_config_attrs *get_random_config_attrs()
{
@@ -301,19 +306,22 @@ static void *prepare_state_with_config_attrs(struct test_state *state,
static int setup_max_config_attrs_state(void **state)
{
- *state = prepare_state_with_config_attrs(&simple_state, &max_config_attrs);
+ *state = prepare_state_with_config_attrs(&simple_state,
+ &max_config_attrs);
return 0;
}
static int setup_min_config_attrs_state(void **state)
{
- *state = prepare_state_with_config_attrs(&simple_state, &min_config_attrs);
+ *state = prepare_state_with_config_attrs(&simple_state,
+ &min_config_attrs);
return 0;
}
static int setup_random_config_attrs_state(void **state)
{
- *state = prepare_state_with_config_attrs(&simple_state, get_random_config_attrs());
+ *state = prepare_state_with_config_attrs(&simple_state,
+ get_random_config_attrs());
return 0;
}
@@ -763,7 +771,8 @@ static void test_init(void **state)
/**
* @brief Test getting function by name
- * @param[in] state Pointer to pointer to correctly initialized test_state structure
+ * @param[in] state Pointer to pointer to correctly initialized
+ * test_state structure
*/
static void test_get_function(void **state)
{
@@ -778,7 +787,8 @@ static void test_get_function(void **state)
* @brief Tests usbg_get_function with some non-existing functions
* @details Check if get function will return NULL, when invalid
* functions names and types are passed as arguments and will not cause crash.
- * @param[in] state Pointer to pointer to correctly initialized test_state structure
+ * @param[in] state Pointer to pointer to correctly initialized
+ * test_state structure
*/
static void test_get_function_fail(void **state)
{
@@ -802,7 +812,8 @@ static void test_get_function_fail(void **state)
/**
* @brief Tests function type translation to string
- * @param[in] state Pointer to pointer to correctly initialized test_state structure
+ * @param[in] state Pointer to pointer to correctly initialized
+ * test_state structure
* @details Check if get_function_type_str returns proper strings for all types.
*/
static void test_get_function_type_str(void **state)
@@ -844,8 +855,10 @@ static struct {
/**
* @brief Tests gadget codeing name getting
- * @param[in] state Pointer to pointer to correctly initialized test_state codeucture
- * @details Check if usbg_get_gadget_code_name returns proper codeings for all types.
+ * @param[in] state Pointer to pointer to correctly initialized
+ * test_state structure
+ * @details Check if usbg_get_gadget_code_name returns proper
+ * codeings for all types.
*/
static void test_get_gadget_str_name(void **state)
{
@@ -861,7 +874,8 @@ static void test_get_gadget_str_name(void **state)
/**
* @brief Tests gadget codeing code getting by its name
- * @param[in] state Pointer to pointer to correctly initialized test_state codeucture
+ * @param[in] state Pointer to pointer to correctly initialized
+ * test_state structure
* @details Check if usbg_lookup_gadget_code returns values matching codeings
*/
static void test_lookup_gadget_str(void **state)
@@ -894,7 +908,8 @@ static void test_get_function_type_str_fail(void **state)
* @param[in] f Usbg function
* @param[in] tf Test function which should match f
*/
-static void try_get_function_instance(usbg_function *f, struct test_function *tf)
+static void try_get_function_instance(usbg_function *f,
+ struct test_function *tf)
{
const char *str;
@@ -904,7 +919,8 @@ static void try_get_function_instance(usbg_function *f, struct test_function *tf
/**
* @brief Tests getting function instance from usbg_function structure
- * @param[in] state Pointer to pointer to correctly initialized test_state structure
+ * @param[in] state Pointer to pointer to correctly initialized
+ * test_state structure
* @details Check if returned instance name is correct.
*/
static void test_get_function_instance(void **state)
@@ -921,7 +937,8 @@ static void test_get_function_instance(void **state)
* @param[in] f Usbg function
* @param[in] tf Test function which should match f
*/
-static void try_get_function_instance_s(usbg_function *f, struct test_function *tf)
+static void try_get_function_instance_s(usbg_function *f,
+ struct test_function *tf)
{
char str[USBG_MAX_NAME_LENGTH];
int ret;
@@ -938,7 +955,8 @@ static void try_get_function_instance_s(usbg_function *f, struct test_function *
}
/**
- * @brief Tests copying function instance from usbg_function structure into buffer
+ * @brief Tests copying function instance from usbg_function structure
+ * into buffer
* @param[in] state Pointer to pointer to correctly initialized state
* @details Check if buffer contains expected string
*/
@@ -984,7 +1002,8 @@ static void test_get_function_type(void **state)
* @param[in] f Usbg function
* @param[in] tf Test function which should match f
*/
-static void try_get_function_instance_len(usbg_function *f, struct test_function *tf)
+static void try_get_function_instance_len(usbg_function *f,
+ struct test_function *tf)
{
size_t len;
char buf;
@@ -1391,7 +1410,8 @@ static void test_get_gadget_attr_str_fail(void **state)
/**
* @brief set gadget strings
* @details Also do it one by one
- * @param[in] data Pointer to correctly initialized test_gadget_strs_data structure
+ * @param[in] data Pointer to correctly initialized
+ * test_gadget_strs_data structure
*/
static void test_set_gadget_strs(void **data)
{
@@ -1416,35 +1436,44 @@ static void test_set_gadget_strs(void **data)
assert_int_equal(ret, 0);
for (i = 0; i < GADGET_STR_MAX; i++)
- pull_gadget_string(tg, LANG_US_ENG, i, get_gadget_str(ts->strs, i));
+ pull_gadget_string(tg, LANG_US_ENG, i,
+ get_gadget_str(ts->strs, i));
- ret = usbg_set_gadget_serial_number(g, LANG_US_ENG, ts->strs->str_ser);
+ ret = usbg_set_gadget_serial_number(g, LANG_US_ENG,
+ ts->strs->str_ser);
assert_int_equal(ret, 0);
- ret = usbg_set_gadget_manufacturer(g, LANG_US_ENG, ts->strs->str_mnf);
+ ret = usbg_set_gadget_manufacturer(g, LANG_US_ENG,
+ ts->strs->str_mnf);
assert_int_equal(ret, 0);
- ret = usbg_set_gadget_product(g, LANG_US_ENG, ts->strs->str_prd);
+ ret = usbg_set_gadget_product(g, LANG_US_ENG,
+ ts->strs->str_prd);
assert_int_equal(ret, 0);
for (i = 0; i < GADGET_STR_MAX; i++)
- pull_gadget_string(tg, LANG_US_ENG, i, get_gadget_str(ts->strs, i));
+ pull_gadget_string(tg, LANG_US_ENG,
+ i, get_gadget_str(ts->strs, i));
- ret = usbg_set_gadget_str(g, USBG_STR_SERIAL_NUMBER, LANG_US_ENG, ts->strs->str_ser);
+ ret = usbg_set_gadget_str(g, USBG_STR_SERIAL_NUMBER,
+ LANG_US_ENG, ts->strs->str_ser);
assert_int_equal(ret, 0);
- ret = usbg_set_gadget_str(g, USBG_STR_MANUFACTURER, LANG_US_ENG, ts->strs->str_mnf);
+ ret = usbg_set_gadget_str(g, USBG_STR_MANUFACTURER,
+ LANG_US_ENG, ts->strs->str_mnf);
assert_int_equal(ret, 0);
- ret = usbg_set_gadget_str(g, USBG_STR_PRODUCT, LANG_US_ENG, ts->strs->str_prd);
+ ret = usbg_set_gadget_str(g, USBG_STR_PRODUCT,
+ LANG_US_ENG, ts->strs->str_prd);
assert_int_equal(ret, 0);
}
}
/**
* @brief get gadget strings
- * @param[in] data Pointer to correctly initialized test_gadget_strs_data structure
+ * @param[in] data Pointer to correctly initialized
+ * test_gadget_strs_data structure
*/
static void test_get_gadget_strs(void **data)
{
@@ -2599,7 +2628,8 @@ static int apply_test_config(FILE *input)
test_name = config_setting_get_string(node);
if (!test_name) {
- fprintf(stderr, "Incorrect tests list. Element %d\n", i);
+ fprintf(stderr,
+ "Incorrect tests list. Element %d\n", i);
ret = -EINVAL;
goto out;
}
diff --git a/tests/usbg-test.c b/tests/usbg-test.c
index c8fabf9..52bb890 100644
--- a/tests/usbg-test.c
+++ b/tests/usbg-test.c
@@ -175,7 +175,8 @@ static int test_config_cmp(struct test_config *a, struct test_config *b)
return strcoll(a->name, b->name);
}
-void prepare_binding(struct test_binding *b, struct test_function *f, char *fpath)
+void prepare_binding(struct test_binding *b, struct test_function *f,
+ char *fpath)
{
if (!f->name)
prepare_function(f, fpath);
@@ -278,7 +279,7 @@ void prepare_gadget(struct test_state *state, struct test_gadget *g)
}
static void cpy_test_function(struct test_function *to,
- struct test_function *from)
+ struct test_function *from)
{
/* Reuse instance */
to->instance = from->instance;
@@ -580,8 +581,10 @@ static void push_binding(struct test_config *conf, struct test_binding *binding)
char *s_path;
char *d_path;
- safe_asprintf(&s_path, "%s/%s/%s", conf->path, conf->name, binding->name);
- safe_asprintf(&d_path, "%s/%s", binding->target->path, binding->target->name);
+ safe_asprintf(&s_path, "%s/%s/%s",
+ conf->path, conf->name, binding->name);
+ safe_asprintf(&d_path, "%s/%s",
+ binding->target->path, binding->target->name);
PUSH_LINK(s_path, d_path, USBG_MAX_PATH_LENGTH - 1);
}
@@ -700,13 +703,14 @@ int get_gadget_attr(struct usbg_gadget_attrs *attrs, usbg_gadget_attr attr)
}
void pull_gadget_attribute(struct test_gadget *gadget,
- usbg_gadget_attr attr, int value)
+ usbg_gadget_attr attr, int value)
{
char *path;
char *content;
safe_asprintf(&path, "%s/%s/%s",
- gadget->path, gadget->name, usbg_get_gadget_attr_str(attr));
+ gadget->path, gadget->name,
+ usbg_get_gadget_attr_str(attr));
safe_asprintf(&content, "0x%x\n", value);
@@ -714,13 +718,14 @@ void pull_gadget_attribute(struct test_gadget *gadget,
}
void push_gadget_attribute(struct test_gadget *gadget,
- usbg_gadget_attr attr, int value)
+ usbg_gadget_attr attr, int value)
{
char *path;
char *content;
safe_asprintf(&path, "%s/%s/%s",
- gadget->path, gadget->name, usbg_get_gadget_attr_str(attr));
+ gadget->path, gadget->name,
+ usbg_get_gadget_attr_str(attr));
safe_asprintf(&content, "0x%x\n", value);
PUSH_FILE(path, content);
@@ -787,7 +792,8 @@ void push_config_attribute(struct test_config *config, config_attr attr,
char *path;
char *content;
- safe_asprintf(&path, "%s/%s/%s", config->path, config->name, config_attr_names[attr]);
+ safe_asprintf(&path, "%s/%s/%s",
+ config->path, config->name, config_attr_names[attr]);
switch (config_attr_format[attr]) {
case FORMAT_HEX:
@@ -817,7 +823,8 @@ void pull_config_attribute(struct test_config *config, config_attr attr,
char *path;
char *content;
- safe_asprintf(&path, "%s/%s/%s", config->path, config->name, config_attr_names[attr]);
+ safe_asprintf(&path, "%s/%s/%s",
+ config->path, config->name, config_attr_names[attr]);
switch (config_attr_format[attr]) {
case FORMAT_HEX:
@@ -889,7 +896,7 @@ static void pull_gadget_str_dir(struct test_gadget *gadget, int lang)
}
static void pull_gadget_str(struct test_gadget *gadget, const char *attr_name,
- int lang, const char *content)
+ int lang, const char *content)
{
char *path;
@@ -912,7 +919,8 @@ void pull_gadget_strs(struct test_gadget *gadget, int lang,
pull_gadget_str_dir(gadget, lang);
for (i = 0; i < GADGET_STR_MAX; i++)
- pull_gadget_str(gadget, gadget_str_names[i], lang, get_gadget_str(strs, i));
+ pull_gadget_str(gadget, gadget_str_names[i],
+ lang, get_gadget_str(strs, i));
}
static void push_gadget_str_dir(struct test_gadget *gadget, int lang)
@@ -926,7 +934,7 @@ static void push_gadget_str_dir(struct test_gadget *gadget, int lang)
}
static void push_gadget_str(struct test_gadget *gadget, const char *attr_name,
- int lang, const char *content)
+ int lang, const char *content)
{
char *path;
@@ -942,7 +950,8 @@ void push_gadget_strs(struct test_gadget *gadget, int lang,
push_gadget_str_dir(gadget, lang);
for (i = 0; i < GADGET_STR_MAX; i++)
- push_gadget_str(gadget, gadget_str_names[i], lang, get_gadget_str(strs, i));
+ push_gadget_str(gadget, gadget_str_names[i],
+ lang, get_gadget_str(strs, i));
}
void pull_config_string(struct test_config *config, int lang, const char *str)
@@ -1018,7 +1027,7 @@ void pull_create_config(struct test_config *tc)
#define ETHER_ADDR_STR_LEN 19
static void push_serial_attrs(struct test_function *func,
- int *port_num)
+ int *port_num)
{
char *path;
char *content;
@@ -1029,7 +1038,7 @@ static void push_serial_attrs(struct test_function *func,
}
static void push_net_attrs(struct test_function *func,
- struct usbg_f_net_attrs *attrs)
+ struct usbg_f_net_attrs *attrs)
{
char *path;
char *content;
@@ -1060,7 +1069,7 @@ static void push_net_attrs(struct test_function *func,
}
static void push_phonet_attrs(struct test_function *func,
- char **ifname)
+ char **ifname)
{
char *path;
char *content;
@@ -1227,13 +1236,15 @@ int path_cmp(const char *actual, const char *expected)
return SIGNUM(*a - *b);
}
-int path_equal_display_error(const LargestIntegralType actual, const LargestIntegralType expected)
+int path_equal_display_error(const LargestIntegralType actual,
+ const LargestIntegralType expected)
{
if (path_cmp((const char *)actual, (const char *)expected) == 0) {
return 1;
}
- fprintf(stderr, "%s != %s\n", (const char *)actual, (const char *)expected);
+ fprintf(stderr, "%s != %s\n",
+ (const char *)actual, (const char *)expected);
return 0;
}
@@ -1255,13 +1266,15 @@ int hex_str_cmp(const char *actual, const char *expected)
return SIGNUM(a - b);
}
-int hex_str_equal_display_error(const LargestIntegralType actual, const LargestIntegralType expected)
+int hex_str_equal_display_error(const LargestIntegralType actual,
+ const LargestIntegralType expected)
{
if (hex_str_cmp((const char *)actual, (const char *)expected) == 0) {
return 1;
}
- fprintf(stderr, "%s != %s\n", (const char *)actual, (const char *)expected);
+ fprintf(stderr, "%s != %s\n",
+ (const char *)actual, (const char *)expected);
return 0;
}
@@ -1271,7 +1284,8 @@ void assert_gadget_attrs_equal(struct usbg_gadget_attrs *actual,
int i;
for (i = USBG_GADGET_ATTR_MIN; i < USBG_GADGET_ATTR_MAX; i++)
- assert_int_equal(get_gadget_attr(actual, i), get_gadget_attr(expected, i));
+ assert_int_equal(get_gadget_attr(actual, i),
+ get_gadget_attr(expected, i));
}
void assert_gadget_strs_equal(struct usbg_gadget_strs *actual,
@@ -1279,7 +1293,8 @@ void assert_gadget_strs_equal(struct usbg_gadget_strs *actual,
{
int i;
for (i = 0; i < GADGET_STR_MAX; i++)
- assert_string_equal(get_gadget_str(actual, i), get_gadget_str(expected, i));
+ assert_string_equal(get_gadget_str(actual, i),
+ get_gadget_str(expected, i));
}
void assert_f_serial_attrs_equal(int *actual, int *expected)
@@ -1291,7 +1306,7 @@ static void assert_ether_addrs_equal(const struct ether_addr *ea1,
const struct ether_addr *ea2)
{
assert_memory_equal(ea1->ether_addr_octet, ea2->ether_addr_octet,
- ETHER_ADDR_LEN);
+ ETHER_ADDR_LEN);
}
void assert_f_net_attrs_equal(struct usbg_f_net_attrs *actual,
@@ -1341,7 +1356,8 @@ void assert_function_attrs_equal(void *actual, void *expected,
}
-void for_each_test_function(struct test_state *ts, usbg_state *s, FunctionTest fun)
+void for_each_test_function(struct test_state *ts, usbg_state *s,
+ FunctionTest fun)
{
struct test_gadget *tg;
struct test_function *tf;
@@ -1401,7 +1417,8 @@ void for_each_binding(struct test_state *ts, usbg_state *s, BindingTestFunc fun)
}
}
-void for_each_test_gadget(struct test_state *ts, usbg_state *s, GadgetTestFunc fun)
+void for_each_test_gadget(struct test_state *ts, usbg_state *s,
+ GadgetTestFunc fun)
{
struct test_gadget *tg;
usbg_gadget *g = NULL;
diff --git a/tests/usbg-test.h b/tests/usbg-test.h
index 3748bf7..d0cc9b7 100644
--- a/tests/usbg-test.h
+++ b/tests/usbg-test.h
@@ -199,7 +199,7 @@ int get_gadget_attr(struct usbg_gadget_attrs *attrs, usbg_gadget_attr attr);
* @param[in] value Attributes value
**/
void push_gadget_attribute(struct test_gadget *gadget,
- usbg_gadget_attr attr, int value);
+ usbg_gadget_attr attr, int value);
/**
* @brief Prepare to read given attribute by libusbg
@@ -208,7 +208,7 @@ void push_gadget_attribute(struct test_gadget *gadget,
* @param[in] value Attributes value
**/
void pull_gadget_attribute(struct test_gadget *gadget,
- usbg_gadget_attr attr, int value);
+ usbg_gadget_attr attr, int value);
/**
* @brief Prepare fake filesystem to get given gadget attributes
@@ -268,7 +268,7 @@ const char *get_gadget_str(struct usbg_gadget_strs *strs, gadget_str str);
* @param[in] content String expected to be set
*/
void pull_gadget_string(struct test_gadget *gadget, int lang,
- gadget_str str, const char *content);
+ gadget_str str, const char *content);
/**
* @brief Prepare filesystem to set given gadget strings
@@ -461,7 +461,8 @@ void assert_gadget_attrs_equal(struct usbg_gadget_attrs *actual,
* @param[in] expected Pointer to expected attributes obejct
* @param[in] type Type of function, which attributes are checked
*/
-void assert_function_attrs_equal(void *actual, void *expected, usbg_function_type type);
+void assert_function_attrs_equal(void *actual, void *expected,
+ usbg_function_type type);
/**
* @brief Assert that given gadget strings are equal