diff options
author | Dean Michael Berris <dberris@google.com> | 2018-11-09 07:43:30 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2018-11-09 07:43:30 +0000 |
commit | 9e089fca7e1ebee3be7daac06260078cb5bac558 (patch) | |
tree | 052720e38386c0d1f9162fa80c0f3806c4118921 /compiler-rt/lib/xray/tests | |
parent | ead47aab7827c9720f2f85291a86164f982eeb59 (diff) | |
download | bcm5719-llvm-9e089fca7e1ebee3be7daac06260078cb5bac558.tar.gz bcm5719-llvm-9e089fca7e1ebee3be7daac06260078cb5bac558.zip |
[XRay] Add a test for function id encoding/decoding (NFC)
Increase test coverage for function enter/exit encoding/decoding.
llvm-svn: 346477
Diffstat (limited to 'compiler-rt/lib/xray/tests')
-rw-r--r-- | compiler-rt/lib/xray/tests/unit/fdr_controller_test.cc | 26 |
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)); |