summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2018-06-15 16:45:19 +0000
committerKostya Kortchinsky <kostyak@google.com>2018-06-15 16:45:19 +0000
commit4adf24502ec8c993e3da2fe0ad2f4921e5a76bb9 (patch)
treed67950f68ed4bb6455dcaf9a9041a235d274fadd /compiler-rt/test
parenta6edca72ba6962455ab427759b9380555db0d211 (diff)
downloadbcm5719-llvm-4adf24502ec8c993e3da2fe0ad2f4921e5a76bb9.tar.gz
bcm5719-llvm-4adf24502ec8c993e3da2fe0ad2f4921e5a76bb9.zip
[scudo] Add verbose failures in place of CHECK(0)
Summary: The current `FailureHandler` mechanism was fairly opaque with regard to the failure reason due to using `CHECK(0)`. Scudo is a bit different from the other Sanitizers as it prefers to avoid spurious processing in its failure path. So we just `dieWithMessage` using a somewhat explicit string. Adapted the tests for the new strings. While this takes care of the `OnBadRequest` & `OnOOM` failures, the next step is probably to migrate the other Scudo failures in the same failes (header corruption, invalid state and so on). Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: filcab, mgorny, delcypher, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D48199 llvm-svn: 334843
Diffstat (limited to 'compiler-rt/test')
-rw-r--r--compiler-rt/test/scudo/aligned-new.cpp6
-rw-r--r--compiler-rt/test/scudo/memalign.c3
-rw-r--r--compiler-rt/test/scudo/sizes.cpp14
-rw-r--r--compiler-rt/test/scudo/valloc.c3
4 files changed, 16 insertions, 10 deletions
diff --git a/compiler-rt/test/scudo/aligned-new.cpp b/compiler-rt/test/scudo/aligned-new.cpp
index ef37c9b0cd0..0a10ae188c9 100644
--- a/compiler-rt/test/scudo/aligned-new.cpp
+++ b/compiler-rt/test/scudo/aligned-new.cpp
@@ -1,6 +1,7 @@
// RUN: %clangxx_scudo -std=c++1z -faligned-allocation %s -o %t
-// RUN: %run %t valid 2>&1
-// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1
+// RUN: %run %t valid 2>&1
+// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1
+// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t invalid 2>&1 | FileCheck %s
// Tests that the C++17 aligned new/delete operators are working as expected.
// Currently we do not check the consistency of the alignment on deallocation,
@@ -77,6 +78,7 @@ int main(int argc, char **argv) {
const size_t alignment = (1U << 8) - 1;
void *p = operator new(1, static_cast<std::align_val_t>(alignment),
std::nothrow);
+ // CHECK: Scudo ERROR: invalid allocation alignment
assert(!p);
}
diff --git a/compiler-rt/test/scudo/memalign.c b/compiler-rt/test/scudo/memalign.c
index 694a4dad683..675f5341519 100644
--- a/compiler-rt/test/scudo/memalign.c
+++ b/compiler-rt/test/scudo/memalign.c
@@ -1,6 +1,6 @@
// RUN: %clang_scudo %s -o %t
// RUN: %run %t valid 2>&1
-// RUN: not %run %t invalid 2>&1
+// RUN: not %run %t invalid 2>&1 | FileCheck --check-prefix=CHECK-align %s
// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1
// RUN: not %run %t double-free 2>&1 | FileCheck --check-prefix=CHECK-double-free %s
// RUN: %env_scudo_opts=DeallocationTypeMismatch=1 not %run %t realloc 2>&1 | FileCheck --check-prefix=CHECK-realloc %s
@@ -66,6 +66,7 @@ int main(int argc, char **argv)
if (!strcmp(argv[1], "invalid")) {
// Alignment is not a power of 2.
p = memalign(alignment - 1, size);
+ // CHECK-align: Scudo ERROR: invalid allocation alignment
assert(!p);
// Size is not a multiple of alignment.
p = aligned_alloc(alignment, size >> 1);
diff --git a/compiler-rt/test/scudo/sizes.cpp b/compiler-rt/test/scudo/sizes.cpp
index a5e48a25040..f7ccbebedc3 100644
--- a/compiler-rt/test/scudo/sizes.cpp
+++ b/compiler-rt/test/scudo/sizes.cpp
@@ -1,11 +1,11 @@
// RUN: %clangxx_scudo %s -lstdc++ -o %t
-// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t malloc 2>&1 | FileCheck %s
+// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-max
// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t malloc 2>&1
-// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t calloc 2>&1 | FileCheck %s
+// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t calloc 2>&1 | FileCheck %s --check-prefix=CHECK-calloc
// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t calloc 2>&1
-// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t new 2>&1 | FileCheck %s
-// RUN: %env_scudo_opts=allocator_may_return_null=1 not %run %t new 2>&1 | FileCheck %s
-// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t new-nothrow 2>&1 | FileCheck %s
+// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t new 2>&1 | FileCheck %s --check-prefix=CHECK-max
+// RUN: %env_scudo_opts=allocator_may_return_null=1 not %run %t new 2>&1 | FileCheck %s --check-prefix=CHECK-oom
+// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t new-nothrow 2>&1 | FileCheck %s --check-prefix=CHECK-max
// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t new-nothrow 2>&1
// RUN: %run %t usable 2>&1
@@ -70,4 +70,6 @@ int main(int argc, char **argv) {
return 0;
}
-// CHECK: allocator is terminating the process
+// CHECK-max: {{Scudo ERROR: requested allocation size .* exceeds maximum supported size}}
+// CHECK-oom: Scudo ERROR: allocator is out of memory
+// CHECK-calloc: Scudo ERROR: calloc parameters overflow
diff --git a/compiler-rt/test/scudo/valloc.c b/compiler-rt/test/scudo/valloc.c
index a7507138602..605b9c4d4b9 100644
--- a/compiler-rt/test/scudo/valloc.c
+++ b/compiler-rt/test/scudo/valloc.c
@@ -1,6 +1,6 @@
// RUN: %clang_scudo %s -o %t
// RUN: %run %t valid 2>&1
-// RUN: not %run %t invalid 2>&1
+// RUN: not %run %t invalid 2>&1 | FileCheck %s
// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1
// UNSUPPORTED: android
@@ -54,6 +54,7 @@ int main(int argc, char **argv)
if (!strcmp(argv[1], "invalid")) {
// Size passed to pvalloc overflows when rounded up.
p = pvalloc((size_t)-1);
+ // CHECK: Scudo ERROR: pvalloc parameters overflow
assert(!p);
assert(errno == ENOMEM);
errno = 0;
OpenPOWER on IntegriCloud