1/* 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 27static 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 33static 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)); 40 } else if (r1.header.type == PERF_RECORD_BUILD_ID) { 41 CheckBuildIdRecordDataEqual(static_cast<const BuildIdRecord&>(r1), 42 static_cast<const BuildIdRecord&>(r2)); 43 } 44} 45