* @brief Simple state
*/
static struct test_state simple_state = {
- .path = "config",
+ .configfs_path = "config",
.gadgets = simple_gadgets,
.udcs = simple_udcs
};
* @brief State with all functions avaible
*/
static struct test_state all_funcs_state = {
- .path = "all_funcs_configfs",
+ .configfs_path = "all_funcs_configfs",
.gadgets = all_funcs_gadgets,
.udcs = simple_udcs
};
int usbg_ret;
push_init(in);
- usbg_ret = usbg_init(in->path, out);
+ usbg_ret = usbg_init(in->configfs_path, out);
assert_int_equal(usbg_ret, USBG_SUCCESS);
}
int tmp;
int count;
- tmp = asprintf(&g->path, "%s/usb_gadget", state->path);
- if (tmp < 0)
+ g->path = strdup(state->path);
+ if (!g->path)
fail();
free_later(g->path);
{
struct test_gadget *g;
int count = 0;
+ int tmp;
+
+ tmp = asprintf(&(state->path), "%s/usb_gadget", state->configfs_path);
+ if (tmp < 0)
+ fail();
+ free_later(state->path);
+
for (g = state->gadgets; g->name; g++) {
prepare_gadget(state, g);
void push_init(struct test_state *state)
{
char **udc;
- char *path;
struct test_gadget *g;
int count = 0;
int tmp;
- tmp = asprintf(&path, "%s/usb_gadget", state->path);
- if (tmp < 0)
- fail();
- free_later(path);
-
- EXPECT_OPENDIR(path);
+ EXPECT_OPENDIR(state->path);
for (udc = state->udcs; *udc; udc++)
count++;
for (g = state->gadgets; g->name; g++)
count++;
- PUSH_DIR(path, count);
+ PUSH_DIR(state->path, count);
for (g = state->gadgets; g->name; g++) {
PUSH_DIR_ENTRY(g->name, DT_DIR);
}
int i = 0;
assert_string_equal(s->path, expected->path);
+ assert_string_equal(s->configfs_path, expected->configfs_path);
usbg_for_each_gadget(g, s)
assert_gadget_equal(g, &expected->gadgets[i++]);
struct test_state
{
+ char *configfs_path;
+ /* filled by prepare_state() */
char *path;
struct test_gadget *gadgets;
char **udcs;
* @param[in] expected Pointer to test state struct with expected values
*/
void assert_state_equal(usbg_state *s, struct test_state *expected);
+