]> git.proxmox.com Git - rustc.git/blobdiff - src/compiler-rt/lib/sanitizer_common/tests/sanitizer_common_test.cc
Imported Upstream version 1.6.0+dfsg1
[rustc.git] / src / compiler-rt / lib / sanitizer_common / tests / sanitizer_common_test.cc
index 3150d565d77118a3ddc4bf5e2c3213027f9fe961..c1bb797db203cf711429ff0230d634a8abf66b91 100644 (file)
@@ -15,6 +15,9 @@
 #include "sanitizer_common/sanitizer_flags.h"
 #include "sanitizer_common/sanitizer_libc.h"
 #include "sanitizer_common/sanitizer_platform.h"
+
+#include "sanitizer_pthread_wrappers.h"
+
 #include "gtest/gtest.h"
 
 namespace __sanitizer {
@@ -159,8 +162,8 @@ TEST(SanitizerCommon, ThreadStackTlsMain) {
 TEST(SanitizerCommon, ThreadStackTlsWorker) {
   InitTlsSize();
   pthread_t t;
-  pthread_create(&t, 0, WorkerThread, 0);
-  pthread_join(t, 0);
+  PTHREAD_CREATE(&t, 0, WorkerThread, 0);
+  PTHREAD_JOIN(t, 0);
 }
 
 bool UptrLess(uptr a, uptr b) {
@@ -185,6 +188,15 @@ TEST(SanitizerCommon, FindPathToBinary) {
   InternalFree(true_path);
   EXPECT_EQ(0, FindPathToBinary("unexisting_binary.ergjeorj"));
 }
+#elif SANITIZER_WINDOWS
+TEST(SanitizerCommon, FindPathToBinary) {
+  // ntdll.dll should be on PATH in all supported test environments on all
+  // supported Windows versions.
+  char *ntdll_path = FindPathToBinary("ntdll.dll");
+  EXPECT_NE((char*)0, internal_strstr(ntdll_path, "ntdll.dll"));
+  InternalFree(ntdll_path);
+  EXPECT_EQ(0, FindPathToBinary("unexisting_binary.ergjeorj"));
+}
 #endif
 
 TEST(SanitizerCommon, StripPathPrefix) {
@@ -223,40 +235,4 @@ TEST(SanitizerCommon, InternalScopedString) {
   EXPECT_STREQ("012345678", str.data());
 }
 
-TEST(SanitizerCommon, PrintSourceLocation) {
-  InternalScopedString str(128);
-  PrintSourceLocation(&str, "/dir/file.cc", 10, 5);
-  EXPECT_STREQ("/dir/file.cc:10:5", str.data());
-
-  str.clear();
-  PrintSourceLocation(&str, "/dir/file.cc", 11, 0);
-  EXPECT_STREQ("/dir/file.cc:11", str.data());
-
-  str.clear();
-  PrintSourceLocation(&str, "/dir/file.cc", 0, 0);
-  EXPECT_STREQ("/dir/file.cc", str.data());
-
-  // Check that we strip file prefix if necessary.
-  const char *old_strip_path_prefix = common_flags()->strip_path_prefix;
-  common_flags()->strip_path_prefix = "/dir/";
-  str.clear();
-  PrintSourceLocation(&str, "/dir/file.cc", 10, 5);
-  EXPECT_STREQ("file.cc:10:5", str.data());
-  common_flags()->strip_path_prefix = old_strip_path_prefix;
-}
-
-TEST(SanitizerCommon, PrintModuleAndOffset) {
-  InternalScopedString str(128);
-  PrintModuleAndOffset(&str, "/dir/exe", 0x123);
-  EXPECT_STREQ("(/dir/exe+0x123)", str.data());
-
-  // Check that we strip file prefix if necessary.
-  const char *old_strip_path_prefix = common_flags()->strip_path_prefix;
-  common_flags()->strip_path_prefix = "/dir/";
-  str.clear();
-  PrintModuleAndOffset(&str, "/dir/exe", 0x123);
-  EXPECT_STREQ("(exe+0x123)", str.data());
-  common_flags()->strip_path_prefix = old_strip_path_prefix;
-}
-
 }  // namespace __sanitizer