Fix linked-list KUnit test when run multiple times

A few of the lists used in the linked-list KUnit tests (the
for_each_entry{,_reverse} tests) are declared 'static', and so are
not-reinitialised if the test runs multiple times. This was not a
problem when KUnit tests were run once on startup, but when tests are
able to be run manually (e.g. from debugfs[1]), this is no longer the
case.

Making these lists no longer 'static' causes the lists to be
reinitialised, and the test passes each time it is run. While there may
be some value in testing that initialising static lists works, the
for_each_entry_* tests are unlikely to be the right place for it.

Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
David Gow 2020-01-24 11:45:08 -08:00 committed by Shuah Khan
parent 97752c39bd
commit cb88577bb6

View File

@ -659,7 +659,7 @@ static void list_test_list_for_each_prev_safe(struct kunit *test)
static void list_test_list_for_each_entry(struct kunit *test) static void list_test_list_for_each_entry(struct kunit *test)
{ {
struct list_test_struct entries[5], *cur; struct list_test_struct entries[5], *cur;
static LIST_HEAD(list); LIST_HEAD(list);
int i = 0; int i = 0;
for (i = 0; i < 5; ++i) { for (i = 0; i < 5; ++i) {
@ -680,7 +680,7 @@ static void list_test_list_for_each_entry(struct kunit *test)
static void list_test_list_for_each_entry_reverse(struct kunit *test) static void list_test_list_for_each_entry_reverse(struct kunit *test)
{ {
struct list_test_struct entries[5], *cur; struct list_test_struct entries[5], *cur;
static LIST_HEAD(list); LIST_HEAD(list);
int i = 0; int i = 0;
for (i = 0; i < 5; ++i) { for (i = 0; i < 5; ++i) {