[compiler-rt] r264010 - Fix coverage-related asan tests for VS 2015

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 17:11:52 PDT 2016


Author: rnk
Date: Mon Mar 21 19:11:51 2016
New Revision: 264010

URL: http://llvm.org/viewvc/llvm-project?rev=264010&view=rev
Log:
Fix coverage-related asan tests for VS 2015

printf is an inline function in VS 2015, giving these tests an
unexpected extra point of coverage. This change works around that by
avoiding printf.

Modified:
    compiler-rt/trunk/test/asan/TestCases/Windows/coverage-basic.cc
    compiler-rt/trunk/test/asan/TestCases/coverage-reset.cc

Modified: compiler-rt/trunk/test/asan/TestCases/Windows/coverage-basic.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/coverage-basic.cc?rev=264010&r1=264009&r2=264010&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/coverage-basic.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/coverage-basic.cc Mon Mar 21 19:11:51 2016
@@ -6,8 +6,8 @@
 // RUN: %sancov print *.sancov | FileCheck %s
 #include <stdio.h>
 
-void foo() { fprintf(stderr, "FOO\n"); }
-void bar() { fprintf(stderr, "BAR\n"); }
+void foo() { fputs("FOO", stderr); }
+void bar() { fputs("BAR", stderr); }
 
 int main(int argc, char **argv) {
   if (argc == 2) {

Modified: compiler-rt/trunk/test/asan/TestCases/coverage-reset.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/coverage-reset.cc?rev=264010&r1=264009&r2=264010&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/coverage-reset.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/coverage-reset.cc Mon Mar 21 19:11:51 2016
@@ -13,6 +13,13 @@ static volatile int sink;
 __attribute__((noinline)) void bar() { sink = 2; }
 __attribute__((noinline)) void foo() { sink = 1; }
 
+// In MSVC 2015, printf is an inline function, which causes this test to fail as
+// it introduces an extra coverage point. Define away printf on that platform to
+// avoid the issue.
+#if _MSC_VER >= 1900
+# define printf(arg, ...)
+#endif
+
 #define GET_AND_PRINT_COVERAGE()                                       \
   bitset = 0;                                                  \
   for (size_t i = 0; i < n_guards; i++)                        \




More information about the llvm-commits mailing list