Skip to content

Commit e620799

Browse files
vax-rakpm00
authored andcommitted
list: test: fix tests for list_cut_position()
Fix test for list_cut_position*() for the missing check of integer "i" after the second loop. The variable should be checked for second time to make sure both lists after the cut operation are formed as expected. Link: https://lkml.kernel.org/r/20240910043531.71343-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 1330976 commit e620799

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/list-test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,13 @@ static void list_test_list_cut_position(struct kunit *test)
404404

405405
KUNIT_EXPECT_EQ(test, i, 2);
406406

407+
i = 0;
407408
list_for_each(cur, &list1) {
408409
KUNIT_EXPECT_PTR_EQ(test, cur, &entries[i]);
409410
i++;
410411
}
412+
413+
KUNIT_EXPECT_EQ(test, i, 1);
411414
}
412415

413416
static void list_test_list_cut_before(struct kunit *test)
@@ -432,10 +435,13 @@ static void list_test_list_cut_before(struct kunit *test)
432435

433436
KUNIT_EXPECT_EQ(test, i, 1);
434437

438+
i = 0;
435439
list_for_each(cur, &list1) {
436440
KUNIT_EXPECT_PTR_EQ(test, cur, &entries[i]);
437441
i++;
438442
}
443+
444+
KUNIT_EXPECT_EQ(test, i, 2);
439445
}
440446

441447
static void list_test_list_splice(struct kunit *test)

0 commit comments

Comments
 (0)