mirror of
https://git.proxmox.com/git/llvm-toolchain
synced 2025-11-03 07:19:07 +00:00
add a tsan example
This commit is contained in:
parent
8bca9142e1
commit
66786d35c6
34
debian/qualify-clang.sh
vendored
34
debian/qualify-clang.sh
vendored
@ -510,6 +510,40 @@ int main(int argc, char **argv)
|
||||
clang-$VERSION -fsanitize=address foo.c -o foo -lc
|
||||
./foo &> /dev/null || true
|
||||
|
||||
echo '
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int Global;
|
||||
|
||||
void *Thread1(void *x) {
|
||||
Global++;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *Thread2(void *x) {
|
||||
Global--;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int main() {
|
||||
pthread_t t[2];
|
||||
pthread_create(&t[0], NULL, Thread1, NULL);
|
||||
pthread_create(&t[1], NULL, Thread2, NULL);
|
||||
pthread_join(t[0], NULL);
|
||||
pthread_join(t[1], NULL);
|
||||
} ' > foo.c
|
||||
|
||||
clang-$VERSION -o foo -fsanitize=thread -g -O1 foo.c
|
||||
if ! strings ./foo 2>&1 | grep -q "tsan"; then
|
||||
echo "binary doesn't contain tsan code"
|
||||
strings foo
|
||||
exit 42
|
||||
fi
|
||||
if ! ./foo 2>&1 | grep -q "data race"; then
|
||||
echo "sanitize=address is failing"
|
||||
exit 42
|
||||
fi
|
||||
|
||||
echo '
|
||||
class a {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user