Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: Sadiya Kazi <sadiyakazi@google.com>
To: David Gow <davidgow@google.com>
Cc: Benjamin Berg <benjamin@sipsolutions.net>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Rae Moar <rmoar@google.com>, Daniel Latypov <dlatypov@google.com>,
	maxime@cerno.tech, Stephen Boyd <sboyd@kernel.org>,
	kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] Documentation: kunit: Note that assertions should not be used in cleanup
Date: Tue, 25 Apr 2023 11:26:28 +0530	[thread overview]
Message-ID: <CAO2JNKXE4fevipABRLsp=UkfL3tt9rbpoT8D4MeokyLndG3SCQ@mail.gmail.com> (raw)
In-Reply-To: <20230421040218.2156548-2-davidgow@google.com>

On Fri, Apr 21, 2023 at 9:32 AM David Gow <davidgow@google.com> wrote:
>
> As assertions abort the test cleanup process, they should be avoided
> from within a suite's exit function, or from within resource 'free'
> functions. Unlike with initialisation or main test execution, no further
> cleanup will be performed after a failed assertion, potentially causing
> a leak of resources.
>
> Signed-off-by: David Gow <davidgow@google.com>
> ---

Thank you, David. The note looks fine to me.
Reviewed-by: Sadiya Kazi <sadiyakazi@google.com>

Regards,
Sadiya
>
> No changes since v2:
> https://lore.kernel.org/linux-kselftest/20230419085426.1671703-2-davidgow@google.com/
>
> This patch was introduced in v2.
>
> ---
>  Documentation/dev-tools/kunit/usage.rst | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/dev-tools/kunit/usage.rst b/Documentation/dev-tools/kunit/usage.rst
> index 9faf2b4153fc..9f720f1317d3 100644
> --- a/Documentation/dev-tools/kunit/usage.rst
> +++ b/Documentation/dev-tools/kunit/usage.rst
> @@ -121,6 +121,12 @@ there's an allocation error.
>     ``return`` so they only work from the test function. In KUnit, we stop the
>     current kthread on failure, so you can call them from anywhere.
>
> +.. note::
> +   Warning: There is an exception to the above rule. You shouldn't use assertions
> +   in the suite's exit() function, or in the free function for a resource. These
> +   run when a test is shutting down, and an assertion here prevents further
> +   cleanup code from running, potentially leading to a memory leak.
> +
>  Customizing error messages
>  --------------------------
>
> --
> 2.40.0.634.g4ca3ef3211-goog
>

  reply	other threads:[~2023-04-25  5:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21  4:02 [PATCH v3 1/4] kunit: Always run cleanup from a test kthread David Gow
2023-04-21  4:02 ` [PATCH v3 2/4] Documentation: kunit: Note that assertions should not be used in cleanup David Gow
2023-04-25  5:56   ` Sadiya Kazi [this message]
2023-04-21  4:02 ` [PATCH v3 3/4] Documentation: kunit: Warn that exit functions run even if init fails David Gow
2023-04-25  5:48   ` Sadiya Kazi
2023-04-21  4:02 ` [PATCH v3 4/4] kunit: example: Provide example exit functions David Gow
2023-04-25 19:11   ` Rae Moar
2023-04-21  7:06 ` [PATCH v3 1/4] kunit: Always run cleanup from a test kthread kernel test robot
2023-04-21  8:52 ` Benjamin Berg
2023-04-25 15:47 ` Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAO2JNKXE4fevipABRLsp=UkfL3tt9rbpoT8D4MeokyLndG3SCQ@mail.gmail.com' \
    --to=sadiyakazi@google.com \
    --cc=benjamin@sipsolutions.net \
    --cc=brendan.higgins@linux.dev \
    --cc=davidgow@google.com \
    --cc=dlatypov@google.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=maxime@cerno.tech \
    --cc=rmoar@google.com \
    --cc=sboyd@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox