• 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 Path, DataPath, Metric
17from python.generators.diff_tests.testing import Csv, Json, TextProto
18from python.generators.diff_tests.testing import DiffTestBlueprint
19from python.generators.diff_tests.testing import TestSuite
20
21
22class ProfilingHeapProfiling(TestSuite):
23
24  def test_heap_profile_jit(self):
25    return DiffTestBlueprint(
26        trace=Path('heap_profile_jit.textproto'),
27        query="""
28        SELECT name, mapping, rel_pc FROM stack_profile_frame ORDER BY name;
29        """,
30        out=Csv("""
31        "name","mapping","rel_pc"
32        "java_frame_1",0,4096
33        "java_frame_2",0,4096
34        """))
35
36  def test_heap_profile_deobfuscate(self):
37    return DiffTestBlueprint(
38        trace=Path('heap_profile_deobfuscate.textproto'),
39        query=Path('heap_profile_deobfuscate_test.sql'),
40        out=Csv("""
41        "deobfuscated_name","mapping","rel_pc"
42        "Bar.function1",0,4096
43        """))
44
45  def test_heap_profile_deobfuscate_2(self):
46    return DiffTestBlueprint(
47        trace=Path('heap_profile_deobfuscate_memfd.textproto'),
48        query=Path('heap_profile_deobfuscate_test.sql'),
49        out=Csv("""
50        "deobfuscated_name","mapping","rel_pc"
51        "Bar.function1",0,4096
52        """))
53
54  def test_heap_profile_dump_max_legacy(self):
55    return DiffTestBlueprint(
56        trace=Path('heap_profile_dump_max_legacy.textproto'),
57        query="""
58        SELECT id, ts, upid, heap_name, callsite_id, count, size
59        FROM heap_profile_allocation;
60        """,
61        out=Csv("""
62        "id","ts","upid","heap_name","callsite_id","count","size"
63        0,-10,2,"unknown",2,0,1000
64        1,-10,2,"unknown",3,0,90
65        """))
66
67  def test_heap_profile_dump_max(self):
68    return DiffTestBlueprint(
69        trace=Path('heap_profile_dump_max.textproto'),
70        query="""
71        SELECT id, ts, upid, heap_name, callsite_id, count, size
72        FROM heap_profile_allocation;
73        """,
74        out=Csv("""
75        "id","ts","upid","heap_name","callsite_id","count","size"
76        0,-10,2,"unknown",2,6,1000
77        1,-10,2,"unknown",3,1,90
78        """))
79