[RISCV] Add missing SiFive P400 scheduling model test for divisions. NFC
[llvm-project.git] / compiler-rt / lib / sanitizer_common / tests / sanitizer_symbolizer_test.cpp
blobb8267e400799798fa3875ba5c8a01feb5551a591
1 //===-- sanitizer_symbolizer_test.cpp -------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Tests for sanitizer_symbolizer.h and sanitizer_symbolizer_internal.h
11 //===----------------------------------------------------------------------===//
13 #include "sanitizer_common/sanitizer_allocator_internal.h"
14 #include "sanitizer_common/sanitizer_symbolizer_internal.h"
15 #include "gtest/gtest.h"
17 namespace __sanitizer {
19 TEST(Symbolizer, ExtractToken) {
20 char *token;
21 const char *rest;
23 rest = ExtractToken("a;b;c", ";", &token);
24 EXPECT_STREQ("a", token);
25 EXPECT_STREQ("b;c", rest);
26 InternalFree(token);
28 rest = ExtractToken("aaa-bbb.ccc", ";.-*", &token);
29 EXPECT_STREQ("aaa", token);
30 EXPECT_STREQ("bbb.ccc", rest);
31 InternalFree(token);
34 TEST(Symbolizer, ExtractInt) {
35 int token;
36 const char *rest = ExtractInt("123,456;789", ";,", &token);
37 EXPECT_EQ(123, token);
38 EXPECT_STREQ("456;789", rest);
41 TEST(Symbolizer, ExtractUptr) {
42 uptr token;
43 const char *rest = ExtractUptr("123,456;789", ";,", &token);
44 EXPECT_EQ(123U, token);
45 EXPECT_STREQ("456;789", rest);
48 TEST(Symbolizer, ExtractTokenUpToDelimiter) {
49 char *token;
50 const char *rest =
51 ExtractTokenUpToDelimiter("aaa-+-bbb-+-ccc", "-+-", &token);
52 EXPECT_STREQ("aaa", token);
53 EXPECT_STREQ("bbb-+-ccc", rest);
54 InternalFree(token);
57 #if !SANITIZER_WINDOWS
58 TEST(Symbolizer, DemangleSwiftAndCXX) {
59 // Swift names are not demangled in default llvm build because Swift
60 // runtime is not linked in.
61 EXPECT_STREQ(nullptr, DemangleSwiftAndCXX("_TtSd"));
62 // Check that the rest demangles properly.
63 EXPECT_STREQ("f1(char*, int)", DemangleSwiftAndCXX("_Z2f1Pci"));
64 #if !SANITIZER_FREEBSD // QoI issue with libcxxrt on FreeBSD
65 EXPECT_STREQ(nullptr, DemangleSwiftAndCXX("foo"));
66 #endif
67 EXPECT_STREQ(nullptr, DemangleSwiftAndCXX(""));
69 #endif
71 } // namespace __sanitizer