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,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 F23C3C433FF for ; Mon, 12 Aug 2019 23:56:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BEEC22054F for ; Mon, 12 Aug 2019 23:56:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kj+TnowR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726878AbfHLX4n (ORCPT ); Mon, 12 Aug 2019 19:56:43 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41035 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbfHLX4n (ORCPT ); Mon, 12 Aug 2019 19:56:43 -0400 Received: by mail-pg1-f196.google.com with SMTP id x15so39932594pgg.8 for ; Mon, 12 Aug 2019 16:56:42 -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=gYpSAuCXXKxryh8QTeN+G2zHTLzdvz4q0W6bw5kxZF4=; b=kj+TnowRhwNBHJOh8ghz79tlvll8x/4UGw5bdSUzfSM675Bmppn0T+5pwwMqUi1Pj8 SkfxC53wkTjuPEqLDzqpMT8o02usB1hT7ISXFNR37RoScwW9mBXE4G6OWWcEhGxQ4RjE ZULQCeKPfhmyKaUvhvxsP1ztH072L3pIFOOb1mQPoepGl9JYtada5S4xJGf8kTW6G2ed agtpkDcP4Se/8cfElAOE/jMH6pWLmTG0sCRAYFHxhMUFNN99If6/5pZXWUcydlo5gP79 cH+LRfP7b/BQG+d1ym6KyAQRfa3JaLfiK6f13kXjD96rm3bbdFV/J9GFHUpWjzV//M/H yS1Q== 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=gYpSAuCXXKxryh8QTeN+G2zHTLzdvz4q0W6bw5kxZF4=; b=GtuAnJzRvzQPB9019WW0cz8cA3hoJk6RT7AhA1IPjmCVJe6J5Yiz9ycZY9sJrulzI8 xSAdxpl99Ix5kNg/gVFAYXG64UBI6wPJ7NBnZUZcqQwCCkuL9H9AVa+U2ecv2XRAL4zb V90ZvfPTZjplNhqf/+q79PZCqa7Q8OhsqoC++hccyHfSg4i5n1/GR8VjLDSZShEB5jiW 59dCk/FUw+PbOe/XOdVPr9k+FMP+lUc+/a9XUhrASlBuGkPyRmJGFMZth6BlGb9xcsvh u6KvZhR0g3RO6S8VW/S5Eu0jtTw1YpBKXzG2UDL9um4EvvrDJf3DZbiThU9TRBDg0C9M s1UA== X-Gm-Message-State: APjAAAUh+DUPyZIQ90xSp4/47bjUqeHtDND7apdOHQSjRZ+qW5H/A6ZS HbcD0gHM/4zdEXvLVjr8VhqsuWvjDO0Fktl/0vhRGQ== X-Google-Smtp-Source: APXvYqw7Md+FhMdhe7gt7ZbaYFjad4Qutk9q143YLYnyDZF1R0tUF3skBOerqPAJS3PaDxgm1xGa9mrupUlIDIlaGXw= X-Received: by 2002:a63:b919:: with SMTP id z25mr31882885pge.201.1565654201390; Mon, 12 Aug 2019 16:56:41 -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: <20190812234644.E054D20679@mail.kernel.org> From: Brendan Higgins Date: Mon, 12 Aug 2019 16:56:29 -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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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). > > +} > > + > > +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.