lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 23 Oct 2019 15:02:48 -0700
From:   Brendan Higgins <brendanhiggins@...gle.com>
To:     David Gow <davidgow@...gle.com>
Cc:     shuah@...nel.org, akpm@...ux-foundation.org, keescook@...omium.org,
        linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com,
        linux-kernel@...r.kernel.org, dan.carpenter@...cle.com
Subject: Re: [PATCH linux-kselftest/test v5] lib/list-test: add a test for
 the 'list' doubly linked list

On Tue, Oct 22, 2019 at 03:13:22PM -0700, 'David Gow' via KUnit Development wrote:
> Add a KUnit test for the kernel doubly linked list implementation in
> include/linux/list.h
> 
> Each test case (list_test_x) is focused on testing the behaviour of the
> list function/macro 'x'. None of the tests pass invalid lists to these
> macros, and so should behave identically with DEBUG_LIST enabled and
> disabled.
> 
> 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).
> 
> Signed-off-by: David Gow <davidgow@...gle.com>

Reviewed-by: Brendan Higgins <brendanhiggins@...gle.com>
Tested-by: Brendan Higgins <brendanhiggins@...gle.com>

I think I already had a "Reviewed-by and a Tested-by" on this patch.
Please make sure to apply the footers to subsequent versions of a patch
in the future.

> ---
> v5 replaces the use of KUNIT_ASSERT_NOT_ERR_OR_NULL() -- to check the
> return value from kzalloc() and kmalloc() -- with the __GFP_NOFAIL
> arugment. (Both in the list_test_list_init test.)
> 
> Earlier versions of the test can be found:
> v4: https://lore.kernel.org/linux-kselftest/20191018215549.65000-1-davidgow@google.com/
> v3: https://lore.kernel.org/linux-kselftest/20191016215707.95317-1-davidgow@google.com/
> v2: https://lore.kernel.org/linux-kselftest/20191010185631.26541-1-davidgow@google.com/
> v1: https://lore.kernel.org/linux-kselftest/20191007213633.92565-1-davidgow@google.com/
> 
> 
>  MAINTAINERS       |   5 +
>  lib/Kconfig.debug |  18 ++
>  lib/Makefile      |   3 +
>  lib/list-test.c   | 738 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 764 insertions(+)
>  create mode 100644 lib/list-test.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7ef985e01457..7ced1b69a3d3 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9504,6 +9504,11 @@ F:	Documentation/misc-devices/lis3lv02d.rst
>  F:	drivers/misc/lis3lv02d/
>  F:	drivers/platform/x86/hp_accel.c
>  
> +LIST KUNIT TEST
> +M:	David Gow <davidgow@...gle.com>
> +S:	Maintained
> +F:	lib/list-test.c

Probably want to have a "mailing list" line. Something like:
"""
L:	linux-kselftest@...r.kernel.org
L:	kunit-dev@...glegroups.com
"""

> +
>  LIVE PATCHING
>  M:	Josh Poimboeuf <jpoimboe@...hat.com>
>  M:	Jiri Kosina <jikos@...nel.org>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index a3017a5dadcd..7991b78eb1f3 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -1961,6 +1961,24 @@ config SYSCTL_KUNIT_TEST
>  
>  	  If unsure, say N.
>  
> +config LIST_KUNIT_TEST
> +	bool "KUnit Test for Kernel Linked-list structures"
> +	depends on KUNIT
> +	help
> +	  This builds the linked list KUnit test suite.
> +	  It tests that the API and basic functionality of the list_head type
> +	  and associated macros.
> +	

nit: unnecessary tab.

> +	  KUnit tests run during boot and output the results to the debug log
> +	  in TAP format (http://testanything.org/). Only useful for kernel devs
> +	  running the KUnit test harness, and not intended for inclusion into a
> +	  production build.
> +
> +	  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/list-test.c b/lib/list-test.c
> new file mode 100644
> index 000000000000..a6d17647e309
> --- /dev/null
> +++ b/lib/list-test.c
[...]
> +static void list_test_list_entry(struct kunit *test)
> +{
> +	struct list_test_struct test_struct;
> +
> +	KUNIT_EXPECT_PTR_EQ(test, &test_struct, list_entry(&(test_struct.list), struct list_test_struct, list));

nit: here and elsewhere: over 80 chars.

> +}
> +
> +static void list_test_list_first_entry(struct kunit *test)
> +{
> +	struct list_test_struct test_struct1, test_struct2;
> +	LIST_HEAD(list);
> +
> +	list_add_tail(&test_struct1.list, &list);
> +	list_add_tail(&test_struct2.list, &list);
> +
> +
> +	KUNIT_EXPECT_PTR_EQ(test, &test_struct1, list_first_entry(&list, struct list_test_struct, list));
> +}
[...]
> +static void list_test_list_for_each_entry(struct kunit *test)
> +{
> +	struct list_test_struct entries[5], *cur;
> +	static LIST_HEAD(list);
> +	int i = 0;
> +
> +	for (i = 0; i < 5; ++i) {
> +		entries[i].data = i;
> +		list_add_tail(&entries[i].list, &list);
> +	}
> +
> +	i = 0;
> +
> +	list_for_each_entry(cur, &list, list) {
> +		KUNIT_EXPECT_EQ(test, cur->data, i);
> +		i++;
> +	}
> +	

nit: another unnecessary tab. Looks like you should probably run checkpatch.

> +	KUNIT_EXPECT_EQ(test, i, 5);
> +}
> +
> +static void list_test_list_for_each_entry_reverse(struct kunit *test)
> +{
> +	struct list_test_struct entries[5], *cur;
> +	static LIST_HEAD(list);
> +	int i = 0;
> +
> +	for (i = 0; i < 5; ++i) {
> +		entries[i].data = i;
> +		list_add_tail(&entries[i].list, &list);
> +	}
> +
> +	i = 4;
> +
> +	list_for_each_entry_reverse(cur, &list, list) {
> +		KUNIT_EXPECT_EQ(test, cur->data, i);
> +		i--;
> +	}
> +	
> +	KUNIT_EXPECT_EQ(test, i, -1);
> +}
[...]

Cheers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ