[test] Disable sunrpc tests when rpc/xdr.h is missing
authorMichal Gorny <mgorny@gentoo.org>
Mon, 14 Jan 2019 19:18:34 +0000 (19:18 +0000)
committerMichal Gorny <mgorny@gentoo.org>
Mon, 14 Jan 2019 19:18:34 +0000 (19:18 +0000)
Disable tests requiring sunrpc when the relevant headers are missing.
In order to accommodate that, move the header check
from sanitizer_common to base-config-ix, and define the check result
as a global variable there.  Use it afterwards both for definition
needed by sanitizer_common, and to control 'sunrpc' test feature.

While at it, remove the append_have_file_definition macro that was used
only once, and no longer fits the split check-definition.

Bug report: https://github.com/google/sanitizers/issues/974

Differential Revision: https://reviews.llvm.org/D47819

llvm-svn: 351109

compiler-rt/cmake/Modules/CompilerRTUtils.cmake
compiler-rt/cmake/base-config-ix.cmake
compiler-rt/lib/sanitizer_common/CMakeLists.txt
compiler-rt/test/lit.common.cfg
compiler-rt/test/lit.common.configured.in
compiler-rt/test/msan/Linux/sunrpc.cc
compiler-rt/test/msan/Linux/sunrpc_bytes.cc
compiler-rt/test/msan/Linux/sunrpc_string.cc
compiler-rt/test/tsan/sunrpc.cc

index 518a16a..5348f20 100644 (file)
@@ -58,14 +58,6 @@ macro(append_rtti_flag polarity list)
   endif()
 endmacro()
 
-macro(append_have_file_definition filename varname list)
-  check_include_file("${filename}" "${varname}")
-  if (NOT ${varname})
-    set("${varname}" 0)
-  endif()
-  list(APPEND ${list} "${varname}=${${varname}}")
-endmacro()
-
 macro(list_intersect output input1 input2)
   set(${output})
   foreach(it ${${input1}})
index 2a44d83..6684d73 100644 (file)
@@ -8,6 +8,12 @@ include(CheckCXXSourceCompiles)
 
 check_include_file(unwind.h HAVE_UNWIND_H)
 
+# Used by sanitizer_common and tests.
+check_include_file(rpc/xdr.h HAVE_RPC_XDR_H)
+if (NOT HAVE_RPC_XDR_H)
+  set(HAVE_RPC_XDR_H 0)
+endif()
+
 # Top level target used to build all compiler-rt libraries.
 add_custom_target(compiler-rt ALL)
 add_custom_target(install-compiler-rt)
index f4e768f..f7bf4b0 100644 (file)
@@ -192,10 +192,8 @@ set(SANITIZER_IMPL_HEADERS
 
 include_directories(..)
 
-set(SANITIZER_COMMON_DEFINITIONS)
-
-include(CheckIncludeFile)
-append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
+set(SANITIZER_COMMON_DEFINITIONS
+  HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H})
 
 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SANITIZER_CFLAGS)
index cbd9082..163e587 100644 (file)
@@ -359,6 +359,9 @@ if config.lto_supported:
   if config.use_newpm:
     config.lto_flags += ["-fexperimental-new-pass-manager"]
 
+if config.have_rpc_xdr_h:
+  config.available_features.add('sunrpc')
+
 # Ask llvm-config about assertion mode.
 try:
   llvm_config_cmd = subprocess.Popen(
index 63d55bf..97c6ed5 100644 (file)
@@ -36,6 +36,7 @@ set_default("use_thinlto", False)
 set_default("use_lto", config.use_thinlto)
 set_default("use_newpm", False)
 set_default("android", @ANDROID_PYBOOL@)
+set_default("have_rpc_xdr_h", @HAVE_RPC_XDR_H@)
 config.available_features.add('target-is-%s' % config.target_arch)
 
 if config.enable_per_target_runtime_dir:
index c92ad63..edf49c2 100644 (file)
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
 // RUN: %clangxx_msan -g -O0 -DTYPE=int -DFN=xdr_int %s -o %t && \
 // RUN:     %run %t 2>&1
 // RUN: %clangxx_msan -g -O0 -DTYPE=int -DFN=xdr_int -DUNINIT=1 %s -o %t && \
index 477637a..7eb47e1 100644 (file)
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
 // RUN: %clangxx_msan -g -O0 %s -o %t && \
 // RUN:     %run %t 2>&1
 // RUN: %clangxx_msan -g -O0 -DUNINIT=1 %s -o %t && \
index 350222f..723b855 100644 (file)
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
 // RUN: %clangxx_msan -g -O0 %s -o %t && \
 // RUN:     %run %t 2>&1
 // RUN: %clangxx_msan -g -O0 -DUNINIT=1 %s -o %t && \
index 5cfb534..8e32d6d 100644 (file)
@@ -1,3 +1,5 @@
+// REQUIRES: sunrpc
+
 // RUN: %clang_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
 
 #include <pthread.h>