Page MenuHomePhabricator

Tread TSan LLVM flags to driver: unit tests.
ClosedPublic

Authored by alekseyshl on Nov 9 2016, 9:55 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

alekseyshl updated this revision to Diff 77368.Nov 9 2016, 9:55 AM
alekseyshl retitled this revision from to Tread TSan LLVM flags to driver: unit tests..
alekseyshl updated this object.
alekseyshl added a reviewer: eugenis.
alekseyshl added a subscriber: llvm-commits.
kubamracek added inline comments.Nov 9 2016, 10:01 AM
test/tsan/atomic_free.cc
1–2 ↗(On Diff #77368)

Why not just use a pipe instead of writing to %t.out? If you're doing this only to maintain 80-column width, then you can split a line using a backslash:

// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t 2>&1 \
// RUN:   | FileCheck %s

Anyway, I think RUN commands are allowed to be longer that 80 columns (but others probably disagree), there's a lot of tests already doing that.

alekseyshl updated this revision to Diff 77397.Nov 9 2016, 2:54 PM
  • Use pipe instead of a temp file as FileCheck input.
alekseyshl marked an inline comment as done.Nov 9 2016, 2:55 PM

Comments addressed.

dvyukov accepted this revision.Nov 9 2016, 3:01 PM
dvyukov edited edge metadata.
This revision is now accepted and ready to land.Nov 9 2016, 3:01 PM
alekseyshl updated this revision to Diff 77434.Nov 9 2016, 6:07 PM
alekseyshl edited edge metadata.
  • Flags renamed.
This revision was automatically updated to reflect the committed changes.
seurer added a subscriber: seurer.Nov 14 2016, 9:35 AM

This revision causes failures on power for both BE and LE:

FAIL: ThreadSanitizer-powerpc64le :: simple_stack.c (237 of 339)

  • TEST 'ThreadSanitizer-powerpc64le :: simple_stack.c' FAILED ****

Script:

/home/seurer/llvm/build/llvm-test2/./bin/clang -fsanitize=thread -Wall -m64 -gline-tables-only -O1 /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c -o /home/seurer/llvm/build/llvm-test2/projects/compiler-rt/test/tsan/POWERPC64LEConfig/Output/simple_stack.c.tmp && /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/deflake.bash /home/seurer/llvm/build/llvm-test2/projects/compiler-rt/test/tsan/POWERPC64LEConfig/Output/simple_stack.c.tmp 2>&1 | FileCheck /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c
/home/seurer/llvm/build/llvm-test2/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -gline-tables-only -std=c++11 -O1 /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c -o /home/seurer/llvm/build/llvm-test2/projects/compiler-rt/test/tsan/POWERPC64LEConfig/Output/simple_stack.c.tmp -fno-sanitize-thread-func-entry-exit && /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/deflake.bash /home/seurer/llvm/build/llvm-test2/projects/compiler-rt/test/tsan/POWERPC64LEConfig/Output/simple_stack.c.tmp 2>&1 | FileCheck --check-prefix=CHECK-FUNC-ENTRY-EXIT-OFF /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c

/home/seurer/llvm/build/llvm-test2/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -gline-tables-only -std=c++11 -O1 /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c -o /home/seurer/llvm/build/llvm-test2/projects/compiler-rt/test/tsan/POWERPC64LEConfig/Output/simple_stack.c.tmp -mllvm -tsan-instrument-func-entry-exit=0 && /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/deflake.bash /home/seurer/llvm/build/llvm-test2/projects/compiler-rt/test/tsan/POWERPC64LEConfig/Output/simple_stack.c.tmp 2>&1 | FileCheck --check-prefix=CHECK-FUNC-ENTRY-EXIT-OFF /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c

Exit Code: 1

Command Output (stderr):

clang-4.0: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
/home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c:84:36: error: expected string not found in input
// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT: #1 main{{.*}} {{.*}}simple_stack.c:42{{(:3)?}} ({{.*}})

^

<stdin>:13:2: note: scanning from here
#1 StartThread(unsigned long*, void* (*)(void*)) /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c:36:3 (simple_stack.c.tmp+0x0000100e79c8)
^
<stdin>:19:90: note: possible intended match here
SUMMARY: ThreadSanitizer: data race /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c:6:10 in foo1()

         ^

In the new sets of tests the output being looked for is wrong.

Actual output:

Thread T1 (tid=131029, running) created by main thread at:
  #0 pthread_create /home/seurer/llvm/llvm-test2/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (simple_stack.test2+0x00001005a3f0)
  #1 StartThread(unsigned long*, void* (*)(void*)) /home/seurer/llvm/llvm-test2/projects/compiler-rt/test/tsan/simple_stack.c:36 (simple_stack.test2+0x0000100e79c8)

What is being looked for:
CHECK-FUNC-ENTRY-EXIT-OFF: Thread T1 (tid={{.*}}, running) created by main thread at:
CHECK-FUNC-ENTRY-EXIT-OFF-NEXT: #0 pthread_create {{.*}} ({{.*}})
// CHECK-FUNC-ENTRY-EXIT-OFF-NEXT: #1 main{{.*}} {{.*}}simple_stack.c:42{{(:3)?}} ({{.*}})

Note the actual output has "StartThread" as the #1 function while "main" is being looked for.

This is true for the test for Thread T2 as well.

I'll look into that (meanwhile D26629 should make this test pass).

Apparently, on other platforms it look like this (from my local run on x86):

Thread T1 (tid=113512, running) created by main thread at:
  #0 pthread_create /usr/local/google/home/alekseys/llvm-dev/llvm/projects/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc:902 (simple_stack.c.tmp+0x00000043ea75)
  #1 main /usr/local/google/home/alekseys/llvm-dev/llvm/projects/compiler-rt/test/tsan/simple_stack.c:42 (simple_stack.c.tmp+0x00000049d75b)