gcc/testsuite/
authorAndrew Pinski <apinski@cavium.com>
Thu, 2 Oct 2014 06:35:49 +0000 (06:35 +0000)
committerMaxim Ostapenko <chefmax@gcc.gnu.org>
Thu, 2 Oct 2014 06:35:49 +0000 (09:35 +0300)
2014-10-01  Andrew Pinski  <apinski@cavium.com>
            Max Ostapenko  <m.ostapenko@partner.samsung.com>

* 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 <m.ostapenko@partner.samsung.com>
From-SVN: r215793

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/asan/asan.exp
gcc/testsuite/g++.dg/tsan/tsan.exp
gcc/testsuite/g++.dg/ubsan/ubsan.exp
gcc/testsuite/gcc.dg/asan/asan.exp
gcc/testsuite/gcc.dg/tsan/tsan.exp
gcc/testsuite/gcc.dg/ubsan/ubsan.exp
gcc/testsuite/lib/asan-dg.exp
gcc/testsuite/lib/tsan-dg.exp
gcc/testsuite/lib/ubsan-dg.exp

index 0cf36a08329ed69d2f537680042f2031929bed02..b11b45aace7de34e4b5cb082b53e71cf084a6630 100644 (file)
@@ -1,3 +1,36 @@
+2014-10-02  Andrew Pinski  <apinski@cavium.com>
+           Max Ostapenko  <m.ostapenko@partner.samsung.com>
+
+       * 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  <segher@kernel.crashing.org>
 
        * gcc.dg/combine-clobber.c: New.
index 98ff59c16123527c260e4c169c2d5bde3f86b2c0..f51f87a01283f13ae3291593625f3b4a49e2edc9 100644 (file)
 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.
index 37caeb904115208e975038b11f97e156fb706a73..c7f97f6e80f9c4c35871acfb26bf909e60678bd3 100644 (file)
@@ -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.
index 769855e2e50874d7acb5d1e3e754a88efd5f0fca..a835c19893f61bb4c33a1cb4c41acc8929feb16c 100644 (file)
@@ -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.
index 69534c411ba49e4904dbbcac2eb2c007a57e490c..2e0d5921b0e6b299606863a1ebf4fd14b3300671 100644 (file)
 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.
index 8fa29bd0bf0384e01ea20f43b930ac58b44d89d0..1558c0f8e7b7c097acc0f2b9a2c8fc2f67369243 100644 (file)
@@ -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.
index 5518d55843121dfb361e876e57c8c2e700d93e76..9fd102b3bc6e4a07c69e5b7ee5b9556560315cfb 100644 (file)
@@ -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.
index 7a12160bb19cf4a68b1107619f8f76046bd78b79..9769138d77de27f1bf0cbb39b32a4c7e0c93a984 100644 (file)
@@ -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
index f313123aaaa4a55fb479cf3df67b7137d12e3b10..54ec4047c6b26064289166dcab79b4840c92abcd 100644 (file)
@@ -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
 }
index fecce7bf00f6de64b15484bd22d79ff2f1f797f8..5a7a6534cad88b6ec36fead5f0dc0b94ff3cdd22 100644 (file)
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
+# 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
 }