diff options
author | Derek Bruening <bruening@google.com> | 2016-04-21 21:32:25 +0000 |
---|---|---|
committer | Derek Bruening <bruening@google.com> | 2016-04-21 21:32:25 +0000 |
commit | 33f89a1f101182f2f316a3e142caa93d244b4ee7 (patch) | |
tree | e612c4052a65867414acb78ae588d500b20d7484 /test/esan | |
parent | 94a44ec2b58ed284cb7175b7ed605ae8675a7de9 (diff) |
[esan] EfficiencySanitizer base runtime library
Summary:
Adds the initial version of a runtime library for the new
EfficiencySanitizer ("esan") family of tools. The library includes:
+ Slowpath code via callouts from the compiler instrumentation for
each memory access.
+ Registration of atexit() to call finalization code.
+ Runtime option flags controlled by the environment variable
ESAN_OPTIONS. The common sanitizer flags are supported such as
verbosity and log_path.
+ An initial simple test.
Still TODO: common code for libc interceptors and shadow memory mapping,
and tool-specific code for shadow state updating.
Reviewers: eugenis, vitalybuka, aizatsky, filcab
Subscribers: filcab, vkalintiris, kubabrecka, llvm-commits, zhaoqin, kcc
Differential Revision: http://reviews.llvm.org/D19168
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267060 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/esan')
-rw-r--r-- | test/esan/CMakeLists.txt | 32 | ||||
-rw-r--r-- | test/esan/TestCases/verbose-simple.c | 11 | ||||
-rw-r--r-- | test/esan/lit.cfg | 32 | ||||
-rw-r--r-- | test/esan/lit.site.cfg.in | 14 |
4 files changed, 89 insertions, 0 deletions
diff --git a/test/esan/CMakeLists.txt b/test/esan/CMakeLists.txt new file mode 100644 index 000000000..c392f9982 --- /dev/null +++ b/test/esan/CMakeLists.txt @@ -0,0 +1,32 @@ +set(ESAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) +if(NOT COMPILER_RT_STANDALONE_BUILD) + list(APPEND ESAN_TEST_DEPS esan) +endif() + +set(ESAN_TESTSUITES) + +set(ESAN_TEST_ARCH ${ESAN_SUPPORTED_ARCH}) + +set(ESAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +foreach(arch ${ESAN_TEST_ARCH}) + set(ESAN_TEST_TARGET_ARCH ${arch}) + string(TOLOWER "-${arch}" ESAN_TEST_CONFIG_SUFFIX) + get_target_flags_for_arch(${arch} ESAN_TEST_TARGET_CFLAGS) + string(REPLACE ";" " " ESAN_TEST_TARGET_CFLAGS "${ESAN_TEST_TARGET_CFLAGS}") + + string(TOUPPER ${arch} ARCH_UPPER_CASE) + set(CONFIG_NAME ${ARCH_UPPER_CASE}Config) + + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) + list(APPEND ESAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) +endforeach() + +# TODO(bruening): add Unit/ tests as well + +add_lit_testsuite(check-esan "Running EfficiencySanitizer tests" + ${ESAN_TESTSUITES} + DEPENDS ${ESAN_TEST_DEPS}) +set_target_properties(check-esan PROPERTIES FOLDER "Esan tests") diff --git a/test/esan/TestCases/verbose-simple.c b/test/esan/TestCases/verbose-simple.c new file mode 100644 index 000000000..e66648166 --- /dev/null +++ b/test/esan/TestCases/verbose-simple.c @@ -0,0 +1,11 @@ +// RUN: %clang_esan_frag -O0 %s -o %t 2>&1 +// RUN: %env_esan_opts=verbosity=1 %run %t 2>&1 | FileCheck %s + +#include <stdlib.h> +#include <string.h> +int main(int argc, char **argv) { + // CHECK: in esan::initializeLibrary + // CHECK-NEXT: in esan::finalizeLibrary + // CHECK-NEXT: {{.*}}EfficiencySanitizer is not finished: nothing yet to report + return 0; +} diff --git a/test/esan/lit.cfg b/test/esan/lit.cfg new file mode 100644 index 000000000..99e93561a --- /dev/null +++ b/test/esan/lit.cfg @@ -0,0 +1,32 @@ +# -*- Python -*- + +import os + +# Setup config name. +config.name = 'EfficiencySanitizer' + config.name_suffix + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# Setup default compiler flags used with -fsanitize=efficiency option. +base_cflags = ([config.target_cflags] + config.debug_info_flags) +base_cxxflags = config.cxx_mode_flags + base_cflags + +frag_cflags = (["-fsanitize=efficiency-cache-frag"] + base_cflags) + +def build_invocation(compile_flags): + return " " + " ".join([config.clang] + compile_flags) + " " + +config.substitutions.append( ("%clang_esan_frag ", + build_invocation(frag_cflags)) ) + +default_esan_opts = '' +config.substitutions.append(('%env_esan_opts=', + 'env ESAN_OPTIONS=' + default_esan_opts)) + +# Default test suffixes. +config.suffixes = ['.c', '.cpp'] + +# EfficiencySanitizer tests are currently supported on Linux x86-64 only. +if config.host_os not in ['Linux'] or config.target_arch != 'x86_64': + config.unsupported = True diff --git a/test/esan/lit.site.cfg.in b/test/esan/lit.site.cfg.in new file mode 100644 index 000000000..b631ce42d --- /dev/null +++ b/test/esan/lit.site.cfg.in @@ -0,0 +1,14 @@ +## Autogenerated by LLVM/Clang configuration. +# Do not edit! + +# Tool-specific config options. +config.name_suffix = "@ESAN_TEST_CONFIG_SUFFIX@" +config.esan_lit_source_dir = "@ESAN_LIT_SOURCE_DIR@" +config.target_cflags = "@ESAN_TEST_TARGET_CFLAGS@" +config.target_arch = "@ESAN_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@ESAN_LIT_SOURCE_DIR@/lit.cfg") |