linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Gow <davidgow@google.com>
To: Shuah Khan <skhan@linuxfoundation.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Brendan Higgins <brendanhiggins@google.com>
Cc: David Gow <davidgow@google.com>,
	Daniel Latypov <dlatypov@google.com>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kunit-dev@googlegroups.com
Subject: [PATCH 3/3] list: test: Add a test for list_entry_is_head()
Date: Sat,  5 Feb 2022 14:15:38 +0800	[thread overview]
Message-ID: <20220205061539.273330-3-davidgow@google.com> (raw)
In-Reply-To: <20220205061539.273330-1-davidgow@google.com>

The list_entry_is_head() macro was added[1] after the list KUnit tests,
so wasn't tested. Add a new KUnit test to complete the set.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e130816164e244b692921de49771eeb28205152d

Signed-off-by: David Gow <davidgow@google.com>
---
 lib/list-test.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/list-test.c b/lib/list-test.c
index 7ce7eaebe060..4cd06a9fc73c 100644
--- a/lib/list-test.c
+++ b/lib/list-test.c
@@ -538,6 +538,18 @@ static void list_test_list_entry(struct kunit *test)
 				struct list_test_struct, list));
 }
 
+static void list_test_list_entry_is_head(struct kunit *test)
+{
+	struct list_test_struct test_struct1, test_struct2;
+	LIST_HEAD(list);
+
+	list_add_tail(&test_struct1.list, &list);
+	list_add_tail(&test_struct2.list, &list);
+
+	KUNIT_EXPECT_FALSE(test, list_entry_is_head((&test_struct1), &list, list));
+	KUNIT_EXPECT_FALSE(test, list_entry_is_head((&test_struct2), &list, list));
+}
+
 static void list_test_list_first_entry(struct kunit *test)
 {
 	struct list_test_struct test_struct1, test_struct2;
@@ -753,6 +765,7 @@ static struct kunit_case list_test_cases[] = {
 	KUNIT_CASE(list_test_list_splice_init),
 	KUNIT_CASE(list_test_list_splice_tail_init),
 	KUNIT_CASE(list_test_list_entry),
+	KUNIT_CASE(list_test_list_entry_is_head),
 	KUNIT_CASE(list_test_list_first_entry),
 	KUNIT_CASE(list_test_list_last_entry),
 	KUNIT_CASE(list_test_list_first_entry_or_null),
-- 
2.35.0.263.gb82422642f-goog


      parent reply	other threads:[~2022-02-05  6:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-05  6:15 [PATCH 1/3] list: test: Add test for list_del_init_careful() David Gow
2022-02-05  6:15 ` [PATCH 2/3] list: test: Add a test for list_is_head() David Gow
2022-02-05 13:06   ` Andy Shevchenko
2022-02-08  4:08     ` David Gow
2022-02-05  6:15 ` David Gow [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=20220205061539.273330-3-davidgow@google.com \
    --to=davidgow@google.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brendanhiggins@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).