Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7209901rwb; Tue, 6 Dec 2022 02:43:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KaellFTfaHuynpI+0hz3ObqDfT48puOIKUEHxyS5llILAy3eNdDD3SBDeaOhsxn+RZM6Y X-Received: by 2002:a17:906:b0d7:b0:78d:39e8:89eb with SMTP id bk23-20020a170906b0d700b0078d39e889ebmr58793179ejb.639.1670323396682; Tue, 06 Dec 2022 02:43:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670323396; cv=none; d=google.com; s=arc-20160816; b=x6zZ9ef+Sc9HUGseoMzn412SVIuh08jtvL1jNI5mAL6mQy5eVvDIhmLxcWEd7myqf+ 4718jp4JXm2Br4ZrTqvBJihxswtZrYlQQcialq8ZLS3inY6D3wfpODJekONcXS5jlLFk bZKBY5ZlofhjEyRGFw3RfVsFZdb62jGda87atc11siU1uuWIiMZ5PbxA9PCNh9mWxrmK YmE+BwMgP7jOdYBuwfIzAfNrR89I9TvA84wpCPiODJhAn3L2wSy3L51S7aYSxHcGF8pf 1XX/N0I2ccLVcttF9eqWQ0Uv1yV2w7wL4IMlaAyneIQF/Wz1CZzX168/+yjQC+eU/F6R KGTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=nplTo9ZKBIapoAm8/cSHXWQq2fSo+p21HcrD9WDHSSI=; b=n7FM26r7hHCG9Szv7z1WuSbTI6WYkIslFHHeE2WogP1eQMBwqC3TOeK0GfEfC6la40 1dKxeQMwwq8rFM7W7Luso6/E5MAq9gQaZ1J7p1kpsEQ6bAEnXAoLl0E58gbfnDD7MfHY AzKu6tHz9NrY2Tz7NsI3pJKRPc/e+BMsfp4MguJFCeRE7Wbsd27xVxFKAfRSf2Ubw8tu 80xyFUKlrK5dPdMyqT+Q6CnLSJ/OGcwJqZlnp5NA4lv0wvRV7jj0VyC1lRb+dT/qocGb 2QB6W7cRjeYp6j1qNs1RQwbZbAoI0D3j+lrKt1b4Ernkdfv2UARSePELJJP9mM6Uv2dz mqFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=ewCF4cAR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb3-20020a1709071c8300b007c0abf0760fsi13829743ejc.54.2022.12.06.02.42.57; Tue, 06 Dec 2022 02:43:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@canonical.com header.s=20210705 header.b=ewCF4cAR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232801AbiLFKMR (ORCPT + 79 others); Tue, 6 Dec 2022 05:12:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233776AbiLFKLn (ORCPT ); Tue, 6 Dec 2022 05:11:43 -0500 Received: from smtp-relay-canonical-0.canonical.com (smtp-relay-canonical-0.canonical.com [185.125.188.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 056B6FE9; Tue, 6 Dec 2022 02:07:41 -0800 (PST) Received: from [192.168.192.83] (unknown [50.47.134.245]) (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) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id EB13C3F12A; Tue, 6 Dec 2022 10:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1670321257; bh=nplTo9ZKBIapoAm8/cSHXWQq2fSo+p21HcrD9WDHSSI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ewCF4cARfYQx42U+vjs8pcyJ5ceRclU0esL78RuH/6PPwmYrIYvzlODDV1AZTz4XZ WD9GvlE/h92slGtznwwNsMgshqU4NinourDR2pAzdHud5VydNbQ+Ahli02vko0ov3h cruLsaTIDORASyxxWmUldtq/9kN5IrgeutO5AIO0yZ08Mhvf22TxmJr9b61HLd4AhM T4wUYEV+E04U/IAMucOP2gVBfhVtaRKP1Gc3ixncNsmPjEdlsQSmP9Z+BE6gr9/MOi x1IL6cPUuhvcazAF7cdno2GKnkN3EesMGtwmDaTUgf3A8OJiGki2FogFyV/ywUaR7C StNl1GMHofb8w== Message-ID: <45a7a499-bf80-7cdf-6db8-4792f8bfb7a0@canonical.com> Date: Tue, 6 Dec 2022 02:07:33 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2 1/2] kunit: add macro to allow conditionally exposing static symbols to tests Content-Language: en-US To: David Gow , Rae Moar Cc: brendanhiggins@google.com, dlatypov@google.com, skhan@linuxfoundation.org, tales.aparecida@gmail.com, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, apparmor@lists.ubuntu.com References: <20221205215058.143688-1-rmoar@google.com> <20221205215058.143688-2-rmoar@google.com> From: John Johansen Organization: Canonical In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org On 12/6/22 01:40, David Gow wrote: > On Tue, Dec 6, 2022 at 5:51 AM Rae Moar wrote: >> >> Create two macros: >> >> VISIBLE_IF_KUNIT - A macro that sets symbols to be static if CONFIG_KUNIT >> is not enabled. Otherwise if CONFIG_KUNIT is enabled there is no change to >> the symbol definition. >> >> EXPORT_SYMBOL_IF_KUNIT(symbol) - Exports symbol into >> EXPORTED_FOR_KUNIT_TESTING namespace only if CONFIG_KUNIT is enabled. Must >> use MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING) in test file in order to >> use symbols. >> >> Signed-off-by: Rae Moar >> Reviewed-by: John Johansen >> Reviewed-by: David Gow >> --- >> >> Changes since v1: >> - Separated the documentation comments for macros. >> - Changed copyright date and author for new header file. >> > > This still looks good to me, thanks! > > Reviewed-by: David Gow yep, and you already have my Reviewed-by for this one > > Cheers, > -- David > > >> include/kunit/visibility.h | 33 +++++++++++++++++++++++++++++++++ >> 1 file changed, 33 insertions(+) >> create mode 100644 include/kunit/visibility.h >> >> diff --git a/include/kunit/visibility.h b/include/kunit/visibility.h >> new file mode 100644 >> index 000000000000..0dfe35feeec6 >> --- /dev/null >> +++ b/include/kunit/visibility.h >> @@ -0,0 +1,33 @@ >> +/* SPDX-License-Identifier: GPL-2.0 */ >> +/* >> + * KUnit API to allow symbols to be conditionally visible during KUnit >> + * testing >> + * >> + * Copyright (C) 2022, Google LLC. >> + * Author: Rae Moar >> + */ >> + >> +#ifndef _KUNIT_VISIBILITY_H >> +#define _KUNIT_VISIBILITY_H >> + >> +#if IS_ENABLED(CONFIG_KUNIT) >> + /** >> + * VISIBLE_IF_KUNIT - A macro that sets symbols to be static if >> + * CONFIG_KUNIT is not enabled. Otherwise if CONFIG_KUNIT is enabled >> + * there is no change to the symbol definition. >> + */ >> + #define VISIBLE_IF_KUNIT >> + /** >> + * EXPORT_SYMBOL_IF_KUNIT(symbol) - Exports symbol into >> + * EXPORTED_FOR_KUNIT_TESTING namespace only if CONFIG_KUNIT is >> + * enabled. Must use MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING) >> + * in test file in order to use symbols. >> + */ >> + #define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, \ >> + EXPORTED_FOR_KUNIT_TESTING) >> +#else >> + #define VISIBLE_IF_KUNIT static >> + #define EXPORT_SYMBOL_IF_KUNIT(symbol) >> +#endif >> + >> +#endif /* _KUNIT_VISIBILITY_H */ >> -- >> 2.39.0.rc0.267.gcb52ba06e7-goog >>