================ @@ -88,6 +89,45 @@ struct PerfSpeEventsTestHelper : public testing::Test { return SampleSize == DA.BasicSamples.size(); } + + /// Compare LBREntries + bool checkLBREntry(const LBREntry &Lhs, const LBREntry &Rhs) { + return Lhs.From == Rhs.From && Lhs.To == Rhs.To && + Lhs.Mispred == Rhs.Mispred; + } + + /// Parse and check SPE brstack as LBR + void parseAndCheckBrstackEvents( + uint64_t PID, + const std::vector<SmallVector<LBREntry, 2>> &ExpectedSamples) { + int NumSamples = 0; + + DataAggregator DA("<pseudo input>"); + DA.ParsingBuf = opts::ReadPerfEvents; + DA.BC = BC.get(); + DataAggregator::MMapInfo MMap; + DA.BinaryMMapInfo.insert(std::make_pair(PID, MMap)); + + // Process buffer. + while (DA.hasData()) { ---------------- kaadam wrote:
The main question is what we should test, 1) only the parser, 2) or more? The `parseBranchEvents` function does a bit more thing than just parsing the output of the `perf script`. In `parseLBREntry` function, it is also recording/verifying the parsed traces, and determine the 'From/To' BinaryFunctions based on the sampled addresses. If we have a valid trace, the from/to pairs will be appended to `BranchLBRs` container. In our cases we use a dummy ELF file, so the BranchLBRs is empty. 1) If we would like to test only the parsing mechanism, we have to extract the proper logic for the testing. 2) If we would like to test the all complex logic, it needs to use a bit more complex input. https://github.com/llvm/llvm-project/pull/129231 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits