Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F949C61DA4 for ; Tue, 31 Jan 2023 00:05:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229895AbjAaAE7 (ORCPT ); Mon, 30 Jan 2023 19:04:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229580AbjAaAE5 (ORCPT ); Mon, 30 Jan 2023 19:04:57 -0500 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 833832693 for ; Mon, 30 Jan 2023 16:04:56 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id h18so3100989ilj.6 for ; Mon, 30 Jan 2023 16:04:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8BhSRwMVXxuU+369SFYGj7Ymc7BXj/kKm12kMslOVkM=; b=ZSVdaMAKZzRpWwR2cThrlBzJ79H2pkCj6uEqIKXvJTwXvplRmXOQN6pCPhFGER4ixd YIBurgyroGALBV7pjIFjvfxCRrI61cbYAM2FFS2klSQ5SjegAq2KwPGj/RLwzf9PCDg/ xo6qKZpPydrk9sSDL9xqIkwnUltYkwPmC45hYkrehH4QNTOUk+en7oOfJ6mmb2zu23Lq aFgtqd7vmMv5qAwYEIIHOA8lf08PjVFlUy/2NSdmIHFuYjGBkwGhKArJENGxb1uyOndc MHr+XqGqfeKhZd6iNdHFLp9UHK1n08Kkjz9uMhLPqkwOCbTlMg/qH8+RtM4WzdPlT/e6 NMUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8BhSRwMVXxuU+369SFYGj7Ymc7BXj/kKm12kMslOVkM=; b=j69NRZvrw/PfsLKkpnNQ0KRbn69qurS/q65E9xy3yf5V3j8Jp440l5oscjLEovDCC3 jx9ipLglaCE2WIfTWdRe5oufOutY+0TKfW5lkRVNNtrmwO77uXU09OMjKbrc8ZPDJ/qr G67cRe+sSRvg6aB/iPZvNG7Q/p46uRnze11YnSreD4X9Rnfwp5tyCSRoalw74IpLRx0M zbSCi5aPIjVa9ypxkrFV7ZVJuEx83Rm4jorght4kDcGlwPXmrPJxDT6+KvQ9KhRPo78F 6p5KgUz4Ht9kvuVCEXwwTG783PZ/Exf4BbbbQUMzKRhEQ3squBk7YlSes3FfeV7TF2W4 pklA== X-Gm-Message-State: AO0yUKUJE2egM7z7oKaSoIq/4rDkMHOV+rYclBwQA2+MF/pxeWwvUz8C dbDPuAOkgYRqi+L/9fbhClgOK7dHJXPZrKb/y4hB7A== X-Google-Smtp-Source: AK7set+HE0Eoj6fa0jUiHRwdtyKKhGLsxOR16qJEZ6t6OUjst5IC0bdCNQvWgGhrj20GQRntSGrPNK87dMpmntyxFxw= X-Received: by 2002:a92:c981:0:b0:310:99f5:df36 with SMTP id y1-20020a92c981000000b0031099f5df36mr3521198iln.65.1675123495672; Mon, 30 Jan 2023 16:04:55 -0800 (PST) MIME-Version: 1.0 References: <20230128071007.1134942-1-davidgow@google.com> In-Reply-To: <20230128071007.1134942-1-davidgow@google.com> From: Brendan Higgins Date: Mon, 30 Jan 2023 19:04:44 -0500 Message-ID: Subject: Re: [PATCH] kunit: Add "hooks" to call into KUnit when it's built as a module To: David Gow Cc: Brendan Higgins , Kees Cook , Shuah Khan , Daniel Latypov , Rae Moar , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 28, 2023 at 2:10 AM 'David Gow' via KUnit Development wrote: > > KUnit has several macros and functions intended for use from non-test > code. These hooks, currently the kunit_get_current_test() and > kunit_fail_current_test() macros, didn't work when CONFIG_KUNIT=m. > > In order to support this case, the required functions and static data > need to be available unconditionally, even when KUnit itself is not > built-in. The new 'hooks.c' file is therefore always included, and has > both the static key required for kunit_get_current_test(), and a table > of function pointers in struct kunit_hooks_table. This is filled in with > the real implementations by kunit_install_hooks(), which is kept in > hooks-impl.h and called when the kunit module is loaded. > > This can be extended for future features which require similar > "hook" behaviour, such as static stubs, by simply adding new entries to > the struct, and the appropriate code to set them. > Signed-off-by: David Gow I agree with Rae that a new file for just setting the pointer seems a bit much, but I also understand the point of separating it out now - not sure of a better place for it to live. Aside from that, looks good to me: Reviewed-by: Brendan Higgins