From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F4DCC32750 for ; Tue, 13 Aug 2019 04:27:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63C88206C2 for ; Tue, 13 Aug 2019 04:27:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fbg8VeT4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726556AbfHME1S (ORCPT ); Tue, 13 Aug 2019 00:27:18 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45668 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725815AbfHME1R (ORCPT ); Tue, 13 Aug 2019 00:27:17 -0400 Received: by mail-pf1-f194.google.com with SMTP id w26so5565158pfq.12 for ; Mon, 12 Aug 2019 21:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fQL9RUtIML/PZe8MNFP8yQiCjWtKgPLyEfIL1k8PJhc=; b=fbg8VeT4fWy8MdPE5NDtumx+KrkUlXY0FY4hQL0ZwFaSB+aAw9A23C2a0B2+TAgTcn QRSm6g30QyXjT5+Li/OxZJId+1mikYGNYaRjFswNcd6fvPG4iGcxHlUtL+YOAsZsA1S0 rcxRRdXDnZm1MmAStKLyKDuVzVZJLX5Lpcsp/wnXCV2B+DSuCumnuklf6b0VFdNwZEgN UTua35jaJGosxDOytq+pTP+fwXsPV3GIbr3R559nMEJhIG1Zt9VqS/XG0JoEGRztyMPv pjPkYqPfyv4d0basCqZO32/EFQQWHTlJ0mQAVIAE2306A8Q+UbbHGf9TCQnW3CYkOtTX JP8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fQL9RUtIML/PZe8MNFP8yQiCjWtKgPLyEfIL1k8PJhc=; b=aYrLKTG8C+TJ4D7GhzLnd6uE8sCOWxBNvk2+J7a5060eMCozCXmSaHIendZiXoDlwT AfB7f3ewkku48v6PhYqOvntAf2qABhmhVlfH9wZrmYVRxu+UuqMPjSqB1XYP/HTuK6Ou BtNmoJo9Z/nCeUhJoW3zE0yEfOLTvVWdp/87/By2docrN5fJgaLUacprtGv7Wl6UfBsG q8VeEUI4eeeBbuNLS5V+vezHNoPfZmwGzYIIDMCu6DxPsRoG0sCqru8aUizABkFwJpfq iQWlwZ7JLE0jZ9jZF1mGVvzmohal5cU4ZlUyavKedeNuPhEbI99W3CtiCR9jNqdN/sOC /HgA== X-Gm-Message-State: APjAAAVMvM3OYnx3AQWR2lduOe4hPiaEVWKQXvdpsiNqUbIBOkG5lR8T 8zq6pghtEp9zi0Z+2Up3tMKY+HmiqnM8x6UC4NRZfQ== X-Google-Smtp-Source: APXvYqyDNtjg1vEeMDr2gVCEsRefZmM7lb53WZNnRaIftMCnD83RA48eWcYK2L1Qi2YiTKmhvzfk7GUpdRuiK3gA3Wg= X-Received: by 2002:a63:b919:: with SMTP id z25mr32569272pge.201.1565670436109; Mon, 12 Aug 2019 21:27:16 -0700 (PDT) MIME-Version: 1.0 References: <20190812182421.141150-1-brendanhiggins@google.com> <20190812182421.141150-5-brendanhiggins@google.com> <20190812234644.E054D20679@mail.kernel.org> In-Reply-To: From: Brendan Higgins Date: Mon, 12 Aug 2019 21:27:05 -0700 Message-ID: Subject: Re: [PATCH v12 04/18] kunit: test: add assertion printing library To: Stephen Boyd Cc: Frank Rowand , Greg KH , Josh Poimboeuf , Kees Cook , Kieran Bingham , Luis Chamberlain , Peter Zijlstra , Rob Herring , shuah , "Theodore Ts'o" , Masahiro Yamada , devicetree , dri-devel , kunit-dev@googlegroups.com, "open list:DOCUMENTATION" , linux-fsdevel@vger.kernel.org, linux-kbuild , Linux Kernel Mailing List , "open list:KERNEL SELFTEST FRAMEWORK" , linux-nvdimm , linux-um@lists.infradead.org, Sasha Levin , "Bird, Timothy" , Amir Goldstein , Dan Carpenter , Daniel Vetter , Jeff Dike , Joel Stanley , Julia Lawall , Kevin Hilman , Knut Omang , Logan Gunthorpe , Michael Ellerman , Petr Mladek , Randy Dunlap , Richard Weinberger , David Rientjes , Steven Rostedt , wfg@linux.intel.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On Mon, Aug 12, 2019 at 4:56 PM Brendan Higgins wrote: > > On Mon, Aug 12, 2019 at 4:46 PM Stephen Boyd wrote: > > > > Quoting Brendan Higgins (2019-08-12 11:24:07) > > > Add `struct kunit_assert` and friends which provide a structured way to > > > capture data from an expectation or an assertion (introduced later in > > > the series) so that it may be printed out in the event of a failure. > > > > > > Signed-off-by: Brendan Higgins > > > --- > > > > Reviewed-by: Stephen Boyd > > > > Just some minor nits below > > > > > diff --git a/include/kunit/assert.h b/include/kunit/assert.h > > > new file mode 100644 > > > index 0000000000000..55f1b88b0cb4d > > > --- /dev/null > > > +++ b/include/kunit/assert.h > > > @@ -0,0 +1,183 @@ > > [...] > > > + struct string_stream *stream); > > > + > > > +struct kunit_fail_assert { > > > + struct kunit_assert assert; > > > +}; > > > + > > > +void kunit_fail_assert_format(const struct kunit_assert *assert, > > > + struct string_stream *stream); > > > + > > > +#define KUNIT_INIT_FAIL_ASSERT_STRUCT(test, type) { \ > > > + .assert = KUNIT_INIT_ASSERT_STRUCT(test, \ > > > + type, \ > > > + kunit_fail_assert_format) \ > > > > This one got indented one too many times? > > Not unless I have been using the wrong formatting for multiline > macros. You can see this commit applied here: > https://kunit.googlesource.com/linux/+/870964da2990920030990dd1ffb647ef408e52df/include/kunit/assert.h#59 > > I have test, type, and kunit_fail_assert_format all column aligned (it > just doesn't render nicely in the patch format). Disregard that last comment. I just looked at the line immediately above your comment and thought it looked correct. Sorry about that (you were pointing out that the .assert line looked wrong, correct?). > > > +} > > > + > > > +struct kunit_unary_assert { > > > + struct kunit_assert assert; > > > + const char *condition; > > > + bool expected_true; > > > +}; > > > + > > > +void kunit_unary_assert_format(const struct kunit_assert *assert, > > > + struct string_stream *stream); > > > + > > [...] > > > +#define KUNIT_INIT_BINARY_STR_ASSERT_STRUCT(test, \ > > > + type, \ > > > + op_str, \ > > > + left_str, \ > > > + left_val, \ > > > + right_str, \ > > > + right_val) { \ > > > + .assert = KUNIT_INIT_ASSERT_STRUCT(test, \ > > > + type, \ > > > + kunit_binary_str_assert_format), \ > > > + .operation = op_str, \ > > > + .left_text = left_str, \ > > > + .left_value = left_val, \ > > > + .right_text = right_str, \ > > > + .right_value = right_val \ > > > +} > > > > It would be nice to have kernel doc on these macros so we know how to > > use them. > > Sounds good. Will fix.