Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1552259rwb; Wed, 26 Jul 2023 14:33:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlEVTPBqk26D/TgEmdrmwBMaDEOj6rM/SsDOL0wEyXedeAA7bIREQ69VqQcqhZ4YvR/ecm4S X-Received: by 2002:a05:6a20:3d20:b0:11d:4c79:90ee with SMTP id y32-20020a056a203d2000b0011d4c7990eemr3930253pzi.25.1690407232066; Wed, 26 Jul 2023 14:33:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690407232; cv=pass; d=google.com; s=arc-20160816; b=kI/Jk5nIieVQsabypdmu35fNZ2hsEGicuv95mwQbgbe+zHGXdR5w5d+hl2EgQBUpVC qSWfd2tuv1hIEsz2/luKM5oVEIkHvRoV8K+k/ziyYIXC6gmErz9GyId8GENV+weLUrey j4uche9D+4jAyJypQ4UUduXj7xJJbPokEJfvY3FX0KsKAkR6jXKiJNSFc3sca4/ak3Gu yVzD02h2M7BMyCpmeY5AQ9pDAgj2GkgnHs3vsfIqAMD/J6DQLfRTeVF41cxLWNmBpX/0 vjf6C1jYyLHahbDlCSSKG5xvaq9LKv2g0xqKr8tFxJv5rx4LpbPvb8RjwUzwW/hBl3gM bOkw== ARC-Message-Signature: i=2; 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:cc:to:from :dkim-signature; bh=tW2+2BLo8vtYy6DNWxtLOfiMpuLTNkMKEjYi/wSjFvI=; fh=raBgKoRsHCwQLc6ReOhmOoEQ+DtSaNc74fugaHBwryI=; b=zvQ+N+rAeBCh/onoloNcXrWaKXmItDc7JMrV3F56iu63CdkY/r80bVZweXPJTF44Jb LixHPDbOlS5M0qg9Z3DRucetvJUA+CIn4+lmBUDuN1CeZGaRg0ShNnnXTxXks7IqukBu LJNNArIWKO/FcWvPMh8HE3EVUrljf1qCm5jydacg3p1NpdVB2XglS7fDonIS3POBXtPB s8bXdQEFnNxZWzrsJkBEphNuWq8veOTrIkiTtmwig0UFj8MoNTbIIfgTX7NSGadrxlUr o2HXhf9C0dITmAhHzOfaO42XJAWVusbO21UcQNx1BXujIzuEzo1qEANK0dJY+La62FRV 6jnQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=mO4cVkwM; arc=pass (i=1); 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a056a0024cb00b006867a1f1280si120874pfv.32.2023.07.26.14.33.37; Wed, 26 Jul 2023 14:33:52 -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=@iki.fi header.s=lahtoruutu header.b=mO4cVkwM; arc=pass (i=1); 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230194AbjGZVZj (ORCPT + 99 others); Wed, 26 Jul 2023 17:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231288AbjGZVZe (ORCPT ); Wed, 26 Jul 2023 17:25:34 -0400 Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E0E3269E for ; Wed, 26 Jul 2023 14:25:27 -0700 (PDT) Received: from monolith.lan (91-152-120-101.elisa-laajakaista.fi [91.152.120.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4RB6Pd06gsz49QBX; Thu, 27 Jul 2023 00:25:25 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1690406725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tW2+2BLo8vtYy6DNWxtLOfiMpuLTNkMKEjYi/wSjFvI=; b=mO4cVkwMkGVTjXqtYw1FibEUH8kQfBT1UNJ6oY0EbnfEVA/pUXG/LV9Wq/aHaVLYnmHwB6 U6wwaveaQVhLaxT5FBh7hNhfN+xRCio0r17Tu/7t7xfmU4Xif+K9czUXIBN27hHJ2XDfTQ fMTXkHxo13V2MJ68Jlseiid12+HTbKu1HpTe3f2n8DmA1VbcIc0y2Ey8+IPVq+OS2ETER4 JhvujoEXEXOgTUO13uhyiri/IomJAOZHygi+ypKfDyFLVKJsDe/zxlAUxNuA9H7C4SDY1e Ta7E2McH8omwMcPPd723wQ2X59IHjCBfY4WywR26wjl01YdTanAPU3hhmvUUQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1690406725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tW2+2BLo8vtYy6DNWxtLOfiMpuLTNkMKEjYi/wSjFvI=; b=UvJKrou4fweS5uLOuUAQAjRSoTe0kcT0ZfoozffHvUUqBSUJrMuaF/Mso5pAwt9QH9TtPf nvd/mK7tLh4k9Owg4iDME0upCYVViYWTyHtWLAjv1aLVVojaMdSQbAsZK6zarEPQENcqZx rqCHEIw0Ad0SQ0J0bpsWBfaodZjnlJBMeNRnL68b2YInIKMl0mll7kQmVclw4jD6RzXdX+ 9pMiSN51m7nxRBgcmfThu2BeOYoZZka3ixxI9guPARe2kIwV4rT2J1YWzjPWEayGdSt1YT bl7D5+zQHv/e6ZPBwPB0A8xhuuE2ZSKyV08hHcbizOtiTs1FWtiosIx+Va73gg== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1690406725; a=rsa-sha256; cv=none; b=d/XQX4Ij2GCTD1hr1588vXpq1uL85700ILEDanMDUjjacKbJEx3ohD0rEGsK9CmzjkAJqY Zme53wPORXLxeO89YE9iv1TBFaflJuQ53pEN08XxuCJyMekEZ/SYx9k4BPa0GOTXY4VTds p8pGCtK5BUWi5r/10/Yg26EJh2jiiwj5sv0YmwwcfVpG1ClynnXH05+GXeWNU1+6FItOPV v6n5+QcEmqmY4GRSkDAJinoK/ksKs+z8Ru6LfGC1Zw0rFtRsXheQgSmp0tNPhBtr/MeooE b6vGzYinVXqMMLthDdL5E32ofEz/8IDHsO3z2/SUrORJx4XaW9vr2tDPPOpe2w== From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ 4/5] iso-tester: add tests checking Remove CIG is emitted Date: Thu, 27 Jul 2023 00:25:18 +0300 Message-ID: <357f1735cf611bc23d422a8b3cdd777dabababc9.1690405564.git.pav@iki.fi> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Kernel should send LE Remove CIG after all CIS are shut down. Add tests checking this, closing either immediately or after waiting connection to complete. ISO Defer Close - Success ISO Connect Close - Success ISO Defer Wait Close - Success ISO Connect Wait Close - Success --- tools/iso-tester.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/tools/iso-tester.c b/tools/iso-tester.c index 9f853a0f9..bbf959420 100644 --- a/tools/iso-tester.c +++ b/tools/iso-tester.c @@ -2425,6 +2425,90 @@ static void test_connect2_nodefer(const void *test_data) close(sk); } +static gboolean iso_connect_close_cb(GIOChannel *io, GIOCondition cond, + gpointer user_data) +{ + struct test_data *data = user_data; + + data->io_id[0] = 0; + + tester_print("Disconnected"); + + --data->step; + if (!data->step) + tester_test_passed(); + + return FALSE; +} + +static bool hook_remove_cig(const void *msg, uint16_t len, void *user_data) +{ + struct test_data *data = user_data; + + tester_print("Remove CIG"); + + --data->step; + if (!data->step) + tester_test_passed(); + + return true; +} + +static void test_connect_close(const void *test_data) +{ + struct test_data *data = tester_get_data(); + int sk; + GIOChannel *io; + + data->step = 2; + + hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_CMD, + BT_HCI_CMD_LE_REMOVE_CIG, + hook_remove_cig, data); + + sk = setup_sock(data, 0); + if (sk < 0) + return; + + io = g_io_channel_unix_new(sk); + g_io_channel_set_close_on_unref(io, TRUE); + data->io_id[0] = g_io_add_watch(io, G_IO_HUP, iso_connect_close_cb, + data); + + shutdown(sk, SHUT_RDWR); +} + +static gboolean iso_connect_wait_close_cb(GIOChannel *io, GIOCondition cond, + gpointer user_data) +{ + struct test_data *data = tester_get_data(); + int sk; + + tester_print("Connected"); + + sk = g_io_channel_unix_get_fd(io); + + data->io_id[0] = g_io_add_watch(io, G_IO_HUP, iso_connect_close_cb, + data); + + shutdown(sk, SHUT_RDWR); + + return FALSE; +} + +static void test_connect_wait_close(const void *test_data) +{ + struct test_data *data = tester_get_data(); + + data->step = 1; + + hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_CMD, + BT_HCI_CMD_LE_REMOVE_CIG, + hook_remove_cig, data); + + setup_connect(data, 0, iso_connect_wait_close_cb); +} + static void test_bcast(const void *test_data) { struct test_data *data = tester_get_data(); @@ -2601,6 +2685,18 @@ int main(int argc, char *argv[]) test_iso("ISO Defer Connect - Success", &defer_16_2_1, setup_powered, test_connect); + test_iso("ISO Defer Close - Success", &defer_16_2_1, setup_powered, + test_connect_close); + + test_iso("ISO Connect Close - Success", &connect_16_2_1, setup_powered, + test_connect_close); + + test_iso("ISO Defer Wait Close - Success", &defer_16_2_1, + setup_powered, test_connect_wait_close); + + test_iso("ISO Connect Wait Close - Success", &connect_16_2_1, + setup_powered, test_connect_wait_close); + test_iso2("ISO Defer Connect2 CIG 0x01 - Success", &defer_1_16_2_1, setup_powered, test_connect2); -- 2.41.0