Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp569064rwi; Thu, 13 Oct 2022 02:04:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6IIeGzdLIgEMz4CyZVijPDKsnY50KTS572zC6SAIvPD9w/Maz++YBLyQ8rcnBoPPjBO4E0 X-Received: by 2002:a17:907:80d:b0:73d:a576:dfbd with SMTP id wv13-20020a170907080d00b0073da576dfbdmr25614146ejb.402.1665651861681; Thu, 13 Oct 2022 02:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665651861; cv=none; d=google.com; s=arc-20160816; b=CP2s1NHQM4Y0DCVaq7gYLFJbecRy5MBWjRZT977cXO5DNO1s2/jy+IHnW0QjsA2VGY bTP5PWhPxK+exnPio6d6KFJyeYsWGxEKvOwLCEoeA/HkeHQ2lAjh0lL4urZc2WleGexM MzEoyDES2NaxwTtmeDoV0tDlcCFeREe0ojHSW1fV8K21US/K/sPjdTGXBN1lTFlphG/x hsnJjDDrHcNuVPCXNYkm4zui7422a31IVU7lOwGCuBTQHLXONkyOZzJ2CuzWrn1z6Cgf B6bifOftmHjZ+ysbwtfOM3dWhBwPjnUApwBIa5t+Ly2z7CpPLGZbcflhclHmvEH7gdFL 46zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:mime-version:date:dkim-signature; bh=0C6s+MNUKUyiE+/v2qK38FP6EUh65MnvoFXMGNDXtt8=; b=Nmg+OdsJ2nGVKR9kXliY/HJftwyoDSlJKpT2xxmuRQaNB/rYwKpzs8UPMuQ7d4d8T0 WVue0lTpKedZeY0yhB7/qXMhyeCxw5ribUil47fCbOHQsFguZ4Go+MVUJ4zmwYaQuP9e kjCo4AYLOxSIqMA5vYaaDNCXGqTHUXGOfzkeNjXQVDxgqDM6/sJxmBgTaDnKPurHQ6EC osRGvxcJuW31w/2gHDYPPW36ULcEzSTNyJUHfEziuiUicHJwty3fN/EU5JS1hRR3Y0M+ Fc3EKWimhLG7CKTZE3yiAPADzib/fGY9AJssAT3AG/00/k1BCoaN9m+rsqlyrl4mLlVB C/3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=LFmej4Ft; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji22-20020a170907981600b0078e06ba4deasi2100912ejc.218.2022.10.13.02.03.54; Thu, 13 Oct 2022 02:04:21 -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=@google.com header.s=20210112 header.b=LFmej4Ft; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbiJMIHQ (ORCPT + 99 others); Thu, 13 Oct 2022 04:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbiJMIGr (ORCPT ); Thu, 13 Oct 2022 04:06:47 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6406D14BB73 for ; Thu, 13 Oct 2022 01:06:18 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id q63-20020a632a42000000b0045724b1dfb9so647896pgq.3 for ; Thu, 13 Oct 2022 01:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=0C6s+MNUKUyiE+/v2qK38FP6EUh65MnvoFXMGNDXtt8=; b=LFmej4FtWtIw+ACUmCkBCvNhPT5OE+ghqTanmbl0BbWy+m7ISQZb20JgrgxyFPdEE3 7UCbQwC7Vn0e+YeertLEaR0iPnrT+nUULrtjTi9do6eHuaN6K1+EZnydHD/9uUIAJg0Q oI0AKC4efh2WQzZ7mUR5l44vVnVRkLJnLSyw/Pq+2OBiIVDY+8EZFmF//lz1sM8EA5VR 40mGlJOI34LUTdr4G6rw4QacZQ6VPAmY6gLjfuo8U+k6VRtnV/aP/gX8R48E/CrfIyea BmUTweXILgGIzEDPq6QDk2mQoYRi6KRH/YSfId4WGkMsUjBH8NRfaY46Y9O1afiqTIry ds0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0C6s+MNUKUyiE+/v2qK38FP6EUh65MnvoFXMGNDXtt8=; b=K3Xduhprr5mElBcWovnHGPW334xtofXQ4ccSMEoZmvM1dv1t0nLdwKgTdbHEgRXDH8 WoN4qW6ONaSmXZscZ3KhVjdloY9r8EoWN9UpVHui7m+Sti3uJB4fptECNAzt/jkgBI8B EEgn/S6JrIIcbPMpTYcCagZo8ALV8jJda+I8Vz2Cqs+k8UbZgXXKUgNtvHkGLTtQ3GuP T5K/fpMnUPp1hW8chg4AL74BktaXPl65lQxZ6piX5bEsnu40eP9jyj/KcXXPFR53b0Yk F0Z8Y1xifudVrNKwv8H35G5IzowhDVAkd6JeQmoplGonPNgJ6zJ0fnwVjo2jSRxeS3aV 0iig== X-Gm-Message-State: ACrzQf0/2vzrqtnFmEC7zo5d8M9W6DdC3Hzb/ZRLJa7iwNmCx/PXkHHb piOdZN6fyEVqGToWNteuWrTOLhn68q8TDt7G X-Received: from skazigti.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:411e]) (user=sadiyakazi job=sendgmr) by 2002:a17:902:d50f:b0:178:6505:fae3 with SMTP id b15-20020a170902d50f00b001786505fae3mr34564172plg.54.1665648378508; Thu, 13 Oct 2022 01:06:18 -0700 (PDT) Date: Thu, 13 Oct 2022 08:05:46 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221013080545.1552573-1-sadiyakazi@google.com> Subject: [PATCH v2] Documentation: Kunit: Update architecture.rst for minor fixes From: Sadiya Kazi To: brendanhiggins@google.com, davidgow@google.com, skhan@linuxfoundation.org, corbet@lwn.net, bagasdotme@gmail.com Cc: Sadiya Kazi , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 Updated the architecture.rst page with the following changes: -Add missing article _the_ across the document. -Reword content across for style and standard. -Update all occurrences of Command Line to Command-line across the document. -Correct grammatical issues, for example, added _it_ wherever missing. -Update all occurrences of =E2=80=9Cvia" to either use =E2=80=9Cthrough=E2=80=9D or =E2=80=9Cusing=E2=80=9D. -Update the text preceding the external links and pushed the full link to a new line for better readability. -Reword content under the config command to make it more clear and concise. Signed-off-by: Sadiya Kazi --- Thank you David and Bagas for reviewing the doc. I have added the feedback. Changes since V1: https://lore.kernel.org/linux-kselftest/20221010171353.1106166-1-sadiyakazi= @google.com/ - Corrected the typo in the commit message. - Followed the style for links as suggested by Bagas throughout the documen= t. - Updated the links for latest versions whereever applicable (Note: Links having no changes between 5.15 and 6.0 have been retained). - Updated the KTAP spec link to point to Documentation/dev-tools/ktap.rst. - Reworded content as per David and Bagas's feedback. --- .../dev-tools/kunit/architecture.rst | 114 +++++++++--------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/Documentation/dev-tools/kunit/architecture.rst b/Documentation= /dev-tools/kunit/architecture.rst index 8efe792bdcb9..b8ee0fa8afc3 100644 --- a/Documentation/dev-tools/kunit/architecture.rst +++ b/Documentation/dev-tools/kunit/architecture.rst @@ -4,16 +4,17 @@ KUnit Architecture =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -The KUnit architecture can be divided into two parts: +The KUnit architecture is divided into two parts: =20 - `In-Kernel Testing Framework`_ -- `kunit_tool (Command Line Test Harness)`_ +- `kunit_tool (Command-line Test Harness)`_ =20 In-Kernel Testing Framework =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D =20 The kernel testing library supports KUnit tests written in C using -KUnit. KUnit tests are kernel code. KUnit does several things: +KUnit. These KUnit tests are kernel code. KUnit performs the following +tasks: =20 - Organizes tests - Reports test results @@ -22,19 +23,17 @@ KUnit. KUnit tests are kernel code. KUnit does several = things: Test Cases ---------- =20 -The fundamental unit in KUnit is the test case. The KUnit test cases are -grouped into KUnit suites. A KUnit test case is a function with type -signature ``void (*)(struct kunit *test)``. -These test case functions are wrapped in a struct called -struct kunit_case. +The test case is the fundamental unit in KUnit. KUnit test cases are organ= ised +into suites. A KUnit test case is a function with type signature +``void (*)(struct kunit *test)``. These test case functions are wrapped in= a +struct called struct kunit_case. =20 .. note: ``generate_params`` is optional for non-parameterized tests. =20 -Each KUnit test case gets a ``struct kunit`` context -object passed to it that tracks a running test. The KUnit assertion -macros and other KUnit utilities use the ``struct kunit`` context -object. As an exception, there are two fields: +Each KUnit test case receives a ``struct kunit`` context object that track= s a +running test. The KUnit assertion macros and other KUnit utilities use the +``struct kunit`` context object. As an exception, there are two fields: =20 - ``->priv``: The setup functions can use it to store arbitrary test user data. @@ -77,12 +76,12 @@ Executor =20 The KUnit executor can list and run built-in KUnit tests on boot. The Test suites are stored in a linker section -called ``.kunit_test_suites``. For code, see: -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/in= clude/asm-generic/vmlinux.lds.h?h=3Dv5.15#n945. +called ``.kunit_test_suites``. For the full code, see +`include/asm-generic/vmlinux.lds.h `_ . The linker section consists of an array of pointers to ``struct kunit_suite``, and is populated by the ``kunit_test_suites()`` -macro. To run all tests compiled into the kernel, the KUnit executor -iterates over the linker section array. +macro. The KUnit executor iterates over the linker section array in order = to +run all the tests that are compiled into the kernel. =20 .. kernel-figure:: kunit_suitememorydiagram.svg :alt: KUnit Suite Memory @@ -90,17 +89,16 @@ iterates over the linker section array. KUnit Suite Memory Diagram =20 On the kernel boot, the KUnit executor uses the start and end addresses -of this section to iterate over and run all tests. For code, see: -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/li= b/kunit/executor.c - +of this section to iterate over and run all tests. For the full code, see +`executor.c `_. When built as a module, the ``kunit_test_suites()`` macro defines a ``module_init()`` function, which runs all the tests in the compilation unit instead of utilizing the executor. =20 In KUnit tests, some error classes do not affect other tests or parts of the kernel, each KUnit case executes in a separate thread -context. For code, see: -https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/li= b/kunit/try-catch.c?h=3Dv5.15#n58 +context. For the full code, see +`try-catch.c `_. =20 Assertion Macros ---------------- @@ -111,37 +109,36 @@ All expectations/assertions are formatted as: =20 - ``{EXPECT|ASSERT}`` determines whether the check is an assertion or an expectation. + In the event of a failure, the testing flow differs as follows: =20 - - For an expectation, if the check fails, marks the test as failed - and logs the failure. + - For expectations, the test is marked as failed and the failure is logge= d. =20 - - An assertion, on failure, causes the test case to terminate - immediately. + - Failing assertions, on the other hand, result in the test case being + terminated immediately. =20 - - Assertions call function: + - Assertions call the function: ``void __noreturn kunit_abort(struct kunit *)``. =20 - - ``kunit_abort`` calls function: + - ``kunit_abort`` calls the function: ``void __noreturn kunit_try_catch_throw(struct kunit_try_catch *try_ca= tch)``. =20 - - ``kunit_try_catch_throw`` calls function: + - ``kunit_try_catch_throw`` calls the function: ``void kthread_complete_and_exit(struct completion *, long) __noreturn= ;`` and terminates the special thread context. =20 - ```` denotes a check with options: ``TRUE`` (supplied property - has the boolean value =E2=80=9Ctrue=E2=80=9D), ``EQ`` (two supplied prop= erties are + has the boolean value "true"), ``EQ`` (two supplied properties are equal), ``NOT_ERR_OR_NULL`` (supplied pointer is not null and does not - contain an =E2=80=9Cerr=E2=80=9D value). + contain an "err" value). =20 - ``[_MSG]`` prints a custom message on failure. =20 Test Result Reporting --------------------- -KUnit prints test results in KTAP format. KTAP is based on TAP14, see: -https://github.com/isaacs/testanything.github.io/blob/tap14/tap-version-14= -specification.md. -KTAP (yet to be standardized format) works with KUnit and Kselftest. -The KUnit executor prints KTAP results to dmesg, and debugfs -(if configured). +KUnit prints the test results in KTAP format. KTAP is based on TAP14, see +Documentation/dev-tools/ktap.rst. +KTAP works with KUnit and Kselftest. The KUnit executor prints KTAP result= s to +dmesg, and debugfs (if configured). =20 Parameterized Tests ------------------- @@ -150,33 +147,33 @@ Each KUnit parameterized test is associated with a co= llection of parameters. The test is invoked multiple times, once for each parameter value and the parameter is stored in the ``param_value`` field. The test case includes a KUNIT_CASE_PARAM() macro that accepts a -generator function. -The generator function is passed the previous parameter and returns the ne= xt -parameter. It also provides a macro to generate common-case generators bas= ed on -arrays. +generator function. The generator function is passed the previous paramete= r +and returns the next parameter. It also includes a macro for generating +array-based common-case generators. =20 -kunit_tool (Command Line Test Harness) +kunit_tool (Command-line Test Harness) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -kunit_tool is a Python script ``(tools/testing/kunit/kunit.py)`` -that can be used to configure, build, exec, parse and run (runs other -commands in order) test results. You can either run KUnit tests using -kunit_tool or can include KUnit in kernel and parse manually. +``kunit_tool`` is a Python script, found in ``tools/testing/kunit/kunit.py= ``. It +is used to configure, build, execute, parse test results and run all of th= e +previous commands in correct order (i.e., configure, build, execute and pa= rse). +You have two options for running KUnit tests: either use KUnit +directly through the kernel and parse manually, or use the ``kunit_tool``. =20 - ``configure`` command generates the kernel ``.config`` from a ``.kunitconfig`` file (and any architecture-specific options). - For some architectures, additional config options are specified in the - ``qemu_config`` Python script - (For example: ``tools/testing/kunit/qemu_configs/powerpc.py``). + The Python scripts available in ``qemu_configs`` folder + (for example, ``tools/testing/kunit/qemu configs/powerpc.py``) contains + additional configuration options for specific architectures. It parses both the existing ``.config`` and the ``.kunitconfig`` files - and ensures that ``.config`` is a superset of ``.kunitconfig``. - If this is not the case, it will combine the two and run - ``make olddefconfig`` to regenerate the ``.config`` file. It then - verifies that ``.config`` is now a superset. This checks if all - Kconfig dependencies are correctly specified in ``.kunitconfig``. - ``kunit_config.py`` includes the parsing Kconfigs code. The code which - runs ``make olddefconfig`` is a part of ``kunit_kernel.py``. You can - invoke this command via: ``./tools/testing/kunit/kunit.py config`` and + to ensure that ``.config`` is a superset of ``.kunitconfig``. + If not, it will combine the two and run ``make olddefconfig`` to regener= ate + the ``.config`` file. It then checks to see if ``.config`` has become a = superset. + This verifies that all the Kconfig dependencies are correctly specified = in the file + ``.kunitconfig``. The ``kunit_config.py`` script contains the code for p= arsing + Kconfigs. The code which runs ``make olddefconfig`` is part of the + ``kunit_kernel.py`` script. You can invoke this command through: + ``./tools/testing/kunit/kunit.py config`` and generate a ``.config`` file. - ``build`` runs ``make`` on the kernel tree with required options (depends on the architecture and some options, for example: build_dir) @@ -184,8 +181,8 @@ kunit_tool or can include KUnit in kernel and parse man= ually. To build a KUnit kernel from the current ``.config``, you can use the ``build`` argument: ``./tools/testing/kunit/kunit.py build``. - ``exec`` command executes kernel results either directly (using - User-mode Linux configuration), or via an emulator such - as QEMU. It reads results from the log via standard + User-mode Linux configuration), or through an emulator such + as QEMU. It reads results from the log using standard output (stdout), and passes them to ``parse`` to be parsed. If you already have built a kernel with built-in KUnit tests, you can run the kernel and display the test results with the ``exec`` @@ -193,3 +190,6 @@ kunit_tool or can include KUnit in kernel and parse man= ually. - ``parse`` extracts the KTAP output from a kernel log, parses the test results, and prints a summary. For failed tests, any diagnostic output will be included. + +For more information on kunit_tool, see +Documentation/dev-tools/kunit/run_wrapper.rst. --=20 2.38.0.rc1.362.ged0d419d3c-goog