[compiler-rt] r213642 - [ASan] Split throw_catch tests into two files: throw/catch + longjmp
Timur Iskhodzhanov
timurrrr at google.com
Tue Jul 22 04:46:25 PDT 2014
Author: timurrrr
Date: Tue Jul 22 06:46:24 2014
New Revision: 213642
URL: http://llvm.org/viewvc/llvm-project?rev=213642&view=rev
Log:
[ASan] Split throw_catch tests into two files: throw/catch + longjmp
Also add some more assertions into these tests
Added:
compiler-rt/trunk/test/asan/TestCases/longjmp.cc
- copied, changed from r213640, compiler-rt/trunk/test/asan/TestCases/throw_catch.cc
Modified:
compiler-rt/trunk/test/asan/TestCases/throw_catch.cc
Copied: compiler-rt/trunk/test/asan/TestCases/longjmp.cc (from r213640, compiler-rt/trunk/test/asan/TestCases/throw_catch.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/longjmp.cc?p2=compiler-rt/trunk/test/asan/TestCases/longjmp.cc&p1=compiler-rt/trunk/test/asan/TestCases/throw_catch.cc&r1=213640&r2=213642&rev=213642&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/throw_catch.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/longjmp.cc Tue Jul 22 06:46:24 2014
@@ -1,8 +1,5 @@
// RUN: %clangxx_asan -O %s -o %t && %run %t
-// Clang doesn't support exceptions on Windows yet.
-// XFAIL: win32
-
#include <assert.h>
#include <setjmp.h>
#include <stdlib.h>
@@ -10,51 +7,6 @@
#include <string.h>
#include <sanitizer/asan_interface.h>
-__attribute__((noinline))
-void Throw() {
- int local;
- fprintf(stderr, "Throw: %p\n", &local);
- throw 1;
-}
-
-__attribute__((noinline))
-void ThrowAndCatch() {
- int local;
- try {
- Throw();
- } catch(...) {
- fprintf(stderr, "Catch: %p\n", &local);
- }
-}
-
-void TestThrow() {
- char x[32];
- fprintf(stderr, "Before: %p poisoned: %d\n", &x,
- __asan_address_is_poisoned(x + 32));
- ThrowAndCatch();
- 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));
-}
-
-void TestThrowInline() {
- char x[32];
- fprintf(stderr, "Before: %p poisoned: %d\n", &x,
- __asan_address_is_poisoned(x + 32));
- try {
- Throw();
- } catch(...) {
- fprintf(stderr, "Catch\n");
- }
- 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));
-}
-
static jmp_buf buf;
void TestLongJmp() {
@@ -62,6 +14,7 @@ void TestLongJmp() {
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,
@@ -72,7 +25,5 @@ void TestLongJmp() {
}
int main(int argc, char **argv) {
- TestThrow();
- TestThrowInline();
TestLongJmp();
}
Modified: compiler-rt/trunk/test/asan/TestCases/throw_catch.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/throw_catch.cc?rev=213642&r1=213641&r2=213642&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/throw_catch.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/throw_catch.cc Tue Jul 22 06:46:24 2014
@@ -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();
}
More information about the llvm-commits
mailing list