• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PerfTextParser(TestSuite):
23
24  def test_perf_text_smoke(self):
25    return DiffTestBlueprint(
26        trace=DataPath('trace_processor_perf_as_text.txt'),
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]","_start","/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2",1,2
37          1,0,"[unknown]","[unknown]",1,1
38          2,"[NULL]","_dl_start","/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2",1,1
39          3,"[NULL]","_dl_start_user","/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2",0,16
40          4,3,"_dl_start","/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2",2,5
41          5,4,"[unknown]","[unknown]",3,3
42          6,"[NULL]","[unknown]","[unknown]",0,27
43          7,6,"[unknown]","[unknown]",0,3
44          8,7,"__GI___tunables_init","/usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2",1,2
45          9,8,"[unknown]","[unknown]",1,1
46        '''))
47
48  def test_perf_text_simpleperf_smoke(self):
49    return DiffTestBlueprint(
50        trace=DataPath('simpleperf_as_text.txt'),
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          LIMIT 10
57        """,
58        out=Csv('''
59          "id","parent_id","name","mapping_name","self_count","cumulative_count"
60          0,"[NULL]","__libc_init","/apex/com.android.runtime/lib64/bionic/libc.so",0,1714
61          1,0,"main","/system/bin/app_process64",0,1714
62          2,1,"android::AndroidRuntime::start(char const*, android::Vector<android::String8> const&, bool)","/system/lib64/libandroid_runtime.so",0,1714
63          3,2,"_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)","/system/lib64/libandroid_runtime.so",0,1714
64          4,3,"art::JNI<true>::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)","/apex/com.android.art/lib64/libart.so",0,1714
65          5,4,"art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)","/apex/com.android.art/lib64/libart.so",0,1714
66          6,5,"art_quick_invoke_static_stub","/apex/com.android.art/lib64/libart.so",0,1714
67          7,6,"com.android.internal.os.ZygoteInit.main","/system/framework/arm64/boot-framework.oat",0,1714
68          8,7,"com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run","/system/framework/arm64/boot-framework.oat",0,1714
69          9,8,"art_jni_trampoline","/system/framework/arm64/boot.oat",0,1714
70        '''))
71