[compiler-rt] r334340 - [MSan] Switch to common aligned allocs tests.

Alex Shlyapnikov via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 8 17:47:37 PDT 2018


Author: alekseyshl
Date: Fri Jun  8 17:47:37 2018
New Revision: 334340

URL: http://llvm.org/viewvc/llvm-project?rev=334340&view=rev
Log:
[MSan] Switch to common aligned allocs tests.

Summary:
Switch to aligned_alloc and posix_memalign tests in sanitizer_common
and delete the MSan-specific ones.

Reviewers: vitalybuka

Subscribers: srhines, kubamracek, delcypher, #sanitizers, llvm-commits

Differential Revision: https://reviews.llvm.org/D47968

Removed:
    compiler-rt/trunk/test/msan/Linux/aligned_alloc-alignment.cc
    compiler-rt/trunk/test/msan/posix_memalign-alignment.cc
Modified:
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/aligned_alloc-alignment.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/posix_memalign-alignment.cc
    compiler-rt/trunk/test/sanitizer_common/lit.common.cfg

Removed: compiler-rt/trunk/test/msan/Linux/aligned_alloc-alignment.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/Linux/aligned_alloc-alignment.cc?rev=334339&view=auto
==============================================================================
--- compiler-rt/trunk/test/msan/Linux/aligned_alloc-alignment.cc (original)
+++ compiler-rt/trunk/test/msan/Linux/aligned_alloc-alignment.cc (removed)
@@ -1,26 +0,0 @@
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 -g %s -o %t
-// RUN: MSAN_OPTIONS=allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s
-// RUN: MSAN_OPTIONS=allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
-
-// UNSUPPORTED: android
-
-// REQUIRES: stable-runtime
-
-#include <stdio.h>
-#include <stdlib.h>
-
-extern void *aligned_alloc(size_t alignment, size_t size);
-
-int main() {
-  void *p = aligned_alloc(17, 100);
-  // CHECK: ERROR: MemorySanitizer: invalid alignment requested in aligned_alloc: 17
-  // Check just the top frame since mips is forced to use store_context_size==1
-  // and also handle a case when aligned_alloc is aliased by memalign.
-  // CHECK: {{#0 0x.* in .*}}{{aligned_alloc|memalign}}
-  // CHECK: SUMMARY: MemorySanitizer: invalid-aligned-alloc-alignment
-
-  printf("pointer after failed aligned_alloc: %zd\n", (size_t)p);
-  // CHECK-NULL: pointer after failed aligned_alloc: 0
-
-  return 0;
-}

Removed: compiler-rt/trunk/test/msan/posix_memalign-alignment.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/posix_memalign-alignment.cc?rev=334339&view=auto
==============================================================================
--- compiler-rt/trunk/test/msan/posix_memalign-alignment.cc (original)
+++ compiler-rt/trunk/test/msan/posix_memalign-alignment.cc (removed)
@@ -1,22 +0,0 @@
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 -g %s -o %t
-// RUN: MSAN_OPTIONS=$MSAN_OPTIONS:allocator_may_return_null=0 not %run %t 2>&1 | FileCheck %s
-// RUN: MSAN_OPTIONS=$MSAN_OPTIONS:allocator_may_return_null=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
-
-// REQUIRES: stable-runtime
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main() {
-  void *p = reinterpret_cast<void*>(42);
-  int res = posix_memalign(&p, 17, 100);
-  // CHECK: ERROR: MemorySanitizer: invalid alignment requested in posix_memalign: 17
-  // Check just the top frame since mips is forced to use store_context_size==1
-  // CHECK: {{#0 0x.* in .*posix_memalign}}
-  // CHECK: SUMMARY: MemorySanitizer: invalid-posix-memalign-alignment
-
-  printf("pointer after failed posix_memalign: %zd\n", (size_t)p);
-  // CHECK-NULL: pointer after failed posix_memalign: 42
-
-  return 0;
-}

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/aligned_alloc-alignment.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/aligned_alloc-alignment.cc?rev=334340&r1=334339&r2=334340&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/aligned_alloc-alignment.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/aligned_alloc-alignment.cc Fri Jun  8 17:47:37 2018
@@ -1,13 +1,13 @@
-// RUN: %clangxx -O0 %s -o %t
+// RUN: %clangxx %collect_stack_traces -O0 %s -o %t
 // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 17 2>&1 | FileCheck %s
 // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 0 2>&1 | FileCheck %s
 // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 17 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
 // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 0 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
 
-// UNSUPPORTED: android, msan, tsan, ubsan
-
 // REQUIRES: stable-runtime
 
+// UNSUPPORTED: android, tsan, ubsan
+
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/posix_memalign-alignment.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/posix_memalign-alignment.cc?rev=334340&r1=334339&r2=334340&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/posix_memalign-alignment.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Posix/posix_memalign-alignment.cc Fri Jun  8 17:47:37 2018
@@ -1,4 +1,4 @@
-// RUN: %clangxx -O0 %s -o %t
+// RUN: %clangxx %collect_stack_traces -O0 %s -o %t
 // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 17 2>&1 | FileCheck %s
 // RUN: %env_tool_opts=allocator_may_return_null=0 not %run %t 0 2>&1 | FileCheck %s
 // RUN: %env_tool_opts=allocator_may_return_null=1 %run %t 17 2>&1 | FileCheck %s --check-prefix=CHECK-NULL
@@ -6,7 +6,7 @@
 
 // REQUIRES: stable-runtime
 
-// UNSUPPORTED: msan, tsan, ubsan
+// UNSUPPORTED: tsan, ubsan
 
 #include <assert.h>
 #include <stdio.h>

Modified: compiler-rt/trunk/test/sanitizer_common/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/lit.common.cfg?rev=334340&r1=334339&r2=334340&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/lit.common.cfg (original)
+++ compiler-rt/trunk/test/sanitizer_common/lit.common.cfg Fri Jun  8 17:47:37 2018
@@ -6,6 +6,7 @@ config.test_source_root = os.path.join(o
 config.name = "SanitizerCommon-" + config.name_suffix
 
 default_tool_options = []
+collect_stack_traces = ""
 if config.tool_name == "asan":
   tool_cflags = ["-fsanitize=address"]
   tool_options = "ASAN_OPTIONS"
@@ -15,6 +16,7 @@ elif config.tool_name == "tsan":
 elif config.tool_name == "msan":
   tool_cflags = ["-fsanitize=memory"]
   tool_options = "MSAN_OPTIONS"
+  collect_stack_traces = "-fsanitize-memory-track-origins"
 elif config.tool_name == "lsan":
   tool_cflags = ["-fsanitize=leak"]
   tool_options = "LSAN_OPTIONS"
@@ -52,6 +54,7 @@ def build_invocation(compile_flags):
 
 config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
 config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
+config.substitutions.append( ("%collect_stack_traces", collect_stack_traces) )
 config.substitutions.append( ("%tool_name", config.tool_name) )
 config.substitutions.append( ("%tool_options", tool_options) )
 config.substitutions.append( ('%env_tool_opts=',




More information about the llvm-commits mailing list