summaryrefslogtreecommitdiff
path: root/tests/usbg-test.c
diff options
context:
space:
mode:
authorPawel Szewczyk <p.szewczyk@samsung.com>2015-02-18 11:51:34 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2015-03-06 16:12:08 +0100
commit778ae7ba9028c399f7379341aa3f8f656427b3c0 (patch)
tree98c74dc33e6636bac881dd0d60980102be46923a /tests/usbg-test.c
parent757f921fafe9243d326e06e54399e699cb13e931 (diff)
downloadlibusbg-778ae7ba9028c399f7379341aa3f8f656427b3c0.tar.gz
libusbg-778ae7ba9028c399f7379341aa3f8f656427b3c0.tar.bz2
libusbg-778ae7ba9028c399f7379341aa3f8f656427b3c0.zip
libusbg: tests: Add simulation of configfs for getting bindings
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com> Add asserts for gadget, config and bindings. Change-Id: If6ce39332101826888c70790f8518876e03f8a44 Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'tests/usbg-test.c')
-rw-r--r--tests/usbg-test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/usbg-test.c b/tests/usbg-test.c
index 5359eb9..ae9e133 100644
--- a/tests/usbg-test.c
+++ b/tests/usbg-test.c
@@ -1082,3 +1082,37 @@ void for_each_test_config(void **state, ConfigTest fun)
}
}
}
+
+void for_each_binding(void **state, 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;
+
+ ts = (struct test_state *)(*state);
+ *state = NULL;
+
+ init_with_state(ts, &s);
+ *state = s;
+
+ for (tg = ts->gadgets; tg->name; tg++) {
+ g = usbg_get_gadget(s, tg->name);
+ assert_non_null(g);
+ for (tc = tg->configs; tc->label; tc++) {
+ c = usbg_get_config(g, tc->id, tc->label);
+ assert_non_null(c);
+
+ b = usbg_get_first_binding(c);
+ for (tb = tc->bindings; tb->name; ++tb) {
+ assert_non_null(b);
+ fun(tb, b);
+ b = usbg_get_next_binding(b);
+ }
+ }
+ }
+}