summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/xray/tests
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/xray/tests')
-rw-r--r--compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc b/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc
index 1f02173256e..8967c4919ae 100644
--- a/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc
+++ b/compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc
@@ -77,6 +77,32 @@ TEST_F(FunctionSequenceTest, DefaultInitFinalizeFlush) {
AllOf(FuncId(1), RecordType(llvm::xray::RecordTypes::EXIT)))));
}
+TEST_F(FunctionSequenceTest, BoundaryFuncIdEncoding) {
+ // We ensure that we can write function id's that are at the boundary of the
+ // acceptable function ids.
+ int32_t FId = (1 << 28) - 1;
+ uint64_t TSC = 2;
+ uint16_t CPU = 1;
+ ASSERT_TRUE(C->functionEnter(FId, TSC++, CPU));
+ ASSERT_TRUE(C->functionExit(FId, TSC++, CPU));
+ ASSERT_TRUE(C->functionEnterArg(FId, TSC++, CPU, 1));
+ ASSERT_TRUE(C->functionTailExit(FId, TSC++, CPU));
+ ASSERT_TRUE(C->flush());
+ ASSERT_EQ(BQ->finalize(), BufferQueue::ErrorCode::Ok);
+
+ // Serialize the buffers then test to see we find the expected records.
+ std::string Serialized = serialize(*BQ, 3);
+ llvm::DataExtractor DE(Serialized, true, 8);
+ auto TraceOrErr = llvm::xray::loadTrace(DE);
+ EXPECT_THAT_EXPECTED(
+ TraceOrErr,
+ HasValue(ElementsAre(
+ AllOf(FuncId(FId), RecordType(llvm::xray::RecordTypes::ENTER)),
+ AllOf(FuncId(FId), RecordType(llvm::xray::RecordTypes::EXIT)),
+ AllOf(FuncId(FId), RecordType(llvm::xray::RecordTypes::ENTER_ARG)),
+ AllOf(FuncId(FId), RecordType(llvm::xray::RecordTypes::TAIL_EXIT)))));
+}
+
TEST_F(FunctionSequenceTest, ThresholdsAreEnforced) {
C = llvm::make_unique<FDRController<>>(BQ.get(), B, *W, clock_gettime, 1000);
ASSERT_TRUE(C->functionEnter(1, 2, 3));
OpenPOWER on IntegriCloud