All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
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>,
	Stephen Boyd <sboyd@kernel.org>,
	kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, Sadiya Kazi <sadiyakazi@google.com>
Subject: Re: [PATCH v3 1/4] kunit: Always run cleanup from a test kthread
Date: Tue, 25 Apr 2023 17:47:11 +0200	[thread overview]
Message-ID: <ugim4ef5kbcamojrhq4ryun5wjktcd2rgnfxt7k64hg2y7bkle@ej4mcwflmqbv> (raw)
In-Reply-To: <20230421040218.2156548-1-davidgow@google.com>

[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]

On Fri, Apr 21, 2023 at 12:02:15PM +0800, David Gow wrote:
> KUnit tests run in a kthread, with the current->kunit_test pointer set
> to the test's context. This allows the kunit_get_current_test() and
> kunit_fail_current_test() macros to work. Normally, this pointer is
> still valid during test shutdown (i.e., the suite->exit function, and
> any resource cleanup). However, if the test has exited early (e.g., due
> to a failed assertion), the cleanup is done in the parent KUnit thread,
> which does not have an active context.
> 
> Instead, in the event test terminates early, run the test exit and
> cleanup from a new 'cleanup' kthread, which sets current->kunit_test,
> and better isolates the rest of KUnit from issues which arise in test
> cleanup.
> 
> If a test cleanup function itself aborts (e.g., due to an assertion
> failing), there will be no further attempts to clean up: an error will
> be logged and the test failed. For example:
> 	 # example_simple_test: test aborted during cleanup. continuing without cleaning up
> 
> This should also make it easier to get access to the KUnit context,
> particularly from within resource cleanup functions, which may, for
> example, need access to data in test->priv.
> 
> Signed-off-by: David Gow <davidgow@google.com>

Thanks for doing this. I've tested it with an action that needs the test
priv pointer, and it works as expected

Reviewed-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Maxime Ripard <maxime@cerno.tech>

Thanks!
Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      parent reply	other threads:[~2023-04-25 15:47 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
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 [this message]

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=ugim4ef5kbcamojrhq4ryun5wjktcd2rgnfxt7k64hg2y7bkle@ej4mcwflmqbv \
    --to=maxime@cerno.tech \
    --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=rmoar@google.com \
    --cc=sadiyakazi@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.