From 723c81ff804e843aafb75385e47c8407ab60ce41 Mon Sep 17 00:00:00 2001 From: Timur Iskhodzhanov Date: Tue, 22 Jul 2014 11:46:24 +0000 Subject: [PATCH] [ASan] Split throw_catch tests into two files: throw/catch + longjmp Also add some more assertions into these tests llvm-svn: 213642 --- compiler-rt/test/asan/TestCases/longjmp.cc | 29 ++++++++++++++++++++++++++ compiler-rt/test/asan/TestCases/throw_catch.cc | 21 +++---------------- 2 files changed, 32 insertions(+), 18 deletions(-) create mode 100644 compiler-rt/test/asan/TestCases/longjmp.cc diff --git a/compiler-rt/test/asan/TestCases/longjmp.cc b/compiler-rt/test/asan/TestCases/longjmp.cc new file mode 100644 index 0000000..6a7ba72 --- /dev/null +++ b/compiler-rt/test/asan/TestCases/longjmp.cc @@ -0,0 +1,29 @@ +// RUN: %clangxx_asan -O %s -o %t && %run %t + +#include +#include +#include +#include +#include +#include + +static jmp_buf buf; + +void TestLongJmp() { + char x[32]; + fprintf(stderr, "\nTestLongJmp\n"); + fprintf(stderr, "Before: %p poisoned: %d\n", &x, + __asan_address_is_poisoned(x + 32)); + assert(__asan_address_is_poisoned(x + 32)); + if (0 == setjmp(buf)) + longjmp(buf, 1); + fprintf(stderr, "After: %p poisoned: %d\n", &x, + __asan_address_is_poisoned(x + 32)); + // FIXME: Invert this assertion once we fix + // https://code.google.com/p/address-sanitizer/issues/detail?id=258 + assert(!__asan_address_is_poisoned(x + 32)); +} + +int main(int argc, char **argv) { + TestLongJmp(); +} diff --git a/compiler-rt/test/asan/TestCases/throw_catch.cc b/compiler-rt/test/asan/TestCases/throw_catch.cc index f35378d..ad7abf7 100644 --- a/compiler-rt/test/asan/TestCases/throw_catch.cc +++ b/compiler-rt/test/asan/TestCases/throw_catch.cc @@ -31,6 +31,7 @@ void TestThrow() { char x[32]; fprintf(stderr, "Before: %p poisoned: %d\n", &x, __asan_address_is_poisoned(x + 32)); + assert(__asan_address_is_poisoned(x + 32)); ThrowAndCatch(); fprintf(stderr, "After: %p poisoned: %d\n", &x, __asan_address_is_poisoned(x + 32)); @@ -43,6 +44,7 @@ void TestThrowInline() { char x[32]; fprintf(stderr, "Before: %p poisoned: %d\n", &x, __asan_address_is_poisoned(x + 32)); + assert(__asan_address_is_poisoned(x + 32)); try { Throw(); } catch(...) { @@ -55,24 +57,7 @@ void TestThrowInline() { assert(!__asan_address_is_poisoned(x + 32)); } -static jmp_buf buf; - -void TestLongJmp() { - char x[32]; - fprintf(stderr, "\nTestLongJmp\n"); - fprintf(stderr, "Before: %p poisoned: %d\n", &x, - __asan_address_is_poisoned(x + 32)); - if (0 == setjmp(buf)) - longjmp(buf, 1); - fprintf(stderr, "After: %p poisoned: %d\n", &x, - __asan_address_is_poisoned(x + 32)); - // FIXME: Invert this assertion once we fix - // https://code.google.com/p/address-sanitizer/issues/detail?id=258 - assert(!__asan_address_is_poisoned(x + 32)); -} - int main(int argc, char **argv) { - TestThrow(); TestThrowInline(); - TestLongJmp(); + TestThrow(); } -- 2.7.4