diff options
| author | Kostya Kortchinsky <kostyak@google.com> | 2018-06-29 14:56:25 +0000 | 
|---|---|---|
| committer | Kostya Kortchinsky <kostyak@google.com> | 2018-06-29 14:56:25 +0000 | 
| commit | e92d7878e583851c691a3c3da0ac49754aa014e0 (patch) | |
| tree | 6d63925d2cf1bc96cd232cff7522043ffc21bd32 /compiler-rt | |
| parent | 27c979ace0f8ee71e020984ce408628b81c6a7b4 (diff) | |
| download | bcm5719-llvm-e92d7878e583851c691a3c3da0ac49754aa014e0.tar.gz bcm5719-llvm-e92d7878e583851c691a3c3da0ac49754aa014e0.zip  | |
[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
llvm-svn: 335981
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/test/scudo/fsanitize.c | 28 | ||||
| -rw-r--r-- | compiler-rt/test/scudo/lit.cfg | 8 | ||||
| -rw-r--r-- | compiler-rt/test/scudo/preload.cpp | 3 | ||||
| -rw-r--r-- | compiler-rt/test/scudo/symbols.test | 8 | 
4 files changed, 43 insertions, 4 deletions
diff --git a/compiler-rt/test/scudo/fsanitize.c b/compiler-rt/test/scudo/fsanitize.c new file mode 100644 index 00000000000..7e5d5451f72 --- /dev/null +++ b/compiler-rt/test/scudo/fsanitize.c @@ -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 diff --git a/compiler-rt/test/scudo/lit.cfg b/compiler-rt/test/scudo/lit.cfg index b7f814ebc11..df78d5f9d6a 100644 --- a/compiler-rt/test/scudo/lit.cfg +++ b/compiler-rt/test/scudo/lit.cfg @@ -10,9 +10,10 @@ config.test_source_root = os.path.dirname(__file__)  # 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_flags + ["-std=c++11"])  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 = '' diff --git a/compiler-rt/test/scudo/preload.cpp b/compiler-rt/test/scudo/preload.cpp index b41a70e472b..7fa8df4c693 100644 --- a/compiler-rt/test/scudo/preload.cpp +++ b/compiler-rt/test/scudo/preload.cpp @@ -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 diff --git a/compiler-rt/test/scudo/symbols.test b/compiler-rt/test/scudo/symbols.test new file mode 100644 index 00000000000..0425e62ba6a --- /dev/null +++ b/compiler-rt/test/scudo/symbols.test @@ -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  | 

