lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABVgOS=pFN4T5HjYpJPW4KOzXRFr-SUTm09xymxBmyidg0h=WA@mail.gmail.com>
Date:   Thu, 24 Feb 2022 14:43:53 +0800
From:   David Gow <davidgow@...gle.com>
To:     Kees Cook <keescook@...omium.org>
Cc:     Brendan Higgins <brendanhiggins@...gle.com>,
        "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>,
        KUnit Development <kunit-dev@...glegroups.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH] kunit: tool: Do not colorize output when redirected

On Thu, Feb 24, 2022 at 1:53 PM Kees Cook <keescook@...omium.org> 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 <brendanhiggins@...gle.com>
> Cc: linux-kselftest@...r.kernel.org
> Cc: kunit-dev@...glegroups.com
> Signed-off-by: Kees Cook <keescook@...omium.org>
> ---

Ah, you can tell a tool has "made it" when people are redirecting its output!

This works fine here.

Reviewed-by: David Gow <davidgow@...gle.com>

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@...glegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/kunit-dev/20220224055350.1854078-1-keescook%40chromium.org.

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4003 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ