blob: 03768dc5328393f8297e280ec1c13cb89b90b27c [file] [log] [blame]
Yabin Cui5beebc82015-05-04 20:27:57 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17static void CheckMmapRecordDataEqual(const MmapRecord& r1, const MmapRecord& r2) {
18 ASSERT_EQ(0, memcmp(&r1.data, &r2.data, sizeof(r1.data)));
19 ASSERT_EQ(r1.filename, r2.filename);
20}
21
22static void CheckCommRecordDataEqual(const CommRecord& r1, const CommRecord& r2) {
23 ASSERT_EQ(0, memcmp(&r1.data, &r2.data, sizeof(r1.data)));
24 ASSERT_EQ(r1.comm, r2.comm);
25}
26
Yabin Cui568b82a2015-05-05 19:58:07 -070027static void CheckBuildIdRecordDataEqual(const BuildIdRecord& r1, const BuildIdRecord& r2) {
28 ASSERT_EQ(r1.pid, r2.pid);
29 ASSERT_EQ(r1.build_id, r2.build_id);
30 ASSERT_EQ(r1.filename, r2.filename);
31}
32
Yabin Cui5beebc82015-05-04 20:27:57 -070033static void CheckRecordEqual(const Record& r1, const Record& r2) {
34 ASSERT_EQ(0, memcmp(&r1.header, &r2.header, sizeof(r1.header)));
35 ASSERT_EQ(0, memcmp(&r1.sample_id, &r2.sample_id, sizeof(r1.sample_id)));
36 if (r1.header.type == PERF_RECORD_MMAP) {
37 CheckMmapRecordDataEqual(static_cast<const MmapRecord&>(r1), static_cast<const MmapRecord&>(r2));
38 } else if (r1.header.type == PERF_RECORD_COMM) {
39 CheckCommRecordDataEqual(static_cast<const CommRecord&>(r1), static_cast<const CommRecord&>(r2));
Yabin Cui568b82a2015-05-05 19:58:07 -070040 } else if (r1.header.type == PERF_RECORD_BUILD_ID) {
41 CheckBuildIdRecordDataEqual(static_cast<const BuildIdRecord&>(r1),
42 static_cast<const BuildIdRecord&>(r2));
Yabin Cui5beebc82015-05-04 20:27:57 -070043 }
44}