[PATCH] D48553: [scudo] Add some runtime tests for the minimal runtime
Kostya Kortchinsky via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 25 10:37:59 PDT 2018
cryptoad created this revision.
cryptoad added reviewers: eugenis, alekseyshl.
Herald added subscribers: Sanitizers, delcypher, srhines.
As well as some tests to ensure that various combinations of the clang command
line flags work (shared/static/minimal).
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D48553
Files:
test/scudo/fsanitize.c
test/scudo/lit.cfg
test/scudo/preload.cpp
test/scudo/symbols.test
Index: test/scudo/symbols.test
===================================================================
--- /dev/null
+++ test/scudo/symbols.test
@@ -0,0 +1,9 @@
+REQUIRES: !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 InternalAlloc
+RUN: nm %shared_minlibscudo | not grep Symbolizer
+RUN: nm %shared_minlibscudo | not grep Coverage
Index: test/scudo/preload.cpp
===================================================================
--- test/scudo/preload.cpp
+++ 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
Index: test/scudo/lit.cfg
===================================================================
--- test/scudo/lit.cfg
+++ test/scudo/lit.cfg
@@ -10,9 +10,10 @@
# Path to the shared library
shared_libscudo = os.path.join(config.compiler_rt_libdir, "libclang_rt.scudo-%s.so" % config.target_arch)
+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] +
@@ -35,11 +36,12 @@
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 = ''
Index: test/scudo/fsanitize.c
===================================================================
--- /dev/null
+++ test/scudo/fsanitize.c
@@ -0,0 +1,28 @@
+// Test various -fsanitize= combinations.
+
+// RUN: %clang -fsanitize=scudo %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+
+// RUN: %clang -fsanitize=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 -fsanitize=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 -fsanitize=scudo -static-libsan %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck %s
+// RUN: %clang -fsanitize=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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48553.152727.patch
Type: text/x-patch
Size: 3551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180625/de246b0c/attachment.bin>
More information about the llvm-commits
mailing list