From 141c5a9ae097596ea850c96caaae6501ce326073 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Mon, 19 Jan 2015 09:21:44 +0000 Subject: [PATCH] [sanitizer] Move options-related tests to sanitizer_common. And handle help=1 in standalone LSan. llvm-svn: 226438 --- compiler-rt/lib/lsan/lsan_common.cc | 5 +++++ .../test/asan/TestCases/asan_options-include.cc | 21 --------------------- .../test/asan/TestCases/asan_options-invalid.cc | 7 ------- .../test/sanitizer_common/TestCases/options-help.cc | 8 ++++++++ .../sanitizer_common/TestCases/options-include.cc | 21 +++++++++++++++++++++ .../sanitizer_common/TestCases/options-invalid.cc | 7 +++++++ 6 files changed, 41 insertions(+), 28 deletions(-) delete mode 100644 compiler-rt/test/asan/TestCases/asan_options-include.cc delete mode 100644 compiler-rt/test/asan/TestCases/asan_options-invalid.cc create mode 100644 compiler-rt/test/sanitizer_common/TestCases/options-help.cc create mode 100644 compiler-rt/test/sanitizer_common/TestCases/options-include.cc create mode 100644 compiler-rt/test/sanitizer_common/TestCases/options-invalid.cc diff --git a/compiler-rt/lib/lsan/lsan_common.cc b/compiler-rt/lib/lsan/lsan_common.cc index 80cf132..c005f46 100644 --- a/compiler-rt/lib/lsan/lsan_common.cc +++ b/compiler-rt/lib/lsan/lsan_common.cc @@ -70,8 +70,13 @@ static void InitializeFlags(bool standalone) { OverrideCommonFlags(cf); } + bool help_before = common_flags()->help; + const char *options = GetEnv("LSAN_OPTIONS"); parser.ParseString(options); + + if (!help_before && common_flags()->help) + parser.PrintFlagDescriptions(); } #define LOG_POINTERS(...) \ diff --git a/compiler-rt/test/asan/TestCases/asan_options-include.cc b/compiler-rt/test/asan/TestCases/asan_options-include.cc deleted file mode 100644 index 86c2e7c..0000000 --- a/compiler-rt/test/asan/TestCases/asan_options-include.cc +++ /dev/null @@ -1,21 +0,0 @@ -// RUN: %clangxx_asan -O0 %s -o %t -// RUN: echo -e "symbolize=1\ninclude='%t.options2.txt'" >%t.options1.txt -// RUN: echo -e "verbosity=1\n" >%t.options2.txt -// RUN: cat %t.options1.txt -// RUN: cat %t.options2.txt -// RUN: ASAN_OPTIONS="verbosity=0:include='%t.options1.txt'" %run %t 2>&1 | tee %t.out -// RUN: FileCheck %s --check-prefix=CHECK-VERBOSITY1 <%t.out -// RUN: ASAN_OPTIONS="include='%t.options1.txt',verbosity=0" %run %t 2>&1 | tee %t.out -// RUN: FileCheck %s --check-prefix=CHECK-VERBOSITY0 <%t.out -// RUN: ASAN_OPTIONS="include='%t.options-not-found.txt',verbosity=0" not %run %t 2>&1 | tee %t.out -// RUN: FileCheck %s --check-prefix=CHECK-NOT-FOUND < %t.out - -#include - -int main() { - fprintf(stderr, "done\n"); -} - -// CHECK-VERBOSITY1: Parsed ASAN_OPTIONS: -// CHECK-VERBOSITY0-NOT: Parsed ASAN_OPTIONS: -// CHECK-NOT-FOUND: Failed to read options from diff --git a/compiler-rt/test/asan/TestCases/asan_options-invalid.cc b/compiler-rt/test/asan/TestCases/asan_options-invalid.cc deleted file mode 100644 index ced2481..0000000 --- a/compiler-rt/test/asan/TestCases/asan_options-invalid.cc +++ /dev/null @@ -1,7 +0,0 @@ -// RUN: %clangxx_asan -O0 %s -o %t -// RUN: ASAN_OPTIONS=invalid_option_name=10 not %run %t 2>&1 | FileCheck %s - -int main() { -} - -// CHECK: Unknown flag{{.*}}invalid_option_name diff --git a/compiler-rt/test/sanitizer_common/TestCases/options-help.cc b/compiler-rt/test/sanitizer_common/TestCases/options-help.cc new file mode 100644 index 0000000..eaa04a4 --- /dev/null +++ b/compiler-rt/test/sanitizer_common/TestCases/options-help.cc @@ -0,0 +1,8 @@ +// RUN: %clangxx -O0 %s -o %t +// RUN: %tool_options=help=1 %run %t 2>&1 | FileCheck %s + +int main() { +} + +// CHECK: Available flags for {{.*}}Sanitizer: +// CHECK: handle_segv diff --git a/compiler-rt/test/sanitizer_common/TestCases/options-include.cc b/compiler-rt/test/sanitizer_common/TestCases/options-include.cc new file mode 100644 index 0000000..ae89951 --- /dev/null +++ b/compiler-rt/test/sanitizer_common/TestCases/options-include.cc @@ -0,0 +1,21 @@ +// RUN: %clangxx -O0 %s -o %t +// RUN: echo -e "symbolize=1\ninclude='%t.options2.txt'" >%t.options1.txt +// RUN: echo -e "help=1\n" >%t.options2.txt +// RUN: cat %t.options1.txt +// RUN: cat %t.options2.txt +// RUN: %tool_options="help=0:include='%t.options1.txt'" %run %t 2>&1 | tee %t.out +// RUN: FileCheck %s --check-prefix=CHECK-VERBOSITY1 <%t.out +// RUN: %tool_options="include='%t.options1.txt',help=0" %run %t 2>&1 | tee %t.out +// RUN: FileCheck %s --check-prefix=CHECK-VERBOSITY0 <%t.out +// RUN: %tool_options="include='%t.options-not-found.txt',help=1" not %run %t 2>&1 | tee %t.out +// RUN: FileCheck %s --check-prefix=CHECK-NOT-FOUND < %t.out + +#include + +int main() { + fprintf(stderr, "done\n"); +} + +// CHECK-VERBOSITY1: Available flags for +// CHECK-VERBOSITY0-NOT: Available flags for +// CHECK-NOT-FOUND: Failed to read options from diff --git a/compiler-rt/test/sanitizer_common/TestCases/options-invalid.cc b/compiler-rt/test/sanitizer_common/TestCases/options-invalid.cc new file mode 100644 index 0000000..940f1bb --- /dev/null +++ b/compiler-rt/test/sanitizer_common/TestCases/options-invalid.cc @@ -0,0 +1,7 @@ +// RUN: %clangxx -O0 %s -o %t +// RUN: %tool_options=invalid_option_name=10 not %run %t 2>&1 | FileCheck %s + +int main() { +} + +// CHECK: Unknown flag{{.*}}invalid_option_name -- 2.7.4