]> www.infradead.org Git - users/hch/misc.git/commitdiff
list: test: increase coverage of list_test_list_replace*()
authorI Hsin Cheng <richard120310@gmail.com>
Tue, 10 Sep 2024 04:08:18 +0000 (12:08 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 17 Sep 2024 08:11:20 +0000 (01:11 -0700)
Increase the test coverage of list_test_list_replace*() by adding the
checks to compare the pointer of "a_new.next" and "a_new.prev" to make
sure a perfect circular doubly linked list is formed after the
replacement.

Link: https://lkml.kernel.org/r/20240910040818.65723-1-richard120310@gmail.com
Signed-off-by: I Hsin Cheng <richard120310@gmail.com>
Cc: David Gow <davidgow@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/list-test.c

index 8d1d47a9fe9ef63c4734ccda3f7ac0f2aaf95487..4f3dc75baec1123620ddca027e8fcf6280a24ae9 100644 (file)
@@ -102,6 +102,8 @@ static void list_test_list_replace(struct kunit *test)
        /* now: [list] -> a_new -> b */
        KUNIT_EXPECT_PTR_EQ(test, list.next, &a_new);
        KUNIT_EXPECT_PTR_EQ(test, b.prev, &a_new);
+       KUNIT_EXPECT_PTR_EQ(test, a_new.next, &b);
+       KUNIT_EXPECT_PTR_EQ(test, a_new.prev, &list);
 }
 
 static void list_test_list_replace_init(struct kunit *test)
@@ -118,6 +120,8 @@ static void list_test_list_replace_init(struct kunit *test)
        /* now: [list] -> a_new -> b */
        KUNIT_EXPECT_PTR_EQ(test, list.next, &a_new);
        KUNIT_EXPECT_PTR_EQ(test, b.prev, &a_new);
+       KUNIT_EXPECT_PTR_EQ(test, a_new.next, &b);
+       KUNIT_EXPECT_PTR_EQ(test, a_new.prev, &list);
 
        /* check a_old is empty (initialized) */
        KUNIT_EXPECT_TRUE(test, list_empty_careful(&a_old));