Message ID | 20220108012304.1049587-1-dlatypov@google.com |
---|---|
Headers | show |
Series | kunit: refactor assertions to use less stack | expand |
On Fri, Jan 7, 2022 at 8:23 PM Daniel Latypov <dlatypov@google.com> wrote: > > Currently, these macros are only really documented near the bottom of > https://www.kernel.org/doc/html/latest/dev-tools/kunit/api/test.html#c.KUNIT_FAIL. > > E.g. it's likely someone might just not realize that > KUNIT_EXPECT_STREQ() exists and instead use KUNIT_EXPECT_FALSE(strcmp()) > or similar. > > This can also serve as a basic smoketest that the KUnit assert machinery > still works for all the macros. > > Signed-off-by: Daniel Latypov <dlatypov@google.com> I still don't like how much this bloats the example test; aside from that, this looks good. Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
On Fri, Jan 7, 2022 at 8:23 PM Daniel Latypov <dlatypov@google.com> wrote: > > The `struct kunit* test` field in kunit_assert is unused. > Note: we have access to `test` where we need it via the string_stream > object. I assume `test` in `kunit_assert` predates this and was leftover > after some refactoring. > > This patch removes the field and cleans up the macros to avoid > needlessly passing around `test`. > > Signed-off-by: Daniel Latypov <dlatypov@google.com> Looks good. Thanks! Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
On Mon, Jan 10, 2022 at 2:14 PM Brendan Higgins <brendanhiggins@google.com> wrote: > > On Fri, Jan 7, 2022 at 8:23 PM Daniel Latypov <dlatypov@google.com> wrote: > > > > Currently, these macros are only really documented near the bottom of > > https://www.kernel.org/doc/html/latest/dev-tools/kunit/api/test.html#c.KUNIT_FAIL. > > > > E.g. it's likely someone might just not realize that > > KUNIT_EXPECT_STREQ() exists and instead use KUNIT_EXPECT_FALSE(strcmp()) > > or similar. > > > > This can also serve as a basic smoketest that the KUnit assert machinery > > still works for all the macros. > > > > Signed-off-by: Daniel Latypov <dlatypov@google.com> > > I still don't like how much this bloats the example test; aside from > that, this looks good. Agreed, it does add bloat. I just wanted something *somewhere* I could use to smoketest the later changes. I just remembered how people weren't very aware of the _MSG variants and thought this could help. If others have a preference, I'll happily move out and into kunit-test.c. I'm fine either way as I initially was going to put it there to begin with. > > Reviewed-by: Brendan Higgins <brendanhiggins@google.com>