aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKito Cheng <kito.cheng@sifive.com>2020-06-02 10:17:12 -0600
committerKito Cheng <kito.cheng@sifive.com>2020-06-02 10:25:42 +0800
commit2b11374cb8d864dff3792e7c84188ba7e8f136e7 (patch)
tree7089f3c028281aa426d1a3ee3eefbe51f56343bc
parentc2449995ca36ea955e3c6d4ee7f0d401b512c897 (diff)
downloadgcc-2b11374cb8d864dff3792e7c84188ba7e8f136e7.zip
gcc-2b11374cb8d864dff3792e7c84188ba7e8f136e7.tar.gz
gcc-2b11374cb8d864dff3792e7c84188ba7e8f136e7.tar.bz2
testsuite: Disable colorization for ubsan test
- 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. gcc/testsuite/ChangeLog: * lib/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.
-rw-r--r--gcc/testsuite/lib/ubsan-dg.exp22
1 files changed, 22 insertions, 0 deletions
diff --git a/gcc/testsuite/lib/ubsan-dg.exp b/gcc/testsuite/lib/ubsan-dg.exp
index 015601c..f4ab29e 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