[PATCH] Don't run tsan tests if a trivial test doesn't work

2014-01-31 Thread Jakub Jelinek
Hi!

Apparently tsan doesn't work e.g. under setarch x86_64 -R, at which point
all tests fail.  This patch just disables the tests in that case.

Tested on x86_64-linux both under setarch x86_64 -R and without, committed
to trunk as obvious.

Of course it would be nicer if libtsan actually supported that (and didn't
rely on PIEs etc.), but I don't see that as a priority for upstream :(.

2014-01-31  Jakub Jelinek  ja...@redhat.com

* lib/tsan-dg.exp (tsan_init): Try to run a trivial program,
if it fails don't run any tsan tests.

--- gcc/testsuite/lib/tsan-dg.exp.jj2014-01-03 11:40:40.0 +0100
+++ gcc/testsuite/lib/tsan-dg.exp   2014-01-31 12:15:06.659406282 +0100
@@ -93,7 +93,11 @@ proc tsan_init { args } {
}
 }
 if { $link_flags !=  } {
-   return 1
+   if [check_runtime_nocache tsan_works {
+   int main () { return 0; }
+   } -fPIE -pie -fsanitize=thread -g] {
+   return 1
+   }
 }
 return 0
 }

Jakub


Re: [PATCH] Don't run tsan tests if a trivial test doesn't work

2014-01-31 Thread Jakub Jelinek
On Fri, Jan 31, 2014 at 12:34:46PM +0100, Jakub Jelinek wrote:
 Apparently tsan doesn't work e.g. under setarch x86_64 -R, at which point
 all tests fail.  This patch just disables the tests in that case.
 
 Tested on x86_64-linux both under setarch x86_64 -R and without, committed
 to trunk as obvious.
 
 Of course it would be nicer if libtsan actually supported that (and didn't
 rely on PIEs etc.), but I don't see that as a priority for upstream :(.
 
 2014-01-31  Jakub Jelinek  ja...@redhat.com
 
   * lib/tsan-dg.exp (tsan_init): Try to run a trivial program,
   if it fails don't run any tsan tests.

As discussed on IRC, some people would like to have tsan tests at least
as compile tests if they can't be reliably executed.

So, this patch implements that by tweaking dg-do-what default.

Ok for trunk?

2014-01-31  Jakub Jelinek  ja...@redhat.com

PR sanitizer/59410
* lib/tsan-dg.exp (tsan_init): Instead of not running any
tsan tests if trivial testcase doesn't run, set dg-do-what-default
to compile.
(tsan_finish): Restore dg-do-what-default.
* g++.dg/tsan/atomic_free.C: Remove dg-do line.
* g++.dg/tsan/fd_close_norace2.C: Likewise.
* g++.dg/tsan/default_options.C: Likewise.
* g++.dg/tsan/aligned_vs_unaligned_race.C: Likewise.
* g++.dg/tsan/atomic_free2.C: Likewise.
* g++.dg/tsan/cond_race.C: Likewise.
* g++.dg/tsan/fd_close_norace.C: Likewise.
* g++.dg/tsan/benign_race.C: Likewise.
* c-c++-common/tsan/fd_pipe_race.c: Likewise.
* c-c++-common/tsan/simple_race.c: Likewise.
* c-c++-common/tsan/mutexset1.c: Likewise.
* c-c++-common/tsan/thread_leak2.c: Likewise.
* c-c++-common/tsan/tls_race.c: Likewise.
* c-c++-common/tsan/write_in_reader_lock.c: Likewise.
* c-c++-common/tsan/race_on_barrier2.c: Likewise.
* c-c++-common/tsan/free_race2.c: Likewise.
* c-c++-common/tsan/thread_leak.c: Likewise.
* c-c++-common/tsan/thread_leak1.c: Likewise.
* c-c++-common/tsan/race_on_barrier.c: Likewise.
* c-c++-common/tsan/free_race.c: Likewise.
* c-c++-common/tsan/sleep_sync.c: Likewise.
* c-c++-common/tsan/tiny_race.c: Likewise.
* c-c++-common/tsan/race_on_mutex2.c: Likewise.
* c-c++-common/tsan/atomic_stack.c: Likewise.
* c-c++-common/tsan/race_on_mutex.c: Likewise.  Adjust line numbers
in dg-output regexps.
* c-c++-common/tsan/simple_stack.c: Likewise.

--- gcc/testsuite/lib/tsan-dg.exp.jj2014-01-31 12:30:09.0 +0100
+++ gcc/testsuite/lib/tsan-dg.exp   2014-01-31 13:21:26.350586160 +0100
@@ -69,6 +69,8 @@ proc tsan_init { args } {
 global ALWAYS_CXXFLAGS
 global TOOL_OPTIONS
 global tsan_saved_TEST_ALWAYS_FLAGS
+global dg-do-what-default
+global tsan_saved_dg-do-what-default
 
 set link_flags 
 if ![is_remote host] {
@@ -79,6 +81,9 @@ proc tsan_init { args } {
}
 }
 
+if [info exists dg-do-what-default] {
+   set tsan_saved-dg-do-what-default dg-do-what-default
+}
 if [info exists TEST_ALWAYS_FLAGS] {
set tsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
 }
@@ -96,8 +101,11 @@ proc tsan_init { args } {
if [check_runtime_nocache tsan_works {
int main () { return 0; }
} -fPIE -pie -fsanitize=thread -g] {
-   return 1
+   set dg-do-what-default run
+   } else {
+   set dg-do-what-default compile
}
+   return 1
 }
 return 0
 }
@@ -109,10 +117,17 @@ proc tsan_init { args } {
 proc tsan_finish { args } {
 global TEST_ALWAYS_FLAGS
 global tsan_saved_TEST_ALWAYS_FLAGS
+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
 } 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
+}
 }
--- gcc/testsuite/g++.dg/tsan/atomic_free.C.jj  2013-12-12 14:28:31.0 
+0100
+++ gcc/testsuite/g++.dg/tsan/atomic_free.C 2014-01-31 13:15:25.110473518 
+0100
@@ -1,4 +1,3 @@
-/* { dg-do run } */
 /* { dg-shouldfail tsan } */
 
 #include pthread.h
--- gcc/testsuite/g++.dg/tsan/fd_close_norace2.C.jj 2013-12-12 
14:28:31.0 +0100
+++ gcc/testsuite/g++.dg/tsan/fd_close_norace2.C2014-01-31 
13:15:30.882443238 +0100
@@ -1,5 +1,3 @@
-/* { dg-do run } */
-
 #include pthread.h
 #include stdio.h
 #include unistd.h
--- gcc/testsuite/g++.dg/tsan/default_options.C.jj  2013-12-12 
14:28:31.0 +0100
+++ gcc/testsuite/g++.dg/tsan/default_options.C 2014-01-31 13:15:29.373451426 
+0100
@@ -1,4 +1,3 @@
-/* { dg-do run } */
 /* { dg-shouldfail tsan } */
 
 #include pthread.h
--- 

Re: [PATCH] Don't run tsan tests if a trivial test doesn't work

2014-01-31 Thread Richard Biener
On Fri, 31 Jan 2014, Jakub Jelinek wrote:

 On Fri, Jan 31, 2014 at 12:34:46PM +0100, Jakub Jelinek wrote:
  Apparently tsan doesn't work e.g. under setarch x86_64 -R, at which point
  all tests fail.  This patch just disables the tests in that case.
  
  Tested on x86_64-linux both under setarch x86_64 -R and without, committed
  to trunk as obvious.
  
  Of course it would be nicer if libtsan actually supported that (and didn't
  rely on PIEs etc.), but I don't see that as a priority for upstream :(.
  
  2014-01-31  Jakub Jelinek  ja...@redhat.com
  
  * lib/tsan-dg.exp (tsan_init): Try to run a trivial program,
  if it fails don't run any tsan tests.
 
 As discussed on IRC, some people would like to have tsan tests at least
 as compile tests if they can't be reliably executed.
 
 So, this patch implements that by tweaking dg-do-what default.
 
 Ok for trunk?

Ok (you remove one target selector - was that spurious)

Thanks,
Richard.

 2014-01-31  Jakub Jelinek  ja...@redhat.com
 
   PR sanitizer/59410
   * lib/tsan-dg.exp (tsan_init): Instead of not running any
   tsan tests if trivial testcase doesn't run, set dg-do-what-default
   to compile.
   (tsan_finish): Restore dg-do-what-default.
   * g++.dg/tsan/atomic_free.C: Remove dg-do line.
   * g++.dg/tsan/fd_close_norace2.C: Likewise.
   * g++.dg/tsan/default_options.C: Likewise.
   * g++.dg/tsan/aligned_vs_unaligned_race.C: Likewise.
   * g++.dg/tsan/atomic_free2.C: Likewise.
   * g++.dg/tsan/cond_race.C: Likewise.
   * g++.dg/tsan/fd_close_norace.C: Likewise.
   * g++.dg/tsan/benign_race.C: Likewise.
   * c-c++-common/tsan/fd_pipe_race.c: Likewise.
   * c-c++-common/tsan/simple_race.c: Likewise.
   * c-c++-common/tsan/mutexset1.c: Likewise.
   * c-c++-common/tsan/thread_leak2.c: Likewise.
   * c-c++-common/tsan/tls_race.c: Likewise.
   * c-c++-common/tsan/write_in_reader_lock.c: Likewise.
   * c-c++-common/tsan/race_on_barrier2.c: Likewise.
   * c-c++-common/tsan/free_race2.c: Likewise.
   * c-c++-common/tsan/thread_leak.c: Likewise.
   * c-c++-common/tsan/thread_leak1.c: Likewise.
   * c-c++-common/tsan/race_on_barrier.c: Likewise.
   * c-c++-common/tsan/free_race.c: Likewise.
   * c-c++-common/tsan/sleep_sync.c: Likewise.
   * c-c++-common/tsan/tiny_race.c: Likewise.
   * c-c++-common/tsan/race_on_mutex2.c: Likewise.
   * c-c++-common/tsan/atomic_stack.c: Likewise.
   * c-c++-common/tsan/race_on_mutex.c: Likewise.  Adjust line numbers
   in dg-output regexps.
   * c-c++-common/tsan/simple_stack.c: Likewise.
 
 --- gcc/testsuite/lib/tsan-dg.exp.jj  2014-01-31 12:30:09.0 +0100
 +++ gcc/testsuite/lib/tsan-dg.exp 2014-01-31 13:21:26.350586160 +0100
 @@ -69,6 +69,8 @@ proc tsan_init { args } {
  global ALWAYS_CXXFLAGS
  global TOOL_OPTIONS
  global tsan_saved_TEST_ALWAYS_FLAGS
 +global dg-do-what-default
 +global tsan_saved_dg-do-what-default
  
  set link_flags 
  if ![is_remote host] {
 @@ -79,6 +81,9 @@ proc tsan_init { args } {
   }
  }
  
 +if [info exists dg-do-what-default] {
 + set tsan_saved-dg-do-what-default dg-do-what-default
 +}
  if [info exists TEST_ALWAYS_FLAGS] {
   set tsan_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS
  }
 @@ -96,8 +101,11 @@ proc tsan_init { args } {
   if [check_runtime_nocache tsan_works {
   int main () { return 0; }
   } -fPIE -pie -fsanitize=thread -g] {
 - return 1
 + set dg-do-what-default run
 + } else {
 + set dg-do-what-default compile
   }
 + return 1
  }
  return 0
  }
 @@ -109,10 +117,17 @@ proc tsan_init { args } {
  proc tsan_finish { args } {
  global TEST_ALWAYS_FLAGS
  global tsan_saved_TEST_ALWAYS_FLAGS
 +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
  } 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
 +}
  }
 --- gcc/testsuite/g++.dg/tsan/atomic_free.C.jj2013-12-12 
 14:28:31.0 +0100
 +++ gcc/testsuite/g++.dg/tsan/atomic_free.C   2014-01-31 13:15:25.110473518 
 +0100
 @@ -1,4 +1,3 @@
 -/* { dg-do run } */
  /* { dg-shouldfail tsan } */
  
  #include pthread.h
 --- gcc/testsuite/g++.dg/tsan/fd_close_norace2.C.jj   2013-12-12 
 14:28:31.0 +0100
 +++ gcc/testsuite/g++.dg/tsan/fd_close_norace2.C  2014-01-31 
 13:15:30.882443238 +0100
 @@ -1,5 +1,3 @@
 -/* { dg-do run } */
 -
  #include pthread.h
  #include stdio.h
  #include unistd.h
 --- gcc/testsuite/g++.dg/tsan/default_options.C.jj2013-12-12 
 14:28:31.0 +0100
 +++ gcc/testsuite/g++.dg/tsan/default_options.C   2014-01-31 
 

Re: [PATCH] Don't run tsan tests if a trivial test doesn't work

2014-01-31 Thread Jakub Jelinek
On Fri, Jan 31, 2014 at 02:57:14PM +0100, Richard Biener wrote:
 Ok (you remove one target selector - was that spurious)

Yes, tsan is supported on x86_64-linux only anyway, so tsan_init
fails everywhere else.

Jakub