summaryrefslogtreecommitdiff
path: root/simpleperf/record_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'simpleperf/record_test.cpp')
-rw-r--r--simpleperf/record_test.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/simpleperf/record_test.cpp b/simpleperf/record_test.cpp
index 76eebe98..32d73336 100644
--- a/simpleperf/record_test.cpp
+++ b/simpleperf/record_test.cpp
@@ -46,20 +46,20 @@ void RecordTest::CheckRecordMatchBinary(const RecordType& record) {
TEST_F(RecordTest, MmapRecordMatchBinary) {
MmapRecord record =
- CreateMmapRecord(event_attr, true, 1, 2, 0x1000, 0x2000, 0x3000, "MmapRecord");
+ CreateMmapRecord(event_attr, true, 1, 2, 0x1000, 0x2000, 0x3000, "MmapRecord", 0);
CheckRecordMatchBinary(record);
}
TEST_F(RecordTest, CommRecordMatchBinary) {
- CommRecord record = CreateCommRecord(event_attr, 1, 2, "CommRecord");
+ CommRecord record = CreateCommRecord(event_attr, 1, 2, "CommRecord", 0);
CheckRecordMatchBinary(record);
}
TEST_F(RecordTest, RecordCache_smoke) {
event_attr.sample_id_all = 1;
event_attr.sample_type |= PERF_SAMPLE_TIME;
- RecordCache cache(event_attr, 2, 2);
- MmapRecord r1 = CreateMmapRecord(event_attr, true, 1, 1, 0x100, 0x200, 0x300, "mmap_record1");
+ RecordCache cache(true, 2, 2);
+ MmapRecord r1 = CreateMmapRecord(event_attr, true, 1, 1, 0x100, 0x200, 0x300, "mmap_record1", 0);
MmapRecord r2 = r1;
MmapRecord r3 = r1;
MmapRecord r4 = r1;
@@ -67,25 +67,21 @@ TEST_F(RecordTest, RecordCache_smoke) {
r2.sample_id.time_data.time = 1;
r3.sample_id.time_data.time = 4;
r4.sample_id.time_data.time = 6;
- std::vector<char> buf1 = r1.BinaryFormat();
- std::vector<char> buf2 = r2.BinaryFormat();
- std::vector<char> buf3 = r3.BinaryFormat();
- std::vector<char> buf4 = r4.BinaryFormat();
// Push r1.
- cache.Push(buf1.data(), buf1.size());
+ cache.Push(std::unique_ptr<Record>(new MmapRecord(r1)));
ASSERT_EQ(nullptr, cache.Pop());
// Push r2.
- cache.Push(buf2.data(), buf2.size());
+ cache.Push(std::unique_ptr<Record>(new MmapRecord(r2)));
// Pop r2.
std::unique_ptr<Record> popped_r = cache.Pop();
ASSERT_TRUE(popped_r != nullptr);
CheckRecordEqual(r2, *popped_r);
ASSERT_EQ(nullptr, cache.Pop());
// Push r3.
- cache.Push(buf3.data(), buf3.size());
+ cache.Push(std::unique_ptr<Record>(new MmapRecord(r3)));
ASSERT_EQ(nullptr, cache.Pop());
// Push r4.
- cache.Push(buf4.data(), buf4.size());
+ cache.Push(std::unique_ptr<Record>(new MmapRecord(r4)));
// Pop r1.
popped_r = cache.Pop();
ASSERT_TRUE(popped_r != nullptr);
@@ -104,13 +100,12 @@ TEST_F(RecordTest, RecordCache_smoke) {
TEST_F(RecordTest, RecordCache_FIFO) {
event_attr.sample_id_all = 1;
event_attr.sample_type |= PERF_SAMPLE_TIME;
- RecordCache cache(event_attr, 2, 2);
+ RecordCache cache(true, 2, 2);
std::vector<MmapRecord> records;
for (size_t i = 0; i < 10; ++i) {
- MmapRecord r = CreateMmapRecord(event_attr, true, 1, i, 0x100, 0x200, 0x300, "mmap_record1");
+ MmapRecord r = CreateMmapRecord(event_attr, true, 1, i, 0x100, 0x200, 0x300, "mmap_record1", 0);
records.push_back(r);
- std::vector<char> buf = r.BinaryFormat();
- cache.Push(buf.data(), buf.size());
+ cache.Push(std::unique_ptr<Record>(new MmapRecord(r)));
}
std::vector<std::unique_ptr<Record>> out_records = cache.PopAll();
ASSERT_EQ(records.size(), out_records.size());