From: Howard Chung <howardchung@google.com>
To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com
Cc: Yun-Hao Chung <howardchung@chromium.org>,
Miao-chen Chou <mcchou@chromium.org>
Subject: [Bluez PATCH v1 02/14] unit: add uuid unit tests
Date: Thu, 8 Jul 2021 14:23:02 +0800 [thread overview]
Message-ID: <20210708142059.Bluez.v1.2.Ifd6e18068b54a0c9c8f8422ff502e46167d8b348@changeid> (raw)
In-Reply-To: <20210708062314.245754-1-howardchung@google.com>
From: Yun-Hao Chung <howardchung@chromium.org>
This adds uuid tests of bt_uuid_hash and bt_uuid_equal to
unit/test-uuid.c
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
---
unit/test-uuid.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/unit/test-uuid.c b/unit/test-uuid.c
index 0889630cfb34..ac613c5c2951 100644
--- a/unit/test-uuid.c
+++ b/unit/test-uuid.c
@@ -169,6 +169,34 @@ static void test_cmp(gconstpointer data)
tester_test_passed();
}
+static void test_hash(gconstpointer data)
+{
+ const struct uuid_test_data *test_data = data;
+ bt_uuid_t uuid1, uuid2;
+ guint uuid_h1, uuid_h2;
+
+ g_assert(bt_string_to_uuid(&uuid1, test_data->str) == 0);
+ g_assert(bt_string_to_uuid(&uuid2, test_data->str128) == 0);
+
+ uuid_h1 = bt_uuid_hash(&uuid1);
+ uuid_h2 = bt_uuid_hash(&uuid2);
+
+ g_assert(uuid_h1 == uuid_h2);
+ tester_test_passed();
+}
+
+static void test_equal(gconstpointer data)
+{
+ const struct uuid_test_data *test_data = data;
+ bt_uuid_t uuid1, uuid2;
+
+ g_assert(bt_string_to_uuid(&uuid1, test_data->str) == 0);
+ g_assert(bt_string_to_uuid(&uuid2, test_data->str128) == 0);
+
+ g_assert(bt_uuid_equal(&uuid1, &uuid2) == 1);
+ tester_test_passed();
+}
+
static const struct uuid_test_data compress[] = {
{
.str = "00001234-0000-1000-8000-00805f9b34fb",
@@ -226,26 +254,46 @@ int main(int argc, char *argv[])
tester_add("/uuid/base", &uuid_base, NULL, test_uuid, NULL);
tester_add("/uuid/base/str", &uuid_base, NULL, test_str, NULL);
tester_add("/uuid/base/cmp", &uuid_base, NULL, test_cmp, NULL);
+ tester_add("/uuid/base/hash", &uuid_base, NULL, test_hash, NULL);
+ tester_add("/uuid/base/equal", &uuid_base, NULL, test_equal, NULL);
tester_add("/uuid/sixteen1", &uuid_sixteen1, NULL, test_uuid, NULL);
tester_add("/uuid/sixteen1/str", &uuid_sixteen1, NULL, test_str, NULL);
tester_add("/uuid/sixteen1/cmp", &uuid_sixteen1, NULL, test_cmp, NULL);
+ tester_add("/uuid/sixteen1/hash", &uuid_sixteen1, NULL, test_hash,
+ NULL);
+ tester_add("/uuid/sixteen1/equal", &uuid_sixteen1, NULL, test_equal,
+ NULL);
tester_add("/uuid/sixteen2", &uuid_sixteen2, NULL, test_uuid, NULL);
tester_add("/uuid/sixteen2/str", &uuid_sixteen2, NULL, test_str, NULL);
tester_add("/uuid/sixteen2/cmp", &uuid_sixteen2, NULL, test_cmp, NULL);
+ tester_add("/uuid/sixteen2/hash", &uuid_sixteen2, NULL, test_hash,
+ NULL);
+ tester_add("/uuid/sixteen2/equal", &uuid_sixteen2, NULL, test_equal,
+ NULL);
tester_add("/uuid/thirtytwo1", &uuid_32_1, NULL, test_uuid, NULL);
tester_add("/uuid/thirtytwo1/str", &uuid_32_1, NULL, test_str, NULL);
tester_add("/uuid/thirtytwo1/cmp", &uuid_32_1, NULL, test_cmp, NULL);
+ tester_add("/uuid/thirtytwo1/hash", &uuid_32_1, NULL, test_hash, NULL);
+ tester_add("/uuid/thirtytwo1/equal", &uuid_32_1, NULL, test_equal,
+ NULL);
tester_add("/uuid/thirtytwo2", &uuid_32_2, NULL, test_uuid, NULL);
tester_add("/uuid/thritytwo2/str", &uuid_32_2, NULL, test_str, NULL);
tester_add("/uuid/thirtytwo2/cmp", &uuid_32_2, NULL, test_cmp, NULL);
+ tester_add("/uuid/thirtytwo2/hash", &uuid_32_2, NULL, test_hash, NULL);
+ tester_add("/uuid/thirtytwo2/equal", &uuid_32_2, NULL, test_equal,
+ NULL);
tester_add("/uuid/onetwentyeight", &uuid_128, NULL, test_uuid, NULL);
tester_add("/uuid/onetwentyeight/str", &uuid_128, NULL, test_str, NULL);
tester_add("/uuid/onetwentyeight/cmp", &uuid_128, NULL, test_cmp, NULL);
+ tester_add("/uuid/onetwentyeight/hash", &uuid_128, NULL, test_hash,
+ NULL);
+ tester_add("/uuid/onetwentyeight/equal", &uuid_128, NULL, test_equal,
+ NULL);
for (i = 0; malformed[i]; i++) {
char *testpath;
--
2.32.0.93.g670b81a890-goog
next prev parent reply other threads:[~2021-07-08 6:23 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 6:23 [Bluez PATCH v1 00/14] Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 01/14] lib: add hash functions for bt_uuid_t Howard Chung
2021-07-08 6:36 ` [Bluez,v1,01/14] " bluez.test.bot
2021-07-09 5:21 ` [Bluez PATCH v1 01/14] " Luiz Augusto von Dentz
2021-07-12 3:20 ` Yun-hao Chung
2021-07-08 6:23 ` Howard Chung [this message]
2021-07-08 6:23 ` [Bluez PATCH v1 03/14] core: add is_allowed property in btd_service Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 04/14] core: add adapter and device allowed_uuid functions Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 05/14] core: add device state and state callbacks Howard Chung
2021-07-09 5:34 ` Luiz Augusto von Dentz
2021-07-12 3:56 ` Yun-hao Chung
2021-07-08 6:23 ` [Bluez PATCH v1 06/14] audio: Remove Media1 interface when a2dp source disallowed Howard Chung
2021-07-09 5:49 ` Luiz Augusto von Dentz
2021-07-12 8:16 ` Yun-hao Chung
2021-07-12 16:37 ` Luiz Augusto von Dentz
2021-07-08 6:23 ` [Bluez PATCH v1 07/14] plugins: add a new plugin for admin_policy Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 08/14] plugins/admin_policy: add admin_policy adapter driver Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 09/14] plugins/admin_policy: add ServiceAllowList method Howard Chung
2021-07-09 6:01 ` Luiz Augusto von Dentz
2021-07-12 9:09 ` Yun-hao Chung
2021-07-12 16:41 ` Luiz Augusto von Dentz
2021-07-08 6:23 ` [Bluez PATCH v1 10/14] plugins/admin_policy: add ServiceAllowList property Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 11/14] plugins/admin_policy: add device state callback Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 12/14] plugins/admin_policy: add AffectedByPolicy property Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 13/14] plugins/admin_policy: persist policy settings Howard Chung
2021-07-08 6:23 ` [Bluez PATCH v1 14/14] core: fix a possible crash when removing devices Howard Chung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210708142059.Bluez.v1.2.Ifd6e18068b54a0c9c8f8422ff502e46167d8b348@changeid \
--to=howardchung@google.com \
--cc=howardchung@chromium.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=mcchou@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).