Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp600519iob; Wed, 18 May 2022 08:55:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4XIGlNljZXv5TDToljhdSj4a8LCNIVLs0dnOv11+tBjnEH55M9zF3ojrHowoT+hu2Wza8 X-Received: by 2002:a65:4581:0:b0:3f2:638f:6f76 with SMTP id o1-20020a654581000000b003f2638f6f76mr144314pgq.324.1652889330242; Wed, 18 May 2022 08:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652889330; cv=none; d=google.com; s=arc-20160816; b=EE1D9eKptwFD/Juvlx0bjiFJEk1IlOxD1uy6186Ut7a6vzuhPIVVeCpVYJMDiB/V4A 3JE8OkMvrimVeDq4ulM/SEYSY7VpJFTrzLx+rsBEY2i4iHHQczuFRWBONUBs8lndkuID lTGKOjYFjdvK13qZIuXGOcH23NVM0GhvdQByBVKRcQm0PQbDWIILpvLHmd7CucKNc8+k iZVMatJJphsJcXj8fPNNSY8PLRucu9oBRkcfxulL6pjZ6OKjKZK4tJ5XdMiJMYmFcG6k 1cqNiL0o4djueUbRWavak45RVlQI4+lUwB7MV6w+N8uTp0HnQxUMSJaqktaQY6PJX8Jh Ax8w== 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=cqJvUd681sz/Rpj3bROR5w8jszwa8bJSwwyEmSegot4=; b=VJOelEZC+1gSMBEXY/9oj1omNH81IhIuUNkarDQsFdFUdEZdicWeIInDgAObEYSstv PX57B/QLzAtar7CbyWDLQFOSGSD+0r3NPmoEl7xH6vyaClSheib+vZl1X48/FFJcM3gB 8Enkxwf+Y/ACPzfyePLiHMfDRQFCaS1jBQVwcviOyC3Rdd3bf0y/5Ec7wx3hx4qqdOUT SxSapgb6KbS8II/WN/IPxMI3O6f8BHMl6+7HlsfKZFHMxalscVowTlXV3+6sSZSch7M1 QWZbqFzHjxa3Z6lE1cL+SXlNvpP13lnecVxDS1256qWaHe6N9p6BT4OAFqByIDcfAIlo AVYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cPb1tJ1h; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f15-20020a62380f000000b0050abac273b4si3339115pfa.133.2022.05.18.08.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 08:55:30 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cPb1tJ1h; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F40D71BB13B; Wed, 18 May 2022 08:51:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239602AbiERPv1 (ORCPT + 99 others); Wed, 18 May 2022 11:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239625AbiERPvD (ORCPT ); Wed, 18 May 2022 11:51:03 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9602791541 for ; Wed, 18 May 2022 08:51:01 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id eg11so3538804edb.11 for ; Wed, 18 May 2022 08:51:01 -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=cqJvUd681sz/Rpj3bROR5w8jszwa8bJSwwyEmSegot4=; b=cPb1tJ1h/ExxwGcfPisCk9cYxVkxu4zTnNyhm8MU3HLzkkedyyXQHCZcS+39qSREQW bZQblEk4puk1CLb2hzJKwRCkaqKnSkOZhhO9SsNZwlh4fSWbl2yIL4PeyF/w48jOyDVb sJan6jKTe8TlxVRFkIrZ62DO3vNuYmkk+32E1Do9LyRqkO/ws+tYsD0PxWGzCzT1Yfv+ d1nRUuirNV3+t0eF2vwIgKY1izNmGxkJiTPA/4/TOAbCMKd/7gUj02TQvyNm7xhMGOQP ACm7bA4BBpmmam8X+adli4IzDzD3AjeKxNzRue4T9B/2PJC/mByNGKw9EBAuh2EC/ONI zkLA== 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=cqJvUd681sz/Rpj3bROR5w8jszwa8bJSwwyEmSegot4=; b=o3z+DLgG4JL5JiMGd6IyoBDa3sUnXAMj4bNHtaZJlz9aKwROzieKOVa5xYsK4ayFqk NjXBe/JYWdf7T+z3Nt/d8C492Qemn79N3k0LDN4UUseX/mruZvirignxXSNl1+C2C5XZ yHMTllIf1K6kDFklaLOGiOTPnAsi95mPCboIP3RbRVRmoFyvTcV1HaT3GUaTGnCWXvmO bNv2JYtypfuXhZq5/O8kOrmx3ZOlvfzodipIAsxD80Wvdym8MIlvFb8bi2gepyaDODUW Lm3VVdDzjNCecKNNa7us2mDVL90EZsK6+mJofjbfs4dsYElpNSXA/QJgI+EqRCAjA49I usqQ== X-Gm-Message-State: AOAM530geBlLv4z8rOY9liylApAluRUsW9KTWzxEsIoQT8jqqpqdUS4d Ook1RiLuVUsxgDX6nB13f9pCOKP2XAO8D5xFutpMKw== X-Received: by 2002:aa7:cb48:0:b0:42a:addf:4bf1 with SMTP id w8-20020aa7cb48000000b0042aaddf4bf1mr392612edt.283.1652889059935; Wed, 18 May 2022 08:50:59 -0700 (PDT) MIME-Version: 1.0 References: <20220516194730.1546328-1-dlatypov@google.com> <20220516194730.1546328-3-dlatypov@google.com> In-Reply-To: From: Daniel Latypov Date: Wed, 18 May 2022 08:50:48 -0700 Message-ID: Subject: Re: [PATCH 3/3] kunit: tool: refactoring printing logic into kunit_printer.py To: David Gow Cc: Brendan Higgins , 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=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 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") 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.