[msan] Optionally disable 2 tests (dlopen & gethostbyname).


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@185076 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/msan/tests/msan_test.cc b/lib/msan/tests/msan_test.cc
index f95fe30..35fd0c1 100644
--- a/lib/msan/tests/msan_test.cc
+++ b/lib/msan/tests/msan_test.cc
@@ -780,12 +780,16 @@
   EXPECT_HOSTENT_NOT_POISONED(he);
 }
 
+#ifndef MSAN_TEST_DISABLE_GETHOSTBYNAME
+
 TEST(MemorySanitizer, gethostbyname) {
   struct hostent *he = gethostbyname("localhost");
   ASSERT_NE((void *)NULL, he);
   EXPECT_HOSTENT_NOT_POISONED(he);
 }
 
+#endif // MSAN_TEST_DISABLE_GETHOSTBYNAME
+
 TEST(MemorySanitizer, gethostbyname2) {
   struct hostent *he = gethostbyname2("localhost", AF_INET);
   ASSERT_NE((void *)NULL, he);
@@ -1762,18 +1766,6 @@
 # error "TODO: port this"
 #endif
 
-// Compute the path to our loadable DSO.  We assume it's in the same
-// directory.  Only use string routines that we intercept so far to do this.
-static int PathToLoadable(char *buf, size_t sz) {
-  const char *basename = "libmsan_loadable.x86_64.so";
-  char *argv0 = program_invocation_name;
-  char *last_slash = strrchr(argv0, '/');
-  assert(last_slash);
-  int res =
-      snprintf(buf, sz, "%.*s/%s", int(last_slash - argv0), argv0, basename);
-  return res < sz ? 0 : res;
-}
-
 static void dladdr_testfn() {}
 
 TEST(MemorySanitizer, dladdr) {
@@ -1801,6 +1793,20 @@
   return 0;
 }
 
+#ifndef MSAN_TEST_DISABLE_DLOPEN
+
+// Compute the path to our loadable DSO.  We assume it's in the same
+// directory.  Only use string routines that we intercept so far to do this.
+static int PathToLoadable(char *buf, size_t sz) {
+  const char *basename = "libmsan_loadable.x86_64.so";
+  char *argv0 = program_invocation_name;
+  char *last_slash = strrchr(argv0, '/');
+  assert(last_slash);
+  int res =
+      snprintf(buf, sz, "%.*s/%s", int(last_slash - argv0), argv0, basename);
+  return res < sz ? 0 : res;
+}
+
 TEST(MemorySanitizer, dl_iterate_phdr) {
   char path[4096];
   int res = PathToLoadable(path, sizeof(path));
@@ -1852,6 +1858,8 @@
   ASSERT_EQ(0, lib);
 }
 
+#endif // MSAN_TEST_DISABLE_DLOPEN
+
 TEST(MemorySanitizer, scanf) {
   const char *input = "42 hello";
   int* d = new int;