aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2024-03-08 17:07:27 -0500
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2024-03-11 18:42:44 -0400
commitf5fecf037b1ea31612cb0226cc2634994a4671c4 (patch)
tree532b6638fa867367260a1156ad675c44e4839c54
parentc0c9e462be465ae3e9458256636f10f4d6acbedb (diff)
test-uhid: Test bt_uhid functions
This tests bt_uhid_create, bt_uhid_input and bt_uhid_destroy instead of directly submitting UHID_CREATE, UHID_INPUT and UHID_DESTROY.
-rw-r--r--unit/test-uhid.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/unit/test-uhid.c b/unit/test-uhid.c
index 8a8eef855b..516b5441bd 100644
--- a/unit/test-uhid.c
+++ b/unit/test-uhid.c
@@ -117,8 +117,8 @@ static gboolean send_pdu(gpointer user_data)
len = write(context->fd, pdu->data, pdu->size);
-
- util_hexdump('<', pdu->data, len, test_debug, "uHID: ");
+ if (tester_use_debug())
+ util_hexdump('<', pdu->data, len, test_debug, "uHID: ");
g_assert_cmpint(len, ==, pdu->size);
@@ -159,7 +159,8 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
g_assert(len > 0);
- util_hexdump('>', buf, len, test_debug, "uHID: ");
+ if (tester_use_debug())
+ util_hexdump('>', buf, len, test_debug, "uHID: ");
g_assert_cmpint(len, ==, pdu->size);
@@ -228,19 +229,31 @@ static const struct uhid_event ev_feature = {
static void test_client(gconstpointer data)
{
struct context *context = create_context(data);
+ int err;
- if (g_str_equal(context->data->test_name, "/uhid/command/create"))
- bt_uhid_send(context->uhid, &ev_create);
+ err = bt_uhid_create(context->uhid, "", NULL, NULL, 0, 0, 0, 0, NULL,
+ 0);
+ if (err < 0)
+ tester_test_failed();
- if (g_str_equal(context->data->test_name, "/uhid/command/destroy"))
- bt_uhid_send(context->uhid, &ev_destroy);
+ if (g_str_equal(context->data->test_name, "/uhid/command/destroy")) {
+ err = bt_uhid_destroy(context->uhid);
+ if (err < 0)
+ tester_test_failed();
+ }
if (g_str_equal(context->data->test_name,
- "/uhid/command/feature_answer"))
- bt_uhid_send(context->uhid, &ev_feature_answer);
+ "/uhid/command/feature_answer")) {
+ err = bt_uhid_send(context->uhid, &ev_feature_answer);
+ if (err < 0)
+ tester_test_failed();
+ }
- if (g_str_equal(context->data->test_name, "/uhid/command/input"))
- bt_uhid_send(context->uhid, &ev_input);
+ if (g_str_equal(context->data->test_name, "/uhid/command/input")) {
+ err = bt_uhid_input(context->uhid, 0, NULL, 0);
+ if (err < 0)
+ tester_test_failed();
+ }
context_quit(context);
}