From: Daniel Latypov <dlatypov@google.com>
To: David Gow <davidgow@google.com>
Cc: Brendan Higgins <brendanhiggins@google.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
KUnit Development <kunit-dev@googlegroups.com>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH 3/3] kunit: tool: refactoring printing logic into kunit_printer.py
Date: Wed, 18 May 2022 08:50:48 -0700 [thread overview]
Message-ID: <CAGS_qxqJNpoZkv0==q_yMTuWzATTtUsXw3o1ZOR=n+fjVS+ghA@mail.gmail.com> (raw)
In-Reply-To: <CABVgOSn1Hq6AX-+=+m_uLwKne3wuUadrsE=uPRsgYH3+TFBEuA@mail.gmail.com>
On Wed, May 18, 2022 at 12:48 AM David Gow <davidgow@google.com> wrote:
>
> On Tue, May 17, 2022 at 3:48 AM Daniel Latypov <dlatypov@google.com> wrote:
> >
> > Context:
> > * kunit_kernel.py is importing kunit_parser.py just to use the
> > print_with_timestamp() function
> > * the parser is directly printing to stdout, which will become an issue
> > if we ever try to run multiple kernels in parallel
> >
> > This patch introduces a kunit_printer.py file and migrates callers of
> > kunit_parser.print_with_timestamp() to call
> > kunit_printer.stdout.print_with_timestamp() instead.
> >
> > Future changes:
> > If we want to support showing results for parallel runs, we could then
> > create new Printer's that don't directly write to stdout and refactor
> > the code to pass around these Printer objects.
> >
> > Signed-off-by: Daniel Latypov <dlatypov@google.com>
> > ---
>
> I agree that this will be useful down the line, as running multiple
> kernels in parallel is definitely something which could be useful. I
> know the original idea for that was to have multiple parsers, and just
> to combine the results they gave after the fact, but given that
> incremental output is so useful, I agree that this is the better path.
>
> My only super-minor gripe (which I can live with) is that importing
> 'stdout' and using it as 'stdout.print_with_timestamp()' is a little
> confusing: I'd've assumed an stdout variable imported into the global
> namespace was sys.stdout, not a wrapper. Explicitly using
> kunit_printer.stdout would be a little clearer, IMO. Up to you,
> though.
I was initially writing it that way, but then the following pattern
got super long
Old:
print_with_timestamp(red("[ERROR]") + " some error")
New options:
stdout.print_with_timestamp(stdout.red("[ERROR]") + " some error")
kunit_printer.stdout.print_with_timestamp(kunit_printer.stdout.red("[ERROR]")
+ " some error")
But yeah, I see what you mean about potential confusion with sys.stdout.
I couldn't think of a better (while still short name) for it.
E.g. "default_printer", "stdout_printer", etc.
FWIW, I have a local patch that drops 99% of the direct uses of
kunit_printer.stdout in the parser and passes around buffered
printers.
And in that case, the use of stdout becomes small enough that we could
do `kunit_printer.stdout` w/o as much pain/noise.
But I have no plans of sending that out until we need it, since it
muddies up the code quite a bit.
And I don't have a clear idea of what the interface to parallel
testing should look like, so that day is still far off.
next prev parent reply other threads:[~2022-05-18 15:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 19:47 [PATCH 1/3] kunit: tool: drop unused load_config argument Daniel Latypov
2022-05-16 19:47 ` [PATCH 2/3] kunit: tool: redo how we construct and mock LinuxSourceTree Daniel Latypov
2022-05-18 7:43 ` David Gow
2022-07-06 19:04 ` Brendan Higgins
2022-05-16 19:47 ` [PATCH 3/3] kunit: tool: refactoring printing logic into kunit_printer.py Daniel Latypov
2022-05-18 7:48 ` David Gow
2022-05-18 15:50 ` Daniel Latypov [this message]
2022-07-06 19:15 ` Brendan Higgins
2022-07-06 19:16 ` Brendan Higgins
2022-05-18 7:42 ` [PATCH 1/3] kunit: tool: drop unused load_config argument David Gow
2022-07-06 18:58 ` Brendan Higgins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGS_qxqJNpoZkv0==q_yMTuWzATTtUsXw3o1ZOR=n+fjVS+ghA@mail.gmail.com' \
--to=dlatypov@google.com \
--cc=brendanhiggins@google.com \
--cc=davidgow@google.com \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).