Skip to content

Commit 5e06e08

Browse files
vax-rakpm00
authored andcommitted
list: test: increase coverage of list_test_list_replace*()
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>
1 parent e620799 commit 5e06e08

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/list-test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ static void list_test_list_replace(struct kunit *test)
102102
/* now: [list] -> a_new -> b */
103103
KUNIT_EXPECT_PTR_EQ(test, list.next, &a_new);
104104
KUNIT_EXPECT_PTR_EQ(test, b.prev, &a_new);
105+
KUNIT_EXPECT_PTR_EQ(test, a_new.next, &b);
106+
KUNIT_EXPECT_PTR_EQ(test, a_new.prev, &list);
105107
}
106108

107109
static void list_test_list_replace_init(struct kunit *test)
@@ -118,6 +120,8 @@ static void list_test_list_replace_init(struct kunit *test)
118120
/* now: [list] -> a_new -> b */
119121
KUNIT_EXPECT_PTR_EQ(test, list.next, &a_new);
120122
KUNIT_EXPECT_PTR_EQ(test, b.prev, &a_new);
123+
KUNIT_EXPECT_PTR_EQ(test, a_new.next, &b);
124+
KUNIT_EXPECT_PTR_EQ(test, a_new.prev, &list);
121125

122126
/* check a_old is empty (initialized) */
123127
KUNIT_EXPECT_TRUE(test, list_empty_careful(&a_old));

0 commit comments

Comments
 (0)