On Mon, Oct 07, 2019 at 02:36:33PM -0700, David Gow wrote: > This change adds a KUnit test for the kernel doubly linked list > implementation in include/linux/list.h > > Note that, at present, it only tests the list_ types (not the > singly-linked hlist_), and does not yet test all of the > list_for_each_entry* macros (and some related things like > list_prepare_entry). > > This change depends on KUnit, so should be merged via the 'test' branch: > https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/log/?h=test Others might feel differently than me, but I think this should go in the comment section (below the "---"). > Signed-off-by: David Gow <davidgow@xxxxxxxxxx> Reviewed-by: Brendan Higgins <brendanhiggins@xxxxxxxxxx> Tested-by: Brendan Higgins <brendanhiggins@xxxxxxxxxx> > --- > lib/Kconfig.debug | 12 + > lib/Makefile | 3 + > lib/list-test.c | 711 ++++++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 726 insertions(+) > create mode 100644 lib/list-test.c > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index a3017a5dadcd..60691c0aac3e 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -1961,6 +1961,18 @@ config SYSCTL_KUNIT_TEST > > If unsure, say N. > > +config LIST_TEST > + bool "KUnit Test for Kernel Linked-list stuctures" > + depends on KUNIT > + help > + This builds the linked list unit test, which runs on boot. > + It tests that the API and basic functionality of the list_head type > + and associated macros. > + For more information on KUnit and unit tests in general please refer > + to the KUnit documentation in Documentation/dev-tools/kunit/. > + > + If unsure, say N. > + > config TEST_UDELAY > tristate "udelay test driver" > help > diff --git a/lib/Makefile b/lib/Makefile > index bba1fd5485f7..309e174ee35d 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -292,3 +292,6 @@ obj-$(CONFIG_GENERIC_LIB_MULDI3) += muldi3.o > obj-$(CONFIG_GENERIC_LIB_CMPDI2) += cmpdi2.o > obj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o > obj-$(CONFIG_OBJAGG) += objagg.o > + > +# KUnit tests > +obj-$(CONFIG_LIST_TEST) += list-test.o > diff --git a/lib/list-test.c b/lib/list-test.c > new file mode 100644 > index 000000000000..f333e8b0d9fe > --- /dev/null > +++ b/lib/list-test.c > @@ -0,0 +1,711 @@ > +// SPDX-License-Identifier: GPL-2.0 Might also want to add a bit more of a description here. Even if it is just something like "KUnit test for the doubly linked list data structure." Also: /* * <Insert description here.> * * Copyright (C) 2019, Google LLC. * Author: David Gow <davidgow@xxxxxxxxxx> */ > +#include <kunit/test.h> > + > +#include <linux/list.h> > + > +struct list_test_struct { > + int data; > + struct list_head list; > +}; <snip> Thanks!