diff mbox series

testsuite: Disable colorization for ubsan test

Message ID 20200520070132.41611-1-kito.cheng@sifive.com
State New
Headers show
Series testsuite: Disable colorization for ubsan test | expand

Commit Message

Kito Cheng May 20, 2020, 7:01 a.m. UTC
- Run gcc testsuite with qemu will print out ascii color code for
   ubsan related testcase, however several testcase didn't consider
   that, so disable colorization prevent such problem and simplify the
   process when adding testcase in future.

 - Verified on native X86 and RISC-V qemu full system mode and user mode.

ChangeLog:

gcc/testsuite/

Kito Cheng  <kito.cheng@sifive.com>

	* ubsan-dg.exp (orig_ubsan_options_saved): New
	(orig_ubsan_options): Ditto.
	(ubsan_init): Store UBSAN_OPTIONS and set UBSAN_OPTIONS.
	(ubsan_finish): Restore UBSAN_OPTIONS.
---
 gcc/testsuite/lib/ubsan-dg.exp | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

Comments

Kito Cheng June 1, 2020, 7:43 a.m. UTC | #1
ping


On Wed, May 20, 2020 at 3:01 PM Kito Cheng <kito.cheng@sifive.com> wrote:
>
>  - Run gcc testsuite with qemu will print out ascii color code for
>    ubsan related testcase, however several testcase didn't consider
>    that, so disable colorization prevent such problem and simplify the
>    process when adding testcase in future.
>
>  - Verified on native X86 and RISC-V qemu full system mode and user mode.
>
> ChangeLog:
>
> gcc/testsuite/
>
> Kito Cheng  <kito.cheng@sifive.com>
>
>         * ubsan-dg.exp (orig_ubsan_options_saved): New
>         (orig_ubsan_options): Ditto.
>         (ubsan_init): Store UBSAN_OPTIONS and set UBSAN_OPTIONS.
>         (ubsan_finish): Restore UBSAN_OPTIONS.
> ---
>  gcc/testsuite/lib/ubsan-dg.exp | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/gcc/testsuite/lib/ubsan-dg.exp b/gcc/testsuite/lib/ubsan-dg.exp
> index 015601cd404..f4ab29e2add 100644
> --- a/gcc/testsuite/lib/ubsan-dg.exp
> +++ b/gcc/testsuite/lib/ubsan-dg.exp
> @@ -17,6 +17,9 @@
>  # Return 1 if compilation with -fsanitize=undefined is error-free for trivial
>  # code, 0 otherwise.
>
> +set orig_ubsan_options_saved 0
> +set orig_ubsan_options 0
> +
>  proc check_effective_target_fsanitize_undefined {} {
>      return [check_runtime fsanitize_undefined {
>         int main (void) { return 0; }
> @@ -74,6 +77,17 @@ proc ubsan_init { args } {
>      global TOOL_OPTIONS
>      global ubsan_saved_TEST_ALWAYS_FLAGS
>      global ubsan_saved_ALWAYS_CXXFLAGS
> +    global orig_ubsan_options_saved
> +    global orig_ubsan_options
> +
> +    if { $orig_ubsan_options_saved == 0 } {
> +       # Save the original environment.
> +       if [info exists env(UBSAN_OPTIONS)] {
> +           set orig_ubsan_options "$env(UBSAN_OPTIONS)"
> +           set orig_ubsan_options_saved 1
> +       }
> +    }
> +    setenv UBSAN_OPTIONS color=never
>
>      set link_flags ""
>      if ![is_remote host] {
> @@ -109,6 +123,14 @@ proc ubsan_finish { args } {
>      global ubsan_saved_ALWAYS_CXXFLAGS
>      global ubsan_saved_library_path
>      global ld_library_path
> +    global orig_ubsan_options_saved
> +    global orig_ubsan_options
> +
> +    if { $orig_ubsan_options_saved } {
> +       setenv UBSAN_OPTIONS "$orig_ubsan_options"
> +    } elseif [info exists env(UBSAN_OPTIONS)] {
> +       unsetenv UBSAN_OPTIONS
> +    }
>
>      if [info exists ubsan_saved_ALWAYS_CXXFLAGS ] {
>         set ALWAYS_CXXFLAGS $ubsan_saved_ALWAYS_CXXFLAGS
> --
> 2.26.2
>
Jakub Jelinek June 1, 2020, 7:46 a.m. UTC | #2
On Mon, Jun 01, 2020 at 03:43:00PM +0800, Kito Cheng wrote:
> ping
> 
> 
> On Wed, May 20, 2020 at 3:01 PM Kito Cheng <kito.cheng@sifive.com> wrote:
> >
> >  - Run gcc testsuite with qemu will print out ascii color code for
> >    ubsan related testcase, however several testcase didn't consider
> >    that, so disable colorization prevent such problem and simplify the
> >    process when adding testcase in future.
> >
> >  - Verified on native X86 and RISC-V qemu full system mode and user mode.
> >
> > ChangeLog:
> >
> > gcc/testsuite/
> >
> > Kito Cheng  <kito.cheng@sifive.com>
> >
> >         * ubsan-dg.exp (orig_ubsan_options_saved): New
> >         (orig_ubsan_options): Ditto.
> >         (ubsan_init): Store UBSAN_OPTIONS and set UBSAN_OPTIONS.
> >         (ubsan_finish): Restore UBSAN_OPTIONS.

Ok, thanks.

	Jakub
Kito Cheng June 2, 2020, 2:26 a.m. UTC | #3
Committed, thanks :)

On Mon, Jun 1, 2020 at 4:10 PM Jakub Jelinek via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Mon, Jun 01, 2020 at 03:43:00PM +0800, Kito Cheng wrote:
> > ping
> >
> >
> > On Wed, May 20, 2020 at 3:01 PM Kito Cheng <kito.cheng@sifive.com> wrote:
> > >
> > >  - Run gcc testsuite with qemu will print out ascii color code for
> > >    ubsan related testcase, however several testcase didn't consider
> > >    that, so disable colorization prevent such problem and simplify the
> > >    process when adding testcase in future.
> > >
> > >  - Verified on native X86 and RISC-V qemu full system mode and user mode.
> > >
> > > ChangeLog:
> > >
> > > gcc/testsuite/
> > >
> > > Kito Cheng  <kito.cheng@sifive.com>
> > >
> > >         * ubsan-dg.exp (orig_ubsan_options_saved): New
> > >         (orig_ubsan_options): Ditto.
> > >         (ubsan_init): Store UBSAN_OPTIONS and set UBSAN_OPTIONS.
> > >         (ubsan_finish): Restore UBSAN_OPTIONS.
>
> Ok, thanks.
>
>         Jakub
>
diff mbox series

Patch

diff --git a/gcc/testsuite/lib/ubsan-dg.exp b/gcc/testsuite/lib/ubsan-dg.exp
index 015601cd404..f4ab29e2add 100644
--- a/gcc/testsuite/lib/ubsan-dg.exp
+++ b/gcc/testsuite/lib/ubsan-dg.exp
@@ -17,6 +17,9 @@ 
 # Return 1 if compilation with -fsanitize=undefined is error-free for trivial
 # code, 0 otherwise.
 
+set orig_ubsan_options_saved 0
+set orig_ubsan_options 0
+
 proc check_effective_target_fsanitize_undefined {} {
     return [check_runtime fsanitize_undefined {
 	int main (void) { return 0; }
@@ -74,6 +77,17 @@  proc ubsan_init { args } {
     global TOOL_OPTIONS
     global ubsan_saved_TEST_ALWAYS_FLAGS
     global ubsan_saved_ALWAYS_CXXFLAGS
+    global orig_ubsan_options_saved
+    global orig_ubsan_options
+
+    if { $orig_ubsan_options_saved == 0 } {
+	# Save the original environment.
+	if [info exists env(UBSAN_OPTIONS)] {
+	    set orig_ubsan_options "$env(UBSAN_OPTIONS)"
+	    set orig_ubsan_options_saved 1
+	}
+    }
+    setenv UBSAN_OPTIONS color=never
 
     set link_flags ""
     if ![is_remote host] {
@@ -109,6 +123,14 @@  proc ubsan_finish { args } {
     global ubsan_saved_ALWAYS_CXXFLAGS
     global ubsan_saved_library_path
     global ld_library_path
+    global orig_ubsan_options_saved
+    global orig_ubsan_options
+
+    if { $orig_ubsan_options_saved } {
+	setenv UBSAN_OPTIONS "$orig_ubsan_options"
+    } elseif [info exists env(UBSAN_OPTIONS)] {
+	unsetenv UBSAN_OPTIONS
+    }
 
     if [info exists ubsan_saved_ALWAYS_CXXFLAGS ] {
 	set ALWAYS_CXXFLAGS $ubsan_saved_ALWAYS_CXXFLAGS