1 //===-- sanitizer_symbolizer_test.cc --------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Tests for sanitizer_symbolizer.h and sanitizer_symbolizer_internal.h
12 //===----------------------------------------------------------------------===//
14 #include "sanitizer_common/sanitizer_allocator_internal.h"
15 #include "sanitizer_common/sanitizer_symbolizer_internal.h"
16 #include "gtest/gtest.h"
18 namespace __sanitizer
{
20 TEST(Symbolizer
, ExtractToken
) {
24 rest
= ExtractToken("a;b;c", ";", &token
);
25 EXPECT_STREQ("a", token
);
26 EXPECT_STREQ("b;c", rest
);
29 rest
= ExtractToken("aaa-bbb.ccc", ";.-*", &token
);
30 EXPECT_STREQ("aaa", token
);
31 EXPECT_STREQ("bbb.ccc", rest
);
35 TEST(Symbolizer
, ExtractInt
) {
37 const char *rest
= ExtractInt("123,456;789", ";,", &token
);
38 EXPECT_EQ(123, token
);
39 EXPECT_STREQ("456;789", rest
);
42 TEST(Symbolizer
, ExtractUptr
) {
44 const char *rest
= ExtractUptr("123,456;789", ";,", &token
);
45 EXPECT_EQ(123U, token
);
46 EXPECT_STREQ("456;789", rest
);
49 TEST(Symbolizer
, ExtractTokenUpToDelimiter
) {
52 ExtractTokenUpToDelimiter("aaa-+-bbb-+-ccc", "-+-", &token
);
53 EXPECT_STREQ("aaa", token
);
54 EXPECT_STREQ("bbb-+-ccc", rest
);
58 #if !SANITIZER_WINDOWS
59 TEST(Symbolizer
, DemangleSwiftAndCXX
) {
60 // Swift names are not demangled in default llvm build because Swift
61 // runtime is not linked in.
62 EXPECT_STREQ("_TtSd", DemangleSwiftAndCXX("_TtSd"));
63 // Check that the rest demangles properly.
64 EXPECT_STREQ("f1(char*, int)", DemangleSwiftAndCXX("_Z2f1Pci"));
65 #if !SANITIZER_FREEBSD // QoI issue with libcxxrt on FreeBSD
66 EXPECT_STREQ("foo", DemangleSwiftAndCXX("foo"));
68 EXPECT_STREQ("", DemangleSwiftAndCXX(""));
72 } // namespace __sanitizer