Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2827484imw; Wed, 6 Jul 2022 12:24:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tDwc6Hz7QuGzK4Wum8M2MvdGzR3QHkzGjJpIsBLYF4FdSLfsOSYewSr85Zex9N5k8dS6DX X-Received: by 2002:a05:6402:40d2:b0:438:3203:cadd with SMTP id z18-20020a05640240d200b004383203caddmr51500228edb.95.1657135485582; Wed, 06 Jul 2022 12:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657135485; cv=none; d=google.com; s=arc-20160816; b=uF5MXYruxxBA/jmc7OcYF/N39vRoBlJZJQmu1aNK3fFiuhJhYCDbJCxnrWGc1xxbR0 RixJ3vi4gx6XuUV5qwuOtA/lAlKdNsy0ulz+rkIGEShqnsGFlDWZu/7J7DLMKeZ45mhY Dsb+NbzEnRGX1iFWV+H8vKpqsuzfgqxEaYWg1bqU/FafqPemCFY8KJC6ScvaAG5nUYzK 7AP/qMca1M03H+2Nm6ZqvqEiqvWhRoG+kvtUHq+OvPscB4f39Un0Gm2VkCz+A6rb73lm QAUTl9ZhQ1x/M10ZDW6ghoU8+0zVEINDC+zP22WT9Y9dx/zvfqvMBcXsaN+LADoK1Cfc k3Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=DaD3IQOOIYs922HyFPt3gDuoj5LcEWxvvwoxeXt8fJI=; b=gsehMpgCD7lk5GyMYVALCGQU3S3gxWpTD9dc8snyrbQheb//JYUogCQs+AHwyzZ1W3 CVMek+lnf+JWI7aRj7RUsBcOZ/O/dJWXE7mu+fUd9aTnq29XW1GL8hDFXVarDLjHvKn5 CeneyCpBbVAUljR+i0BPkaTBwJMxCivhXzNYnFmHDX+dj6hnYuLZqr7BOgIOzGHJ/m9W nORxomAM0uzzK8+6LpHre/oO2q5+JREZ+I9auBllX1UqPKUILRP+5gaeZzaJxkxDAGLv 9zxazd5bd6Tl/UFYWMb2W9haLj/R+1mXsBUwUmuWd6cIq8WjiAlfVOnAKc1Q0wMy0N4I BwUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZeMq41JU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020aa7d648000000b0043a92522129si876454edr.501.2022.07.06.12.24.19; Wed, 06 Jul 2022 12:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZeMq41JU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233908AbiGFTQD (ORCPT + 99 others); Wed, 6 Jul 2022 15:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbiGFTQB (ORCPT ); Wed, 6 Jul 2022 15:16:01 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D06C1237CC for ; Wed, 6 Jul 2022 12:16:00 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id v12so7852006edc.10 for ; Wed, 06 Jul 2022 12:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=DaD3IQOOIYs922HyFPt3gDuoj5LcEWxvvwoxeXt8fJI=; b=ZeMq41JUS362BA1pO+hs1g2s3LKOhlzv1jrk65JQSknyJksYY+pxTiKeIET5RZQJVf FK/VdDQZj/Up11J0mvYVWS3uVPxXDvB0D4JJHSbJz4J4cu/dOcPZmwqkjrv0BSyXHNgD Z1nmWVoA/X0QrsJG7l6gPcmWiGNa3CRKF8AdAspTGM46JtQiAflLEkKM3WwhKd0C2BEP AFmrQ7oLwyo8CFCFzNyKtUzsNUzavZGVATpXGfdikHQDIDXl9dAKWkpMQzOmrK+PN2Yr 7yCXnKnSLgptGiXgNa4EhubV4krJ6TU1oL40NRaWTo3fzZ2hizJbS0Z41hkm6ZZCYDJV WIeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=DaD3IQOOIYs922HyFPt3gDuoj5LcEWxvvwoxeXt8fJI=; b=2KGhD+LHeqhjUJScXJ5Z6Ij2MrbpMOhVTZ6E1xcPALmWQXRLqK9HQdda2BLjdDm/K6 dCirt0vQHDo3HZno+iPv35clBtexldqOQYJcoLSKqcvnbnEDJhOwG5/6wtmd1TGgRFSj ChTY82Gncx2ToKZjOAz/Z86KWNrCaBS4FkxQH9lAzzAu2ikJSGSyOVDgO47o+kTdlYVE PavsBhgT9qUtyPvkWKG5c1n6oraxsEu0/gYNyhW6WyFdS+1kvJrCEWRi7BNDshWVdxr4 o2BQp9sGZFV6KVRrYWrH0PKjG6U4jWA9/bTb8FTB9VOp0FTk/9uVI5pUl+hiHfSqygfu 5vWA== X-Gm-Message-State: AJIora9ImNek13A88gz0JXtUBQMGjp4gSLdI1OeN7t6m+Jt7J1WCJ6w3 Gz8lLOdvoj/REgX/U1shpIDSOpBRGoHGqJuLsiLuSA== X-Received: by 2002:a05:6402:4488:b0:43a:7b6e:4b04 with SMTP id er8-20020a056402448800b0043a7b6e4b04mr12750837edb.202.1657134959282; Wed, 06 Jul 2022 12:15:59 -0700 (PDT) MIME-Version: 1.0 References: <20220516194730.1546328-1-dlatypov@google.com> <20220516194730.1546328-3-dlatypov@google.com> In-Reply-To: From: Brendan Higgins Date: Wed, 6 Jul 2022 15:15:47 -0400 Message-ID: Subject: Re: [PATCH 3/3] kunit: tool: refactoring printing logic into kunit_printer.py To: Daniel Latypov Cc: David Gow , Linux Kernel Mailing List , KUnit Development , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 18, 2022 at 11:51 AM Daniel Latypov wrote: > > On Wed, May 18, 2022 at 12:48 AM David Gow wrote: > > > > On Tue, May 17, 2022 at 3:48 AM Daniel Latypov 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 > > > --- > > > > 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") Kind of late to mention this (and we might have already talked about this offline), but I am fine with what you have done here with the stdout. My initial reaction was similar to David's, but after thinking about it, I don't think it is prone to misuse, and I think it is clear - and allows for easy refactoring in the future. > 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.