*/
static void test_get_gadget(void **state)
{
- for_each_test_gadget(state, assert_gadget_equal);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_gadget(ts, s, assert_gadget_equal);
}
/**
*/
static void test_get_gadget_name(void **state)
{
- for_each_test_gadget(state, try_get_gadget_name);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_gadget(ts, s, try_get_gadget_name);
}
static void try_get_gadget_name_len(usbg_gadget *g, struct test_gadget *tg)
*/
static void test_get_gadget_name_len(void **state)
{
- for_each_test_gadget(state, try_get_gadget_name_len);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_gadget(ts, s, try_get_gadget_name_len);
}
/**
*/
static void test_cpy_gadget_name(void **state)
{
- for_each_test_gadget(state, try_cpy_gadget_name);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_gadget(ts, s, try_cpy_gadget_name);
}
/**
*/
static void test_get_function(void **state)
{
- for_each_test_function(state, assert_func_equal);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_function(ts, s, assert_func_equal);
}
/**
*/
static void test_get_function_instance(void **state)
{
- for_each_test_function(state, try_get_function_instance);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_function(ts, s, try_get_function_instance);
}
/**
*/
static void test_cpy_function_instance(void **state)
{
- for_each_test_function(state, try_cpy_function_instance);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_function(ts, s, try_cpy_function_instance);
}
/**
*/
static void test_get_function_type(void **state)
{
- for_each_test_function(state, try_get_function_type);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_function(ts, s, try_get_function_type);
}
/**
*/
static void test_get_function_instance_len(void **state)
{
- for_each_test_function(state, try_get_function_instance_len);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_function(ts, s, try_get_function_instance_len);
}
/**
*/
static void test_get_config(void **state)
{
- for_each_test_config(state, assert_config_equal);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_config(ts, s, assert_config_equal);
}
static void test_get_config_without_label(void **state)
*/
static void test_get_config_label(void **state)
{
- for_each_test_config(state, try_get_config_label);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_config(ts, s, try_get_config_label);
}
/**
*/
static void test_get_config_id(void **state)
{
- for_each_test_config(state, try_get_config_id);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_config(ts, s, try_get_config_id);
}
/**
*/
static void test_get_binding_target(void **state)
{
- for_each_binding(state, try_get_binding_target);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_binding(ts, s, try_get_binding_target);
}
/**
*/
static void test_get_binding_name(void **state)
{
- for_each_binding(state, try_get_binding_name);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_binding(ts, s, try_get_binding_name);
}
/**
*/
static void test_get_binding_name_len(void **state)
{
- for_each_binding(state, try_get_binding_name_len);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_binding(ts, s, try_get_binding_name_len);
}
/**
*/
static void test_set_config_strs(void **state)
{
- for_each_test_config(state, try_set_config_strs);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_config(ts, s, try_set_config_strs);
}
/**
*/
static void test_set_config_string(void **state)
{
- for_each_test_config(state, try_set_config_string);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_config(ts, s, try_set_config_string);
}
/**
*/
static void test_get_config_strs(void **state)
{
- for_each_test_config(state, try_get_config_strs);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_config(ts, s, try_get_config_strs);
}
/**
*/
static void test_get_config_attrs(void **state)
{
- for_each_test_config(state, try_get_config_attrs);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_config(ts, s, try_get_config_attrs);
}
/**
*/
static void test_set_config_attrs(void **state)
{
- for_each_test_config(state, try_set_config_attrs);
+ usbg_state *s = NULL;
+ struct test_state *ts;
+
+ safe_init_with_state(state, &ts, &s);
+ for_each_test_config(ts, s, try_set_config_attrs);
}
/**
assert_string_equal(get_gadget_str(actual, i), get_gadget_str(expected, i));
}
-void for_each_test_function(void **state, FunctionTest fun)
+void for_each_test_function(struct test_state *ts, usbg_state *s, FunctionTest fun)
{
- usbg_state *s = NULL;
- struct test_state *ts;
struct test_gadget *tg;
struct test_function *tf;
usbg_gadget *g = NULL;
usbg_function *f = NULL;
- safe_init_with_state(state, &ts, &s);
-
for (tg = ts->gadgets; tg->name; ++tg) {
g = usbg_get_gadget(s, tg->name);
assert_non_null(g);
}
}
-void for_each_test_config(void **state, ConfigTest fun)
+void for_each_test_config(struct test_state *ts, usbg_state *s, ConfigTest fun)
{
- usbg_state *s = NULL;
usbg_gadget *g = NULL;
usbg_config *c = NULL;
- struct test_state *ts;
struct test_gadget *tg;
struct test_config *tc;
- safe_init_with_state(state, &ts, &s);
-
for (tg = ts->gadgets; tg->name; tg++) {
g = usbg_get_gadget(s, tg->name);
assert_non_null(g);
}
}
-void for_each_binding(void **state, BindingTestFunc fun)
+void for_each_binding(struct test_state *ts, usbg_state *s, BindingTestFunc fun)
{
- struct test_state *ts;
struct test_gadget *tg;
struct test_config *tc;
struct test_binding *tb;
- usbg_state *s = NULL;
usbg_gadget *g = NULL;
usbg_config *c = NULL;
usbg_binding *b = NULL;
- safe_init_with_state(state, &ts, &s);
-
for (tg = ts->gadgets; tg->name; tg++) {
g = usbg_get_gadget(s, tg->name);
assert_non_null(g);
}
}
-void for_each_test_gadget(void **state, GadgetTestFunc fun)
+void for_each_test_gadget(struct test_state *ts, usbg_state *s, GadgetTestFunc fun)
{
- struct test_state *ts;
struct test_gadget *tg;
- usbg_state *s = NULL;
usbg_gadget *g = NULL;
- safe_init_with_state(state, &ts, &s);
-
for (tg = ts->gadgets; tg->name; ++tg) {
g = usbg_get_gadget(s, tg->name);
assert_non_null(g);
/**
* @brief Call given function for all usb functions present in given state
- * @param[in] state Properly prepared state to be tested
+ * @param[in] ts Test state to be tested
+ * @param[in] s Properly prepared usbg state to be tested
* @param[in] fun Function to be called on each usb function in state
*/
-void for_each_test_function(void **state, FunctionTest fun);
+void for_each_test_function(struct test_state *ts, usbg_state *s, FunctionTest fun);
/**
* @brief Function that performs some test on given usbg config
/**
* @brief Call given function for all usb configs present in given state
- * @param[in] state Properly prepared state to be tested
+ * @param[in] ts Test state to be tested
+ * @param[in] s Properly prepared usbg state to be tested
* @param[in] fun Function to be called on each usb function in state
*/
-void for_each_test_config(void **state, ConfigTest fun);
+void for_each_test_config(struct test_state *ts, usbg_state *s, ConfigTest fun);
/**
* @brief Function that performs test on given usbg binding
/**
* @brief Call given function for all usb bindings present in given state
- * @param[in] state Properly prepared state to be tested
+ * @param[in] ts Test state to be tested
+ * @param[in] s Properly prepared usbg state to be tested
* @param[in] fun Function to be called on each usb binding in state
*/
-void for_each_binding(void **state, BindingTestFunc fun);
+void for_each_binding(struct test_state *ts, usbg_state *s, BindingTestFunc fun);
/**
* @brief Function that performs test on given usbg gadget
/**
* @brief Call given function for all usb gadgets present in given state
- * @param[in] state Properly prepared state to be tested
+ * @param[in] ts Test state to be tested
+ * @param[in] s Properly prepared usbg state to be tested
* @param[in] fun Function to be called on each usb gadget in state
*/
-void for_each_test_gadget(void **state, GadgetTestFunc fun);
+void for_each_test_gadget(struct test_state *ts, usbg_state *s, GadgetTestFunc fun);
static inline void *safe_calloc(int count, size_t size)
{