diff options
author | 2022-09-30 17:26:37 -0700 | |
---|---|---|
committer | 2022-12-12 14:13:47 -0700 | |
commit | 697365c086791372945037557f99bc164e2db855 (patch) | |
tree | d2eb60b5634c34fed99c391c462c55df97fac34f /lib/kunit/executor.c | |
parent | kunit: tool: remove redundant file.close() call in unit test (diff) | |
download | wireguard-linux-697365c086791372945037557f99bc164e2db855.tar.xz wireguard-linux-697365c086791372945037557f99bc164e2db855.zip |
kunit: eliminate KUNIT_INIT_*_ASSERT_STRUCT macros
These macros exist because passing an initializer list to other macros
is hard.
The goal of these macros is to generate a line like
struct $ASSERT_TYPE __assertion = $APPROPRIATE_INITIALIZER;
e.g.
struct kunit_unary_assertion __assertion = {
.condition = "foo()",
.expected_true = true
};
But the challenge is you can't pass `{.condition=..., .expect_true=...}`
as a macro argument, since the comma means you're actually passing two
arguments, `{.condition=...` and `.expect_true=....}`.
So we'd made custom macros for each different initializer-list shape.
But we can work around this with the following generic macro
#define KUNIT_INIT_ASSERT(initializers...) { initializers }
Note: this has the downside that we have to rename some macros arguments
to not conflict with the struct field names (e.g. `expected_true`).
It's a bit gross, but probably worth reducing the # of macros.
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit/executor.c')
0 files changed, 0 insertions, 0 deletions