Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1271560pxm; Wed, 23 Feb 2022 23:02:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4H51b5pNJ1ktzv2py+xsc6VvFSphPPTsu11iieIxGUmxDZgvPtuQic/TemvLfZ3s77FMq X-Received: by 2002:a17:906:4c46:b0:6cf:5489:da5b with SMTP id d6-20020a1709064c4600b006cf5489da5bmr1124724ejw.203.1645686155078; Wed, 23 Feb 2022 23:02:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645686155; cv=none; d=google.com; s=arc-20160816; b=FqsCZ1U6wN/m2NARJsO1+uh/LkVdrki2azy4LfAlVJf1OD8DMsk9rrvmfOFrxhqi8d ABFfZXS0CJXPMzGpxE3qmspCFZIuadx+CTGm+lEjEB/UpsiZCYKbh1HQTdqeH+esV8fG DOaRqbNOC/nCAdJG2LT/weX8ABgLkMvmBqtfDwfFWUehnClPxFQJOoohu6NtYzENmr7e fH8mNMYSjxarsrWcOmQwK/OZbgT5p1WhKYcWJCtobWcBgp8UiHo/57U6rtOskDYUAz21 qWVxqLEsSO7nXRQiH0U9FyQJqYeQ0VLSApXqzGG7+fi4+vCADfqjanTSOsGk3ezf9Eb4 +e5w== 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=zX0d05mBZ7OPXTDazzQ3nGUZv8wk3WNnmgZLFg1d23U=; b=LLhRwK2/l7Wyp0Hoq9XrJ3uIIf9zeIQxJG2wAZur0vA2UckkG4fhHn3XISK/mDrp3w 3z4zez4VVqgioX4gRu4BkQOyqBwa44AV+Mr9i5sx1vApwTzdWGVDgiR+2sXOHtiFhQsG 8KPeSVrdRH7Wa5PF6bZ/Q2MXFbB1H1xzddq9ijN/ymYh6cbK0kh0XxPX0Qpj9/qIZrHs rCF0NxR1I8FeQQIa1W6327Ar0NwQFbF7EdGX/EfPFCRqNmvRkCz/NZn8Bkj7pR8Y6xxj EU9D7hMPVjl69GLCVLThQ82M0I0DYOTZhQOEFAe12gJXUkhJxxFl2p03mbnBU6J5NSi6 xr4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jPgomuX2; 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 z5si1091165edc.641.2022.02.23.23.02.11; Wed, 23 Feb 2022 23:02:34 -0800 (PST) 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=jPgomuX2; 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 S231239AbiBXGoh (ORCPT + 99 others); Thu, 24 Feb 2022 01:44:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230310AbiBXGof (ORCPT ); Thu, 24 Feb 2022 01:44:35 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A2E826A3A1 for ; Wed, 23 Feb 2022 22:44:06 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id d28so1412592wra.4 for ; Wed, 23 Feb 2022 22:44:06 -0800 (PST) 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=zX0d05mBZ7OPXTDazzQ3nGUZv8wk3WNnmgZLFg1d23U=; b=jPgomuX2z0txC91NLov5eOFI1VTdFK3BZoVNOEuZGmyr0dFInIqRpuux+vzeec7WpI 4+hPaZdVAlsejMWTWS8bxreWy9SSdCyrNBhXivJwdMoHnl+c+tqG0sKUmq+X0nm0F0GY Goxh1r4cExAFg8AE5SHgGuP8VlltIMg8dORoCXN0/nFrWjGeZBS9872zjemYX4uWzYwZ CHNzqxBtDbjfn0HGv7UEN6CcnuT8zpFTmS42j+k40gwLhFQBo44RP9gvpNew1IOZB/F1 RgWwWNK+MNgeTgfoqimdHZcS0npFPlwHTN8cfiUaz7h82GsZvqx9wVn1ip+AfR5q22vQ UT7w== 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=zX0d05mBZ7OPXTDazzQ3nGUZv8wk3WNnmgZLFg1d23U=; b=WIr5zQABD44lUD/cIwk0xJYCyfYy5ihie8ICbJzaf4olNBW6zmG6g73+/dxMmIYBv0 9C+wG88+Kszb3cAiI7s+SrTiwLIvm19cUtazKRlCiuinlsJH27nFEPEuZR1GqICZ21VP ++5Aew3RMSB+U8Fa7UTPo83R6w2UFVTW1Rjz5z1JMTzGJSdeM8jWR7GZUMZ0Xrkcx5+Z Je0Qi923aLrSJ79KKxoY5fwnEUIqsDtniumHWwAof4X3TkNeyCZDmj//2mbaYH/uk4LA m76V/2V6qXkLSMtMX2sIl/+BELkCII3Vptv40SNe1ky/Tyr1Io2WeD8le8EZoe42CgTz 80uw== X-Gm-Message-State: AOAM531NI3gWgQR93F5y9SAzNC3yeXunr3Asz1uakF0SLjl0ujOGwe+J 5hDmwbf5B26J4VQ0wXE5XDnCjvCRP2C/O6mrWt7jAA== X-Received: by 2002:adf:a486:0:b0:1ed:9cfe:179d with SMTP id g6-20020adfa486000000b001ed9cfe179dmr1005465wrb.113.1645685044848; Wed, 23 Feb 2022 22:44:04 -0800 (PST) MIME-Version: 1.0 References: <20220224055350.1854078-1-keescook@chromium.org> In-Reply-To: <20220224055350.1854078-1-keescook@chromium.org> From: David Gow Date: Thu, 24 Feb 2022 14:43:53 +0800 Message-ID: Subject: Re: [PATCH] kunit: tool: Do not colorize output when redirected To: Kees Cook Cc: Brendan Higgins , "open list:KERNEL SELFTEST FRAMEWORK" , KUnit Development , Linux Kernel Mailing List , linux-hardening@vger.kernel.org Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="00000000000087104905d8bde898" 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 --00000000000087104905d8bde898 Content-Type: text/plain; charset="UTF-8" On Thu, Feb 24, 2022 at 1:53 PM Kees Cook wrote: > > Filling log files with color codes makes diffs and other comparisons > difficult. Only emit vt100 codes when the stdout is a TTY. > > Cc: Brendan Higgins > Cc: linux-kselftest@vger.kernel.org > Cc: kunit-dev@googlegroups.com > Signed-off-by: Kees Cook > --- Ah, you can tell a tool has "made it" when people are redirecting its output! This works fine here. Reviewed-by: David Gow Thanks, -- David > tools/testing/kunit/kunit_parser.py | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py > index 05ff334761dd..807ed2bd6832 100644 > --- a/tools/testing/kunit/kunit_parser.py > +++ b/tools/testing/kunit/kunit_parser.py > @@ -11,6 +11,7 @@ > > from __future__ import annotations > import re > +import sys > > import datetime > from enum import Enum, auto > @@ -503,14 +504,20 @@ RESET = '\033[0;0m' > > def red(text: str) -> str: > """Returns inputted string with red color code.""" > + if not sys.stdout.isatty(): > + return text > return '\033[1;31m' + text + RESET > > def yellow(text: str) -> str: > """Returns inputted string with yellow color code.""" > + if not sys.stdout.isatty(): > + return text > return '\033[1;33m' + text + RESET > > def green(text: str) -> str: > """Returns inputted string with green color code.""" > + if not sys.stdout.isatty(): > + return text > return '\033[1;32m' + text + RESET > > ANSI_LEN = len(red('')) > -- > 2.30.2 > > -- > You received this message because you are subscribed to the Google Groups "KUnit Development" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kunit-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20220224055350.1854078-1-keescook%40chromium.org. --00000000000087104905d8bde898 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIPnwYJKoZIhvcNAQcCoIIPkDCCD4wCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg ggz5MIIEtjCCA56gAwIBAgIQeAMYYHb81ngUVR0WyMTzqzANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA3MjgwMDAwMDBaFw0yOTAzMTgwMDAwMDBaMFQxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMSowKAYDVQQDEyFHbG9iYWxTaWduIEF0bGFz IFIzIFNNSU1FIENBIDIwMjAwggEiMA0GCSqGSIb3DQEBAQU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