Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3389369pxk; Mon, 21 Sep 2020 12:21:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqNxuxU6K1lGP46ElKSxpVVUtdjQ5SowK/l1J7vL1NqktW9fHt5AzHuRZHLJ3X4VHYAmO6 X-Received: by 2002:a05:6402:17ed:: with SMTP id t13mr434195edy.163.1600716098257; Mon, 21 Sep 2020 12:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600716098; cv=none; d=google.com; s=arc-20160816; b=lnm/7FFrHj5u/MJScWQw4lrCJGG2/rpf5TwSjORHqrZ6UBm6WWh8VxR58orEUsHsOR od/4ZdlVi5z4qlq9p7pZmi7Hup5vnw4e7vv7Oxl90ogeeq2ej/xWeelLkiFk10EOiXB0 rww3YrFbi9O7GELGXrS+YQmwZOd4TqtFdqiXRUl2Xztx0yZeCuy9iSXetAb4Of4PyIyd 5/NFIn37LgQGmyQjJ5z5UIkwMbgHBmM5gtLBBaFGzvtgYq+32bmHRI6GF8NOnJDI0eA2 hJor5zE8RW3Ed0CASLgrrrt2jTbzO3nFA6aFhQoYmdznryX9wBko7rpNtxGfqJ1rgb4B 2iag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w1PaecozHR4M5eRnCxHIbVVrIPnLcorg/Z74qyJThlI=; b=cgcFx9A4VdfV0MHgEsEdELzaN3FfQpBGcgIjDgxqgKWXh67HEc9jUEyd0+oJSh8UH0 hocFKxNUd8Uo5Aq1Zle4YgPctxLsLyBPVTvYTPCYW3Nw/oKa7H5xMR/yCZq82rOd+3wx SxHV6SenAutneMs727f7OhMWTNrwgsd0m/Tz4mjEjTyE0QSdyb1LPM1IqVxc5YDa+4sJ 1nxi+2hUBxH2JfptO6BrrYv3vCmCkFOPhZRhVWHWy8DfaAXnRMknnjQuU/TM/xzUxeSS NBJ3RHBqya0TQ7HNIbT3uLwvItyAtd9G2Jrg5savjX+ll5r0w2kg+Cz4vbtBZd0U/alX wN0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="bGt4t/Uq"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u6si9065560ejg.449.2020.09.21.12.21.12; Mon, 21 Sep 2020 12:21:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="bGt4t/Uq"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726969AbgIUTVI (ORCPT + 99 others); Mon, 21 Sep 2020 15:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726810AbgIUTVI (ORCPT ); Mon, 21 Sep 2020 15:21:08 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B4BC061755 for ; Mon, 21 Sep 2020 12:21:08 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id z19so15331684lfr.4 for ; Mon, 21 Sep 2020 12:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w1PaecozHR4M5eRnCxHIbVVrIPnLcorg/Z74qyJThlI=; b=bGt4t/Uqsgw1OIj0LPjhocd+TK25QWC2VDpeLdDGa5QZ/alI/Fcm41FivflnSS/EQR FJJDzx7XRLHMLvVBU1mHyMpt6X6B0IplukuGNhvzwnLYO3meYDtfka9tDZX6/J86Fp0y x5be2rnLGsBIvrqvHogKxErUR5LK0WSU9IW4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w1PaecozHR4M5eRnCxHIbVVrIPnLcorg/Z74qyJThlI=; b=WGJP5zLptVHKvUHv8PYgrGQOnJdLs2gn+sR0nI/yDiB30IBNC/tPvTSgpQnbiKpDlf WZpZNf/YChUgO2W1nt/BvC41btodn7Af8wzL70V/mlgtoWbJplZM4QoU/yB9h8hURtjj vC6qLOS/BsRbcXIo1DoQ5PaY+J0wPOxIDi7+HQJjYK1+9wVR+KguoWJJEd5CR4lNLpDP Alw1lz3nwwx4eY0IrSG2ly5+OU4IMcu4y4kcWHBx5ivSKK9q5XGtm6Q1bohfY9MGTbhJ CUix5DM8Zdm18TV1Vt7P3ogS/ypXntUSIVrV2FojoXe3ASsgIh1vjopG3MmMgwdsSdPN wmdw== X-Gm-Message-State: AOAM530vnF/35gJf9eA/ObDoyLAzYRC1Hwuv0LAoKQFEWwieJV5DTkOU 83jdOTy/7+3kE70HS3dPsLwxU1kaQhMkeRuEBoFj1A== X-Received: by 2002:a19:5619:: with SMTP id k25mr445034lfb.324.1600716065399; Mon, 21 Sep 2020 12:21:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Miao-chen Chou Date: Mon, 21 Sep 2020 12:20:54 -0700 Message-ID: Subject: Re: Modifying Makefile.am to facilitate test-adv-monitor and future unit tests. To: Luiz Augusto von Dentz Cc: Bluetooth Kernel Mailing List , Marcel Holtmann , Luiz Augusto von Dentz , Alain Michaud , Manish Mandlik , Howard Chung , Abhishek Pandit-Subedi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Luiz, On Fri, Sep 18, 2020 at 3:12 PM Luiz Augusto von Dentz wrote: > > Hi Miao, > > On Fri, Sep 18, 2020 at 12:44 PM Miao-chen Chou wrote: > > > > Hi Luiz and Marcel, > > > > Unlike the rest of the existing unit tests in BlueZ, the logic blocks > > tested in test-adv-monitor require dependencies of not only > > src/adv_monitor.c but also all the dependency tree of > > src/adv_monitor.c. The current convention in Makefile.am is to add all > > the extra dependencies one by one. However, the maintenance cost is > > high and not suitable in the case of test-adv-monitor. Therefore, we'd > > like to propose changes in Makefile.am to make the source of > > bluetoothd as a static library and link it for bluetoothd target and > > the unit test target. It would be great if you can provide feedback on > > this idea before the implementation. Thanks in advance! > > Then we should have had the code move to src/shared for unit testing, > but how exactly are you planning to do that? For testing the kernel > interface it normally done via a dedicated tester, but that again can > be done with shared library. > In series https://patchwork.kernel.org/project/bluetooth/list/?series=351021, we introduced some helper functions in adv_monitor.h to perform unit testing and test-adv-monitor to facilitate the unit tests of adv_monitor. We are encountering an expected build check failure on this series. There are two categories in test-adv-monitor, content filtering and RSSI tracking, and content filter is easy to be moved to a standalone shared component while RSSI tracking involves the use of timer, D-Bus method calls and adv_monitor's internal structures, and that makes it strongly coupled with the adv_monitor implementation which require a tree of dependencies apart from adv_monitor. There are two options to resolve the build failures in our case. (1) Reorganize Makefile.am This option is to make the sources (except src/main.c) into a static lib and link this lib in bluetoothd executable target and whichever unit test the sources are required. (2) Create src/shared/am to facilitate helpers and core logic This option is to create a new source under src/shared/ to facilitate helper functions and core logic for src/adv_monitor. The interface of src/shared/am may have the following functions. - Create/destroy functions of struct adv_monitor - Create/destroy functions of struct adv_monitor_device - Helper function for monitor content matching. - Helper function for RSSI tracking However, the logic of RSSI tracking is hard to be ripped off and moved to src/shared/am. One example would be the use of timer in RSSI tracking, and there is currently no previous example of the timer use in the shared library. Series https://patchwork.kernel.org/project/bluetooth/list/?series=351021 is up for review. Our next step here would be ripped off the unit test for now and submit v5 of the series. Once we reach an conclusion on advmon unit test, we can submit a separate series including the refactoring and unit tests. Looking forward to any feedbacks. Thanks! Regards, Miao