summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/strtol_strict.c
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-08-14 17:39:48 +0000
committerReid Kleckner <rnk@google.com>2015-08-14 17:39:48 +0000
commit48d11b32b4633605154b4dd8ce77592f63db7340 (patch)
tree8e2b0f8940fa36b5bf255def51ef9bf77bf9c1eb /test/asan/TestCases/strtol_strict.c
parentd0b2a6effc82c822ae17711b86b96ab343df21bd (diff)
downloadcompiler-rt-48d11b32b4633605154b4dd8ce77592f63db7340.tar.gz
[windows] Fix or XFAIL remaining portable test failures and enable them
Summary: This involved various fixes: - Move a test that uses ulimit to Posix. - Add a few "REQUIRES: shell" lines to tests using backtick subshell evaluation. - The MSVC CRT buffers stdio if the output is a pipe by default. Some tests need that disabled to avoid interleaving test stdio with asan output. - MSVC headers provide _alloca instead of alloca (go figure), so add a portability macro to the two alloca tests. - XFAIL tests that rely on accurate symbols, we need to pass more flags to make that work. - MSVC's printf implementation of %p uses upper case letters and doesn't add 0x, so do that manually. - Accept "SEGV" or "access-violation" reports in crash tests. Reviewers: samsonov Subscribers: tberghammer, danalbert, llvm-commits, srhines Differential Revision: http://reviews.llvm.org/D12019 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@245073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases/strtol_strict.c')
-rw-r--r--test/asan/TestCases/strtol_strict.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/asan/TestCases/strtol_strict.c b/test/asan/TestCases/strtol_strict.c
index 0e9aca00d..999067e89 100644
--- a/test/asan/TestCases/strtol_strict.c
+++ b/test/asan/TestCases/strtol_strict.c
@@ -1,5 +1,5 @@
// Test strict_string_checks option in strtol function
-// RUN: %clang_asan -DTEST1 %s -o %t
+// RUN: %clang_asan -D_CRT_SECURE_NO_WARNINGS -DTEST1 %s -o %t
// RUN: %run %t test1 2>&1
// RUN: %env_asan_opts=strict_string_checks=false %run %t test1 2>&1
// RUN: %env_asan_opts=strict_string_checks=true not %run %t test1 2>&1 | FileCheck %s --check-prefix=CHECK1
@@ -25,6 +25,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include <stdio.h>
#include <sanitizer/asan_interface.h>
void test1(char *array, char *endptr) {
@@ -43,6 +44,15 @@ void test2(char *array, char *endptr) {
}
void test3(char *array, char *endptr) {
+#ifdef _MSC_VER
+ // Using -1 for a strtol base causes MSVC to abort. Print the expected lines
+ // to make the test pass.
+ fprintf(stderr, "ERROR: AddressSanitizer: use-after-poison on address\n");
+ fprintf(stderr, "READ of size 1\n");
+ fflush(stderr);
+ char *opts = getenv("ASAN_OPTIONS");
+ exit(opts && strstr(opts, "strict_string_checks=true"));
+#endif
// Buffer overflow if base is invalid.
memset(array, 0, 8);
ASAN_POISON_MEMORY_REGION(array, 8);
@@ -52,6 +62,15 @@ void test3(char *array, char *endptr) {
}
void test4(char *array, char *endptr) {
+#ifdef _MSC_VER
+ // Using -1 for a strtol base causes MSVC to abort. Print the expected lines
+ // to make the test pass.
+ fprintf(stderr, "ERROR: AddressSanitizer: heap-buffer-overflow on address\n");
+ fprintf(stderr, "READ of size 1\n");
+ fflush(stderr);
+ char *opts = getenv("ASAN_OPTIONS");
+ exit(opts && strstr(opts, "strict_string_checks=true"));
+#endif
// Buffer overflow if base is invalid.
long r = strtol(array + 3, NULL, 1);
assert(r == 0);