[compiler-rt] r208802 - [ASan tests] Add the first Windows-only lit test
Timur Iskhodzhanov
timurrrr at google.com
Wed May 14 12:10:43 PDT 2014
Author: timurrrr
Date: Wed May 14 14:10:43 2014
New Revision: 208802
URL: http://llvm.org/viewvc/llvm-project?rev=208802&view=rev
Log:
[ASan tests] Add the first Windows-only lit test
Reviewed at http://reviews.llvm.org/D3767
Added:
compiler-rt/trunk/test/asan/TestCases/Windows/
compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg
compiler-rt/trunk/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
Modified:
compiler-rt/trunk/CMakeLists.txt
compiler-rt/trunk/test/asan/lit.cfg
compiler-rt/trunk/test/lit.common.cfg
Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=208802&r1=208801&r2=208802&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Wed May 14 14:10:43 2014
@@ -131,6 +131,8 @@ endif()
if("${COMPILER_RT_TEST_COMPILER}" MATCHES "clang[+]*$")
set(COMPILER_RT_TEST_COMPILER_ID Clang)
+elseif("${COMPILER_RT_TEST_COMPILER}" MATCHES "clang-cl.exe$")
+ set(COMPILER_RT_TEST_COMPILER_ID Clang)
else()
set(COMPILER_RT_TEST_COMPILER_ID GNU)
endif()
Added: compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg?rev=208802&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg (added)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/lit.local.cfg Wed May 14 14:10:43 2014
@@ -0,0 +1,14 @@
+def getRoot(config):
+ if not config.parent:
+ return config
+ return getRoot(config.parent)
+
+root = getRoot(config)
+
+# We only run a small set of tests on Windows for now.
+# Override the parent directory's "unsupported" decision until we can handle
+# all of its tests.
+if root.host_os in ['Windows']:
+ config.unsupported = False
+else:
+ config.unsupported = True
Added: compiler-rt/trunk/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc?rev=208802&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc Wed May 14 14:10:43 2014
@@ -0,0 +1,26 @@
+// RUN: %clangxx_asan -O0 %s -Fe%t 2>&1
+// 'cat' is used below to work around FileCheck buffering bug which makes this
+// test flaky. FIXME: file an issue.
+// RUN: not %run %t 2>&1 | cat | FileCheck %s --check-prefix=CHECK
+
+#include <windows.h>
+
+DWORD WINAPI thread_proc(void *context) {
+ int subscript = -1;
+ volatile char stack_buffer[42];
+ stack_buffer[subscript] = 42;
+// CHECK: AddressSanitizer: stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
+// CHECK: WRITE of size 1 at [[ADDR]] thread T1
+// CHECK: {{#0 .* thread_proc .*thread_stack_array_left_oob.cc}}:[[@LINE-3]]
+// CHECK: Address [[ADDR]] is located in stack of thread T1 at offset {{.*}} in frame
+// CHECK: thread_proc
+ return 0;
+}
+
+int main(void) {
+ HANDLE thr = CreateThread(NULL, 0, thread_proc, NULL, 0, NULL);
+// CHECK: Thread T1 created by T0 here:
+// CHECK: {{#[01] .* main .*thread_stack_array_left_oob.cc}}:[[@LINE-2]]
+ WaitForSingleObject(thr, INFINITE);
+ return 0;
+}
Modified: compiler-rt/trunk/test/asan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/lit.cfg?rev=208802&r1=208801&r2=208802&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/lit.cfg (original)
+++ compiler-rt/trunk/test/asan/lit.cfg Wed May 14 14:10:43 2014
@@ -32,11 +32,19 @@ else:
# FIXME: Review the set of required flags and check if it can be reduced.
target_cflags = [get_required_attr(config, "target_cflags")] + extra_linkflags
target_cxxflags = config.cxx_mode_flags + target_cflags
-clang_asan_static_cflags = ["-fsanitize=address",
- "-mno-omit-leaf-frame-pointer",
- "-fno-omit-frame-pointer",
- "-fno-optimize-sibling-calls",
- "-g"] + target_cflags
+clang_asan_static_cflags = ["-fsanitize=address"] + target_cflags
+
+clang_path = getattr(config, 'clang', None)
+if clang_path.find("clang-cl") == -1:
+ clang_asan_static_cflags += ["-g",
+ "-mno-omit-leaf-frame-pointer",
+ "-fno-omit-frame-pointer",
+ "-fno-optimize-sibling-calls"]
+else:
+ clang_asan_static_cflags += ["-Zi",
+ "-Wno-deprecated-declarations",
+ "-D_HAS_EXCEPTIONS=0"]
+
clang_asan_static_cxxflags = config.cxx_mode_flags + clang_asan_static_cflags
if config.asan_dynamic:
Modified: compiler-rt/trunk/test/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lit.common.cfg?rev=208802&r1=208801&r2=208802&view=diff
==============================================================================
--- compiler-rt/trunk/test/lit.common.cfg (original)
+++ compiler-rt/trunk/test/lit.common.cfg Wed May 14 14:10:43 2014
@@ -20,7 +20,10 @@ if (not compiler_path) or (not os.path.e
compiler_id = getattr(config, 'compiler_id', None)
if compiler_id == "Clang":
- config.cxx_mode_flags = ["--driver-mode=g++"]
+ if platform.system() != 'Windows':
+ config.cxx_mode_flags = ["--driver-mode=g++"]
+ else:
+ config.cxx_mode_flags = []
elif compiler_id == 'GNU':
config.cxx_mode_flags = ["-x c++"]
else:
@@ -50,6 +53,10 @@ if (not llvm_tools_dir) or (not os.path.
path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
config.environment['PATH'] = path
+# Help MSVS link.exe find the standard libraries.
+if platform.system() == 'Windows':
+ config.environment['LIB'] = os.environ['LIB']
+
# Use ugly construction to explicitly prohibit "clang", "clang++" etc.
# in RUN lines.
config.substitutions.append(
More information about the llvm-commits
mailing list