[libvirt] [PATCH] tests: fix TTY check in virTestUseTerminalColors()

Pino Toscano posted 1 patch 6 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20171109123103.20678-1-ptoscano@redhat.com
tests/testutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] tests: fix TTY check in virTestUseTerminalColors()
Posted by Pino Toscano 6 years, 5 months ago
Since colors would be used when writing to stdout, then check that
stdout is a TTY, instead of stdin.

This avoids the usage of terminal color codes when the output is
directed to file.
---
 tests/testutils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/testutils.c b/tests/testutils.c
index 915cd3b79..9266f15e8 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -92,7 +92,7 @@ bool virTestOOMActive(void)
 
 static int virTestUseTerminalColors(void)
 {
-    return isatty(STDIN_FILENO);
+    return isatty(STDOUT_FILENO);
 }
 
 static unsigned int
-- 
2.13.6

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] tests: fix TTY check in virTestUseTerminalColors()
Posted by Martin Kletzander 6 years, 5 months ago
On Thu, Nov 09, 2017 at 01:31:03PM +0100, Pino Toscano wrote:
>Since colors would be used when writing to stdout, then check that
>stdout is a TTY, instead of stdin.
>
>This avoids the usage of terminal color codes when the output is
>directed to file.

Hehe, nice typo, I guess =) ACK

>---
> tests/testutils.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/tests/testutils.c b/tests/testutils.c
>index 915cd3b79..9266f15e8 100644
>--- a/tests/testutils.c
>+++ b/tests/testutils.c
>@@ -92,7 +92,7 @@ bool virTestOOMActive(void)
>
> static int virTestUseTerminalColors(void)
> {
>-    return isatty(STDIN_FILENO);
>+    return isatty(STDOUT_FILENO);
> }
>
> static unsigned int
>-- 
>2.13.6
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list