• 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 ChromeArgs(TestSuite):
23  # Unsymbolized args.
24  def test_unsymbolized_args(self):
25    return DiffTestBlueprint(
26        trace=Path('unsymbolized_args.textproto'),
27        query=Metric('chrome_unsymbolized_args'),
28        out=TextProto(r"""
29        [perfetto.protos.chrome_unsymbolized_args]: {
30          args {
31             module: "/liblib.so"
32             build_id: "6275696c642d6964"
33             address: 123
34             google_lookup_id: "6275696c642d6964"
35           }
36           args {
37             module: "/libmonochrome_64.so"
38             build_id: "7f0715c286f8b16c10e4ad349cda3b9b56c7a773"
39             address: 234
40             google_lookup_id: "c215077ff8866cb110e4ad349cda3b9b0"
41           }
42        }
43        """))
44
45  def test_async_trace_1_count_slices(self):
46    return DiffTestBlueprint(
47        trace=DataPath('async-trace-1.json'),
48        query="""
49        SELECT COUNT(1) FROM slice;
50        """,
51        out=Csv("""
52        "COUNT(1)"
53        16
54        """))
55
56  def test_async_trace_2_count_slices(self):
57    return DiffTestBlueprint(
58        trace=DataPath('async-trace-2.json'),
59        query="""
60        SELECT COUNT(1) FROM slice;
61        """,
62        out=Csv("""
63        "COUNT(1)"
64        35
65        """))
66
67  # Chrome args class names
68  def test_chrome_args_class_names(self):
69    return DiffTestBlueprint(
70        trace=TextProto(r"""
71        packet {
72          timestamp: 0
73          incremental_state_cleared: true
74          trusted_packet_sequence_id: 1
75          track_descriptor {
76            uuid: 12345
77            thread {
78              pid: 123
79              tid: 345
80            }
81            parent_uuid: 0
82            chrome_thread {
83              thread_type: THREAD_POOL_FG_WORKER
84            }
85          }
86        }
87
88        packet {
89          trusted_packet_sequence_id: 1
90          timestamp: 0
91          incremental_state_cleared: true
92          track_event {
93            track_uuid: 12345
94            categories: "cat1"
95            type: 3
96            name: "name1"
97            [perfetto.protos.ChromeTrackEvent.android_view_dump] {
98              activity {
99                name: "A"
100                view {
101                  class_name: "abc"
102                },
103                view {
104                  class_name: "def"
105                },
106                view {
107                  class_name: "ghi"
108                }
109              }
110              activity {
111                name: "B"
112                view {
113                  class_name: "jkl"
114                }
115              }
116            }
117          }
118        }
119        """),
120        query=Metric('chrome_args_class_names'),
121        out=TextProto(r"""
122
123        [perfetto.protos.chrome_args_class_names] {
124          class_names_per_version {
125            class_name: "abc"
126            class_name: "def"
127            class_name: "ghi"
128            class_name: "jkl"
129          }
130        }
131        """))
132