Skip to content

Commit 1794532

Browse files
committed
[InstrProf] Move BPFunctionNode test to ProfileDataTests
In https://reviews.llvm.org/D147812 I created `BalancedPartitioningTest.cpp` and inadvertently drastically increased the number of files needed to compile `SupportTests`. Instead lets move the `BPFunctionNode` test to `unittests/ProfileData` so we can remove the extra dependency. Reviewed By: thakis Differential Revision: https://reviews.llvm.org/D152325
1 parent eab8c1e commit 1794532

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//===- BPFunctionNodeTest.cpp - BPFunctionNode tests ----------------------===//
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+
#include "llvm/ProfileData/InstrProf.h"
10+
#include "llvm/Support/BalancedPartitioning.h"
11+
#include "llvm/Testing/Support/SupportHelpers.h"
12+
#include "gmock/gmock.h"
13+
#include "gtest/gtest.h"
14+
15+
using testing::Field;
16+
using testing::UnorderedElementsAre;
17+
using testing::UnorderedElementsAreArray;
18+
19+
namespace llvm {
20+
21+
void PrintTo(const BPFunctionNode &Node, std::ostream *OS) {
22+
raw_os_ostream ROS(*OS);
23+
Node.dump(ROS);
24+
}
25+
26+
TEST(BPFunctionNodeTest, Basic) {
27+
auto Nodes = TemporalProfTraceTy::createBPFunctionNodes({
28+
TemporalProfTraceTy({0, 1, 2, 3, 4}),
29+
TemporalProfTraceTy({4, 2}),
30+
});
31+
32+
auto NodeIs = [](BPFunctionNode::IDT Id,
33+
ArrayRef<BPFunctionNode::UtilityNodeT> UNs) {
34+
return AllOf(Field("Id", &BPFunctionNode::Id, Id),
35+
Field("UtilityNodes", &BPFunctionNode::UtilityNodes,
36+
UnorderedElementsAreArray(UNs)));
37+
};
38+
39+
EXPECT_THAT(Nodes,
40+
UnorderedElementsAre(NodeIs(0, {0, 1, 2}), NodeIs(1, {1, 2}),
41+
NodeIs(2, {1, 2, 4, 5}), NodeIs(3, {2}),
42+
NodeIs(4, {2, 3, 4, 5})));
43+
}
44+
45+
} // end namespace llvm

llvm/unittests/ProfileData/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(LLVM_LINK_COMPONENTS
77
)
88

99
add_llvm_unittest(ProfileDataTests
10+
BPFunctionNodeTest.cpp
1011
CoverageMappingTest.cpp
1112
InstrProfDataTest.cpp
1213
InstrProfTest.cpp

llvm/unittests/Support/BalancedPartitioningTest.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/Support/BalancedPartitioning.h"
10-
#include "llvm/ProfileData/InstrProf.h"
1110
#include "llvm/Testing/Support/SupportHelpers.h"
1211
#include "gmock/gmock.h"
1312
#include "gtest/gtest.h"
1413

15-
using namespace llvm;
1614
using testing::Each;
1715
using testing::Field;
1816
using testing::Not;
@@ -26,25 +24,6 @@ void PrintTo(const BPFunctionNode &Node, std::ostream *OS) {
2624
Node.dump(ROS);
2725
}
2826

29-
TEST(BPFunctionNodeTest, Basic) {
30-
auto Nodes = TemporalProfTraceTy::createBPFunctionNodes({
31-
TemporalProfTraceTy({0, 1, 2, 3, 4}),
32-
TemporalProfTraceTy({4, 2}),
33-
});
34-
35-
auto NodeIs = [](BPFunctionNode::IDT Id,
36-
ArrayRef<BPFunctionNode::UtilityNodeT> UNs) {
37-
return AllOf(Field("Id", &BPFunctionNode::Id, Id),
38-
Field("UtilityNodes", &BPFunctionNode::UtilityNodes,
39-
UnorderedElementsAreArray(UNs)));
40-
};
41-
42-
EXPECT_THAT(Nodes,
43-
UnorderedElementsAre(NodeIs(0, {0, 1, 2}), NodeIs(1, {1, 2}),
44-
NodeIs(2, {1, 2, 4, 5}), NodeIs(3, {2}),
45-
NodeIs(4, {2, 3, 4, 5})));
46-
}
47-
4827
class BalancedPartitioningTest : public ::testing::Test {
4928
protected:
5029
BalancedPartitioningConfig Config;

llvm/unittests/Support/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
set(LLVM_LINK_COMPONENTS
2-
ProfileData
32
Support
43
TargetParser
54
)

0 commit comments

Comments
 (0)