[sanitizer] Move options-related tests to sanitizer_common.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Mon, 19 Jan 2015 09:21:44 +0000 (09:21 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Mon, 19 Jan 2015 09:21:44 +0000 (09:21 +0000)
And handle help=1 in standalone LSan.

llvm-svn: 226438

compiler-rt/lib/lsan/lsan_common.cc
compiler-rt/test/asan/TestCases/asan_options-include.cc [deleted file]
compiler-rt/test/asan/TestCases/asan_options-invalid.cc [deleted file]
compiler-rt/test/sanitizer_common/TestCases/options-help.cc [new file with mode: 0644]
compiler-rt/test/sanitizer_common/TestCases/options-include.cc [new file with mode: 0644]
compiler-rt/test/sanitizer_common/TestCases/options-invalid.cc [new file with mode: 0644]

index 80cf132..c005f46 100644 (file)
@@ -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 (file)
index 86c2e7c..0000000
+++ /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 <stdio.h>
-
-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 (file)
index ced2481..0000000
+++ /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 (file)
index 0000000..eaa04a4
--- /dev/null
@@ -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 (file)
index 0000000..ae89951
--- /dev/null
@@ -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 <stdio.h>
+
+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 (file)
index 0000000..940f1bb
--- /dev/null
@@ -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