diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-02-03 14:16:42 +0100 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-03-06 16:12:06 +0100 |
commit | 006c3a790682d358ddd49bbb5bdce2e33f6db651 (patch) | |
tree | 79a473feb01c04412496be95eda74a665906af2e /tests/usbg-test.c | |
parent | 33f4e951fca194cacd597ed10ab74c0d04988642 (diff) | |
download | libusbg-006c3a790682d358ddd49bbb5bdce2e33f6db651.tar.gz libusbg-006c3a790682d358ddd49bbb5bdce2e33f6db651.tar.bz2 libusbg-006c3a790682d358ddd49bbb5bdce2e33f6db651.zip |
libusbg: tests: Fix tests to use correct usbg_state field
Due to recent changes in usbg_state, lets
introduce configfs_path field in state test_state
structure and fill it.
Since now path field should not be filled as it's
filled by prepare_state() function and generates
subsystem path using given configfs path.
Change-Id: I50e606c9f8c5eb478ac48fc453840b9a3efdd117
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'tests/usbg-test.c')
-rw-r--r-- | tests/usbg-test.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/usbg-test.c b/tests/usbg-test.c index 95168f9..d4dff77 100644 --- a/tests/usbg-test.c +++ b/tests/usbg-test.c @@ -169,8 +169,8 @@ void prepare_gadget(struct test_state *state, struct test_gadget *g) 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); @@ -217,6 +217,13 @@ void prepare_state(struct test_state *state) { 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); @@ -309,17 +316,11 @@ static void push_gadget(struct test_gadget *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++; @@ -332,7 +333,7 @@ void push_init(struct test_state *state) 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); } @@ -384,6 +385,7 @@ void assert_state_equal(usbg_state *s, struct test_state *expected) 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++]); |