[TSan] Port check_memcpy.sh script to a regular lit test.

Check that TSan runtime doesn't contain compiler-inserted calls
to memset/memmove functions.

In future, we may consider moving this test to test/sanitizer_common,
as we don't want to have compiler-inserted memcpy/memmove calls in
any sanitizer runtime.

llvm-svn: 254955
This commit is contained in:
Alexey Samsonov 2015-12-07 21:53:59 +00:00
parent 4b5634af44
commit dc37ee2226
4 changed files with 37 additions and 33 deletions

View File

@ -71,14 +71,12 @@ presubmit:
# Release build with clang.
$(MAKE) -f Makefile.old clean
$(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=$(CLANG) CXX=$(CLANG)++
./check_memcpy.sh
# Debug build with gcc
$(MAKE) -f Makefile.old clean
$(MAKE) -f Makefile.old run DEBUG=1 -j 16 CC=gcc CXX=g++
# Release build with gcc
$(MAKE) -f Makefile.old clean
$(MAKE) -f Makefile.old run DEBUG=0 -j 16 CC=gcc CXX=g++
./check_memcpy.sh
# Sanity check for Go runtime
(cd go && ./buildgo.sh)
# Check cmake build

View File

@ -1,31 +0,0 @@
#!/bin/bash
# Ensure that tsan runtime does not contain compiler-emitted memcpy and memset calls.
set -eu
ROOTDIR=$(dirname $0)
TEST_DIR=$ROOTDIR/../../test/tsan
: ${CXX:=clang++}
CFLAGS="-fsanitize=thread -fPIE -O1 -g"
LDFLAGS="-pie -lpthread -ldl -lrt -lm -Wl,--whole-archive $ROOTDIR/rtl/libtsan.a -Wl,--no-whole-archive"
SRC=$TEST_DIR/simple_race.cc
OBJ=$SRC.o
EXE=$SRC.exe
$CXX $SRC $CFLAGS -c -o $OBJ
$CXX $OBJ $LDFLAGS -o $EXE
NCALL=$(objdump -d $EXE | egrep "callq .*<__interceptor_mem(cpy|set)>" | wc -l)
if [ "$NCALL" != "0" ]; then
echo FAIL: found $NCALL memcpy/memset calls
exit 1
fi
# tail calls
NCALL=$(objdump -d $EXE | egrep "jmpq .*<__interceptor_mem(cpy|set)>" | wc -l)
if [ "$NCALL" != "0" ]; then
echo FAIL: found $NCALL memcpy/memset calls
exit 1
fi

View File

@ -0,0 +1,11 @@
// Test that verifies TSan runtime doesn't contain compiler-emitted
// memcpy/memmove calls. It builds the binary with TSan and passes it to
// check_memcpy.sh script.
// RUN: %clangxx_tsan -O1 %s -o %t
// RUN: %S/check_memcpy.sh %t
int main() {
return 0;
}

View File

@ -0,0 +1,26 @@
#!/bin/bash
# Script that ensures that TSan runtime does not contain compiler-emitted
# memcpy and memset calls.
set -eu
if [[ "$#" != 1 ]]; then
echo "Usage: $0 /path/to/binary/built/with/tsan"
exit 1
fi
EXE=$1
NCALL=$(objdump -d $EXE | egrep "callq .*<__interceptor_mem(cpy|set)>" | wc -l)
if [ "$NCALL" != "0" ]; then
echo FAIL: found $NCALL memcpy/memset calls
exit 1
fi
# tail calls
NCALL=$(objdump -d $EXE | egrep "jmpq .*<__interceptor_mem(cpy|set)>" | wc -l)
if [ "$NCALL" != "0" ]; then
echo FAIL: found $NCALL memcpy/memset calls
exit 1
fi