[compiler-rt] r335981 - [scudo] Add some runtime tests for the minimal runtime
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 29 07:56:25 PDT 2018
Author: cryptoad
Date: Fri Jun 29 07:56:25 2018
New Revision: 335981
URL: http://llvm.org/viewvc/llvm-project?rev=335981&view=rev
Log:
[scudo] Add some runtime tests for the minimal runtime
Summary:
As well as some tests to ensure that various combinations of the clang command
line flags work (shared/static/minimal).
Reviewers: eugenis, alekseyshl, vitalybuka
Reviewed By: vitalybuka
Subscribers: srhines, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D48553
Added:
compiler-rt/trunk/test/scudo/fsanitize.c
compiler-rt/trunk/test/scudo/symbols.test
Modified:
compiler-rt/trunk/test/scudo/lit.cfg
compiler-rt/trunk/test/scudo/preload.cpp
Added: compiler-rt/trunk/test/scudo/fsanitize.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/scudo/fsanitize.c?rev=335981&view=auto
==============================================================================
--- compiler-rt/trunk/test/scudo/fsanitize.c (added)
+++ compiler-rt/trunk/test/scudo/fsanitize.c Fri Jun 29 07:56:25 2018
@@ -0,0 +1,28 @@
+// Test various -fsanitize= additional flags combinations.
+
+// RUN: %clang_scudo %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+
+// RUN: %clang_scudo -shared-libsan %s -o %t
+// RUN: env LD_LIBRARY_PATH=`dirname %shared_libscudo`:$LD_LIBRARY_PATH not %run %t 2>&1 | FileCheck %s
+// RUN: %clang_scudo -shared-libsan -fsanitize-minimal-runtime %s -o %t
+// RUN: env LD_LIBRARY_PATH=`dirname %shared_minlibscudo`:$LD_LIBRARY_PATH not %run %t 2>&1 | FileCheck %s
+
+// RUN: %clang_scudo -static-libsan %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+// RUN: %clang_scudo -static-libsan -fsanitize-minimal-runtime %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+
+#include <assert.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[]) {
+ unsigned long *p = (unsigned long *)malloc(sizeof(unsigned long));
+ assert(p);
+ *p = 0;
+ free(p);
+ free(p);
+ return 0;
+}
+
+// CHECK: ERROR: invalid chunk state
Modified: compiler-rt/trunk/test/scudo/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/scudo/lit.cfg?rev=335981&r1=335980&r2=335981&view=diff
==============================================================================
--- compiler-rt/trunk/test/scudo/lit.cfg (original)
+++ compiler-rt/trunk/test/scudo/lit.cfg Fri Jun 29 07:56:25 2018
@@ -10,9 +10,10 @@ config.test_source_root = os.path.dirnam
# Path to the shared library
shared_libscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo%s.so" % config.target_suffix)
+shared_minlibscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo_minimal-%s.so" % config.target_arch)
# Test suffixes.
-config.suffixes = ['.c', '.cc', '.cpp']
+config.suffixes = ['.c', '.cc', '.cpp', '.test']
# C & CXX flags.
c_flags = ([config.target_cflags] +
@@ -32,14 +33,15 @@ cxx_flags = (c_flags + config.cxx_mode_f
scudo_flags = ["-fsanitize=scudo"]
-def build_invocation(compile_flags):
+def build_invocation(compile_flags):
return " " + " ".join([config.clang] + compile_flags) + " "
-# Add clang substitutions.
+# Add substitutions.
config.substitutions.append(("%clang ", build_invocation(c_flags)))
config.substitutions.append(("%clang_scudo ", build_invocation(c_flags + scudo_flags)))
config.substitutions.append(("%clangxx_scudo ", build_invocation(cxx_flags + scudo_flags)))
config.substitutions.append(("%shared_libscudo", shared_libscudo))
+config.substitutions.append(("%shared_minlibscudo", shared_minlibscudo))
# Platform-specific default SCUDO_OPTIONS for lit tests.
default_scudo_opts = ''
Modified: compiler-rt/trunk/test/scudo/preload.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/scudo/preload.cpp?rev=335981&r1=335980&r2=335981&view=diff
==============================================================================
--- compiler-rt/trunk/test/scudo/preload.cpp (original)
+++ compiler-rt/trunk/test/scudo/preload.cpp Fri Jun 29 07:56:25 2018
@@ -1,7 +1,8 @@
// Test that the preloaded runtime works without linking the static library.
// RUN: %clang %s -lstdc++ -o %t
-// RUN: env LD_PRELOAD=%shared_libscudo not %run %t 2>&1 | FileCheck %s
+// RUN: env LD_PRELOAD=%shared_libscudo not %run %t 2>&1 | FileCheck %s
+// RUN: env LD_PRELOAD=%shared_minlibscudo not %run %t 2>&1 | FileCheck %s
// This way of setting LD_PRELOAD does not work with Android test runner.
// REQUIRES: !android
Added: compiler-rt/trunk/test/scudo/symbols.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/scudo/symbols.test?rev=335981&view=auto
==============================================================================
--- compiler-rt/trunk/test/scudo/symbols.test (added)
+++ compiler-rt/trunk/test/scudo/symbols.test Fri Jun 29 07:56:25 2018
@@ -0,0 +1,8 @@
+UNSUPPORTED: android
+
+Verify that various functions are *not* present in the minimal binary. Presence
+of those symbols in the minimal runtime would mean that the split code made it
+back into the core Sanitizer runtime library.
+
+RUN: nm %shared_minlibscudo | not grep Symbolizer
+RUN: nm %shared_minlibscudo | not grep Coverage
More information about the llvm-commits
mailing list