diff options
Diffstat (limited to 'compiler-rt/test')
7 files changed, 60 insertions, 14 deletions
diff --git a/compiler-rt/test/asan/TestCases/Linux/long-object-path.cpp b/compiler-rt/test/asan/TestCases/Linux/long-object-path.cpp index 592b0ab..ffc2fbf 100644 --- a/compiler-rt/test/asan/TestCases/Linux/long-object-path.cpp +++ b/compiler-rt/test/asan/TestCases/Linux/long-object-path.cpp @@ -1,6 +1,6 @@ -// RUN: mkdir -p %T/a-long-directory-name-to-test-allocations-for-exceptions-in-_dl_lookup_symbol_x-since-glibc-2.27 -// RUN: %clangxx_asan -g %s -o %T/long-object-path -// RUN: %run %T/a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../long-object-path +// RUN: mkdir -p %t.dir/a-long-directory-name-to-test-allocations-for-exceptions-in-_dl_lookup_symbol_x-since-glibc-2.27 +// RUN: %clangxx_asan -g %s -o %t.dir/long-object-path +// RUN: %run %t.dir/a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../a-*/../long-object-path int main(void) { return 0; diff --git a/compiler-rt/test/fuzzer/SigTrapTest.cpp b/compiler-rt/test/fuzzer/SigTrapTest.cpp new file mode 100644 index 0000000..c3019a1 --- /dev/null +++ b/compiler-rt/test/fuzzer/SigTrapTest.cpp @@ -0,0 +1,29 @@ +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +// Simple test for a fuzzer. The fuzzer must find the string "Hi!". +#include <assert.h> +#include <cstddef> +#include <cstdint> +#include <cstdlib> +#include <iostream> +#include <ostream> +#include <signal.h> + +static volatile int Sink; + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + assert(Data); + if (Size > 0 && Data[0] == 'H') { + Sink = 1; + if (Size > 1 && Data[1] == 'i') { + Sink = 2; + if (Size > 2 && Data[2] == '!') { + std::cout << "BINGO; Found the target, exiting\n" << std::flush; + raise(SIGTRAP); + } + } + } + return 0; +} diff --git a/compiler-rt/test/fuzzer/afl-driver-stderr.test b/compiler-rt/test/fuzzer/afl-driver-stderr.test index 4b0c3b4..1ee0960 100644 --- a/compiler-rt/test/fuzzer/afl-driver-stderr.test +++ b/compiler-rt/test/fuzzer/afl-driver-stderr.test @@ -7,7 +7,8 @@ RUN: %no_fuzzer_cpp_compiler %S/AFLDriverTest.cpp %libfuzzer_src/afl/afl_driver. RUN: env -u AFL_DRIVER_STDERR_DUPLICATE_FILENAME %run %t-AFLDriverTest ; Test that specifying an invalid file causes a crash. -RUN: env ASAN_OPTIONS= AFL_DRIVER_STDERR_DUPLICATE_FILENAME="%T" not --crash %run %t-AFLDriverTest +RUN: mkdir -p %t.dir +RUN: env ASAN_OPTIONS= AFL_DRIVER_STDERR_DUPLICATE_FILENAME="%t.dir" not --crash %run %t-AFLDriverTest ; Test that a file is created when specified as the duplicate stderr. RUN: env AFL_DRIVER_STDERR_DUPLICATE_FILENAME=%t %run %t-AFLDriverTest diff --git a/compiler-rt/test/fuzzer/sig-trap.test b/compiler-rt/test/fuzzer/sig-trap.test new file mode 100644 index 0000000..30d9d47 --- /dev/null +++ b/compiler-rt/test/fuzzer/sig-trap.test @@ -0,0 +1,11 @@ +# Check that libFuzzer handles SIGTRAP; disabled on Windows due to reliance on +# posix only features +UNSUPPORTED: target={{.*windows.*}} + +RUN: %cpp_compiler %S/SigTrapTest.cpp -o %t + +RUN: not %run %t 2>&1 | FileCheck %s +CHECK: BINGO +CHECK: ERROR: libFuzzer: deadly signal + +RUN: trap "%run %t -handle_trap=0" TRAP diff --git a/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c b/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c index 8e13105..bf0e4e1 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c +++ b/compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c @@ -1,12 +1,13 @@ -// RUN: %clang %s -o %T/suffix-log-path_test-binary +// RUN: rm -rf %t.dir +// RUN: mkdir -p %t.dir +// RUN: %clang %s -o %t.dir/suffix-log-path_test-binary // The glob below requires bash. // REQUIRES: shell // Good log_path with suffix. -// RUN: rm -f %T/sanitizer.log.*.txt -// RUN: %env_tool_opts=log_path=%T/sanitizer.log:log_exe_name=1:log_suffix=.txt %run %T/suffix-log-path_test-binary 2> %t.out -// RUN: FileCheck %s < %T/sanitizer.log.suffix-log-path_test-binary.*.txt +// RUN: %env_tool_opts=log_path=%t.dir/sanitizer.log:log_exe_name=1:log_suffix=.txt %run %t.dir/suffix-log-path_test-binary 2> %t.out +// RUN: FileCheck %s < %t.dir/sanitizer.log.suffix-log-path_test-binary.*.txt // UNSUPPORTED: ios, android diff --git a/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp b/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp index 4a866e2..6c94dbd 100644 --- a/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp +++ b/compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp @@ -1,12 +1,14 @@ // RUN: %clangxx_xray -g -std=c++11 %s -o %t -fxray-modes=xray-fdr -// RUN: rm -f fdr-inmemory-test-* +// RUN: rm -rf %t.dir +// RUN: mkdir -p %t.dir +// RUN: cd %t.dir // RUN: XRAY_OPTIONS="patch_premain=false xray_logfile_base=fdr-inmemory-test- \ // RUN: verbosity=1" \ // RUN: XRAY_FDR_OPTIONS="no_file_flush=true func_duration_threshold_us=0" \ // RUN: %run %t 2>&1 | FileCheck %s -// RUN: FILES=`find %T -name 'fdr-inmemory-test-*' | wc -l` +// RUN: FILES=`find %t.dir -name 'fdr-inmemory-test-*' | wc -l` // RUN: [ $FILES -eq 0 ] -// RUN: rm -f fdr-inmemory-test-* +// RUN: rm -rf %t.dir // // REQUIRES: built-in-llvm-tree diff --git a/compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp b/compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp index b0411a2..f9288d9 100644 --- a/compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp +++ b/compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp @@ -1,12 +1,14 @@ // RUN: %clangxx_xray -g -std=c++11 %s -o %t -fxray-modes=xray-fdr -// RUN: rm -f fdr-inmemory-test-* +// RUN: rm -rf %t.dir +// RUN: mkdir -p %t.dir +// RUN: cd %t.dir // RUN: XRAY_OPTIONS="patch_premain=false xray_logfile_base=fdr-inmemory-test- \ // RUN: verbosity=1" \ // RUN: XRAY_FDR_OPTIONS="no_file_flush=true func_duration_threshold_us=0" \ // RUN: %run %t 2>&1 | FileCheck %s -// RUN: FILES=`find %T -name 'fdr-inmemory-test-*' | wc -l` +// RUN: FILES=`find %t.dir -name 'fdr-inmemory-test-*' | wc -l` // RUN: [ $FILES -eq 0 ] -// RUN: rm -f fdr-inmemory-test-* +// RUN: rm -rf %t.dir // // REQUIRES: built-in-llvm-tree |