linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: David Gow <davidgow@google.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Brendan Higgins <brendanhiggins@google.com>,
	Daniel Latypov <dlatypov@google.com>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kunit-dev@googlegroups.com
Subject: Re: [PATCH v3 1/3] list: test: Add test for list_del_init_careful()
Date: Wed, 9 Feb 2022 15:43:53 +0200	[thread overview]
Message-ID: <YgPFGUyK4ood7WvU@smile.fi.intel.com> (raw)
In-Reply-To: <20220209052813.854014-1-davidgow@google.com>

On Wed, Feb 09, 2022 at 01:28:11PM +0800, David Gow wrote:
> The list_del_init_careful() function was added[1] after the list KUnit
> test. Add a very basic test to cover it.
> 
> Note that this test only covers the single-threaded behaviour (which
> matches list_del_init()), as is already the case with the test for
> list_empty_careful().
> 
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c6fe44d96fc1536af5b11cd859686453d1b7bfd1


Now the negative tests make more sense, thanks!

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
to the entire series.

> Signed-off-by: David Gow <davidgow@google.com>
> ---
> 
> Changes since v2:
> https://lore.kernel.org/linux-kselftest/20220208040122.695258-1-davidgow@google.com/
> - Fix the test calling list_del_init() instead of
>   list_del_init_careful()
> - Improve the comment noting we only test single-threaded behaviour.
> 
> Changes since v1:
> https://lore.kernel.org/linux-kselftest/20220205061539.273330-1-davidgow@google.com/
> - Patch 1/3 unchanged
> ---
>  lib/list-test.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/lib/list-test.c b/lib/list-test.c
> index ee09505df16f..f82a3c7788b8 100644
> --- a/lib/list-test.c
> +++ b/lib/list-test.c
> @@ -161,6 +161,25 @@ static void list_test_list_del_init(struct kunit *test)
>  	KUNIT_EXPECT_TRUE(test, list_empty_careful(&a));
>  }
>  
> +static void list_test_list_del_init_careful(struct kunit *test)
> +{
> +	/* NOTE: This test only checks the behaviour of this function in
> +	 * isolation. It does not verify memory model guarantees. */
> +	struct list_head a, b;
> +	LIST_HEAD(list);
> +
> +	list_add_tail(&a, &list);
> +	list_add_tail(&b, &list);
> +
> +	/* before: [list] -> a -> b */
> +	list_del_init_careful(&a);
> +	/* after: [list] -> b, a initialised */
> +
> +	KUNIT_EXPECT_PTR_EQ(test, list.next, &b);
> +	KUNIT_EXPECT_PTR_EQ(test, b.prev, &list);
> +	KUNIT_EXPECT_TRUE(test, list_empty_careful(&a));
> +}
> +
>  static void list_test_list_move(struct kunit *test)
>  {
>  	struct list_head a, b;
> @@ -707,6 +726,7 @@ static struct kunit_case list_test_cases[] = {
>  	KUNIT_CASE(list_test_list_replace_init),
>  	KUNIT_CASE(list_test_list_swap),
>  	KUNIT_CASE(list_test_list_del_init),
> +	KUNIT_CASE(list_test_list_del_init_careful),
>  	KUNIT_CASE(list_test_list_move),
>  	KUNIT_CASE(list_test_list_move_tail),
>  	KUNIT_CASE(list_test_list_bulk_move_tail),
> -- 
> 2.35.0.263.gb82422642f-goog
> 

-- 
With Best Regards,
Andy Shevchenko



      parent reply	other threads:[~2022-02-09 13:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09  5:28 [PATCH v3 1/3] list: test: Add test for list_del_init_careful() David Gow
2022-02-09  5:28 ` [PATCH v3 2/3] list: test: Add a test for list_is_head() David Gow
2022-02-09  5:28 ` [PATCH v3 3/3] list: test: Add a test for list_entry_is_head() David Gow
2022-02-09 13:43 ` Andy Shevchenko [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=YgPFGUyK4ood7WvU@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=brendanhiggins@google.com \
    --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=skhan@linuxfoundation.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).