Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp967023rwb; Wed, 28 Sep 2022 11:19:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wBn28dVKg7SvYOgPky1wFewUZh1GbLJvDcfnQUkrNRwa3n7D4uVF6g2WrHWQHUrOvXt4O X-Received: by 2002:a05:6402:d05:b0:425:b7ab:776e with SMTP id eb5-20020a0564020d0500b00425b7ab776emr35749594edb.142.1664389182331; Wed, 28 Sep 2022 11:19:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664389182; cv=none; d=google.com; s=arc-20160816; b=A88hd9hCB3ojF8Ifk47VNZEb2hld4MWtcJq/jb95du4LnUWiqziIFKyLx0Vj+B9S/s og61wd6K0glfz7PWiDIfgZECADHnJzlYvsIhuYqPfJIKl2ndbiXN6NQa2ywH4tTeTdJa hdhGVE9NPtxcD5YB4z+EKheqOSVCbde1PpVrtveabkqBU6R2XKe8RgAuiCQYHSQp5Q5h +1sDkB0TGcjWfd6yRTQWNi8KFpcgFfJcaMWj2B1coLo+zKta/L8bNx708iMYjsWz/WiD IFJ9S+sChP6GfdqpY/pP3K9MZ9SgX4hD3dZqB5FjnfjLKHfuCOhxpegcCn8AZwtDtxWy 3cEg== 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 :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=PxNaDeF78j51lFfkEadsKMLXI6VN8WO63ACpoLyrqAc=; b=M5xtlDmdUux+6P6amQExJo/kW8KQR3rt72OThM2b1D9FULtJxFRgtVTVwVEwHNcj/a PxEZGHU25cMZfIYZDRIU8iW76IuO1mgF3qnIyBURrnXtJPAm7uBWNs6OhFwFHxtw/gSJ nev3gVRfSzo0db4DAZD0vHK8srWFsRq2Gl2K6/+xAhJO3u3zsegCr0hOpClhBws/jjdI YDdozJyWIvnt46euGravrH/8hY3Y4ZbZQ1PwzVo5snvYv/7BnVIc/RWC3yL+u/jmh8Vu EuODE+T8u9ouc2/ByLHZCxgq1a77RdoByT+CW4Uxkw08Q6L1QXSRc7fCN+md3rrh058v w2Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BMH+foBe; 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=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 s25-20020a170906455900b007813c565e59si4721889ejq.210.2022.09.28.11.19.17; Wed, 28 Sep 2022 11:19:42 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=BMH+foBe; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229640AbiI1R03 (ORCPT + 99 others); Wed, 28 Sep 2022 13:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234282AbiI1R0W (ORCPT ); Wed, 28 Sep 2022 13:26:22 -0400 Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7948564FF; Wed, 28 Sep 2022 10:26:20 -0700 (PDT) Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1319cf91d8aso4192649fac.5; Wed, 28 Sep 2022 10:26:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date; bh=PxNaDeF78j51lFfkEadsKMLXI6VN8WO63ACpoLyrqAc=; b=BMH+foBeGZ0fT1YqRY6YhuE+yCJl0PVTMuhsDCZrdLLygiTQi+LziyJTd/8zgvDFwb 1DLKN627LNM33uU0L4iAwTJWeyYNUO9jUYEzJEcAOg+tQxaQMgUqsPlm9gvCnkzga7m7 yQQy3C1Pwo39TEsXD5LiIwdaCT+Tgv3gr3hg3A3nLNINcqoYpuP7eFWAPCt6+zfPfbp0 PE9Ce/mzWP0bpeCh0kjYTQl5xxM7skkOc7iX/qdQSgB5FLLV+lFw8PMgDk34pRRz0iGb bDPEYPrc36hZgwnSlTt0ID4hvoZ/N2lSYymNA84/bJAggcSGKVw6OMBuFO8u1d+0TLj4 YGCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=PxNaDeF78j51lFfkEadsKMLXI6VN8WO63ACpoLyrqAc=; b=RMPmGJAWEnqyIOSaWDgL1SemppErHp6sP7ryJJ7GUPK5i40lYkcRb6xg4IN+zlyQH/ xViKIItA1udWJb8Kk/h8/IaPV4ey4MbWN0IyHXeWyG9idXQ2P65trhFB2MYyRhXbbN9s gwU+HfDFP8ZQDPc/+VeBowEe4Kie2sRo1OqMdsN++rfSGohTYNooHxlhS/ksuXQxrKku Zpq8gsVrp7JjNKPr1iAiJ9OGS/Hfr0Ifh9XIhynrWtj5OR+iDUr+uQr0FoccAN1gms7Y rInQXyiXlGIiTi2deNl/h2cMhZWUqysIwF3YP2fbvijU2e4VrjSjbByHmSbdxoMi1O6x vfFQ== X-Gm-Message-State: ACrzQf3daVKoB84J/QPct2x8x1BjGQSisGeFMFFFm/dtPczsaPkiwa53 fxk5lBFCx7pbMuDwiIU06Z2tMU8eMsHsR/pv X-Received: by 2002:a05:6870:eaa9:b0:131:65bc:e475 with SMTP id s41-20020a056870eaa900b0013165bce475mr5880425oap.15.1664385979703; Wed, 28 Sep 2022 10:26:19 -0700 (PDT) Received: from ?IPV6:2804:14c:4c2:8202:7121:ae72:af3b:9956? ([2804:14c:4c2:8202:7121:ae72:af3b:9956]) by smtp.gmail.com with ESMTPSA id q42-20020a056871082a00b0012796e8033dsm2702795oap.57.2022.09.28.10.26.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Sep 2022 10:26:19 -0700 (PDT) Message-ID: <9024bdb2-4460-0424-42f4-b280983f3146@gmail.com> Date: Wed, 28 Sep 2022 14:26:14 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 From: Tales Aparecida Subject: Re: [PATCH v2 0/2] kunit: add boot time parameter to enable KUnit To: Joe Fradley Cc: Jonathan Corbet , David Gow , Brendan Higgins , kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com References: <20220823142456.3977086-1-joefradley@google.com> <10f97a94-ab35-fbc7-4dd7-98586a027c8b@gmail.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,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 28/09/2022 10:58, Joe Fradley wrote: > On Sat, Sep 24, 2022 at 5:42 PM Tales Aparecida > wrote: >> >> Hi, >> >> >> This series is >> Tested-by: Tales Aparecida >> >> 1. Tested using kunit_tool: running tests and showing output as expected. >> >> 2. Tested further by running QEMU through virtme-run with: >> $ ../virtme/virtme-run --show-command --kdir ../linux/.for-amd/ --mods=auto --kopt kunit.enable=1 >> >> 2.a. "KUNIT_DEFAULT_ENABLED" works as expected when "kunit.enable" is omitted >> 2.b. kunit.enable=0 results in printing "kunit: disabled" on boot and on loading test modules, as expected >> 3.c. kunit.enable=1 runs tests on boot and allows them to run when loading test modules >> >> 3. Regarding taint >> 3.a. /proc/sys/kernel/tainted is 0 when kunit.enable=0 and does not change when trying to load test modules. >> 3.b. /proc/sys/kernel/tainted is 0 when kunit.enable=1 until the first test runs, then it becomes 262144 (2^18) as expected. > > Tales, thank you for doing this testing. > >> >> >> On other note, there's something I would like to delve into below. >> >> >> On 23/08/2022 11:24, Joe Fradley wrote: >>> v2: >>> - Added enable check in executor.c to prevent wrong error output from >>> kunit_tool.py when run against a KUnit disabled kernel >>> - kunit_tool.py now passes kunit.enable=1 >>> - Flipped around logic of new config to KUNIT_DEFAULT_ENABLED >>> - Now load modules containing tests but not executing them >>> - Various message/description text clean up >>> >>> There are some use cases where the kernel binary is desired to be the same >>> for both production and testing. This poses a problem for users of KUnit >>> as built-in tests will automatically run at startup and test modules >>> can still be loaded leaving the kernel in an unsafe state. There is a >>> "test" taint flag that gets set if a test runs but nothing to prevent >>> the execution. >> >> Do you have any info on whether these use cases would have something against writing tests for static functions using the documented approach of including the tests into the actual runtime code? >> https://docs.kernel.org/dev-tools/kunit/usage.html#testing-static-functions >> >> Otherwise, would them agree to export the symbols that need to be tested? >> >> I would really like to understand better what are these use cases :) > > I feel using the static functions as described in your link is a good > alternative to > modules with embedded KUnit tests. However, this is a different use case then > I refer to, which is the ability to have the framework embedded in the > kernel for > both production and test with the control of test execution gated on a kernel > command line parameter. > I have another question regarding the compilation in this use case. Does it have a strict requirement to minimize the kernel size? That is, is there any requirement around built-in test modules and/or a plan to load test modules on demand when booting with kunit.enable=1? I would also like to know whether the use case includes running unit tests for AMDGPU or DRM, just so we can be aware of it when writing more tests for static functions using the approach shown in that link. >> >>> >>> This patch adds the kunit.enable module parameter that will need to be >>> set to true in addition to KUNIT being enabled for KUnit tests to run. >>> The default value is true giving backwards compatibility. However, for >>> the production+testing use case the new config option KUNIT_DEFAULT_ENABLED >>> can be set to N requiring the tester to opt-in by passing kunit.enable=1 to >>> the kernel. >>> >>> Joe Fradley (2): >>> kunit: add kunit.enable to enable/disable KUnit test >>> kunit: no longer call module_info(test, "Y") for kunit modules >>> >>> .../admin-guide/kernel-parameters.txt | 6 +++++ >>> include/kunit/test.h | 3 ++- >>> lib/kunit/Kconfig | 11 +++++++++ >>> lib/kunit/executor.c | 4 ++++ >>> lib/kunit/test.c | 24 +++++++++++++++++++ >>> tools/testing/kunit/kunit_kernel.py | 1 + >>> 6 files changed, 48 insertions(+), 1 deletion(-) >>> >> >> Great work! >> >> Kind regards, >> Tales