#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 {
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) {
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) {
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