[PATCH] [compiler-rt] Make the UBSan coverage-levels.cc test be Linux specific

Kuba Brecka kuba.brecka at gmail.com
Wed Mar 11 17:00:02 PDT 2015


The ubsan/TestCases/Misc/coverage-levels.cc is currently broken in the OS X buildbot: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA_check/2144/console

However, `XFAIL: darwin` is not enough, because it fails only on i386, but not on x86_64.  Let's move the test into a Linux/ subdirectory to make it not run on Darwin at all.

http://reviews.llvm.org/D8278

Files:
  test/ubsan/TestCases/Misc/Linux/coverage-levels.cc
  test/ubsan/TestCases/Misc/Linux/lit.local.cfg
  test/ubsan/TestCases/Misc/coverage-levels.cc

Index: test/ubsan/TestCases/Misc/Linux/coverage-levels.cc
===================================================================
--- test/ubsan/TestCases/Misc/Linux/coverage-levels.cc
+++ test/ubsan/TestCases/Misc/Linux/coverage-levels.cc
@@ -0,0 +1,38 @@
+// Test various levels of coverage
+//
+// RUN: mkdir -p %T/coverage-levels
+// RUN: OPT=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels
+// RUN: %clangxx -fsanitize=shift                        -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=1  %s -o %t
+// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
+// RUN: %clangxx -fsanitize=undefined                    -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=1  %s -o %t
+// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
+
+// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=1  %s -o %t
+// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
+// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=2  %s -o %t
+// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
+// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=3  %s -o %t
+// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
+
+// XFAIL: darwin
+
+volatile int sink;
+int main(int argc, char **argv) {
+  int shift = argc * 32;
+#if GOOD_SHIFT
+  shift = 3;
+#endif
+  if ((argc << shift) == 16)  // False.
+    return 1;
+  return 0;
+}
+
+// CHECK_WARN: shift exponent 32 is too large
+// CHECK_NOWARN-NOT: ERROR
+// FIXME: Currently, coverage instrumentation kicks in after ubsan, so we get
+// more than the minimal number of instrumented blocks.
+// FIXME: Currently, ubsan with -fno-sanitize-recover and w/o asan will fail
+// to dump coverage.
+// CHECK1:  1 PCs written
+// CHECK2:  3 PCs written
+// CHECK3:  4 PCs written
Index: test/ubsan/TestCases/Misc/Linux/lit.local.cfg
===================================================================
--- test/ubsan/TestCases/Misc/Linux/lit.local.cfg
+++ test/ubsan/TestCases/Misc/Linux/lit.local.cfg
@@ -0,0 +1,9 @@
+def getRoot(config):
+  if not config.parent:
+    return config
+  return getRoot(config.parent)
+
+root = getRoot(config)
+
+if root.host_os not in ['Linux']:
+  config.unsupported = True
Index: test/ubsan/TestCases/Misc/coverage-levels.cc
===================================================================
--- test/ubsan/TestCases/Misc/coverage-levels.cc
+++ test/ubsan/TestCases/Misc/coverage-levels.cc
@@ -1,38 +0,0 @@
-// Test various levels of coverage
-//
-// RUN: mkdir -p %T/coverage-levels
-// RUN: OPT=coverage=1:verbosity=1:coverage_dir=%T/coverage-levels
-// RUN: %clangxx -fsanitize=shift                        -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=1  %s -o %t
-// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
-// RUN: %clangxx -fsanitize=undefined                    -DGOOD_SHIFT=1 -O1 -fsanitize-coverage=1  %s -o %t
-// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_NOWARN
-
-// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=1  %s -o %t
-// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1 --check-prefix=CHECK_WARN
-// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=2  %s -o %t
-// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK2 --check-prefix=CHECK_WARN
-// RUN: %clangxx -fsanitize=shift -O1 -fsanitize-coverage=3  %s -o %t
-// RUN: UBSAN_OPTIONS=$OPT ASAN_OPTIONS=$OPT %run %t 2>&1 | FileCheck %s --check-prefix=CHECK3 --check-prefix=CHECK_WARN
-
-// XFAIL: darwin
-
-volatile int sink;
-int main(int argc, char **argv) {
-  int shift = argc * 32;
-#if GOOD_SHIFT
-  shift = 3;
-#endif
-  if ((argc << shift) == 16)  // False.
-    return 1;
-  return 0;
-}
-
-// CHECK_WARN: shift exponent 32 is too large
-// CHECK_NOWARN-NOT: ERROR
-// FIXME: Currently, coverage instrumentation kicks in after ubsan, so we get
-// more than the minimal number of instrumented blocks.
-// FIXME: Currently, ubsan with -fno-sanitize-recover and w/o asan will fail
-// to dump coverage.
-// CHECK1:  1 PCs written
-// CHECK2:  3 PCs written
-// CHECK3:  4 PCs written

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8278.21793.patch
Type: text/x-patch
Size: 4514 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150312/1259a69a/attachment.bin>


More information about the llvm-commits mailing list