[compiler-rt] c0b1b52 - [NFC][sanitizer] Rename stack depot tests
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 16 13:38:16 PDT 2021
Author: Vitaly Buka
Date: 2021-10-16T13:38:09-07:00
New Revision: c0b1b52a28bea47cf707015993b6870eac0a7fcb
URL: https://github.com/llvm/llvm-project/commit/c0b1b52a28bea47cf707015993b6870eac0a7fcb
DIFF: https://github.com/llvm/llvm-project/commit/c0b1b52a28bea47cf707015993b6870eac0a7fcb.diff
LOG: [NFC][sanitizer] Rename stack depot tests
Added:
Modified:
compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp b/compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp
index ab0ae7896e5ae..113c41eaa1b5d 100644
--- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp
+++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_stackdepot_test.cpp
@@ -24,7 +24,16 @@
namespace __sanitizer {
-TEST(SanitizerCommon, StackDepotBasic) {
+class StackDepotTest : public testing::Test {
+ protected:
+ void TearDown() override {
+ StackDepotStats stack_depot_stats = StackDepotGetStats();
+ Printf("StackDepot: %zd ids; %zdM allocated\n",
+ stack_depot_stats.n_uniq_ids, stack_depot_stats.allocated >> 20);
+ }
+};
+
+TEST_F(StackDepotTest, Basic) {
uptr array[] = {1, 2, 3, 4, 5};
StackTrace s1(array, ARRAY_SIZE(array));
u32 i1 = StackDepotPut(s1);
@@ -34,23 +43,23 @@ TEST(SanitizerCommon, StackDepotBasic) {
EXPECT_EQ(0, internal_memcmp(stack.trace, array, sizeof(array)));
}
-TEST(SanitizerCommon, StackDepotAbsent) {
+TEST_F(StackDepotTest, Absent) {
StackTrace stack = StackDepotGet((1 << 30) - 1);
EXPECT_EQ((uptr*)0, stack.trace);
}
-TEST(SanitizerCommon, StackDepotEmptyStack) {
+TEST_F(StackDepotTest, EmptyStack) {
u32 i1 = StackDepotPut(StackTrace());
StackTrace stack = StackDepotGet(i1);
EXPECT_EQ((uptr*)0, stack.trace);
}
-TEST(SanitizerCommon, StackDepotZeroId) {
+TEST_F(StackDepotTest, ZeroId) {
StackTrace stack = StackDepotGet(0);
EXPECT_EQ((uptr*)0, stack.trace);
}
-TEST(SanitizerCommon, StackDepotSame) {
+TEST_F(StackDepotTest, Same) {
uptr array[] = {1, 2, 3, 4, 6};
StackTrace s1(array, ARRAY_SIZE(array));
u32 i1 = StackDepotPut(s1);
@@ -62,7 +71,7 @@ TEST(SanitizerCommon, StackDepotSame) {
EXPECT_EQ(0, internal_memcmp(stack.trace, array, sizeof(array)));
}
-TEST(SanitizerCommon, StackDepotSeveral) {
+TEST_F(StackDepotTest, Several) {
uptr array1[] = {1, 2, 3, 4, 7};
StackTrace s1(array1, ARRAY_SIZE(array1));
u32 i1 = StackDepotPut(s1);
@@ -72,7 +81,7 @@ TEST(SanitizerCommon, StackDepotSeveral) {
EXPECT_NE(i1, i2);
}
-TEST(SanitizerCommon, StackDepotPrint) {
+TEST_F(StackDepotTest, Print) {
uptr array1[] = {0x111, 0x222, 0x333, 0x444, 0x777};
StackTrace s1(array1, ARRAY_SIZE(array1));
u32 i1 = StackDepotPut(s1);
@@ -95,7 +104,7 @@ TEST(SanitizerCommon, StackDepotPrint) {
"Stack for id .*#0 0x1.*#1 0x2.*#2 0x3.*#3 0x4.*#4 0x8.*#5 0x9.*"));
}
-TEST(SanitizerCommon, StackDepotPrintNoLock) {
+TEST_F(StackDepotTest, PrintNoLock) {
u32 n = 2000;
std::vector<u32> idx2id(n);
for (u32 i = 0; i < n; ++i) {
@@ -111,13 +120,13 @@ TEST(SanitizerCommon, StackDepotPrintNoLock) {
}
}
-static struct SanitizerCommonBenchmarkparams {
+static struct StackDepotBenchmarkParams {
int UniqueStacksPerThread;
int RepeatPerThread;
int Threads;
bool UniqueThreads;
bool UseCount;
-} Params[] = {
+} params[] = {
// All traces are unique, very unusual.
{10000000, 1, 1},
{8000000, 1, 4},
@@ -139,8 +148,8 @@ static struct SanitizerCommonBenchmarkparams {
{800000, 10, 16, true, true},
};
-std::string PrintSanitizerCommonBenchmarkparams(
- const testing::TestParamInfo<SanitizerCommonBenchmarkparams>& info) {
+static std::string PrintStackDepotBenchmarkParams(
+ const testing::TestParamInfo<StackDepotBenchmarkParams>& info) {
std::stringstream name;
name << info.param.UniqueStacksPerThread << "_" << info.param.RepeatPerThread
<< "_" << info.param.Threads << (info.param.UseCount ? "_UseCount" : "")
@@ -148,8 +157,9 @@ std::string PrintSanitizerCommonBenchmarkparams(
return name.str();
}
-class SanitizerCommonBenchmark
- : public testing::TestWithParam<SanitizerCommonBenchmarkparams> {
+class StackDepotBenchmark
+ : public StackDepotTest,
+ public testing::WithParamInterface<StackDepotBenchmarkParams> {
protected:
void Run() {
auto Param = GetParam();
@@ -183,13 +193,13 @@ class SanitizerCommonBenchmark
// down check-sanitizer.
// Usage: Sanitizer-<ARCH>-Test --gtest_also_run_disabled_tests \
// '--gtest_filter=*Benchmark*'
-TEST_P(SanitizerCommonBenchmark, DISABLED_Benchmark) {
+TEST_P(StackDepotBenchmark, DISABLED_Benchmark) {
// Call in subprocess to avoid reuse of the depot.
EXPECT_EXIT((Run(), exit(0)), ::testing::ExitedWithCode(0), "");
}
-INSTANTIATE_TEST_SUITE_P(SanitizerCommonBenchmarkSuite,
- SanitizerCommonBenchmark, testing::ValuesIn(Params),
- PrintSanitizerCommonBenchmarkparams);
+INSTANTIATE_TEST_SUITE_P(StackDepotBenchmarkSuite, StackDepotBenchmark,
+ testing::ValuesIn(params),
+ PrintStackDepotBenchmarkParams);
} // namespace __sanitizer
More information about the llvm-commits
mailing list