Message ID | 1581949660-20113-3-git-send-email-alan.maguire@oracle.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | kunit: add debugfs representation to show results | expand |
On Mon, Feb 17, 2020 at 6:28 AM Alan Maguire <alan.maguire@oracle.com> wrote: > > the logging test ensures multiple strings logged appear in the > log string associated with the test when CONFIG_KUNIT_DEBUGFS is > enabled. > > Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> One minor comment below. > --- > lib/kunit/kunit-test.c | 27 ++++++++++++++++++++++++++- > 1 file changed, 26 insertions(+), 1 deletion(-) > > diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c > index aceb5bf..0789060 100644 > --- a/lib/kunit/kunit-test.c > +++ b/lib/kunit/kunit-test.c > @@ -329,6 +329,31 @@ static void kunit_resource_test_exit(struct kunit *test) > .exit = kunit_resource_test_exit, > .test_cases = kunit_resource_test_cases, > }; > -kunit_test_suites(&kunit_try_catch_test_suite, &kunit_resource_test_suite); > + > +static void kunit_log_test(struct kunit *test) > +{ > + kunit_log(KERN_INFO, test, "put this in log."); > + kunit_log(KERN_INFO, test, "this too."); > + > +#ifdef CONFIG_KUNIT_DEBUGFS > + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, > + strstr(test->log, "put this in log.")); > + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, > + strstr(test->log, "this too.")); > +#endif > +} Would you mind adding some expectations against the suite log? It might be good for the sake of completeness. > + > +static struct kunit_case kunit_log_test_cases[] = { > + KUNIT_CASE(kunit_log_test), > + {} > +}; > + > +static struct kunit_suite kunit_log_test_suite = { > + .name = "kunit-log-test", > + .test_cases = kunit_log_test_cases, > +}; > + > +kunit_test_suites(&kunit_try_catch_test_suite, &kunit_resource_test_suite, > + &kunit_log_test_suite); > > MODULE_LICENSE("GPL v2"); > -- > 1.8.3.1 >
diff --git a/lib/kunit/kunit-test.c b/lib/kunit/kunit-test.c index aceb5bf..0789060 100644 --- a/lib/kunit/kunit-test.c +++ b/lib/kunit/kunit-test.c @@ -329,6 +329,31 @@ static void kunit_resource_test_exit(struct kunit *test) .exit = kunit_resource_test_exit, .test_cases = kunit_resource_test_cases, }; -kunit_test_suites(&kunit_try_catch_test_suite, &kunit_resource_test_suite); + +static void kunit_log_test(struct kunit *test) +{ + kunit_log(KERN_INFO, test, "put this in log."); + kunit_log(KERN_INFO, test, "this too."); + +#ifdef CONFIG_KUNIT_DEBUGFS + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, + strstr(test->log, "put this in log.")); + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, + strstr(test->log, "this too.")); +#endif +} + +static struct kunit_case kunit_log_test_cases[] = { + KUNIT_CASE(kunit_log_test), + {} +}; + +static struct kunit_suite kunit_log_test_suite = { + .name = "kunit-log-test", + .test_cases = kunit_log_test_cases, +}; + +kunit_test_suites(&kunit_try_catch_test_suite, &kunit_resource_test_suite, + &kunit_log_test_suite); MODULE_LICENSE("GPL v2");
the logging test ensures multiple strings logged appear in the log string associated with the test when CONFIG_KUNIT_DEBUGFS is enabled. Signed-off-by: Alan Maguire <alan.maguire@oracle.com> --- lib/kunit/kunit-test.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-)