Re: [PATCH v12 05/18] kunit: test: add the concept of expectations

From: Stephen Boyd
Date: Mon Aug 12 2019 - 19:57:05 EST


Quoting Brendan Higgins (2019-08-12 11:24:08)
> Add support for expectations, which allow properties to be specified and
> then verified in tests.
>
> Signed-off-by: Brendan Higgins <brendanhiggins@xxxxxxxxxx>
> Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Reviewed-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>

Reviewed-by: Stephen Boyd <sboyd@xxxxxxxxxx>

Just some minor nits again.

> diff --git a/include/kunit/test.h b/include/kunit/test.h
> index d0bf112910caf..2625bcfeb19ac 100644
> --- a/include/kunit/test.h
> +++ b/include/kunit/test.h
> @@ -9,8 +9,10 @@
> #ifndef _KUNIT_TEST_H
> #define _KUNIT_TEST_H
>
> +#include <linux/kernel.h>
> #include <linux/types.h>
> #include <linux/slab.h>
> +#include <kunit/assert.h>

Can you alphabet sort these?

>
> struct kunit_resource;
>
> @@ -319,4 +321,845 @@ void __printf(3, 4) kunit_printk(const char *level,
> #define kunit_err(test, fmt, ...) \
> kunit_printk(KERN_ERR, test, fmt, ##__VA_ARGS__)
>
> +/*
> + * Generates a compile-time warning in case of comparing incompatible types.
> + */
> +#define __kunit_typecheck(lhs, rhs) \
> + ((void) __typecheck(lhs, rhs))

Is there a reason why this can't be inlined and the __kunit_typecheck()
macro can't be removed?

> +
> +/**
> + * KUNIT_SUCCEED() - A no-op expectation. Only exists for code clarity.
> + * @test: The test context object.
[...]
> + * @condition: an arbitrary boolean expression. The test fails when this does
> + * not evaluate to true.
> + *
> + * This and expectations of the form `KUNIT_EXPECT_*` will cause the test case
> + * to fail when the specified condition is not met; however, it will not prevent
> + * the test case from continuing to run; this is otherwise known as an
> + * *expectation failure*.
> + */
> +#define KUNIT_EXPECT_TRUE(test, condition) \
> + KUNIT_TRUE_ASSERTION(test, KUNIT_EXPECTATION, condition)

A lot of these macros seem double indented.

> +
> +#define KUNIT_EXPECT_TRUE_MSG(test, condition, fmt, ...) \
> + KUNIT_TRUE_MSG_ASSERTION(test, \
> + KUNIT_EXPECTATION, \
> + condition, \
> + fmt, \
> + ##__VA_ARGS__)
> +