summaryrefslogtreecommitdiffstats
path: root/lib/list-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/list-test.c')
-rw-r--r--lib/list-test.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/list-test.c b/lib/list-test.c
index 302b7382bff4..3870ebfd84aa 100644
--- a/lib/list-test.c
+++ b/lib/list-test.c
@@ -254,6 +254,24 @@ static void list_test_list_bulk_move_tail(struct kunit *test)
KUNIT_EXPECT_EQ(test, i, 2);
}
+static void list_test_list_is_head(struct kunit *test)
+{
+ struct list_head a, b, c;
+
+ /* Two lists: [a] -> b, [c] */
+ INIT_LIST_HEAD(&a);
+ INIT_LIST_HEAD(&c);
+ list_add_tail(&b, &a);
+
+ KUNIT_EXPECT_TRUE_MSG(test, list_is_head(&a, &a),
+ "Head element of same list");
+ KUNIT_EXPECT_FALSE_MSG(test, list_is_head(&a, &b),
+ "Non-head element of same list");
+ KUNIT_EXPECT_FALSE_MSG(test, list_is_head(&a, &c),
+ "Head element of different list");
+}
+
+
static void list_test_list_is_first(struct kunit *test)
{
struct list_head a, b;
@@ -731,6 +749,7 @@ static struct kunit_case list_test_cases[] = {
KUNIT_CASE(list_test_list_move),
KUNIT_CASE(list_test_list_move_tail),
KUNIT_CASE(list_test_list_bulk_move_tail),
+ KUNIT_CASE(list_test_list_is_head),
KUNIT_CASE(list_test_list_is_first),
KUNIT_CASE(list_test_list_is_last),
KUNIT_CASE(list_test_list_empty),