Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp279873rwp; Wed, 12 Jul 2023 13:12:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlH16gyE9hQtD+L4yoEd9wQTSLg9a9g/t2+PJ9kWo6y9zbPc6k0aNZU8cMeRoxmKDHHCiSA0 X-Received: by 2002:a17:906:1ecf:b0:982:30e3:ddcb with SMTP id m15-20020a1709061ecf00b0098230e3ddcbmr15836507ejj.65.1689192749027; Wed, 12 Jul 2023 13:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689192749; cv=none; d=google.com; s=arc-20160816; b=zQ+bbQ3ZhyF8YVfrmwZo8uibFc5QRDpe0oZbOw0QKeKGOmHGAcUvH4FQ3Nreve/4QL Qw41eXHNT4U+rsoNmeUIcBCp6MkBkBUaWCN2YDtQySqbbkQ3fEE0OF5iWZGOb5kQGJaT NTGNBBAlNRG94MoZqSH7xb8LFtgaA6MNMXqVEI0TFaoqjQUfa85RpR8hMJ4diMHqSis5 +jh8/5HEV8wdHdmQS1IdKA9N2eunJMJ2YfR7GLuS+VvRt8S75aFJfA807FJOSq0nnEJZ 4GrSOZqC+BkcgExwSeO2Mn3tPklDtYuRFU4t4ieI8L4jPli0KDmzPwRZwOnfSoJqlGr8 /qZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=6153T5ieEnaG37eYeGkcbX1K38aAKSTQ2AYPcqQcsRE=; fh=V2LL5OuZUBGeSu6TXDWykcThOoazTGUpkln19rrO2KM=; b=wLe7mH1kQ54ps5ZfMQC5kpg6g2RpeJCUx3Q7LKMkSIFRh3JwNl9alFCubHabimL44X pGnpnUTQeaPDXqbN4EKvXG+eSjzYBhW2PsS3pb1Jo4Dg1EFyGnDxcQrXB/jhP3c0ikfk netIqW+76IGlqnxclC3XXwgTRXOITpXaPe0zYnZhVU+gq2XZ1du2KltVnknp7bQMNO6r L/su7MNepiE0pwLaZE8Cgy78DsSCkwdIOGxY/TbcmSFhnNbMF7jj50/5xsvvoDs5q0e6 bvS8eg4N5iWs2ZYcEsyGQLTN89eW3SVeU3QudJX4t/BQEK+eWg0B+r+9SgMZr5MUzuSz 2aog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=aadf56kd; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i3-20020a1709063c4300b00988e963c3adsi5260659ejg.755.2023.07.12.13.12.04; Wed, 12 Jul 2023 13:12:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=aadf56kd; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232584AbjGLTjH (ORCPT + 99 others); Wed, 12 Jul 2023 15:39:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232541AbjGLTjG (ORCPT ); Wed, 12 Jul 2023 15:39:06 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FD1A1FCC for ; Wed, 12 Jul 2023 12:39:05 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-53482b44007so12971a12.2 for ; Wed, 12 Jul 2023 12:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689190744; x=1691782744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6153T5ieEnaG37eYeGkcbX1K38aAKSTQ2AYPcqQcsRE=; b=aadf56kdHNMP9H3lgiWOx9ZEkE5cbj0eshPjkBbj8GlnwvM4fZSRyFhtnv4TMrE12k 8Li6lzfeSMsyNM2LzFKRFiDSgUwcj7g3QANOVVDhPb5aBeBsKQEyJ9mEWmTajB7fukC4 NfFab8NPoFACnsUDEaIyMu625RlOjqw3lljHGC95MhSP2XkXtsm1UMlQ21plKrVElI5T U9GWNVCDMK+U+tJHQfZniYi0EOsL4bqmZrrS4C+lqbALYE7hM7Vnz5GEQbOHjfDDIRQt 7zu5osmXaFnzBIdAPJivvKfHuqmZvOUvd9b04G7xfnfScOT+cp1O7kmGPTxwqzwXe1Fc 9aBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689190744; x=1691782744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6153T5ieEnaG37eYeGkcbX1K38aAKSTQ2AYPcqQcsRE=; b=ZskOVQWXFOkT6B5xJqKQxHduK9L4pLmPX5UASjAXIKMJDl/D2h1RiKaPO/DSApYtkx SHUbmLA13CD3cu/zyP64vVxBQYkg1L7CwJngdY72EAu7lZZAzTJZDSi6lQLkWnFXOO/S HZv8XdrPx9/D35sHE5P/CEN25UDWKkJ4HO4af3EDBoZaX2pCBg4Q7BItnuWlszDRrBZ+ rcGrkdYevygkUFucNpzpjy6T7nx+Qe2MMv5iwpXfgY3vJ+3ROBmo2qOghIxVvi7BAWS5 F/0jGNcYkUbrOHaxYMzRgdF+apZv9zsYHUhu0lgAmwEMTmFoSY2aLtkhBdahuwaKmXbI KuLQ== X-Gm-Message-State: ABy/qLYdEh3p7zwWXsg+sMJsFaTR3KL5F64hnogWSgx2HhOwdXaBkhs1 WKyWmUpJbRALH4fm5tRhHynS7/BF870= X-Received: by 2002:a17:902:e74b:b0:1b8:9b5e:a218 with SMTP id p11-20020a170902e74b00b001b89b5ea218mr19590307plf.42.1689190743988; Wed, 12 Jul 2023 12:39:03 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-236-201-58.hsd1.or.comcast.net. [71.236.201.58]) by smtp.gmail.com with ESMTPSA id ij12-20020a170902ab4c00b001b84cd8814bsm4413264plb.65.2023.07.12.12.39.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jul 2023 12:39:02 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 5/5] test-eir: Run tests using bt_ad Date: Wed, 12 Jul 2023 12:38:54 -0700 Message-Id: <20230712193854.1862996-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230712193854.1862996-1-luiz.dentz@gmail.com> References: <20230712193854.1862996-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This enables the same tests done with eir_data using bt_ad. --- unit/test-eir.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/unit/test-eir.c b/unit/test-eir.c index e05a37d01306..49ce65f24bc9 100644 --- a/unit/test-eir.c +++ b/unit/test-eir.c @@ -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(); -- 2.40.1