1#!/usr/bin/env python3 2# Copyright (C) 2023 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 a 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 16from python.generators.diff_tests.testing import DataPath 17from python.generators.diff_tests.testing import Csv 18from python.generators.diff_tests.testing import DiffTestBlueprint 19from python.generators.diff_tests.testing import TestSuite 20 21 22class GeckoParser(TestSuite): 23 24 def test_gecko_samples_smoke(self): 25 return DiffTestBlueprint( 26 trace=DataPath('trace_processor_perf_as_gecko.json'), 27 query=""" 28 INCLUDE PERFETTO MODULE stacks.cpu_profiling; 29 30 SELECT id, parent_id, name, mapping_name, self_count, cumulative_count 31 FROM cpu_profiling_summary_tree 32 LIMIT 10 33 """, 34 out=Csv(''' 35 "id","parent_id","name","mapping_name","self_count","cumulative_count" 36 0,"[NULL]","__libc_start_call_main","/usr/lib/x86_64-linux-gnu/libc.so.6",0,37030 37 1,0,"main","/usr/local/google/home/lalitm/perfetto/out/linux_clang_release/trace_processor_shell",0,37030 38 2,1,"perfetto::trace_processor::(anonymous namespace)::TraceProcessorMain(int, char**)","/usr/local/google/home/lalitm/perfetto/out/linux_clang_release/trace_processor_shell",0,37030 39 3,2,"perfetto::trace_processor::(anonymous namespace)::StartInteractiveShell(perfetto::trace_processor::(anonymous namespace)::InteractiveOptions const&)","/usr/local/google/home/lalitm/perfetto/out/linux_clang_release/trace_processor_shell",0,37029 40 4,3,"read","/usr/lib/x86_64-linux-gnu/libc.so.6",8,8 41 5,3,"cfree@GLIBC_2.2.5","/usr/lib/x86_64-linux-gnu/libc.so.6",1,1 42 6,2,"clock_gettime@@GLIBC_2.17","/usr/lib/x86_64-linux-gnu/libc.so.6",1,1 43 7,3,"perfetto::trace_processor::TraceProcessorImpl::ExecuteQuery(std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char> > const&)","/usr/local/google/home/lalitm/perfetto/out/linux_clang_release/trace_processor_shell",0,37020 44 8,7,"perfetto::trace_processor::PerfettoSqlEngine::ExecuteUntilLastStatement(perfetto::trace_processor::SqlSource)","/usr/local/google/home/lalitm/perfetto/out/linux_clang_release/trace_processor_shell",0,37020 45 9,8,"perfetto::trace_processor::PerfettoSqlEngine::ExecuteInclude(perfetto::trace_processor::PerfettoSqlParser::Include const&, perfetto::trace_processor::PerfettoSqlParser const&)","/usr/local/google/home/lalitm/perfetto/out/linux_clang_release/trace_processor_shell",0,37020 46 ''')) 47 48 def test_gecko_samples_simpleperf_smoke(self): 49 return DiffTestBlueprint( 50 trace=DataPath('simpleperf_as_gecko.json'), 51 query=""" 52 INCLUDE PERFETTO MODULE stacks.cpu_profiling; 53 54 SELECT id, parent_id, name, mapping_name, self_count, cumulative_count 55 FROM cpu_profiling_summary_tree 56 ORDER BY cumulative_count desc 57 LIMIT 10 58 """, 59 out=Csv(''' 60 "id","parent_id","name","mapping_name","self_count","cumulative_count" 61 13260,"[NULL]","__start_thread","/apex/com.android.runtime/lib64/bionic/libc.so",0,5551 62 13261,13260,"__pthread_start(void*)","/apex/com.android.runtime/lib64/bionic/libc.so",0,5551 63 13262,13261,"art::Thread::CreateCallbackWithUffdGc(void*)","/apex/com.android.art/lib64/libart.so",0,3043 64 13263,13262,"art::Thread::CreateCallback(void*)","/apex/com.android.art/lib64/libart.so",2,3043 65 13266,13263,"art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)","/apex/com.android.art/lib64/libart.so",0,3036 66 13267,13266,"art_quick_invoke_stub","/apex/com.android.art/lib64/libart.so",0,3036 67 13268,13267,"java.lang.Thread.run","/system/framework/arm64/boot.oat",0,2159 68 0,"[NULL]","__libc_init","/apex/com.android.runtime/lib64/bionic/libc.so",0,1714 69 1,0,"main","/system/bin/app_process64",0,1714 70 2,1,"android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)","/system/lib64/libandroid_runtime.so",0,1714 71 ''')) 72