@@ -21,6 +21,7 @@
#include "lib/sdp.h"
#include "src/shared/tester.h"
#include "src/shared/util.h"
+#include "src/shared/ad.h"
#include "src/eir.h"
struct test_data {
@@ -539,6 +540,54 @@ static void print_debug(const char *str, void *user_data)
tester_debug("%s%s", prefix, str);
}
+static void test_ad(const struct test_data *test, struct eir_data *eir)
+{
+ struct bt_ad *ad;
+ GSList *list;
+
+ ad = bt_ad_new_with_data(test->eir_size, test->eir_data);
+ g_assert(ad);
+
+ g_assert_cmpint(bt_ad_get_flags(ad), ==, test->flags);
+ g_assert_cmpstr(bt_ad_get_name(ad), ==, test->name);
+ g_assert_cmpint(bt_ad_get_tx_power(ad), ==, test->tx_power);
+
+ if (test->uuid) {
+ int i;
+
+ for (i = 0; test->uuid[i]; i++) {
+ bt_uuid_t uuid;
+
+ bt_string_to_uuid(&uuid, test->uuid[i]);
+ g_assert(bt_ad_has_service_uuid(ad, &uuid));
+ }
+ }
+
+ for (list = eir->msd_list; list; list = list->next) {
+ struct eir_msd *msd = list->data;
+ struct bt_ad_manufacturer_data adm;
+
+ adm.manufacturer_id = msd->company;
+ adm.data = msd->data;
+ adm.len = msd->data_len;
+
+ g_assert(bt_ad_has_manufacturer_data(ad, &adm));
+ }
+
+ for (list = eir->sd_list; list; list = list->next) {
+ struct eir_sd *sd = list->data;
+ struct bt_ad_service_data ads;
+
+ bt_string_to_uuid(&ads.uuid, sd->uuid);
+ ads.data = sd->data;
+ ads.len = sd->data_len;
+
+ g_assert(bt_ad_has_service_data(ad, &ads));
+ }
+
+ bt_ad_unref(ad);
+}
+
static void test_parsing(gconstpointer data)
{
const struct test_data *test = data;
@@ -599,6 +648,8 @@ static void test_parsing(gconstpointer data)
"Service Data:");
}
+ test_ad(data, &eir);
+
eir_data_free(&eir);
tester_test_passed();
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> This enables the same tests done with eir_data using bt_ad. --- unit/test-eir.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)