• 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 AtraceErrorHandling(TestSuite):
23  # Check error handling when parsing print events.
24  def test_bad_print_textproto_list_slices(self):
25    return DiffTestBlueprint(
26        trace=Path('bad_print.textproto'),
27        query="""
28        SELECT ts, dur, name
29        FROM slice;
30        """,
31        out=Csv("""
32        "ts","dur","name"
33        74662603048,2,"valid_print"
34        """))
35
36  def test_bad_print_systrace_list_slices(self):
37    return DiffTestBlueprint(
38        trace=Path('bad_print.systrace'),
39        query="""
40        SELECT ts, dur, name
41        FROM slice;
42        """,
43        out=Csv("""
44        "ts","dur","name"
45        10852771242000,3000,"some event"
46        """))
47
48  def test_instant_atrace_instant_with_thread(self):
49    return DiffTestBlueprint(
50        trace=Path('instant_atrace.py'),
51        query="""
52        SELECT
53            thread.name AS thread_name,
54            instant.name AS track_name,
55            instant.ts
56        FROM slice instant
57        JOIN thread_track ON instant.track_id = thread_track.id
58        JOIN thread USING (utid)
59        WHERE dur = 0;
60        """,
61        out=Csv("""
62        "thread_name","track_name","ts"
63        "t2","t2_event",51
64        "t1","t1_event",53
65        """))
66
67  def test_instant_async_atrace_instant_async(self):
68    return DiffTestBlueprint(
69        trace=Path('instant_async_atrace.py'),
70        query="""
71        SELECT
72          process.name AS process_name,
73          process_track.name AS track_name,
74          instant.name AS instant_name,
75          ts
76        FROM slice instant
77        JOIN process_track ON instant.track_id = process_track.id
78        JOIN process USING (upid)
79        WHERE dur = 0;
80        """,
81        out=Csv("""
82        "process_name","track_name","instant_name","ts"
83        "p2","track_p2","ev1",51
84        "p1","track_p1","ev2",53
85        """))
86