lkml.org 
[lkml]   [2020]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH kunit 1/3] kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display
On Thu, Jan 23, 2020 at 02:47:18PM +0000, Alan Maguire wrote:
> add debugfs support for displaying kunit test suite results; this is
> especially useful for module-loaded tests to allow disentangling of
> test result display from other dmesg events.
>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---
> include/kunit/test.h | 21 +++++++---
> lib/kunit/Makefile | 3 +-
> lib/kunit/debugfs.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++
> lib/kunit/debugfs.h | 11 +++++
> lib/kunit/test.c | 88 ++++++++++++++++++++++++++++++----------
> 5 files changed, 206 insertions(+), 28 deletions(-)
> create mode 100644 lib/kunit/debugfs.c
> create mode 100644 lib/kunit/debugfs.h
>
> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index 2dfb550..37219b8a 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -125,6 +125,8 @@ struct kunit_case {
> bool success;
> };
>
> +#define kunit_status2str(status) (status ? "ok" : "not ok")
> +
> /**
> * KUNIT_CASE - A helper for creating a &struct kunit_case
> *
> @@ -157,6 +159,9 @@ struct kunit_suite {
> int (*init)(struct kunit *test);
> void (*exit)(struct kunit *test);
> struct kunit_case *test_cases;
> +
> + /* private - internal use only */
> + struct dentry *debugfs;
> };
>
> /**
> @@ -197,6 +202,15 @@ struct kunit {
>
> int kunit_run_tests(struct kunit_suite *suite);
>
> +size_t kunit_suite_num_test_cases(struct kunit_suite *suite);
> +
> +unsigned int kunit_test_case_num(struct kunit_suite *suite,
> + struct kunit_case *test_case);
> +
> +int __kunit_test_suites_init(struct kunit_suite **suites);
> +
> +void __kunit_test_suites_exit(struct kunit_suite **suites);
> +
> /**
> * kunit_test_suites() - used to register one or more &struct kunit_suite
> * with KUnit.
> @@ -226,15 +240,12 @@ struct kunit {
> static struct kunit_suite *suites[] = { __VA_ARGS__, NULL}; \
> static int kunit_test_suites_init(void) \
> { \
> - unsigned int i; \
> - for (i = 0; suites[i] != NULL; i++) \
> - kunit_run_tests(suites[i]); \
> - return 0; \
> + return __kunit_test_suites_init(suites); \
> } \
> late_initcall(kunit_test_suites_init); \
> static void __exit kunit_test_suites_exit(void) \
> { \
> - return; \
> + return __kunit_test_suites_exit(suites); \
> } \
> module_exit(kunit_test_suites_exit)
>
> diff --git a/lib/kunit/Makefile b/lib/kunit/Makefile
> index fab5564..869aab0 100644
> --- a/lib/kunit/Makefile
> +++ b/lib/kunit/Makefile
> @@ -3,7 +3,8 @@ obj-$(CONFIG_KUNIT) += kunit.o
> kunit-objs += test.o \
> string-stream.o \
> assert.o \
> - try-catch.o
> + try-catch.o \
> + debugfs.o
>
> obj-$(CONFIG_KUNIT_TEST) += kunit-test.o
>
> diff --git a/lib/kunit/debugfs.c b/lib/kunit/debugfs.c
> new file mode 100644
> index 0000000..5994f32
> --- /dev/null
> +++ b/lib/kunit/debugfs.c
> @@ -0,0 +1,111 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2020, Oracle and/or its affiliates.
> + * Author: Alan Maguire <alan.maguire@oracle.com>
> + */
> +#include <asm/unistd.h>
Why do you need this asm include file?

> +#include <linux/debugfs.h>
> +#include <linux/module.h>
> +#include <linux/time.h>
> +
> +#include <uapi/linux/limits.h>
> +#include <kunit/test.h>
> +
> +#include "string-stream.h"
> +
> +#define KUNIT_DEBUGFS_ROOT "kunit"
> +#define KUNIT_DEBUGFS_RESULTS "results"
> +
> +/*
> + * Create a debugfs representation of test suites:
> + *
> + * Path Semantics
> + * /sys/kernel/debug/kunit/<testsuite>/results Show results of last run for
> + * testsuite
> + *
> + */
> +
> +static struct dentry *debugfs_rootdir;
> +
> +void debugfs_cleanup(void)

Can you prefix all of your global symbols here with "kunit_debugfs"
instead of just "debugfs" to show that this really is not the core
debugfs kernel code?

thanks,

greg k-h

\
 
 \ /
  Last update: 2020-01-23 15:54    [W:0.071 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site