From: Andrew Pinski Date: Thu, 2 Oct 2014 06:35:49 +0000 (+0000) Subject: gcc/testsuite/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9fbbb20da58853217f84a9c4b82c84274c27144f;p=gcc.git gcc/testsuite/ 2014-10-01 Andrew Pinski Max Ostapenko * lib/ubsan-dg.exp (check_effective_target_fsanitize_address): New function. (ubsan_init): Save off ALWAYS_CXXFLAGS. (ubsan_finish): Restore ALWAYS_CXXFLAGS correctly. * lib/asan-dg.exp (check_effective_target_faddress_sanitizer): Rename to ... (check_effective_target_fsanitize_address): ... this. Change to creating an executable. (asan_init): Save off ALWAYS_CXXFLAGS. (asan_finish): Restore ALWAYS_CXXFLAGS correctly. * lib/tsan-dg.exp (check_effective_target_fthread_sanitizer): Rename to ... (check_effective_target_fsanitize_thread): ... this. Change to creating an executable. (tsan_init): Save off ALWAYS_CXXFLAGS. (tsan_finish): Restore ALWAYS_CXXFLAGS correctly. Set dg-do-what-default to run as a default behaviour. * gcc.dg/ubsan/ubsan.exp: Don't check the return value of ubsan_init. Check check_effective_target_fsanitize_undefined before running the tests. * g++.dg/ubsan/ubsan.exp: Likewise. * gcc.dg/asan/asan.exp: Don't check the return value of asan_init. check_effective_target_fsanitize_address too early. Check check_effective_target_fsanitize_address before running the tests. * g++.dg/asan/asan.exp: Likewise. * gcc.dg/tsan/tsan.exp: Don't check the return value of tsan_init. check_effective_target_fsanitize_thread too early. Check check_effective_target_fsanitize_thread before running the tests. * g++.dg/tsan/tsan.exp: Likewise. Co-Authored-By: Max Ostapenko From-SVN: r215793 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0cf36a08329..b11b45aace7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,36 @@ +2014-10-02 Andrew Pinski + Max Ostapenko + + * lib/ubsan-dg.exp + (check_effective_target_fsanitize_address): New function. + (ubsan_init): Save off ALWAYS_CXXFLAGS. + (ubsan_finish): Restore ALWAYS_CXXFLAGS correctly. + * lib/asan-dg.exp + (check_effective_target_faddress_sanitizer): Rename to ... + (check_effective_target_fsanitize_address): ... this. Change to creating + an executable. + (asan_init): Save off ALWAYS_CXXFLAGS. + (asan_finish): Restore ALWAYS_CXXFLAGS correctly. + * lib/tsan-dg.exp + (check_effective_target_fthread_sanitizer): Rename to ... + (check_effective_target_fsanitize_thread): ... this. Change to creating + an executable. + (tsan_init): Save off ALWAYS_CXXFLAGS. + (tsan_finish): Restore ALWAYS_CXXFLAGS correctly. Set dg-do-what-default + to run as a default behaviour. + * gcc.dg/ubsan/ubsan.exp: Don't check the return value of ubsan_init. + Check check_effective_target_fsanitize_undefined before running the + tests. + * g++.dg/ubsan/ubsan.exp: Likewise. + * gcc.dg/asan/asan.exp: Don't check the return value of asan_init. + check_effective_target_fsanitize_address too early. + Check check_effective_target_fsanitize_address before running the tests. + * g++.dg/asan/asan.exp: Likewise. + * gcc.dg/tsan/tsan.exp: Don't check the return value of tsan_init. + check_effective_target_fsanitize_thread too early. + Check check_effective_target_fsanitize_thread before running the tests. + * g++.dg/tsan/tsan.exp: Likewise. + 2014-10-01 Segher Boessenkool * gcc.dg/combine-clobber.c: New. diff --git a/gcc/testsuite/g++.dg/asan/asan.exp b/gcc/testsuite/g++.dg/asan/asan.exp index 98ff59c1612..f51f87a0128 100644 --- a/gcc/testsuite/g++.dg/asan/asan.exp +++ b/gcc/testsuite/g++.dg/asan/asan.exp @@ -20,17 +20,13 @@ load_lib g++-dg.exp load_lib asan-dg.exp -if ![check_effective_target_faddress_sanitizer] { - return -} - # Initialize `dg'. dg-init -if [asan_init] { +asan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/asan/*.c]] "" "" - +if [check_effective_target_fsanitize_address] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/asan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/g++.dg/tsan/tsan.exp b/gcc/testsuite/g++.dg/tsan/tsan.exp index 37caeb90411..c7f97f6e80f 100644 --- a/gcc/testsuite/g++.dg/tsan/tsan.exp +++ b/gcc/testsuite/g++.dg/tsan/tsan.exp @@ -23,10 +23,6 @@ load_lib g++-dg.exp load_lib tsan-dg.exp load_lib torture-options.exp -if ![check_effective_target_fthread_sanitizer] { - return -} - # Initialize `dg'. dg-init torture-init @@ -34,11 +30,11 @@ set-torture-options [list \ { -O0 } \ { -O2 } ] -if [tsan_init] { +tsan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/tsan/*.c]] "" "" - +if [check_effective_target_fsanitize_thread] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/tsan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/g++.dg/ubsan/ubsan.exp b/gcc/testsuite/g++.dg/ubsan/ubsan.exp index 769855e2e50..a835c19893f 100644 --- a/gcc/testsuite/g++.dg/ubsan/ubsan.exp +++ b/gcc/testsuite/g++.dg/ubsan/ubsan.exp @@ -22,11 +22,11 @@ load_lib ubsan-dg.exp # Initialize `dg'. dg-init -if [ubsan_init] { +ubsan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/ubsan/*.c]] "" "" - +if [check_effective_target_fsanitize_undefined] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C $srcdir/c-c++-common/ubsan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/gcc.dg/asan/asan.exp b/gcc/testsuite/gcc.dg/asan/asan.exp index 69534c411ba..2e0d5921b0e 100644 --- a/gcc/testsuite/gcc.dg/asan/asan.exp +++ b/gcc/testsuite/gcc.dg/asan/asan.exp @@ -22,17 +22,13 @@ load_lib gcc-dg.exp load_lib asan-dg.exp -if ![check_effective_target_faddress_sanitizer] { - return -} - # Initialize `dg'. dg-init -if [asan_init] { +asan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/asan/*.c]] "" "" - +if [check_effective_target_fsanitize_address] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/asan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/gcc.dg/tsan/tsan.exp b/gcc/testsuite/gcc.dg/tsan/tsan.exp index 8fa29bd0bf0..1558c0f8e7b 100644 --- a/gcc/testsuite/gcc.dg/tsan/tsan.exp +++ b/gcc/testsuite/gcc.dg/tsan/tsan.exp @@ -23,10 +23,6 @@ load_lib gcc-dg.exp load_lib tsan-dg.exp load_lib torture-options.exp -if ![check_effective_target_fthread_sanitizer] { - return -} - # Initialize `dg'. dg-init torture-init @@ -34,11 +30,11 @@ set-torture-options [list \ { -O0 } \ { -O2 } ] -if [tsan_init] { +tsan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/tsan/*.c]] "" "" - +if [check_effective_target_fsanitize_thread] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/tsan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/gcc.dg/ubsan/ubsan.exp b/gcc/testsuite/gcc.dg/ubsan/ubsan.exp index 5518d558431..9fd102b3bc6 100644 --- a/gcc/testsuite/gcc.dg/ubsan/ubsan.exp +++ b/gcc/testsuite/gcc.dg/ubsan/ubsan.exp @@ -24,11 +24,11 @@ load_lib ubsan-dg.exp # Initialize `dg'. dg-init -if [ubsan_init] { +ubsan_init # Main loop. -gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/ubsan/*.c]] "" "" - +if [check_effective_target_fsanitize_undefined] { + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c $srcdir/c-c++-common/ubsan/*.c]] "" "" } # All done. diff --git a/gcc/testsuite/lib/asan-dg.exp b/gcc/testsuite/lib/asan-dg.exp index 7a12160bb19..9769138d77d 100644 --- a/gcc/testsuite/lib/asan-dg.exp +++ b/gcc/testsuite/lib/asan-dg.exp @@ -17,9 +17,9 @@ # Return 1 if compilation with -fsanitize=address is error-free for trivial # code, 0 otherwise. -proc check_effective_target_faddress_sanitizer {} { - return [check_no_compiler_messages faddress_sanitizer object { - void foo (void) { } +proc check_effective_target_fsanitize_address {} { + return [check_no_compiler_messages fsanitize_address executable { + int main (void) { return 0; } } "-fsanitize=address"] } @@ -85,6 +85,7 @@ proc asan_init { args } { global ALWAYS_CXXFLAGS global TOOL_OPTIONS global asan_saved_TEST_ALWAYS_FLAGS + global asan_saved_ALWAYS_CXXFLAGS set link_flags "" if ![is_remote host] { @@ -101,6 +102,7 @@ proc asan_init { args } { set asan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS } if [info exists ALWAYS_CXXFLAGS] { + set asan_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS] set ALWAYS_CXXFLAGS [concat "{additional_flags=-fsanitize=address -g $include_flags}" $ALWAYS_CXXFLAGS] } else { @@ -110,10 +112,6 @@ proc asan_init { args } { set TEST_ALWAYS_FLAGS "$link_flags -fsanitize=address -g $include_flags" } } - if { $link_flags != "" } { - return 1 - } - return 0 } # @@ -123,12 +121,18 @@ proc asan_init { args } { proc asan_finish { args } { global TEST_ALWAYS_FLAGS global asan_saved_TEST_ALWAYS_FLAGS + global asan_saved_ALWAYS_CXXFLAGS - if [info exists asan_saved_TEST_ALWAYS_FLAGS] { - set TEST_ALWAYS_FLAGS $asan_saved_TEST_ALWAYS_FLAGS + if [info exists asan_saved_ALWAYS_CXXFLAGS ] { + set ALWAYS_CXXFLAGS $asan_saved_ALWAYS_CXXFLAGS } else { - unset TEST_ALWAYS_FLAGS + if [info exists asan_saved_TEST_ALWAYS_FLAGS] { + set TEST_ALWAYS_FLAGS $asan_saved_TEST_ALWAYS_FLAGS + } else { + unset TEST_ALWAYS_FLAGS + } } + restore_ld_library_path_env_vars } # Symbolize lines like diff --git a/gcc/testsuite/lib/tsan-dg.exp b/gcc/testsuite/lib/tsan-dg.exp index f313123aaaa..54ec4047c6b 100644 --- a/gcc/testsuite/lib/tsan-dg.exp +++ b/gcc/testsuite/lib/tsan-dg.exp @@ -17,9 +17,9 @@ # Return 1 if compilation with -fsanitize=thread is error-free for trivial # code, 0 otherwise. -proc check_effective_target_fthread_sanitizer {} { - return [check_no_compiler_messages faddress_sanitizer object { - void foo (void) { } +proc check_effective_target_fsanitize_thread {} { + return [check_no_compiler_messages fanitize_thread executable { + int main (void) { return 0; } } "-fPIE -pie -fsanitize=thread"] } @@ -69,6 +69,7 @@ proc tsan_init { args } { global ALWAYS_CXXFLAGS global TOOL_OPTIONS global tsan_saved_TEST_ALWAYS_FLAGS + global tsan_saved_ALWAYS_CXXFLAGS global dg-do-what-default global tsan_saved_dg-do-what-default @@ -88,6 +89,7 @@ proc tsan_init { args } { set tsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS } if [info exists ALWAYS_CXXFLAGS] { + set tsan_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS] set ALWAYS_CXXFLAGS [concat "{additional_flags=-fPIE -pie -fsanitize=thread -g}" $ALWAYS_CXXFLAGS] } else { @@ -97,6 +99,8 @@ proc tsan_init { args } { set TEST_ALWAYS_FLAGS "$link_flags -fPIE -pie -fsanitize=thread -g" } } + + set dg-do-what-default run if { $link_flags != "" } { global individual_timeout @@ -110,9 +114,7 @@ proc tsan_init { args } { set dg-do-what-default compile } unset individual_timeout - return 1 } - return 0 } # @@ -122,17 +124,24 @@ proc tsan_init { args } { proc tsan_finish { args } { global TEST_ALWAYS_FLAGS global tsan_saved_TEST_ALWAYS_FLAGS + global tsan_saved_ALWAYS_CXXFLAGS global dg-do-what-default global tsan_saved_dg-do-what-default - if [info exists tsan_saved_TEST_ALWAYS_FLAGS] { - set TEST_ALWAYS_FLAGS $tsan_saved_TEST_ALWAYS_FLAGS + if [info exists tsan_saved_ALWAYS_CXXFLAGS ] { + set ALWAYS_CXXFLAGS $tsan_saved_ALWAYS_CXXFLAGS } else { - unset TEST_ALWAYS_FLAGS + if [info exists tsan_saved_TEST_ALWAYS_FLAGS] { + set TEST_ALWAYS_FLAGS $tsan_saved_TEST_ALWAYS_FLAGS + } else { + unset TEST_ALWAYS_FLAGS + } } + if [info exists tsan_saved_dg-do-what-default] { set dg-do-what-default ${tsan_saved_dg-do-what-default} } else { unset dg-do-what-default } + restore_ld_library_path_env_vars } diff --git a/gcc/testsuite/lib/ubsan-dg.exp b/gcc/testsuite/lib/ubsan-dg.exp index fecce7bf00f..5a7a6534cad 100644 --- a/gcc/testsuite/lib/ubsan-dg.exp +++ b/gcc/testsuite/lib/ubsan-dg.exp @@ -14,6 +14,15 @@ # along with GCC; see the file COPYING3. If not see # . +# Return 1 if compilation with -fsanitize=undefined is error-free for trivial +# code, 0 otherwise. + +proc check_effective_target_fsanitize_undefined {} { + return [check_no_compiler_messages fsanitize_undefined executable { + int main (void) { return 0; } + } "-fsanitize=undefined"] +} + # # ubsan_link_flags -- compute library path and flags to find libubsan. # (originally from g++.exp) @@ -61,6 +70,7 @@ proc ubsan_init { args } { global ALWAYS_CXXFLAGS global TOOL_OPTIONS global ubsan_saved_TEST_ALWAYS_FLAGS + global ubsan_saved_ALWAYS_CXXFLAGS set link_flags "" if ![is_remote host] { @@ -75,6 +85,7 @@ proc ubsan_init { args } { set ubsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS } if [info exists ALWAYS_CXXFLAGS] { + set ubsan_saved_ALWAYS_CXXFLAGS $ALWAYS_CXXFLAGS set ALWAYS_CXXFLAGS [concat "{ldflags=$link_flags}" $ALWAYS_CXXFLAGS] } else { if [info exists TEST_ALWAYS_FLAGS] { @@ -83,10 +94,6 @@ proc ubsan_init { args } { set TEST_ALWAYS_FLAGS "$link_flags" } } - if { $link_flags != "" } { - return 1 - } - return 0 } # @@ -96,10 +103,16 @@ proc ubsan_init { args } { proc ubsan_finish { args } { global TEST_ALWAYS_FLAGS global ubsan_saved_TEST_ALWAYS_FLAGS + global ubsan_saved_ALWAYS_CXXFLAGS - if [info exists ubsan_saved_TEST_ALWAYS_FLAGS] { - set TEST_ALWAYS_FLAGS $ubsan_saved_TEST_ALWAYS_FLAGS + if [info exists ubsan_saved_ALWAYS_CXXFLAGS ] { + set ALWAYS_CXXFLAGS $ubsan_saved_ALWAYS_CXXFLAGS } else { - unset TEST_ALWAYS_FLAGS + if [info exists ubsan_saved_TEST_ALWAYS_FLAGS] { + set TEST_ALWAYS_FLAGS $ubsan_saved_TEST_ALWAYS_FLAGS + } else { + unset TEST_ALWAYS_FLAGS + } } + restore_ld_library_path_env_vars }