@@ -42,17 +42,13 @@ struct kunit_loc {
42
42
43
43
/**
44
44
* struct kunit_assert - Data for printing a failed assertion or expectation.
45
- * @type: the type (either an expectation or an assertion) of this kunit_assert.
46
45
* @message: an optional message to provide additional context.
47
46
* @format: a function which formats the data in this kunit_assert to a string.
48
47
*
49
48
* Represents a failed expectation/assertion. Contains all the data necessary to
50
49
* format a string to a user reporting the failure.
51
50
*/
52
51
struct kunit_assert {
53
- // TODO(dlatypov@google.com): delete this unused field when we've
54
- // updated all the related KUNIT_INIT_ASSERT* macros.
55
- enum kunit_assert_type type ;
56
52
struct va_format message ;
57
53
void (* format )(const struct kunit_assert * assert ,
58
54
struct string_stream * stream );
@@ -68,13 +64,11 @@ struct kunit_assert {
68
64
69
65
/**
70
66
* KUNIT_INIT_ASSERT_STRUCT() - Initializer for a &struct kunit_assert.
71
- * @assert_type: The type (assertion or expectation) of this kunit_assert.
72
67
* @fmt: The formatting function which builds a string out of this kunit_assert.
73
68
*
74
69
* The base initializer for a &struct kunit_assert.
75
70
*/
76
- #define KUNIT_INIT_ASSERT_STRUCT (assert_type , fmt ) { \
77
- .type = assert_type, \
71
+ #define KUNIT_INIT_ASSERT_STRUCT (fmt ) { \
78
72
.message = KUNIT_INIT_VA_FMT_NULL, \
79
73
.format = fmt \
80
74
}
@@ -100,15 +94,13 @@ void kunit_fail_assert_format(const struct kunit_assert *assert,
100
94
struct string_stream * stream );
101
95
102
96
/**
103
- * KUNIT_INIT_FAIL_ASSERT_STRUCT() - Initializer for &struct kunit_fail_assert.
104
- * @type: The type (assertion or expectation) of this kunit_assert.
97
+ * KUNIT_INIT_FAIL_ASSERT_STRUCT - Initializer for &struct kunit_fail_assert.
105
98
*
106
99
* Initializes a &struct kunit_fail_assert. Intended to be used in
107
100
* KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
108
101
*/
109
- #define KUNIT_INIT_FAIL_ASSERT_STRUCT (type ) { \
110
- .assert = KUNIT_INIT_ASSERT_STRUCT(type, \
111
- kunit_fail_assert_format) \
102
+ #define KUNIT_INIT_FAIL_ASSERT_STRUCT { \
103
+ .assert = KUNIT_INIT_ASSERT_STRUCT(kunit_fail_assert_format) \
112
104
}
113
105
114
106
/**
@@ -132,16 +124,14 @@ void kunit_unary_assert_format(const struct kunit_assert *assert,
132
124
133
125
/**
134
126
* KUNIT_INIT_UNARY_ASSERT_STRUCT() - Initializes &struct kunit_unary_assert.
135
- * @type: The type (assertion or expectation) of this kunit_assert.
136
127
* @cond: A string representation of the expression asserted true or false.
137
128
* @expect_true: True if of type KUNIT_{EXPECT|ASSERT}_TRUE, false otherwise.
138
129
*
139
130
* Initializes a &struct kunit_unary_assert. Intended to be used in
140
131
* KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
141
132
*/
142
- #define KUNIT_INIT_UNARY_ASSERT_STRUCT (type , cond , expect_true ) { \
143
- .assert = KUNIT_INIT_ASSERT_STRUCT(type, \
144
- kunit_unary_assert_format), \
133
+ #define KUNIT_INIT_UNARY_ASSERT_STRUCT (cond , expect_true ) { \
134
+ .assert = KUNIT_INIT_ASSERT_STRUCT(kunit_unary_assert_format), \
145
135
.condition = cond, \
146
136
.expected_true = expect_true \
147
137
}
@@ -168,16 +158,14 @@ void kunit_ptr_not_err_assert_format(const struct kunit_assert *assert,
168
158
/**
169
159
* KUNIT_INIT_PTR_NOT_ERR_ASSERT_STRUCT() - Initializes a
170
160
* &struct kunit_ptr_not_err_assert.
171
- * @type: The type (assertion or expectation) of this kunit_assert.
172
161
* @txt: A string representation of the expression passed to the expectation.
173
162
* @val: The actual evaluated pointer value of the expression.
174
163
*
175
164
* Initializes a &struct kunit_ptr_not_err_assert. Intended to be used in
176
165
* KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
177
166
*/
178
- #define KUNIT_INIT_PTR_NOT_ERR_STRUCT (type , txt , val ) { \
179
- .assert = KUNIT_INIT_ASSERT_STRUCT(type, \
180
- kunit_ptr_not_err_assert_format), \
167
+ #define KUNIT_INIT_PTR_NOT_ERR_STRUCT (txt , val ) { \
168
+ .assert = KUNIT_INIT_ASSERT_STRUCT(kunit_ptr_not_err_assert_format), \
181
169
.text = txt, \
182
170
.value = val \
183
171
}
@@ -211,7 +199,6 @@ void kunit_binary_assert_format(const struct kunit_assert *assert,
211
199
/**
212
200
* KUNIT_INIT_BINARY_ASSERT_STRUCT() - Initializes a
213
201
* &struct kunit_binary_assert.
214
- * @type: The type (assertion or expectation) of this kunit_assert.
215
202
* @op_str: A string representation of the comparison operator (e.g. "==").
216
203
* @left_str: A string representation of the expression in the left slot.
217
204
* @left_val: The actual evaluated value of the expression in the left slot.
@@ -221,14 +208,12 @@ void kunit_binary_assert_format(const struct kunit_assert *assert,
221
208
* Initializes a &struct kunit_binary_assert. Intended to be used in
222
209
* KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
223
210
*/
224
- #define KUNIT_INIT_BINARY_ASSERT_STRUCT (type , \
225
- op_str , \
211
+ #define KUNIT_INIT_BINARY_ASSERT_STRUCT (op_str , \
226
212
left_str , \
227
213
left_val , \
228
214
right_str , \
229
215
right_val ) { \
230
- .assert = KUNIT_INIT_ASSERT_STRUCT(type, \
231
- kunit_binary_assert_format), \
216
+ .assert = KUNIT_INIT_ASSERT_STRUCT(kunit_binary_assert_format), \
232
217
.operation = op_str, \
233
218
.left_text = left_str, \
234
219
.left_value = left_val, \
@@ -275,14 +260,12 @@ void kunit_binary_ptr_assert_format(const struct kunit_assert *assert,
275
260
* Initializes a &struct kunit_binary_ptr_assert. Intended to be used in
276
261
* KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
277
262
*/
278
- #define KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT (type , \
279
- op_str , \
263
+ #define KUNIT_INIT_BINARY_PTR_ASSERT_STRUCT (op_str , \
280
264
left_str , \
281
265
left_val , \
282
266
right_str , \
283
267
right_val ) { \
284
- .assert = KUNIT_INIT_ASSERT_STRUCT(type, \
285
- kunit_binary_ptr_assert_format), \
268
+ .assert = KUNIT_INIT_ASSERT_STRUCT(kunit_binary_ptr_assert_format), \
286
269
.operation = op_str, \
287
270
.left_text = left_str, \
288
271
.left_value = left_val, \
@@ -319,7 +302,6 @@ void kunit_binary_str_assert_format(const struct kunit_assert *assert,
319
302
/**
320
303
* KUNIT_INIT_BINARY_STR_ASSERT_STRUCT() - Initializes a
321
304
* &struct kunit_binary_str_assert.
322
- * @type: The type (assertion or expectation) of this kunit_assert.
323
305
* @op_str: A string representation of the comparison operator (e.g. "==").
324
306
* @left_str: A string representation of the expression in the left slot.
325
307
* @left_val: The actual evaluated value of the expression in the left slot.
@@ -329,14 +311,12 @@ void kunit_binary_str_assert_format(const struct kunit_assert *assert,
329
311
* Initializes a &struct kunit_binary_str_assert. Intended to be used in
330
312
* KUNIT_EXPECT_* and KUNIT_ASSERT_* macros.
331
313
*/
332
- #define KUNIT_INIT_BINARY_STR_ASSERT_STRUCT (type , \
333
- op_str , \
314
+ #define KUNIT_INIT_BINARY_STR_ASSERT_STRUCT (op_str , \
334
315
left_str , \
335
316
left_val , \
336
317
right_str , \
337
318
right_val ) { \
338
- .assert = KUNIT_INIT_ASSERT_STRUCT(type, \
339
- kunit_binary_str_assert_format), \
319
+ .assert = KUNIT_INIT_ASSERT_STRUCT(kunit_binary_str_assert_format), \
340
320
.operation = op_str, \
341
321
.left_text = left_str, \
342
322
.left_value = left_val, \
0 commit comments