Message ID | 1446464924-20878-2-git-send-email-thomas.wood@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
2015-11-02 9:48 GMT-02:00 Thomas Wood <thomas.wood@intel.com>: > Make subtest results easier to identify by making them bold when the output > is a terminal. Cool! A long time ago I suggested using different colors when writing SUCCESS/FAIL/SKIP/CRASH (green, red, yellow, orange) and I was told this wouldn't get merged since I should be using piglit. Since you're creating the precedent here, can I also volunteer you to give colors to those words on a next commit? Thanks, Paulo > > Signed-off-by: Thomas Wood <thomas.wood@intel.com> > --- > lib/igt_core.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/lib/igt_core.c b/lib/igt_core.c > index 59127ca..7123455 100644 > --- a/lib/igt_core.c > +++ b/lib/igt_core.c > @@ -779,9 +779,12 @@ bool __igt_run_subtest(const char *subtest_name) > } > > if (skip_subtests_henceforth) { > - printf("Subtest %s: %s\n", subtest_name, > + bool istty = isatty(STDOUT_FILENO); > + > + printf("%sSubtest %s: %s%s\n", > + (istty) ? "\x1b[1m" : "", subtest_name, > skip_subtests_henceforth == SKIP ? > - "SKIP" : "FAIL"); > + "SKIP" : "FAIL", (istty) ? "\x1b[0m" : ""); > return false; > } > > @@ -825,12 +828,14 @@ static void exit_subtest(const char *result) > { > struct timespec now; > double elapsed; > + bool istty = isatty(STDOUT_FILENO); > > gettime(&now); > elapsed = now.tv_sec - subtest_time.tv_sec; > elapsed += (now.tv_nsec - subtest_time.tv_nsec) * 1e-9; > > - printf("Subtest %s: %s (%.3fs)\n", in_subtest, result, elapsed); > + printf("%sSubtest %s: %s (%.3fs)%s\n", (istty) ? "\x1b[1m" : "", > + in_subtest, result, elapsed, (istty) ? "\x1b[0m" : ""); > fflush(stdout); > > in_subtest = NULL; > -- > 1.9.1 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Thomas, This causes all the formatting characters to appear in our logs on Android. The problem I think is because the ADB connection to the device is always seen as a terminal and any redirection to log files is being done on the host. Would it be possible to add a command line option to explicitly disable any pretty text formatting regardless of the isatty() call (--plain)? If it could also apply to the isatty() call in igt_core.c/common_init() as well I could be persuaded to drop the formatting change I currently have in another patch to gem_exec_nop :-) e.g. Have a library function that always returns false if --plain is specified otherwise the return value of isatty()? //Derek -----Original Message----- From: Intel-gfx [mailto:intel-gfx-bounces@lists.freedesktop.org] On Behalf Of Paulo Zanoni Sent: Wednesday, November 4, 2015 7:58 PM To: Wood, Thomas Cc: Intel Graphics Development Subject: Re: [Intel-gfx] [PATCH i-g-t 2/8] lib: highlight subtest results on terminals 2015-11-02 9:48 GMT-02:00 Thomas Wood <thomas.wood@intel.com>: > Make subtest results easier to identify by making them bold when the > output is a terminal. Cool! A long time ago I suggested using different colors when writing SUCCESS/FAIL/SKIP/CRASH (green, red, yellow, orange) and I was told this wouldn't get merged since I should be using piglit. Since you're creating the precedent here, can I also volunteer you to give colors to those words on a next commit? Thanks, Paulo > > Signed-off-by: Thomas Wood <thomas.wood@intel.com> > --- > lib/igt_core.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/lib/igt_core.c b/lib/igt_core.c index 59127ca..7123455 > 100644 > --- a/lib/igt_core.c > +++ b/lib/igt_core.c > @@ -779,9 +779,12 @@ bool __igt_run_subtest(const char *subtest_name) > } > > if (skip_subtests_henceforth) { > - printf("Subtest %s: %s\n", subtest_name, > + bool istty = isatty(STDOUT_FILENO); > + > + printf("%sSubtest %s: %s%s\n", > + (istty) ? "\x1b[1m" : "", subtest_name, > skip_subtests_henceforth == SKIP ? > - "SKIP" : "FAIL"); > + "SKIP" : "FAIL", (istty) ? "\x1b[0m" : ""); > return false; > } > > @@ -825,12 +828,14 @@ static void exit_subtest(const char *result) { > struct timespec now; > double elapsed; > + bool istty = isatty(STDOUT_FILENO); > > gettime(&now); > elapsed = now.tv_sec - subtest_time.tv_sec; > elapsed += (now.tv_nsec - subtest_time.tv_nsec) * 1e-9; > > - printf("Subtest %s: %s (%.3fs)\n", in_subtest, result, elapsed); > + printf("%sSubtest %s: %s (%.3fs)%s\n", (istty) ? "\x1b[1m" : "", > + in_subtest, result, elapsed, (istty) ? "\x1b[0m" : ""); > fflush(stdout); > > in_subtest = NULL; > -- > 1.9.1 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Paulo Zanoni _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff --git a/lib/igt_core.c b/lib/igt_core.c index 59127ca..7123455 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -779,9 +779,12 @@ bool __igt_run_subtest(const char *subtest_name) } if (skip_subtests_henceforth) { - printf("Subtest %s: %s\n", subtest_name, + bool istty = isatty(STDOUT_FILENO); + + printf("%sSubtest %s: %s%s\n", + (istty) ? "\x1b[1m" : "", subtest_name, skip_subtests_henceforth == SKIP ? - "SKIP" : "FAIL"); + "SKIP" : "FAIL", (istty) ? "\x1b[0m" : ""); return false; } @@ -825,12 +828,14 @@ static void exit_subtest(const char *result) { struct timespec now; double elapsed; + bool istty = isatty(STDOUT_FILENO); gettime(&now); elapsed = now.tv_sec - subtest_time.tv_sec; elapsed += (now.tv_nsec - subtest_time.tv_nsec) * 1e-9; - printf("Subtest %s: %s (%.3fs)\n", in_subtest, result, elapsed); + printf("%sSubtest %s: %s (%.3fs)%s\n", (istty) ? "\x1b[1m" : "", + in_subtest, result, elapsed, (istty) ? "\x1b[0m" : ""); fflush(stdout); in_subtest = NULL;
Make subtest results easier to identify by making them bold when the output is a terminal. Signed-off-by: Thomas Wood <thomas.wood@intel.com> --- lib/igt_core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)