kunit: transition: add Kconfig option for test.h to use upstream names, start impl
Start with just changing `struct test` to `struct kunit`.
If this was defined as `typedef struct test test;` then a simple
`typedef test kunit.` would have sufficed.
But alas, there's no way to make `struct kunit` actually refer to
`struct test`.
So we define a KUNIT_T macro used by all internal files.
(We use a _T suffix so we can use KUNIT_CASE_T instead of KUNIT_CASE)
Since the type is passed into several macros, this requires reworking
them to expand their arguments before trying to concatenate them.
Users can now add
CONFIG_KUNIT_USE_UPSTREAM_NAMES=y
to their kunitconfig to build their code with the new names.
(Or change the default to 'y' when their code is ready).
Change-Id: Ie77fe1d731843b91c7cd2b2dc36e2cf74fadcc34
diff --git a/include/test/mock.h b/include/test/mock.h
index e37ab9f..8b8031c 100644
--- a/include/test/mock.h
+++ b/include/test/mock.h
@@ -113,7 +113,7 @@ enum mock_type {
struct mock {
struct test_post_condition parent;
- struct test *test;
+ struct KUNIT_T *test;
struct list_head methods;
enum mock_type type;
const void *(*do_expect)(struct mock *mock,
@@ -126,7 +126,7 @@ struct mock {
#define DEFAULT_MOCK_TYPE MOCK_TYPE_NAGGY
-void mock_init_ctrl(struct test *test, struct mock *mock);
+void mock_init_ctrl(struct KUNIT_T *test, struct mock *mock);
void mock_validate_expectations(struct mock *mock);
@@ -155,7 +155,10 @@ void mock_unregister_formatter(struct mock_param_formatter *formatter);
struct mock *mock_get_global_mock(void);
-#define MOCK(name) name##_mock
+// Transitional: hacks necessary to force expansion if `name` is a macro.
+#define MOCK(name) MOCK_NOEXPAND(EXPAND(name))
+#define MOCK_NOEXPAND(name) MOCK_ACTUALLY(name)
+#define MOCK_ACTUALLY(name) name##_mock
/**
* STRICT_MOCK() - sets the mock to be strict and returns the mock
@@ -242,7 +245,7 @@ static inline bool is_naggy_mock(struct mock *mock)
*
* DEFINE_STRUCT_CLASS_MOCK_INIT(example, example_init);
*
- * static void foo_example_test_success(struct test *test)
+ * static void foo_example_test_success(struct KUNIT_T *test)
* {
* struct MOCK(example) *mock_example;
* struct example *example = mock_get_trgt(mock_example);
@@ -443,7 +446,7 @@ static inline struct mock_expectation *Returns(
#define InSequence(test, first, ...) \
mock_in_sequence(test, first, __VA_ARGS__, 0)
-int mock_in_sequence(struct test *test, struct mock_expectation *first, ...);
+int mock_in_sequence(struct KUNIT_T *test, struct mock_expectation *first, ...);
#define mock_get_ctrl_internal(mock_object) (&(mock_object)->ctrl)
#define mock_get_ctrl(mock_object) mock_get_ctrl_internal(mock_object)
@@ -453,7 +456,7 @@ int mock_in_sequence(struct test *test, struct mock_expectation *first, ...);
#define mock_get_test(mock_object) (mock_get_ctrl(mock_object)->test)
-#define CLASS(struct_name) struct_name
+#define CLASS(struct_name) EXPAND(struct_name)
#define HANDLE_INDEX(index) index
#define METHOD(method_name) method_name
#define RETURNS(return_type) return_type
@@ -478,7 +481,7 @@ int mock_in_sequence(struct test *test, struct mock_expectation *first, ...);
#define DECLARE_REDIRECT_MOCKABLE(name, return_type, param_types...) \
return_type REAL_ID(name)(param_types); \
return_type name(param_types); \
- void *INVOKE_ID(name)(struct test *test, \
+ void *INVOKE_ID(name)(struct KUNIT_T *test, \
const void *params[], \
int len)
@@ -584,8 +587,11 @@ int mock_in_sequence(struct test *test, struct mock_expectation *first, ...);
* declarations.
*/
#define DECLARE_STRUCT_CLASS_MOCK_INIT(struct_name) \
+ DECLARE_STRUCT_CLASS_MOCK_INIT_NOEXPAND(EXPAND(struct_name))
+
+#define DECLARE_STRUCT_CLASS_MOCK_INIT_NOEXPAND(struct_name) \
struct MOCK(struct_name) *MOCK_INIT_ID(struct_name)( \
- struct test *test)
+ struct KUNIT_T *test)
#define DECLARE_VOID_CLASS_MOCK_HANDLE_INDEX_INTERNAL(name, \
handle_index, \
@@ -664,7 +670,7 @@ int mock_in_sequence(struct test *test, struct mock_expectation *first, ...);
#if IS_ENABLED(CONFIG_TEST)
#define DEFINE_INVOKABLE(name, return_type, RETURN_ASSIGN, param_types...) \
- void *INVOKE_ID(name)(struct test *test, \
+ void *INVOKE_ID(name)(struct KUNIT_T *test, \
const void *params[], \
int len) { \
return_type *retval; \
@@ -714,7 +720,7 @@ int mock_in_sequence(struct test *test, struct mock_expectation *first, ...);
* ...
* }
*
- * static int aspeed_i2c_test_init(struct test *test)
+ * static int aspeed_i2c_test_init(struct KUNIT_T *test)
* {
* struct mock_param_capturer *adap_capturer;
* struct mock_expectation *handle;
@@ -972,7 +978,7 @@ int mock_in_sequence(struct test *test, struct mock_expectation *first, ...);
*/
#define DEFINE_STRUCT_CLASS_MOCK_INIT(struct_name, init_func) \
struct MOCK(struct_name) *MOCK_INIT_ID(struct_name)( \
- struct test *test) \
+ struct KUNIT_T *test) \
{ \
struct MOCK(struct_name) *mock_obj; \
\
@@ -1096,7 +1102,7 @@ DECLARE_STRUCT_CLASS_MOCK_INIT(void);
*
* .. code-block:: c
*
- * struct mock_param_matcher *any(struct test *test);
+ * struct mock_param_matcher *any(struct KUNIT_T *test);
*
* There are matchers for integers based on the binary condition:
*
@@ -1109,192 +1115,192 @@ DECLARE_STRUCT_CLASS_MOCK_INIT(void);
*
* .. code-block:: c
*
- * struct mock_param_matcher *int_eq(struct test *test, int expected);
- * struct mock_param_matcher *int_ne(struct test *test, int expected);
- * struct mock_param_matcher *int_lt(struct test *test, int expected);
- * struct mock_param_matcher *int_le(struct test *test, int expected);
- * struct mock_param_matcher *int_gt(struct test *test, int expected);
- * struct mock_param_matcher *int_ge(struct test *test, int expected);
+ * struct mock_param_matcher *int_eq(struct KUNIT_T *test, int expected);
+ * struct mock_param_matcher *int_ne(struct KUNIT_T *test, int expected);
+ * struct mock_param_matcher *int_lt(struct KUNIT_T *test, int expected);
+ * struct mock_param_matcher *int_le(struct KUNIT_T *test, int expected);
+ * struct mock_param_matcher *int_gt(struct KUNIT_T *test, int expected);
+ * struct mock_param_matcher *int_ge(struct KUNIT_T *test, int expected);
*
* For a detailed list, please see
* ``include/linux/mock.h``.
*/
/* Matches any argument */
-struct mock_param_matcher *any(struct test *test);
+struct mock_param_matcher *any(struct KUNIT_T *test);
/*
* Matches different types of integers, the argument is compared to the
* `expected` field, based on the comparison defined.
*/
-struct mock_param_matcher *u8_eq(struct test *test, u8 expected);
-struct mock_param_matcher *u8_ne(struct test *test, u8 expected);
-struct mock_param_matcher *u8_le(struct test *test, u8 expected);
-struct mock_param_matcher *u8_lt(struct test *test, u8 expected);
-struct mock_param_matcher *u8_ge(struct test *test, u8 expected);
-struct mock_param_matcher *u8_gt(struct test *test, u8 expected);
+struct mock_param_matcher *u8_eq(struct KUNIT_T *test, u8 expected);
+struct mock_param_matcher *u8_ne(struct KUNIT_T *test, u8 expected);
+struct mock_param_matcher *u8_le(struct KUNIT_T *test, u8 expected);
+struct mock_param_matcher *u8_lt(struct KUNIT_T *test, u8 expected);
+struct mock_param_matcher *u8_ge(struct KUNIT_T *test, u8 expected);
+struct mock_param_matcher *u8_gt(struct KUNIT_T *test, u8 expected);
-struct mock_param_matcher *u16_eq(struct test *test, u16 expected);
-struct mock_param_matcher *u16_ne(struct test *test, u16 expected);
-struct mock_param_matcher *u16_le(struct test *test, u16 expected);
-struct mock_param_matcher *u16_lt(struct test *test, u16 expected);
-struct mock_param_matcher *u16_ge(struct test *test, u16 expected);
-struct mock_param_matcher *u16_gt(struct test *test, u16 expected);
+struct mock_param_matcher *u16_eq(struct KUNIT_T *test, u16 expected);
+struct mock_param_matcher *u16_ne(struct KUNIT_T *test, u16 expected);
+struct mock_param_matcher *u16_le(struct KUNIT_T *test, u16 expected);
+struct mock_param_matcher *u16_lt(struct KUNIT_T *test, u16 expected);
+struct mock_param_matcher *u16_ge(struct KUNIT_T *test, u16 expected);
+struct mock_param_matcher *u16_gt(struct KUNIT_T *test, u16 expected);
-struct mock_param_matcher *u32_eq(struct test *test, u32 expected);
-struct mock_param_matcher *u32_ne(struct test *test, u32 expected);
-struct mock_param_matcher *u32_le(struct test *test, u32 expected);
-struct mock_param_matcher *u32_lt(struct test *test, u32 expected);
-struct mock_param_matcher *u32_ge(struct test *test, u32 expected);
-struct mock_param_matcher *u32_gt(struct test *test, u32 expected);
+struct mock_param_matcher *u32_eq(struct KUNIT_T *test, u32 expected);
+struct mock_param_matcher *u32_ne(struct KUNIT_T *test, u32 expected);
+struct mock_param_matcher *u32_le(struct KUNIT_T *test, u32 expected);
+struct mock_param_matcher *u32_lt(struct KUNIT_T *test, u32 expected);
+struct mock_param_matcher *u32_ge(struct KUNIT_T *test, u32 expected);
+struct mock_param_matcher *u32_gt(struct KUNIT_T *test, u32 expected);
-struct mock_param_matcher *u64_eq(struct test *test, u64 expected);
-struct mock_param_matcher *u64_ne(struct test *test, u64 expected);
-struct mock_param_matcher *u64_le(struct test *test, u64 expected);
-struct mock_param_matcher *u64_lt(struct test *test, u64 expected);
-struct mock_param_matcher *u64_ge(struct test *test, u64 expected);
-struct mock_param_matcher *u64_gt(struct test *test, u64 expected);
+struct mock_param_matcher *u64_eq(struct KUNIT_T *test, u64 expected);
+struct mock_param_matcher *u64_ne(struct KUNIT_T *test, u64 expected);
+struct mock_param_matcher *u64_le(struct KUNIT_T *test, u64 expected);
+struct mock_param_matcher *u64_lt(struct KUNIT_T *test, u64 expected);
+struct mock_param_matcher *u64_ge(struct KUNIT_T *test, u64 expected);
+struct mock_param_matcher *u64_gt(struct KUNIT_T *test, u64 expected);
-struct mock_param_matcher *char_eq(struct test *test, char expected);
-struct mock_param_matcher *char_ne(struct test *test, char expected);
-struct mock_param_matcher *char_le(struct test *test, char expected);
-struct mock_param_matcher *char_lt(struct test *test, char expected);
-struct mock_param_matcher *char_ge(struct test *test, char expected);
-struct mock_param_matcher *char_gt(struct test *test, char expected);
+struct mock_param_matcher *char_eq(struct KUNIT_T *test, char expected);
+struct mock_param_matcher *char_ne(struct KUNIT_T *test, char expected);
+struct mock_param_matcher *char_le(struct KUNIT_T *test, char expected);
+struct mock_param_matcher *char_lt(struct KUNIT_T *test, char expected);
+struct mock_param_matcher *char_ge(struct KUNIT_T *test, char expected);
+struct mock_param_matcher *char_gt(struct KUNIT_T *test, char expected);
-struct mock_param_matcher *uchar_eq(struct test *test, unsigned char expected);
-struct mock_param_matcher *uchar_ne(struct test *test, unsigned char expected);
-struct mock_param_matcher *uchar_le(struct test *test, unsigned char expected);
-struct mock_param_matcher *uchar_lt(struct test *test, unsigned char expected);
-struct mock_param_matcher *uchar_ge(struct test *test, unsigned char expected);
-struct mock_param_matcher *uchar_gt(struct test *test, unsigned char expected);
+struct mock_param_matcher *uchar_eq(struct KUNIT_T *test, unsigned char expected);
+struct mock_param_matcher *uchar_ne(struct KUNIT_T *test, unsigned char expected);
+struct mock_param_matcher *uchar_le(struct KUNIT_T *test, unsigned char expected);
+struct mock_param_matcher *uchar_lt(struct KUNIT_T *test, unsigned char expected);
+struct mock_param_matcher *uchar_ge(struct KUNIT_T *test, unsigned char expected);
+struct mock_param_matcher *uchar_gt(struct KUNIT_T *test, unsigned char expected);
-struct mock_param_matcher *schar_eq(struct test *test, signed char expected);
-struct mock_param_matcher *schar_ne(struct test *test, signed char expected);
-struct mock_param_matcher *schar_le(struct test *test, signed char expected);
-struct mock_param_matcher *schar_lt(struct test *test, signed char expected);
-struct mock_param_matcher *schar_ge(struct test *test, signed char expected);
-struct mock_param_matcher *schar_gt(struct test *test, signed char expected);
+struct mock_param_matcher *schar_eq(struct KUNIT_T *test, signed char expected);
+struct mock_param_matcher *schar_ne(struct KUNIT_T *test, signed char expected);
+struct mock_param_matcher *schar_le(struct KUNIT_T *test, signed char expected);
+struct mock_param_matcher *schar_lt(struct KUNIT_T *test, signed char expected);
+struct mock_param_matcher *schar_ge(struct KUNIT_T *test, signed char expected);
+struct mock_param_matcher *schar_gt(struct KUNIT_T *test, signed char expected);
-struct mock_param_matcher *short_eq(struct test *test, short expected);
-struct mock_param_matcher *short_ne(struct test *test, short expected);
-struct mock_param_matcher *short_le(struct test *test, short expected);
-struct mock_param_matcher *short_lt(struct test *test, short expected);
-struct mock_param_matcher *short_ge(struct test *test, short expected);
-struct mock_param_matcher *short_gt(struct test *test, short expected);
+struct mock_param_matcher *short_eq(struct KUNIT_T *test, short expected);
+struct mock_param_matcher *short_ne(struct KUNIT_T *test, short expected);
+struct mock_param_matcher *short_le(struct KUNIT_T *test, short expected);
+struct mock_param_matcher *short_lt(struct KUNIT_T *test, short expected);
+struct mock_param_matcher *short_ge(struct KUNIT_T *test, short expected);
+struct mock_param_matcher *short_gt(struct KUNIT_T *test, short expected);
-struct mock_param_matcher *ushort_eq(struct test *test,
+struct mock_param_matcher *ushort_eq(struct KUNIT_T *test,
unsigned short expected);
-struct mock_param_matcher *ushort_ne(struct test *test,
+struct mock_param_matcher *ushort_ne(struct KUNIT_T *test,
unsigned short expected);
-struct mock_param_matcher *ushort_le(struct test *test,
+struct mock_param_matcher *ushort_le(struct KUNIT_T *test,
unsigned short expected);
-struct mock_param_matcher *ushort_lt(struct test *test,
+struct mock_param_matcher *ushort_lt(struct KUNIT_T *test,
unsigned short expected);
-struct mock_param_matcher *ushort_ge(struct test *test,
+struct mock_param_matcher *ushort_ge(struct KUNIT_T *test,
unsigned short expected);
-struct mock_param_matcher *ushort_gt(struct test *test,
+struct mock_param_matcher *ushort_gt(struct KUNIT_T *test,
unsigned short expected);
-struct mock_param_matcher *int_eq(struct test *test, int expected);
-struct mock_param_matcher *int_ne(struct test *test, int expected);
-struct mock_param_matcher *int_lt(struct test *test, int expected);
-struct mock_param_matcher *int_le(struct test *test, int expected);
-struct mock_param_matcher *int_gt(struct test *test, int expected);
-struct mock_param_matcher *int_ge(struct test *test, int expected);
+struct mock_param_matcher *int_eq(struct KUNIT_T *test, int expected);
+struct mock_param_matcher *int_ne(struct KUNIT_T *test, int expected);
+struct mock_param_matcher *int_lt(struct KUNIT_T *test, int expected);
+struct mock_param_matcher *int_le(struct KUNIT_T *test, int expected);
+struct mock_param_matcher *int_gt(struct KUNIT_T *test, int expected);
+struct mock_param_matcher *int_ge(struct KUNIT_T *test, int expected);
-struct mock_param_matcher *uint_eq(struct test *test, unsigned int expected);
-struct mock_param_matcher *uint_ne(struct test *test, unsigned int expected);
-struct mock_param_matcher *uint_lt(struct test *test, unsigned int expected);
-struct mock_param_matcher *uint_le(struct test *test, unsigned int expected);
-struct mock_param_matcher *uint_gt(struct test *test, unsigned int expected);
-struct mock_param_matcher *uint_ge(struct test *test, unsigned int expected);
+struct mock_param_matcher *uint_eq(struct KUNIT_T *test, unsigned int expected);
+struct mock_param_matcher *uint_ne(struct KUNIT_T *test, unsigned int expected);
+struct mock_param_matcher *uint_lt(struct KUNIT_T *test, unsigned int expected);
+struct mock_param_matcher *uint_le(struct KUNIT_T *test, unsigned int expected);
+struct mock_param_matcher *uint_gt(struct KUNIT_T *test, unsigned int expected);
+struct mock_param_matcher *uint_ge(struct KUNIT_T *test, unsigned int expected);
-struct mock_param_matcher *long_eq(struct test *test, long expected);
-struct mock_param_matcher *long_ne(struct test *test, long expected);
-struct mock_param_matcher *long_le(struct test *test, long expected);
-struct mock_param_matcher *long_lt(struct test *test, long expected);
-struct mock_param_matcher *long_ge(struct test *test, long expected);
-struct mock_param_matcher *long_gt(struct test *test, long expected);
+struct mock_param_matcher *long_eq(struct KUNIT_T *test, long expected);
+struct mock_param_matcher *long_ne(struct KUNIT_T *test, long expected);
+struct mock_param_matcher *long_le(struct KUNIT_T *test, long expected);
+struct mock_param_matcher *long_lt(struct KUNIT_T *test, long expected);
+struct mock_param_matcher *long_ge(struct KUNIT_T *test, long expected);
+struct mock_param_matcher *long_gt(struct KUNIT_T *test, long expected);
-struct mock_param_matcher *ulong_eq(struct test *test, unsigned long expected);
-struct mock_param_matcher *ulong_ne(struct test *test, unsigned long expected);
-struct mock_param_matcher *ulong_le(struct test *test, unsigned long expected);
-struct mock_param_matcher *ulong_lt(struct test *test, unsigned long expected);
-struct mock_param_matcher *ulong_ge(struct test *test, unsigned long expected);
-struct mock_param_matcher *ulong_gt(struct test *test, unsigned long expected);
+struct mock_param_matcher *ulong_eq(struct KUNIT_T *test, unsigned long expected);
+struct mock_param_matcher *ulong_ne(struct KUNIT_T *test, unsigned long expected);
+struct mock_param_matcher *ulong_le(struct KUNIT_T *test, unsigned long expected);
+struct mock_param_matcher *ulong_lt(struct KUNIT_T *test, unsigned long expected);
+struct mock_param_matcher *ulong_ge(struct KUNIT_T *test, unsigned long expected);
+struct mock_param_matcher *ulong_gt(struct KUNIT_T *test, unsigned long expected);
-struct mock_param_matcher *longlong_eq(struct test *test, long long expected);
-struct mock_param_matcher *longlong_ne(struct test *test, long long expected);
-struct mock_param_matcher *longlong_le(struct test *test, long long expected);
-struct mock_param_matcher *longlong_lt(struct test *test, long long expected);
-struct mock_param_matcher *longlong_ge(struct test *test, long long expected);
-struct mock_param_matcher *longlong_gt(struct test *test, long long expected);
+struct mock_param_matcher *longlong_eq(struct KUNIT_T *test, long long expected);
+struct mock_param_matcher *longlong_ne(struct KUNIT_T *test, long long expected);
+struct mock_param_matcher *longlong_le(struct KUNIT_T *test, long long expected);
+struct mock_param_matcher *longlong_lt(struct KUNIT_T *test, long long expected);
+struct mock_param_matcher *longlong_ge(struct KUNIT_T *test, long long expected);
+struct mock_param_matcher *longlong_gt(struct KUNIT_T *test, long long expected);
-struct mock_param_matcher *ulonglong_eq(struct test *test,
+struct mock_param_matcher *ulonglong_eq(struct KUNIT_T *test,
unsigned long long expected);
-struct mock_param_matcher *ulonglong_ne(struct test *test,
+struct mock_param_matcher *ulonglong_ne(struct KUNIT_T *test,
unsigned long long expected);
-struct mock_param_matcher *ulonglong_le(struct test *test,
+struct mock_param_matcher *ulonglong_le(struct KUNIT_T *test,
unsigned long long expected);
-struct mock_param_matcher *ulonglong_lt(struct test *test,
+struct mock_param_matcher *ulonglong_lt(struct KUNIT_T *test,
unsigned long long expected);
-struct mock_param_matcher *ulonglong_ge(struct test *test,
+struct mock_param_matcher *ulonglong_ge(struct KUNIT_T *test,
unsigned long long expected);
-struct mock_param_matcher *ulonglong_gt(struct test *test,
+struct mock_param_matcher *ulonglong_gt(struct KUNIT_T *test,
unsigned long long expected);
/* matches booleans. */
-struct mock_param_matcher *bool_eq(struct test *test, bool expected);
-struct mock_param_matcher *bool_ne(struct test *test, bool expected);
+struct mock_param_matcher *bool_eq(struct KUNIT_T *test, bool expected);
+struct mock_param_matcher *bool_ne(struct KUNIT_T *test, bool expected);
/* Matches pointers. */
-struct mock_param_matcher *ptr_eq(struct test *test, void *expected);
-struct mock_param_matcher *ptr_ne(struct test *test, void *expected);
-struct mock_param_matcher *ptr_lt(struct test *test, void *expected);
-struct mock_param_matcher *ptr_le(struct test *test, void *expected);
-struct mock_param_matcher *ptr_gt(struct test *test, void *expected);
-struct mock_param_matcher *ptr_ge(struct test *test, void *expected);
+struct mock_param_matcher *ptr_eq(struct KUNIT_T *test, void *expected);
+struct mock_param_matcher *ptr_ne(struct KUNIT_T *test, void *expected);
+struct mock_param_matcher *ptr_lt(struct KUNIT_T *test, void *expected);
+struct mock_param_matcher *ptr_le(struct KUNIT_T *test, void *expected);
+struct mock_param_matcher *ptr_gt(struct KUNIT_T *test, void *expected);
+struct mock_param_matcher *ptr_ge(struct KUNIT_T *test, void *expected);
/* Matches memory sections and strings. */
-struct mock_param_matcher *memeq(struct test *test,
+struct mock_param_matcher *memeq(struct KUNIT_T *test,
const void *buf,
size_t size);
-struct mock_param_matcher *streq(struct test *test, const char *str);
+struct mock_param_matcher *streq(struct KUNIT_T *test, const char *str);
-struct mock_param_matcher *str_contains(struct test *test, const char *needle);
+struct mock_param_matcher *str_contains(struct KUNIT_T *test, const char *needle);
/* Matches var-arg arguments. */
-struct mock_param_matcher *va_format_cmp(struct test *test,
+struct mock_param_matcher *va_format_cmp(struct KUNIT_T *test,
struct mock_param_matcher *fmt_matcher,
struct mock_param_matcher *va_matcher);
/* Compound matchers */
-struct mock_param_matcher *and(struct test *test,
+struct mock_param_matcher *and(struct KUNIT_T *test,
struct mock_param_matcher *left_matcher,
struct mock_param_matcher *right_matcher);
-struct mock_param_matcher *or(struct test *test,
+struct mock_param_matcher *or(struct KUNIT_T *test,
struct mock_param_matcher *left_matcher,
struct mock_param_matcher *right_matcher);
-struct mock_param_matcher *not(struct test *test,
+struct mock_param_matcher *not(struct KUNIT_T *test,
struct mock_param_matcher *inner_matcher);
-struct mock_action *bool_return(struct test *test, bool ret);
-struct mock_action *u8_return(struct test *test, u8 ret);
-struct mock_action *u16_return(struct test *test, u16 ret);
-struct mock_action *u32_return(struct test *test, u32 ret);
-struct mock_action *u64_return(struct test *test, u64 ret);
-struct mock_action *char_return(struct test *test, char ret);
-struct mock_action *uchar_return(struct test *test, unsigned char ret);
-struct mock_action *schar_return(struct test *test, signed char ret);
-struct mock_action *short_return(struct test *test, short ret);
-struct mock_action *ushort_return(struct test *test, unsigned short ret);
-struct mock_action *int_return(struct test *test, int ret);
-struct mock_action *uint_return(struct test *test, unsigned int ret);
-struct mock_action *long_return(struct test *test, long ret);
-struct mock_action *ulong_return(struct test *test, unsigned long ret);
-struct mock_action *longlong_return(struct test *test, long long ret);
-struct mock_action *ulonglong_return(struct test *test, unsigned long long ret);
-struct mock_action *ptr_return(struct test *test, void *ret);
+struct mock_action *bool_return(struct KUNIT_T *test, bool ret);
+struct mock_action *u8_return(struct KUNIT_T *test, u8 ret);
+struct mock_action *u16_return(struct KUNIT_T *test, u16 ret);
+struct mock_action *u32_return(struct KUNIT_T *test, u32 ret);
+struct mock_action *u64_return(struct KUNIT_T *test, u64 ret);
+struct mock_action *char_return(struct KUNIT_T *test, char ret);
+struct mock_action *uchar_return(struct KUNIT_T *test, unsigned char ret);
+struct mock_action *schar_return(struct KUNIT_T *test, signed char ret);
+struct mock_action *short_return(struct KUNIT_T *test, short ret);
+struct mock_action *ushort_return(struct KUNIT_T *test, unsigned short ret);
+struct mock_action *int_return(struct KUNIT_T *test, int ret);
+struct mock_action *uint_return(struct KUNIT_T *test, unsigned int ret);
+struct mock_action *long_return(struct KUNIT_T *test, long ret);
+struct mock_action *ulong_return(struct KUNIT_T *test, unsigned long ret);
+struct mock_action *longlong_return(struct KUNIT_T *test, long long ret);
+struct mock_action *ulonglong_return(struct KUNIT_T *test, unsigned long long ret);
+struct mock_action *ptr_return(struct KUNIT_T *test, void *ret);
/**
* struct mock_struct_matcher_entry - composed with other &struct
@@ -1340,7 +1346,7 @@ static inline void INIT_MOCK_STRUCT_MATCHER_ENTRY_LAST(
}
struct mock_param_matcher *struct_cmp(
- struct test *test,
+ struct KUNIT_T *test,
const char *struct_name,
struct mock_struct_matcher_entry *entries);
@@ -1352,7 +1358,7 @@ struct mock_param_matcher *struct_cmp(
*
* .. code-block::c
*
- * static int some_test(struct test *test)
+ * static int some_test(struct KUNIT_T *test)
* {
* // imagine a mocked function: int add(int a, int b)
* struct mock_param_capturer *capturer =
@@ -1367,14 +1373,14 @@ struct mock_param_capturer {
/* private: internal use only. */
struct mock_param_matcher matcher;
struct mock_param_matcher *child_matcher;
- void *(*capture_param)(struct test *test, const void *param);
+ void *(*capture_param)(struct KUNIT_T *test, const void *param);
void *captured_param;
};
struct mock_param_capturer *mock_param_capturer_create(
- struct test *test,
+ struct KUNIT_T *test,
struct mock_param_matcher *child_matcher,
- void *(*capture_param)(struct test *, const void *));
+ void *(*capture_param)(struct KUNIT_T *, const void *));
/**
* mock_int_capturer_create() - creates a int parameter capturer
@@ -1384,7 +1390,7 @@ struct mock_param_capturer *mock_param_capturer_create(
* The capturer will capture the value if the matcher is satisfied.
*/
struct mock_param_capturer *mock_int_capturer_create(
- struct test *test, struct mock_param_matcher *child_matcher);
+ struct KUNIT_T *test, struct mock_param_matcher *child_matcher);
/**
* mock_int_capturer_create() - creates a generic pointer parameter capturer
@@ -1394,7 +1400,7 @@ struct mock_param_capturer *mock_int_capturer_create(
* The capturer will capture the value if the matcher is satisfied
*/
struct mock_param_capturer *mock_ptr_capturer_create(
- struct test *test, struct mock_param_matcher *child_matcher);
+ struct KUNIT_T *test, struct mock_param_matcher *child_matcher);
/**
* capturer_to_matcher()
@@ -1427,8 +1433,8 @@ struct mock_param_capturer *mock_ptr_capturer_create(
#define mock_capturer_get(capturer, type) \
CONVERT_TO_ACTUAL_TYPE(type, (capturer)->captured_param)
-struct mock_action *invoke(struct test *test,
- void *(*invokable)(struct test *,
+struct mock_action *invoke(struct KUNIT_T *test,
+ void *(*invokable)(struct KUNIT_T *,
const void *params[],
int len));
@@ -1472,7 +1478,7 @@ static inline void INIT_MOCK_STRUCT_FORMATTER_ENTRY_LAST(
}
struct mock_param_formatter *mock_struct_formatter(
- struct test *test,
+ struct KUNIT_T *test,
const char *struct_name,
struct mock_struct_formatter_entry *entries);
diff --git a/include/test/test-names.h b/include/test/test-names.h
new file mode 100644
index 0000000..6a138d3
--- /dev/null
+++ b/include/test/test-names.h
@@ -0,0 +1,11 @@
+// Transitional: controls which names we should use for kunit structs.
+
+#ifdef CONFIG_KUNIT_USE_UPSTREAM_NAMES
+
+#define KUNIT_T kunit
+
+#else
+
+#define KUNIT_T test
+
+#endif
diff --git a/include/test/test-stream.h b/include/test/test-stream.h
index a53060c..8997828 100644
--- a/include/test/test-stream.h
+++ b/include/test/test-stream.h
@@ -11,9 +11,10 @@
#define _TEST_TEST_STREAM_H
#include <linux/types.h>
+#include <test/test-names.h>
#include <test/string-stream.h>
-struct test;
+struct KUNIT_T;
/**
* struct test_stream - a std::stream style string builder.
@@ -32,7 +33,7 @@ struct test_stream {
void (*commit)(struct test_stream *this);
void (*clear)(struct test_stream *this);
/* private: internal use only. */
- struct test *test;
+ struct KUNIT_T *test;
const char *level;
struct string_stream *internal_stream;
};
@@ -43,6 +44,6 @@ struct test_stream {
*
* Constructs a new test managed &struct test_stream.
*/
-struct test_stream *test_new_stream(struct test *test);
+struct test_stream *test_new_stream(struct KUNIT_T *test);
#endif /* _TEST_TEST_STREAM_H */
diff --git a/include/test/test.h b/include/test/test.h
index 755baf8..f0811e2 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -12,6 +12,7 @@
#include <linux/types.h>
#include <linux/slab.h>
#include <test/strerror.h>
+#include <test/test-names.h>
#include <test/test-stream.h>
#include <test/try-catch.h>
@@ -49,7 +50,7 @@
* kfree(res->allocation);
* }
*
- * void *test_kmalloc(struct test *test, size_t size, gfp_t gfp)
+ * void *test_kmalloc(struct KUNIT_T *test, size_t size, gfp_t gfp)
* {
* struct test_kmalloc_params params;
* struct test_resource *res;
@@ -74,14 +75,14 @@ struct test_resource {
struct list_head node;
};
-struct test;
+struct KUNIT_T;
/**
* struct test_case - represents an individual test case.
* @run_case: the function representing the actual test case.
* @name: the name of the test case.
*
- * A test case is a function with the signature, ``void (*)(struct test *)``
+ * A test case is a function with the signature, ``void (*)(struct KUNIT_T *)``
* that makes expectations and assertions (see EXPECT_TRUE() and ASSERT_TRUE())
* about code under test. Each test case is associated with a
* &struct test_module and will be run after the module's init function and
@@ -95,7 +96,7 @@ struct test;
*
* .. code-block:: c
*
- * void add_test_basic(struct test *test)
+ * void add_test_basic(struct KUNIT_T *test)
* {
* EXPECT_EQ(test, 1, add(1, 0));
* EXPECT_EQ(test, 2, add(1, 1));
@@ -111,7 +112,7 @@ struct test;
*
*/
struct test_case {
- void (*run_case)(struct test *test);
+ void (*run_case)(struct KUNIT_T *test);
const char name[256];
/* private: internal use only. */
bool success;
@@ -144,14 +145,14 @@ struct test_case {
*/
struct test_module {
const char name[256];
- int (*init)(struct test *test);
- void (*exit)(struct test *test);
+ int (*init)(struct KUNIT_T *test);
+ void (*exit)(struct KUNIT_T *test);
struct test_case *test_cases;
};
struct test_initcall {
struct list_head node;
- int (*init)(struct test_initcall *this, struct test *test);
+ int (*init)(struct test_initcall *this, struct KUNIT_T *test);
void (*exit)(struct test_initcall *this);
};
@@ -161,7 +162,7 @@ struct test_post_condition {
};
/**
- * struct test - represents a running instance of a test.
+ * struct KUNIT_T - represents a running instance of a test.
* @priv: for user to store arbitrary data. Commonly used to pass data created
* in the init function (see &struct test_module).
*
@@ -170,7 +171,7 @@ struct test_post_condition {
* via public functions; the one exception is @priv which can be used by the
* test writer to store arbitrary data.
*/
-struct test {
+struct KUNIT_T {
void *priv;
/* private: internal use only. */
spinlock_t lock; /* Guards all mutable test state. */
@@ -179,15 +180,15 @@ struct test {
const char *name;
bool death_test;
bool success;
- void (*vprintk)(const struct test *test,
+ void (*vprintk)(const struct KUNIT_T *test,
const char *level,
struct va_format *vaf);
- void (*fail)(struct test *test, struct test_stream *stream);
- void (*abort)(struct test *test);
+ void (*fail)(struct KUNIT_T *test, struct test_stream *stream);
+ void (*abort)(struct KUNIT_T *test);
struct test_try_catch try_catch;
};
-static inline void test_set_death_test(struct test *test, bool death_test)
+static inline void test_set_death_test(struct KUNIT_T *test, bool death_test)
{
unsigned long flags;
@@ -196,7 +197,7 @@ static inline void test_set_death_test(struct test *test, bool death_test)
spin_unlock_irqrestore(&test->lock, flags);
}
-int test_init_test(struct test *test, const char *name);
+int test_init_test(struct KUNIT_T *test, const char *name);
int test_run_tests(struct test_module *module);
@@ -252,13 +253,13 @@ void test_install_initcall(struct test_initcall *initcall);
* cleaned up at the end of a test case. See &struct test_resource for an
* example.
*/
-struct test_resource *test_alloc_resource(struct test *test,
+struct test_resource *test_alloc_resource(struct KUNIT_T *test,
int (*init)(struct test_resource *,
void *),
void (*free)(struct test_resource *),
void *context);
-void test_free_resource(struct test *test, struct test_resource *res);
+void test_free_resource(struct KUNIT_T *test, struct test_resource *res);
/**
* test_kmalloc() - Just like kmalloc() except the allocation is *test managed*.
@@ -270,7 +271,7 @@ void test_free_resource(struct test *test, struct test_resource *res);
* and is automatically cleaned up after the test case concludes. See &struct
* test_resource for more information.
*/
-void *test_kmalloc(struct test *test, size_t size, gfp_t gfp);
+void *test_kmalloc(struct KUNIT_T *test, size_t size, gfp_t gfp);
/**
* test_kzalloc() - Just like test_kmalloc(), but zeroes the allocation.
@@ -280,15 +281,15 @@ void *test_kmalloc(struct test *test, size_t size, gfp_t gfp);
*
* See kzalloc() and test_kmalloc() for more information.
*/
-static inline void *test_kzalloc(struct test *test, size_t size, gfp_t gfp)
+static inline void *test_kzalloc(struct KUNIT_T *test, size_t size, gfp_t gfp)
{
return test_kmalloc(test, size, gfp | __GFP_ZERO);
}
-void test_cleanup(struct test *test);
+void test_cleanup(struct KUNIT_T *test);
void test_printk(const char *level,
- const struct test *test,
+ const struct KUNIT_T *test,
const char *fmt, ...);
/**
@@ -322,7 +323,7 @@ void test_printk(const char *level,
#define test_err(test, fmt, ...) \
test_printk(KERN_ERR, test, fmt, ##__VA_ARGS__)
-static inline struct test_stream *test_expect_start(struct test *test,
+static inline struct test_stream *test_expect_start(struct KUNIT_T *test,
const char *file,
const char *line)
{
@@ -333,7 +334,7 @@ static inline struct test_stream *test_expect_start(struct test *test,
return stream;
}
-static inline void test_expect_end(struct test *test,
+static inline void test_expect_end(struct KUNIT_T *test,
bool success,
struct test_stream *stream)
{
@@ -480,7 +481,7 @@ static inline void test_expect_end(struct test *test,
EXPECT_END(test, result == errno, __stream); \
} while (0)
-static inline void test_expect_binary(struct test *test,
+static inline void test_expect_binary(struct KUNIT_T *test,
long long left, const char *left_name,
long long right, const char *right_name,
bool compare_result,
@@ -648,7 +649,7 @@ static inline void test_expect_binary(struct test *test,
EXPECT_END(test, !IS_ERR_OR_NULL(__ptr), __stream); \
} while (0)
-static inline struct test_stream *test_assert_start(struct test *test,
+static inline struct test_stream *test_assert_start(struct KUNIT_T *test,
const char *file,
const char *line)
{
@@ -659,7 +660,7 @@ static inline struct test_stream *test_assert_start(struct test *test,
return stream;
}
-static inline void test_assert_end(struct test *test,
+static inline void test_assert_end(struct KUNIT_T *test,
bool success,
struct test_stream *stream)
{
@@ -781,7 +782,7 @@ static inline void test_assert_end(struct test *test,
ASSERT_END(test, result == errno, __stream); \
} while (0)
-static inline void test_assert_binary(struct test *test,
+static inline void test_assert_binary(struct KUNIT_T *test,
long long left, const char *left_name,
long long right, const char *right_name,
bool compare_result,
diff --git a/include/test/try-catch.h b/include/test/try-catch.h
index 2b2a790..6476522 100644
--- a/include/test/try-catch.h
+++ b/include/test/try-catch.h
@@ -11,10 +11,11 @@
#define _TEST_TRY_CATCH_H
#include <linux/types.h>
+#include <test/test-names.h>
typedef void (*test_try_catch_func_t)(void *);
-struct test;
+struct KUNIT_T;
/*
* struct test_try_catch - provides a generic way to run code which might fail.
@@ -41,7 +42,7 @@ struct test_try_catch {
/* private: internal use only. */
void (*run)(struct test_try_catch *try_catch);
void __noreturn (*throw)(struct test_try_catch *try_catch);
- struct test *test;
+ struct KUNIT_T *test;
struct completion *try_completion;
int try_result;
test_try_catch_func_t try;
@@ -55,7 +56,7 @@ struct test_try_catch {
void test_try_catch_init_internal(struct test_try_catch *try_catch);
static inline void test_try_catch_init(struct test_try_catch *try_catch,
- struct test *test,
+ struct KUNIT_T *test,
test_try_catch_func_t try,
test_try_catch_func_t catch)
{
diff --git a/lib/kunit/Kconfig b/lib/kunit/Kconfig
index b333f65..823ba0b 100644
--- a/lib/kunit/Kconfig
+++ b/lib/kunit/Kconfig
@@ -4,28 +4,34 @@
menu "(transitional) KUnit support"
-config KUNIT
+config KUNIT_T
bool "(transitional) Enable support for unit tests (KUnit)"
select TEST
help
Enables support for KUnit via the new name.
-if KUNIT
+if KUNIT_T
config KUNIT_TEST
bool "(transitional) KUnit test for KUnit"
select TEST_TEST
- depends on KUNIT
+ depends on KUNIT_T
help
Enables KUnit test to test KUnit.
config KUNIT_EXAMPLE_TEST
bool "(transitional) Example test for KUnit"
select EXAMPLE_TEST
- depends on KUNIT
+ depends on KUNIT_T
help
Enables example KUnit test to demo features of KUnit.
-endif # KUNIT
+config KUNIT_USE_UPSTREAM_NAMES
+ bool "(transitional) start using upstream names for types/functions"
+ select EXAMPLE_TEST
+ depends on KUNIT_T
+ help
+ Changes names of KUnit types/functions to match the upstream version of KUnit.
+endif # KUNIT_T
endmenu
diff --git a/test/common-mocks.c b/test/common-mocks.c
index e128ef3..9af6f00 100644
--- a/test/common-mocks.c
+++ b/test/common-mocks.c
@@ -21,7 +21,7 @@ static struct mock_param_matcher any_matcher = {
.match = match_any,
};
-struct mock_param_matcher *any(struct test *test)
+struct mock_param_matcher *any(struct KUNIT_T *test)
{
return &any_matcher;
}
@@ -69,7 +69,7 @@ struct mock_param_matcher *any(struct test *test)
#define DEFINE_MATCH_FACTORY(type_name, type, op_name) \
struct mock_param_matcher *type_name##_##op_name( \
- struct test *test, type expected) \
+ struct KUNIT_T *test, type expected) \
{ \
struct mock_##type_name##_matcher *matcher; \
\
@@ -159,7 +159,7 @@ static bool match_memeq(struct mock_param_matcher *pmatcher,
return matches;
}
-struct mock_param_matcher *memeq(struct test *test,
+struct mock_param_matcher *memeq(struct KUNIT_T *test,
const void *buf,
size_t size)
{
@@ -200,7 +200,7 @@ static bool match_streq(struct mock_param_matcher *pmatcher,
return matches;
}
-struct mock_param_matcher *streq(struct test *test, const char *str)
+struct mock_param_matcher *streq(struct KUNIT_T *test, const char *str)
{
struct mock_streq_matcher *matcher;
@@ -243,7 +243,7 @@ static bool match_str_contains(struct mock_param_matcher *pmatcher,
return matches;
}
-struct mock_param_matcher *str_contains(struct test *test, const char *str)
+struct mock_param_matcher *str_contains(struct KUNIT_T *test, const char *str)
{
struct mock_str_contains_matcher *matcher;
@@ -257,7 +257,7 @@ struct mock_param_matcher *str_contains(struct test *test, const char *str)
return &matcher->matcher;
}
-struct mock_param_matcher *va_format_cmp(struct test *test,
+struct mock_param_matcher *va_format_cmp(struct KUNIT_T *test,
struct mock_param_matcher *fmt_matcher,
struct mock_param_matcher *va_matcher)
{
@@ -311,7 +311,7 @@ static bool match_struct(struct mock_param_matcher *pmatcher,
return matches;
}
-struct mock_param_matcher *struct_cmp(struct test *test,
+struct mock_param_matcher *struct_cmp(struct KUNIT_T *test,
const char *struct_name,
struct mock_struct_matcher_entry *entries)
{
@@ -348,9 +348,9 @@ static bool match_and_capture_param(struct mock_param_matcher *pmatcher,
}
struct mock_param_capturer *mock_param_capturer_create(
- struct test *test,
+ struct KUNIT_T *test,
struct mock_param_matcher *child_matcher,
- void *(*capture_param)(struct test *, const void *))
+ void *(*capture_param)(struct KUNIT_T *, const void *))
{
struct mock_param_capturer *capturer;
@@ -366,7 +366,7 @@ struct mock_param_capturer *mock_param_capturer_create(
return capturer;
}
-static void *mock_capture_int(struct test *test, const void *param)
+static void *mock_capture_int(struct KUNIT_T *test, const void *param)
{
int value = CONVERT_TO_ACTUAL_TYPE(int, param);
int *pvalue;
@@ -380,14 +380,14 @@ static void *mock_capture_int(struct test *test, const void *param)
}
struct mock_param_capturer *mock_int_capturer_create(
- struct test *test, struct mock_param_matcher *child_matcher)
+ struct KUNIT_T *test, struct mock_param_matcher *child_matcher)
{
return mock_param_capturer_create(test,
child_matcher,
mock_capture_int);
}
-static void *mock_capture_ptr(struct test *test, const void *param)
+static void *mock_capture_ptr(struct KUNIT_T *test, const void *param)
{
void *ptr = CONVERT_TO_ACTUAL_TYPE(void *, param);
void **pptr;
@@ -399,7 +399,7 @@ static void *mock_capture_ptr(struct test *test, const void *param)
}
struct mock_param_capturer *mock_ptr_capturer_create(
- struct test *test, struct mock_param_matcher *child_matcher)
+ struct KUNIT_T *test, struct mock_param_matcher *child_matcher)
{
return mock_param_capturer_create(test,
child_matcher,
@@ -426,7 +426,7 @@ struct mock_param_capturer *mock_ptr_capturer_create(
}
#define DEFINE_RETURN_ACTION_FACTORY(type_name, type) \
- struct mock_action *type_name##_return(struct test *test, \
+ struct mock_action *type_name##_return(struct KUNIT_T *test, \
type ret) \
{ \
struct mock_##type_name##_action *action; \
@@ -471,8 +471,8 @@ DEFINE_RETURN_ACTION_WITH_TYPENAME(ptr, void *);
struct mock_invoke_action {
struct mock_action action;
- struct test *test;
- void *(*invokable)(struct test *test, const void *params[], int len);
+ struct KUNIT_T *test;
+ void *(*invokable)(struct KUNIT_T *test, const void *params[], int len);
};
static void *do_invoke(struct mock_action *paction,
@@ -487,8 +487,8 @@ static void *do_invoke(struct mock_action *paction,
return action->invokable(action->test, params, len);
}
-struct mock_action *invoke(struct test *test,
- void *(*invokable)(struct test *,
+struct mock_action *invoke(struct KUNIT_T *test,
+ void *(*invokable)(struct KUNIT_T *,
const void *params[],
int len))
{
@@ -620,7 +620,7 @@ static void mock_format_struct(struct mock_param_formatter *pformatter,
}
struct mock_param_formatter *mock_struct_formatter(
- struct test *test,
+ struct KUNIT_T *test,
const char *type_name,
struct mock_struct_formatter_entry *entries)
{
@@ -669,7 +669,7 @@ bool match_##op_name(struct mock_param_matcher *pmatcher, \
} \
#define DEFINE_COMPOSITE_BINARY_MATCHER_FACTORY(combine_op, op_name) \
-struct mock_param_matcher *op_name(struct test *test, \
+struct mock_param_matcher *op_name(struct KUNIT_T *test, \
struct mock_param_matcher *left_matcher, \
struct mock_param_matcher *right_matcher) \
{ \
@@ -721,7 +721,7 @@ bool match_not(struct mock_param_matcher *pmatcher,
}
/* Negates the result of the inner matcher */
-struct mock_param_matcher *not(struct test *test,
+struct mock_param_matcher *not(struct KUNIT_T *test,
struct mock_param_matcher *inner_matcher)
{
struct mock_composite_unary_matcher *matcher;
diff --git a/test/example-test.c b/test/example-test.c
index 8d743b3..6418c5c 100644
--- a/test/example-test.c
+++ b/test/example-test.c
@@ -34,12 +34,12 @@ static int example_init(struct MOCK(example) *mock_example)
DEFINE_STRUCT_CLASS_MOCK_INIT(example, example_init);
-static void example_simple_test(struct test *test)
+static void example_simple_test(struct KUNIT_T *test)
{
KUNIT_EXPECT_EQ(test, 1, 1);
}
-static void example_mock_test(struct test *test)
+static void example_mock_test(struct KUNIT_T *test)
{
struct MOCK(example) *mock_example = test->priv;
struct example *example = mock_get_trgt(mock_example);
@@ -51,7 +51,7 @@ static void example_mock_test(struct test *test)
KUNIT_EXPECT_EQ(test, 2, example_bar(example, 5));
}
-static int example_test_init(struct test *test)
+static int example_test_init(struct KUNIT_T *test)
{
kunit_info(test, "initializing");
diff --git a/test/mock-macro-test.c b/test/mock-macro-test.c
index 1c0397a..df7d209 100644
--- a/test/mock-macro-test.c
+++ b/test/mock-macro-test.c
@@ -67,7 +67,7 @@ struct mock_macro_context {
#define TO_STR_INTERNAL(...) #__VA_ARGS__
#define TO_STR(...) TO_STR_INTERNAL(__VA_ARGS__)
-static void mock_macro_is_equal(struct test *test)
+static void mock_macro_is_equal(struct KUNIT_T *test)
{
EXPECT_STREQ(test, "dropped, 1", TO_STR(EQUAL(1, 1)));
EXPECT_EQ(test, 1, DROP_FIRST_ARG(dropped, 1, 0));
@@ -77,7 +77,7 @@ static void mock_macro_is_equal(struct test *test)
EXPECT_EQ(test, 0, IS_EQUAL(1, 0));
}
-static void mock_macro_if(struct test *test)
+static void mock_macro_if(struct KUNIT_T *test)
{
EXPECT_STREQ(test, "body", ""IF(1)("body"));
EXPECT_STREQ(test, "", ""IF(0)("body"));
@@ -85,7 +85,7 @@ static void mock_macro_if(struct test *test)
EXPECT_STREQ(test, "", ""IF(IS_EQUAL(0, 1))("body"));
}
-static void mock_macro_apply_tokens(struct test *test)
+static void mock_macro_apply_tokens(struct KUNIT_T *test)
{
EXPECT_STREQ(test, "type", TO_STR(APPLY_TOKENS(type, 1, 0)));
EXPECT_STREQ(test, ", type", TO_STR(APPLY_TOKENS(type, 1, 1)));
@@ -94,7 +94,7 @@ static void mock_macro_apply_tokens(struct test *test)
#define IDENTITY(context, type, index) type
-static void mock_macro_param_list_recurse(struct test *test)
+static void mock_macro_param_list_recurse(struct KUNIT_T *test)
{
EXPECT_STREQ(test, "", TO_STR(PARAM_LIST_RECURSE(0,
0,
@@ -122,7 +122,7 @@ static void mock_macro_param_list_recurse(struct test *test)
type15))));
}
-static void mock_macro_for_each_param(struct test *test)
+static void mock_macro_for_each_param(struct KUNIT_T *test)
{
EXPECT_STREQ(test, "type0 , type1", TO_STR(FOR_EACH_PARAM(IDENTITY,
FILTER_NONE,
@@ -136,7 +136,7 @@ static void mock_macro_for_each_param(struct test *test)
type1)));
}
-static void mock_macro_param_list_from_types_basic(struct test *test)
+static void mock_macro_param_list_from_types_basic(struct KUNIT_T *test)
{
EXPECT_STREQ(test, "", TO_STR(PARAM_LIST_FROM_TYPES()));
EXPECT_STREQ(test, "int arg0", TO_STR(PARAM_LIST_FROM_TYPES(int)));
@@ -156,7 +156,7 @@ static void mock_macro_param_list_from_types_basic(struct test *test)
type15)));
}
-static void mock_macro_arg_names_from_types(struct test *test)
+static void mock_macro_arg_names_from_types(struct KUNIT_T *test)
{
EXPECT_STREQ(test, "", TO_STR(ARG_NAMES_FROM_TYPES(0)));
EXPECT_STREQ(test, "", TO_STR(ARG_NAMES_FROM_TYPES(0, int)));
@@ -176,7 +176,7 @@ static void mock_macro_arg_names_from_types(struct test *test)
type15)));
}
-static void mock_macro_test_generated_method_code_works(struct test *test)
+static void mock_macro_test_generated_method_code_works(struct KUNIT_T *test)
{
struct mock_macro_context *ctx = test->priv;
struct MOCK(test_struct) *mock_test_struct = ctx->mock_test_struct;
@@ -197,7 +197,7 @@ static void mock_macro_test_generated_method_code_works(struct test *test)
test_struct->non_first_slot_param(5, test_struct);
}
-static void mock_macro_test_generated_method_void_code_works(struct test *test)
+static void mock_macro_test_generated_method_void_code_works(struct KUNIT_T *test)
{
struct mock_macro_context *ctx = test->priv;
struct MOCK(void) *mock_void_ptr = ctx->mock_void_ptr;
@@ -210,7 +210,7 @@ static void mock_macro_test_generated_method_void_code_works(struct test *test)
test_void_ptr_func(mock_void_ptr, 3);
}
-static void mock_macro_test_generated_function_code_works(struct test *test)
+static void mock_macro_test_generated_function_code_works(struct KUNIT_T *test)
{
struct mock_expectation *handle;
@@ -220,7 +220,7 @@ static void mock_macro_test_generated_function_code_works(struct test *test)
EXPECT_EQ(test, 7, add(4, 3));
}
-static int mock_macro_test_init(struct test *test)
+static int mock_macro_test_init(struct KUNIT_T *test)
{
struct mock_macro_context *ctx;
diff --git a/test/mock-test.c b/test/mock-test.c
index 2b80d37..b2777ca 100644
--- a/test/mock-test.c
+++ b/test/mock-test.c
@@ -12,15 +12,15 @@
#include "test-mock.h"
struct mock_test_context {
- struct MOCK(test) *mock_test;
+ struct MOCK(KUNIT_T) *mock_test;
struct mock *mock;
};
-static void mock_test_do_expect_basic(struct test *test)
+static void mock_test_do_expect_basic(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
int param0 = 5, param1 = -4;
static const char * const two_param_types[] = {"int", "int"};
@@ -48,11 +48,11 @@ static void mock_test_do_expect_basic(struct test *test)
EXPECT_EQ(test, 1, expectation->times_called);
}
-static void mock_test_ptr_eq(struct test *test)
+static void mock_test_ptr_eq(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
void *param0 = ctx, *param1 = trgt;
static const char * const two_param_types[] = {"void *", "void *"};
@@ -81,11 +81,11 @@ static void mock_test_ptr_eq(struct test *test)
EXPECT_EQ(test, 1, expectation->times_called);
}
-static void mock_test_ptr_eq_not_equal(struct test *test)
+static void mock_test_ptr_eq_not_equal(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
void *param0 = ctx, *param1 = trgt;
static const char * const two_param_types[] = {"void *", "void *"};
@@ -118,10 +118,10 @@ static void mock_test_ptr_eq_not_equal(struct test *test)
* In order for us to be able to rely on EXPECT_CALL to validate other behavior,
* we need to test that unsatisfied EXPECT_CALL causes a test failure.
*/
-static void mock_test_failed_expect_call_fails_test(struct test *test)
+static void mock_test_failed_expect_call_fails_test(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
struct mock *mock = ctx->mock;
/* mock is a pretend mock belonging to our mocked_test */
@@ -144,11 +144,11 @@ static void mock_test_failed_expect_call_fails_test(struct test *test)
EXPECT_FALSE(test, mock_get_trgt(mock_test)->success);
}
-static void mock_test_do_expect_default_return(struct test *test)
+static void mock_test_do_expect_default_return(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = NICE_MOCK(ctx->mock_test);
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = NICE_MOCK(ctx->mock_test);
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
int param0 = 5, param1 = -5;
static const char * const two_param_types[] = {"int", "int"};
@@ -201,11 +201,11 @@ static void mock_test_do_expect_default_return(struct test *test)
*/
/* Method called on strict mock with no expectations will fail */
-static void mock_test_strict_no_expectations_will_fail(struct test *test)
+static void mock_test_strict_no_expectations_will_fail(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
int param0 = 5, param1 = -5;
static const char * const two_param_types[] = {"int", "int"};
@@ -230,11 +230,11 @@ static void mock_test_strict_no_expectations_will_fail(struct test *test)
* Method called on naggy mock with no expectations will not fail, but will show
* a warning message
*/
-static void mock_test_naggy_no_expectations_no_fail(struct test *test)
+static void mock_test_naggy_no_expectations_no_fail(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
int param0 = 5, param1 = -5;
static const char * const two_param_types[] = {"int", "int"};
@@ -264,11 +264,11 @@ static void mock_test_naggy_no_expectations_no_fail(struct test *test)
}
/* Method called on nice mock with no expectations will do nothing. */
-static void mock_test_nice_no_expectations_do_nothing(struct test *test)
+static void mock_test_nice_no_expectations_do_nothing(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
int param0 = 5, param1 = -5;
static const char * const two_param_types[] = {"int", "int"};
@@ -302,12 +302,12 @@ static void mock_test_nice_no_expectations_do_nothing(struct test *test)
* will fail test and print all the tried expectations.
*/
static void
-run_method_called_but_no_matching_expectation_test(struct test *test,
+run_method_called_but_no_matching_expectation_test(struct KUNIT_T *test,
enum mock_type mock_type)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
int param0 = 5, param1 = -5;
static const char * const two_param_types[] = {"int", "int"};
@@ -327,29 +327,29 @@ run_method_called_but_no_matching_expectation_test(struct test *test,
two_params, ARRAY_SIZE(two_params));
}
-static void mock_test_naggy_no_matching_expectations_fail(struct test *test)
+static void mock_test_naggy_no_matching_expectations_fail(struct KUNIT_T *test)
{
run_method_called_but_no_matching_expectation_test(test,
MOCK_TYPE_NAGGY);
}
-static void mock_test_strict_no_matching_expectations_fail(struct test *test)
+static void mock_test_strict_no_matching_expectations_fail(struct KUNIT_T *test)
{
run_method_called_but_no_matching_expectation_test(test,
MOCK_TYPE_STRICT);
}
-static void mock_test_nice_no_matching_expectations_fail(struct test *test)
+static void mock_test_nice_no_matching_expectations_fail(struct KUNIT_T *test)
{
run_method_called_but_no_matching_expectation_test(test,
MOCK_TYPE_NICE);
}
-static void mock_test_mock_validate_expectations(struct test *test)
+static void mock_test_mock_validate_expectations(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *matchers[] = {
int_eq(trgt, 5),
@@ -373,11 +373,11 @@ static void mock_test_mock_validate_expectations(struct test *test)
mock_validate_expectations(mock);
}
-static void mock_test_validate_clears_expectations(struct test *test)
+static void mock_test_validate_clears_expectations(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *matchers[] = {
int_eq(trgt, 5),
@@ -435,11 +435,11 @@ static const void *b_params[] = { &(int){2} };
static const void *c_params[] = { &(int){3} };
/* Simple test of InSequence, a -> b -> c */
-static void mock_test_in_sequence_simple_pass(struct test *test)
+static void mock_test_in_sequence_simple_pass(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -464,11 +464,11 @@ static void mock_test_in_sequence_simple_pass(struct test *test)
mock_validate_expectations(mock);
}
-static void mock_test_in_sequence_simple_fail(struct test *test)
+static void mock_test_in_sequence_simple_fail(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -495,11 +495,11 @@ static void mock_test_in_sequence_simple_fail(struct test *test)
* a -> c
* b -> c
*/
-static void mock_test_in_sequence_abc_success(struct test *test)
+static void mock_test_in_sequence_abc_success(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -523,11 +523,11 @@ static void mock_test_in_sequence_abc_success(struct test *test)
mock->do_expect(mock, "c", mock_stub, param_type, c_params, param_len);
}
-static void mock_test_in_sequence_bac_success(struct test *test)
+static void mock_test_in_sequence_bac_success(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -551,11 +551,11 @@ static void mock_test_in_sequence_bac_success(struct test *test)
mock->do_expect(mock, "c", mock_stub, param_type, c_params, param_len);
}
-static void mock_test_in_sequence_no_a_fail(struct test *test)
+static void mock_test_in_sequence_no_a_fail(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -578,11 +578,11 @@ static void mock_test_in_sequence_no_a_fail(struct test *test)
mock->do_expect(mock, "c", mock_stub, param_type, c_params, param_len);
}
-static void mock_test_in_sequence_retire_on_saturation(struct test *test)
+static void mock_test_in_sequence_retire_on_saturation(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -610,11 +610,11 @@ static void mock_test_in_sequence_retire_on_saturation(struct test *test)
mock_validate_expectations(mock);
}
-static void mock_test_atleast(struct test *test)
+static void mock_test_atleast(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -637,11 +637,11 @@ static void mock_test_atleast(struct test *test)
mock_validate_expectations(mock);
}
-static void mock_test_atleast_fail(struct test *test)
+static void mock_test_atleast_fail(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *b_matchers[] = { int_eq(trgt, 2) };
@@ -657,11 +657,11 @@ static void mock_test_atleast_fail(struct test *test)
mock_validate_expectations(mock);
}
-static void mock_test_atmost(struct test *test)
+static void mock_test_atmost(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -687,11 +687,11 @@ static void mock_test_atmost(struct test *test)
mock_validate_expectations(mock);
}
-static void mock_test_atmost_fail(struct test *test)
+static void mock_test_atmost_fail(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *b_matchers[] = { int_eq(trgt, 2) };
@@ -709,11 +709,11 @@ static void mock_test_atmost_fail(struct test *test)
mock_validate_expectations(mock);
}
-static void mock_test_between(struct test *test)
+static void mock_test_between(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *b_matchers[] = { int_eq(trgt, 2) };
@@ -731,11 +731,11 @@ static void mock_test_between(struct test *test)
mock_validate_expectations(mock);
}
-static void mock_test_between_fail(struct test *test)
+static void mock_test_between_fail(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
struct mock_param_matcher *a_matchers[] = { int_eq(trgt, 1) };
@@ -773,7 +773,7 @@ static struct mock_action mocked_fail = {
.do_action = do_mocked_fail
};
-static int mock_test_init(struct test *test)
+static int mock_test_init(struct KUNIT_T *test)
{
struct mock_test_context *ctx;
@@ -782,7 +782,7 @@ static int mock_test_init(struct test *test)
return -ENOMEM;
test->priv = ctx;
- ctx->mock_test = CONSTRUCT_MOCK(test, test);
+ ctx->mock_test = CONSTRUCT_MOCK(KUNIT_T, test);
if (!ctx->mock_test)
return -EINVAL;
@@ -800,11 +800,11 @@ static int mock_test_init(struct test *test)
return 0;
}
-static void mock_test_and_matcher_accept(struct test *test)
+static void mock_test_and_matcher_accept(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
const int param0 = 5;
static const char * const param_types[] = {"int"};
@@ -835,11 +835,11 @@ static void mock_test_and_matcher_accept(struct test *test)
}
-static void mock_test_and_matcher_reject_left(struct test *test)
+static void mock_test_and_matcher_reject_left(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
const int param0 = 5;
static const char * const param_types[] = {"int"};
@@ -868,11 +868,11 @@ static void mock_test_and_matcher_reject_left(struct test *test)
EXPECT_EQ(test, 0, expectation->times_called);
}
-static void mock_test_and_matcher_reject_right(struct test *test)
+static void mock_test_and_matcher_reject_right(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
const int param0 = 5;
static const char * const param_types[] = {"int"};
@@ -901,11 +901,11 @@ static void mock_test_and_matcher_reject_right(struct test *test)
EXPECT_EQ(test, 0, expectation->times_called);
}
-static void mock_test_or_matcher_reject(struct test *test)
+static void mock_test_or_matcher_reject(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
const int param0 = 5;
static const char * const param_types[] = {"int"};
@@ -936,11 +936,11 @@ static void mock_test_or_matcher_reject(struct test *test)
}
-static void mock_test_or_matcher_accept_left(struct test *test)
+static void mock_test_or_matcher_accept_left(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
const int param0 = 5;
static const char * const param_types[] = {"int"};
@@ -969,11 +969,11 @@ static void mock_test_or_matcher_accept_left(struct test *test)
EXPECT_EQ(test, 1, expectation->times_called);
}
-static void mock_test_or_matcher_accept_right(struct test *test)
+static void mock_test_or_matcher_accept_right(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
const int param0 = 5;
static const char * const param_types[] = {"int"};
@@ -1002,11 +1002,11 @@ static void mock_test_or_matcher_accept_right(struct test *test)
EXPECT_EQ(test, 1, expectation->times_called);
}
-static void mock_test_not_matcher_reject(struct test *test)
+static void mock_test_not_matcher_reject(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
const int param0 = 5;
static const char * const param_types[] = {"int"};
@@ -1037,11 +1037,11 @@ static void mock_test_not_matcher_reject(struct test *test)
}
-static void mock_test_not_matcher_accept(struct test *test)
+static void mock_test_not_matcher_accept(struct KUNIT_T *test)
{
struct mock_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = ctx->mock_test;
- struct test *trgt = mock_get_trgt(mock_test);
+ struct MOCK(KUNIT_T) *mock_test = ctx->mock_test;
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
struct mock *mock = ctx->mock;
const int param0 = 5;
static const char * const param_types[] = {"int"};
diff --git a/test/mock.c b/test/mock.c
index db8498e..e668ab4 100644
--- a/test/mock.c
+++ b/test/mock.c
@@ -94,7 +94,7 @@ static void mock_validate_wrapper(struct test_post_condition *condition)
mock_validate_expectations(mock);
}
-void mock_init_ctrl(struct test *test, struct mock *mock)
+void mock_init_ctrl(struct KUNIT_T *test, struct mock *mock)
{
mock->test = test;
INIT_LIST_HEAD(&mock->methods);
@@ -114,7 +114,7 @@ static struct global_mock global_mock = {
};
static int mock_init_global_mock(struct test_initcall *initcall,
- struct test *test)
+ struct KUNIT_T *test)
{
BUG_ON(global_mock.is_initialized);
@@ -317,7 +317,7 @@ static void mock_add_method_declaration_to_stream(
}
static struct test_stream *mock_initialize_failure_message(
- struct test *test,
+ struct KUNIT_T *test,
const char *function_name,
const char * const *type_names,
const void **params,
@@ -345,7 +345,7 @@ static bool mock_is_expectation_retired(struct mock_expectation *expectation)
expectation->max_calls_expected;
}
-static void mock_add_method_expectation_error(struct test *test,
+static void mock_add_method_expectation_error(struct KUNIT_T *test,
struct test_stream *stream,
char *message,
struct mock *mock,
@@ -383,7 +383,7 @@ static bool mock_are_prereqs_satisfied(struct mock_expectation *expectation,
}
/* Assumes that the var args are null terminated. */
-int mock_in_sequence(struct test *test, struct mock_expectation *first, ...)
+int mock_in_sequence(struct KUNIT_T *test, struct mock_expectation *first, ...)
{
struct mock_expectation *prereq = first;
struct mock_expectation *curr = NULL;
@@ -426,7 +426,7 @@ static struct mock_expectation *mock_apply_expectations(
const void **params,
int len)
{
- struct test *test = mock->test;
+ struct KUNIT_T *test = mock->test;
struct mock_expectation *ret;
struct test_stream *attempted_matching_stream;
bool expectations_all_saturated = true;
diff --git a/test/strerror-test.c b/test/strerror-test.c
index 2de126a..a29aae1 100644
--- a/test/strerror-test.c
+++ b/test/strerror-test.c
@@ -11,18 +11,18 @@
#include <test/test.h>
-static void test_strerror_returns_null_for_unknown_errors(struct test *test)
+static void test_strerror_returns_null_for_unknown_errors(struct KUNIT_T *test)
{
EXPECT_NULL(test, strerror(-1));
EXPECT_NULL(test, strerror(MAX_ERRNO + 1));
}
-static void test_strerror_r_returns_null_if_buflen_is_zero(struct test *test)
+static void test_strerror_r_returns_null_if_buflen_is_zero(struct KUNIT_T *test)
{
EXPECT_NULL(test, strerror_r(-1, NULL, 0));
}
-static void test_strerror_returns_string(struct test *test)
+static void test_strerror_returns_string(struct KUNIT_T *test)
{
const char *err;
char buf[64];
@@ -37,7 +37,7 @@ static void test_strerror_returns_string(struct test *test)
}
static void test_strerror_r_correctly_truncates_message_to_buffer_size(
- struct test *test)
+ struct KUNIT_T *test)
{
const char *err;
char buf[64];
@@ -55,7 +55,7 @@ static void test_strerror_r_correctly_truncates_message_to_buffer_size(
EXPECT_STREQ(test, err, "EAGAIN");
}
-static void test_strerror_r_returns_string_for_unknown_errors(struct test *test)
+static void test_strerror_r_returns_string_for_unknown_errors(struct KUNIT_T *test)
{
char buf[64];
diff --git a/test/string-stream-test.c b/test/string-stream-test.c
index 982150e..c979012 100644
--- a/test/string-stream-test.c
+++ b/test/string-stream-test.c
@@ -10,7 +10,7 @@
#include <test/test.h>
#include <test/string-stream.h>
-static void string_stream_test_get_string(struct test *test)
+static void string_stream_test_get_string(struct KUNIT_T *test)
{
struct string_stream *stream = new_string_stream();
char *output;
@@ -24,7 +24,7 @@ static void string_stream_test_get_string(struct test *test)
destroy_string_stream(stream);
}
-static void string_stream_test_add_and_clear(struct test *test)
+static void string_stream_test_add_and_clear(struct KUNIT_T *test)
{
struct string_stream *stream = new_string_stream();
char *output;
diff --git a/test/test-death-test.c b/test/test-death-test.c
index acdd9e6..be49460 100644
--- a/test/test-death-test.c
+++ b/test/test-death-test.c
@@ -7,7 +7,7 @@
*/
#include <test/test.h>
-static void test_death_test_catches_segfault(struct test *test)
+static void test_death_test_catches_segfault(struct KUNIT_T *test)
{
void (*invalid_func)(void) = (void (*)(void)) SIZE_MAX;
diff --git a/test/test-mock.c b/test/test-mock.c
index b0f222f..09b058a 100644
--- a/test/test-mock.c
+++ b/test/test-mock.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * KUnit mock for struct test.
+ * KUnit mock for struct KUNIT_T.
*
* Copyright (C) 2018, Google LLC.
* Author: Brendan Higgins <brendanhiggins@google.com>
@@ -8,21 +8,21 @@
#include "test-mock.h"
-DEFINE_STRUCT_CLASS_MOCK_VOID_RETURN(METHOD(fail), CLASS(test),
- PARAMS(struct test *,
+DEFINE_STRUCT_CLASS_MOCK_VOID_RETURN(METHOD(fail), CLASS(KUNIT_T),
+ PARAMS(struct KUNIT_T *,
struct test_stream *));
-DEFINE_STRUCT_CLASS_MOCK_VOID_RETURN(METHOD(mock_vprintk), CLASS(test),
- PARAMS(const struct test *,
+DEFINE_STRUCT_CLASS_MOCK_VOID_RETURN(METHOD(mock_vprintk), CLASS(KUNIT_T),
+ PARAMS(const struct KUNIT_T *,
const char *,
struct va_format *));
-static int test_init(struct MOCK(test) *mock_test)
+static int test_init(struct MOCK(KUNIT_T) *mock_test)
{
- struct test *trgt = mock_get_trgt(mock_test);
+ struct KUNIT_T *trgt = mock_get_trgt(mock_test);
int ret;
- ret = test_init_test(trgt, "MOCK(test)");
+ ret = test_init_test(trgt, "MOCK(KUNIT_T)");
trgt->fail = fail;
mock_set_default_action(mock_get_ctrl(mock_test),
"fail",
@@ -36,4 +36,4 @@ static int test_init(struct MOCK(test) *mock_test)
return ret;
}
-DEFINE_STRUCT_CLASS_MOCK_INIT(test, test_init);
+DEFINE_STRUCT_CLASS_MOCK_INIT(KUNIT_T, test_init);
diff --git a/test/test-mock.h b/test/test-mock.h
index 9996e2a..ce22fa1 100644
--- a/test/test-mock.h
+++ b/test/test-mock.h
@@ -1,23 +1,23 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
- * KUnit mock for struct test.
+ * KUnit mock for struct KUNIT_T.
*
* Copyright (C) 2018, Google LLC.
* Author: Brendan Higgins <brendanhiggins@google.com>
*/
#include <test/test.h>
+#include <test/test-names.h>
#include <test/mock.h>
-DECLARE_STRUCT_CLASS_MOCK_PREREQS(test);
+DECLARE_STRUCT_CLASS_MOCK_PREREQS(KUNIT_T);
-DECLARE_STRUCT_CLASS_MOCK_VOID_RETURN(METHOD(fail), CLASS(test),
- PARAMS(struct test *,
+DECLARE_STRUCT_CLASS_MOCK_VOID_RETURN(METHOD(fail), CLASS(KUNIT_T),
+ PARAMS(struct KUNIT_T *,
struct test_stream *));
-DECLARE_STRUCT_CLASS_MOCK_VOID_RETURN(METHOD(mock_vprintk), CLASS(test),
- PARAMS(const struct test *,
+DECLARE_STRUCT_CLASS_MOCK_VOID_RETURN(METHOD(mock_vprintk), CLASS(KUNIT_T),
+ PARAMS(const struct KUNIT_T *,
const char *,
struct va_format *));
-
-DECLARE_STRUCT_CLASS_MOCK_INIT(test);
+DECLARE_STRUCT_CLASS_MOCK_INIT(KUNIT_T);
diff --git a/test/test-stream-test.c b/test/test-stream-test.c
index ada38ea..089ff54 100644
--- a/test/test-stream-test.c
+++ b/test/test-stream-test.c
@@ -13,14 +13,14 @@
#include "test-mock.h"
struct test_stream_test_context {
- struct MOCK(test) *mock_test;
+ struct MOCK(KUNIT_T) *mock_test;
struct test_stream *stream;
};
-static void test_stream_test_add(struct test *test)
+static void test_stream_test_add(struct KUNIT_T *test)
{
struct test_stream_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = NICE_MOCK(ctx->mock_test);
+ struct MOCK(KUNIT_T) *mock_test = NICE_MOCK(ctx->mock_test);
struct test_stream *stream = ctx->stream;
stream->add(stream, "Foo");
@@ -36,10 +36,10 @@ static void test_stream_test_add(struct test *test)
stream->commit(stream);
}
-static void test_stream_test_append(struct test *test)
+static void test_stream_test_append(struct KUNIT_T *test)
{
struct test_stream_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = NICE_MOCK(ctx->mock_test);
+ struct MOCK(KUNIT_T) *mock_test = NICE_MOCK(ctx->mock_test);
struct test_stream *stream = ctx->stream;
struct test_stream *other_stream;
@@ -58,10 +58,10 @@ static void test_stream_test_append(struct test *test)
stream->commit(stream);
}
-static void test_stream_error_message_when_no_level_set(struct test *test)
+static void test_stream_error_message_when_no_level_set(struct KUNIT_T *test)
{
struct test_stream_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = NICE_MOCK(ctx->mock_test);
+ struct MOCK(KUNIT_T) *mock_test = NICE_MOCK(ctx->mock_test);
struct test_stream *stream = ctx->stream;
struct test_stream *other_stream;
@@ -83,7 +83,7 @@ static void test_stream_error_message_when_no_level_set(struct test *test)
stream->commit(stream);
}
-static int test_stream_test_init(struct test *test)
+static int test_stream_test_init(struct KUNIT_T *test)
{
struct mock_struct_formatter_entry *entries;
struct test_stream_test_context *ctx;
@@ -93,7 +93,7 @@ static int test_stream_test_init(struct test *test)
return -ENOMEM;
test->priv = ctx;
- ctx->mock_test = CONSTRUCT_MOCK(test, test);
+ ctx->mock_test = CONSTRUCT_MOCK(KUNIT_T, test);
if (!ctx->mock_test)
return -EINVAL;
@@ -126,10 +126,10 @@ static int test_stream_test_init(struct test *test)
}
static void test_stream_test_commits_any_uncommitted_when_cleanup(
- struct test *test)
+ struct KUNIT_T *test)
{
struct test_stream_test_context *ctx = test->priv;
- struct MOCK(test) *mock_test = NICE_MOCK(ctx->mock_test);
+ struct MOCK(KUNIT_T) *mock_test = NICE_MOCK(ctx->mock_test);
struct test_stream *stream = ctx->stream;
stream->add(stream, "Hello World");
@@ -149,7 +149,7 @@ static void test_stream_test_commits_any_uncommitted_when_cleanup(
test_cleanup(mock_get_trgt(mock_test));
}
-static void test_stream_test_exit(struct test *test)
+static void test_stream_test_exit(struct KUNIT_T *test)
{
mock_unregister_formatter(mock_find_formatter("struct va_format *"));
}
diff --git a/test/test-stream.c b/test/test-stream.c
index 43f28c4..7861bd3 100644
--- a/test/test-stream.c
+++ b/test/test-stream.c
@@ -84,7 +84,7 @@ static void test_stream_commit(struct test_stream *this)
static int test_stream_init(struct test_resource *res, void *context)
{
struct test_stream *stream;
- struct test *test = context;
+ struct KUNIT_T *test = context;
stream = kzalloc(sizeof(*stream), GFP_KERNEL);
if (!stream)
@@ -119,7 +119,7 @@ static void test_stream_free(struct test_resource *res)
kfree(stream);
}
-struct test_stream *test_new_stream(struct test *test)
+struct test_stream *test_new_stream(struct KUNIT_T *test)
{
struct test_resource *res;
diff --git a/test/test-test.c b/test/test-test.c
index bec6e75..6e82e36 100644
--- a/test/test-test.c
+++ b/test/test-test.c
@@ -14,7 +14,7 @@ typedef void (*test_resource_free_t)(struct test_resource *);
* is_resource_initialized is used to test arbitrary resources
*/
struct test_test_context {
- struct test test;
+ struct KUNIT_T test;
bool is_resource_initialized;
};
@@ -34,7 +34,7 @@ static void fake_resource_free(struct test_resource *res)
*is_resource_initialized = false;
}
-static void test_test_init_resources(struct test *test)
+static void test_test_init_resources(struct KUNIT_T *test)
{
struct test_test_context *ctx = test->priv;
@@ -43,7 +43,7 @@ static void test_test_init_resources(struct test *test)
EXPECT_TRUE(test, list_empty(&ctx->test.resources));
}
-static void test_test_alloc_resource(struct test *test)
+static void test_test_alloc_resource(struct KUNIT_T *test)
{
struct test_test_context *ctx = test->priv;
struct test_resource *res;
@@ -61,7 +61,7 @@ static void test_test_alloc_resource(struct test *test)
(test_resource_free_t)res->free);
}
-static void test_test_free_resource(struct test *test)
+static void test_test_free_resource(struct KUNIT_T *test)
{
struct test_test_context *ctx = test->priv;
struct test_resource *res = test_alloc_resource(&ctx->test,
@@ -75,7 +75,7 @@ static void test_test_free_resource(struct test *test)
EXPECT_TRUE(test, list_empty(&ctx->test.resources));
}
-static void test_test_cleanup_resources(struct test *test)
+static void test_test_cleanup_resources(struct KUNIT_T *test)
{
int i;
const int num_res = 5;
@@ -94,7 +94,7 @@ static void test_test_cleanup_resources(struct test *test)
EXPECT_TRUE(test, list_empty(&ctx->test.resources));
}
-static int test_test_init(struct test *test)
+static int test_test_init(struct KUNIT_T *test)
{
struct test_test_context *ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -106,7 +106,7 @@ static int test_test_init(struct test *test)
return 0;
}
-static void test_test_exit(struct test *test)
+static void test_test_exit(struct KUNIT_T *test)
{
struct test_test_context *ctx = test->priv;
diff --git a/test/test.c b/test/test.c
index 43207b6..3077822 100644
--- a/test/test.c
+++ b/test/test.c
@@ -25,7 +25,7 @@ void test_install_initcall(struct test_initcall *initcall)
list_add_tail(&initcall->node, &test_global_context.initcalls);
}
-static bool test_get_success(struct test *test)
+static bool test_get_success(struct KUNIT_T *test)
{
unsigned long flags;
bool success;
@@ -37,7 +37,7 @@ static bool test_get_success(struct test *test)
return success;
}
-static void test_set_success(struct test *test, bool success)
+static void test_set_success(struct KUNIT_T *test, bool success)
{
unsigned long flags;
@@ -46,7 +46,7 @@ static void test_set_success(struct test *test, bool success)
spin_unlock_irqrestore(&test->lock, flags);
}
-static bool test_get_death_test(struct test *test)
+static bool test_get_death_test(struct KUNIT_T *test)
{
unsigned long flags;
bool death_test;
@@ -58,7 +58,7 @@ static bool test_get_death_test(struct test *test)
return death_test;
}
-static int test_vprintk_emit(const struct test *test,
+static int test_vprintk_emit(const struct KUNIT_T *test,
int level,
const char *fmt,
va_list args)
@@ -66,7 +66,7 @@ static int test_vprintk_emit(const struct test *test,
return vprintk_emit(0, level, NULL, 0, fmt, args);
}
-static int test_printk_emit(const struct test *test,
+static int test_printk_emit(const struct KUNIT_T *test,
int level,
const char *fmt, ...)
{
@@ -80,7 +80,7 @@ static int test_printk_emit(const struct test *test,
return ret;
}
-static void test_vprintk(const struct test *test,
+static void test_vprintk(const struct KUNIT_T *test,
const char *level,
struct va_format *vaf)
{
@@ -89,14 +89,14 @@ static void test_vprintk(const struct test *test,
"kunit %s: %pV", test->name, vaf);
}
-static void test_fail(struct test *test, struct test_stream *stream)
+static void test_fail(struct KUNIT_T *test, struct test_stream *stream)
{
test_set_success(test, false);
stream->set_level(stream, KERN_ERR);
stream->commit(stream);
}
-static void __noreturn test_abort(struct test *test)
+static void __noreturn test_abort(struct KUNIT_T *test)
{
test_set_death_test(test, true);
test_try_catch_throw(&test->try_catch);
@@ -110,7 +110,7 @@ static void __noreturn test_abort(struct test *test)
WARN_ONCE(true, "Throw could not abort from test!\n");
}
-int test_init_test(struct test *test, const char *name)
+int test_init_test(struct KUNIT_T *test, const char *name)
{
spin_lock_init(&test->lock);
INIT_LIST_HEAD(&test->resources);
@@ -123,7 +123,7 @@ int test_init_test(struct test *test, const char *name)
return 0;
}
-static void test_case_internal_cleanup(struct test *test)
+static void test_case_internal_cleanup(struct KUNIT_T *test)
{
struct test_initcall *initcall;
@@ -137,7 +137,7 @@ static void test_case_internal_cleanup(struct test *test)
/*
* Initializes and runs test case. Does not clean up or do post validations.
*/
-static void test_run_case_internal(struct test *test,
+static void test_run_case_internal(struct KUNIT_T *test,
struct test_module *module,
struct test_case *test_case)
{
@@ -168,7 +168,7 @@ static void test_run_case_internal(struct test *test,
/*
* Handles an unexpected crash in a test case.
*/
-static void test_handle_test_crash(struct test *test,
+static void test_handle_test_crash(struct KUNIT_T *test,
struct test_module *module,
struct test_case *test_case)
{
@@ -183,7 +183,7 @@ static void test_handle_test_crash(struct test *test,
}
struct test_try_catch_context {
- struct test *test;
+ struct KUNIT_T *test;
struct test_module *module;
struct test_case *test_case;
};
@@ -193,7 +193,7 @@ struct test_try_catch_context {
* Performs post validations and cleanup after a test case was run.
* XXX: Should ONLY BE CALLED AFTER test_run_case_internal!
*/
-static void test_run_case_cleanup(struct test *test,
+static void test_run_case_cleanup(struct KUNIT_T *test,
struct test_module *module,
struct test_case *test_case)
{
@@ -216,7 +216,7 @@ static void test_run_case_cleanup(struct test *test,
static void test_try_run_case(void *data)
{
struct test_try_catch_context *ctx = data;
- struct test *test = ctx->test;
+ struct KUNIT_T *test = ctx->test;
struct test_module *module = ctx->module;
struct test_case *test_case = ctx->test_case;
@@ -233,7 +233,7 @@ static void test_try_run_case(void *data)
static void test_catch_run_case(void *data)
{
struct test_try_catch_context *ctx = data;
- struct test *test = ctx->test;
+ struct KUNIT_T *test = ctx->test;
struct test_module *module = ctx->module;
struct test_case *test_case = ctx->test_case;
int try_exit_code = test_try_catch_get_result(&test->try_catch);
@@ -278,7 +278,7 @@ static void test_catch_run_case(void *data)
* Performs all logic to run a test case. It also catches most errors that
* occurs in a test case and reports them as failures.
*/
-static bool test_run_case_catch_errors(struct test *test,
+static bool test_run_case_catch_errors(struct KUNIT_T *test,
struct test_module *module,
struct test_case *test_case)
{
@@ -304,7 +304,7 @@ int test_run_tests(struct test_module *module)
{
bool all_passed = true, success;
struct test_case *test_case;
- struct test test;
+ struct KUNIT_T test;
int ret;
ret = test_init_test(&test, module->name);
@@ -330,7 +330,7 @@ int test_run_tests(struct test_module *module)
return 0;
}
-struct test_resource *test_alloc_resource(struct test *test,
+struct test_resource *test_alloc_resource(struct KUNIT_T *test,
int (*init)(struct test_resource *,
void *),
void (*free)(struct test_resource *),
@@ -353,7 +353,7 @@ struct test_resource *test_alloc_resource(struct test *test,
return res;
}
-void test_free_resource(struct test *test, struct test_resource *res)
+void test_free_resource(struct KUNIT_T *test, struct test_resource *res)
{
res->free(res);
list_del(&res->node);
@@ -381,7 +381,7 @@ static void test_kmalloc_free(struct test_resource *res)
kfree(res->allocation);
}
-void *test_kmalloc(struct test *test, size_t size, gfp_t gfp)
+void *test_kmalloc(struct KUNIT_T *test, size_t size, gfp_t gfp)
{
struct test_kmalloc_params params;
struct test_resource *res;
@@ -400,7 +400,7 @@ void *test_kmalloc(struct test *test, size_t size, gfp_t gfp)
return NULL;
}
-void test_cleanup(struct test *test)
+void test_cleanup(struct KUNIT_T *test)
{
struct test_resource *resource, *resource_safe;
@@ -413,7 +413,7 @@ void test_cleanup(struct test *test)
}
void test_printk(const char *level,
- const struct test *test,
+ const struct KUNIT_T *test,
const char *fmt, ...)
{
struct va_format vaf;
diff --git a/test/try-catch.c b/test/try-catch.c
index ec8a3bb..cd9096f 100644
--- a/test/try-catch.c
+++ b/test/try-catch.c
@@ -30,7 +30,7 @@ static int test_generic_run_threadfn_adapter(void *data)
static void test_generic_run_try_catch(struct test_try_catch *try_catch)
{
DECLARE_COMPLETION_ONSTACK(try_completion);
- struct test *test = try_catch->test;
+ struct KUNIT_T *test = try_catch->test;
struct task_struct *task_struct;
int exit_code, status;