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=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 4F31DC7618F for ; Tue, 16 Jul 2019 15:30:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22041217D9 for ; Tue, 16 Jul 2019 15:30:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563291005; bh=Q8O6F/yaThVCvHW/cVKsV5tCbDe9BryORGQ4CN6Um0g=; h=In-Reply-To:References:From:To:Cc:Subject:Date:List-ID:From; b=cUAeYaGhtI8oFdSPO/vCGIUUouhNTkp9CAZO4eu1GOuGoKSjN6c5dF+QUR0V5VLL+ j+aW9pu5z/7YWKPcYEPNK3sFAVUDC2NKMalayy6/GpAeEAeet3KnX+TjhGseU4IMS9 H4WevJvUk1gy7ZJoeZTSYfLfbxI7rOOw26YWEzQ4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387965AbfGPPaD (ORCPT ); Tue, 16 Jul 2019 11:30:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:33784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbfGPPaD (ORCPT ); Tue, 16 Jul 2019 11:30:03 -0400 Received: from kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 49E292054F; Tue, 16 Jul 2019 15:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563291002; bh=Q8O6F/yaThVCvHW/cVKsV5tCbDe9BryORGQ4CN6Um0g=; h=In-Reply-To:References:From:To:Cc:Subject:Date:From; b=hmrRtRBTdm4kxBE8EvPPH4y/b/PKD8OaIKtKYc/eioDNf3b02pnbucEOFC99AWMzc pk0CyxfUyQZeYOCLsyuxQzfqzfUvbYo5Iph+PD8JRiCTu/ejPd29269kFVfk3dJjt8 RJKmoux8/+m7uHXASWdbqf+lDk0usxb/6cFDsSio= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: References: <20190712081744.87097-1-brendanhiggins@google.com> <20190712081744.87097-5-brendanhiggins@google.com> <20190715221554.8417320665@mail.kernel.org> From: Stephen Boyd To: Brendan Higgins 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 Subject: Re: [PATCH v9 04/18] kunit: test: add kunit_stream a std::stream like logger User-Agent: alot/0.8.1 Date: Tue, 16 Jul 2019 08:30:01 -0700 Message-Id: <20190716153002.49E292054F@mail.kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Brendan Higgins (2019-07-16 01:37:34) > On Tue, Jul 16, 2019 at 12:57 AM Brendan Higgins > wrote: > > > > On Mon, Jul 15, 2019 at 3:15 PM Stephen Boyd wrote: > > > > > > Quoting Brendan Higgins (2019-07-12 01:17:30) > > > > diff --git a/include/kunit/kunit-stream.h b/include/kunit/kunit-str= eam.h > > > > new file mode 100644 > > > > index 0000000000000..a7b53eabf6be4 > > > > --- /dev/null > > > > +++ b/include/kunit/kunit-stream.h > > > > +/** > > > > + * struct kunit_stream - a std::stream style string builder. > > > > + * > > > > + * A std::stream style string builder. Allows messages to be built= up and > > > > + * printed all at once. > > > > + */ > > > > +struct kunit_stream { > > > > + /* private: internal use only. */ > > > > + struct kunit *test; > > > > + const char *level; > > > > > > Is the level changed? See my comment below, but I wonder if this whole > > > struct can go away and the wrappers can just operate on 'struct > > > string_stream' instead. > > > > I was inclined to agree with you when I first read your comment, but > > then I thought about the case that someone wants to add in a debug > > message (of which I currently have none). I think under most > > circumstances a user of kunit_stream would likely want to pick a > > default verbosity that maybe I should provide, but may still want > > different verbosity levels. > > > > The main reason I want to keep the types separate, string_stream vs. > > kunit_stream, is that they are intended to be used differently. > > string_stream is just a generic string builder. If you are using that, > > you are expecting to see someone building the string at some point and > > then doing something interesting with it. kunit_stream really tells > > you specifically that KUnit is putting together a message to > > communicate something to a user of KUnit. It is really used in a very > > specific way, and I wouldn't want to generalize its usage beyond how > > it is currently used. I think in order to preserve the author's > > intention it adds clarity to keep the types separate regardless of how > > similar they might be in reality. You may want to add some of these reasons to the commit text. > > > > + > > > > + if (!string_stream_is_empty(stream->internal_stream)) { > > > > + kunit_err(stream->test, > > > > + "End of test case reached with uncommitte= d stream entries\n"); > > > > + kunit_stream_commit(stream); > > > > + } > > > > +} > > > > + > > > > > > Nitpick: Drop this extra newline. > > > > Oops, nice catch. >=20 > Not super important, but I don't want you to think that I am ignoring > you. I think you must have unintentionally deleted the last function > in this file, or maybe you are referring to something that I am just > not seeing, but I don't see the extra newline here. No worries. Sorry for the noise. > > property of the input, it may or may not be enough information on its > > own for the expectation to fail, but we want to share the result of > > the property check with the user regardless, BUT only if the > > expectation as a whole fails. > > > > Hence, we can have multiple `struct kunit_stream`s associated with a > > `struct kunit` active at any given time. Makes sense. I wasn't sure if there were more than one stream associated with a test. Sounds like there are many to one so it can't just be a member of the test. This could be documented somewhere so this question doesn't come up again.