• 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 TablesSched(TestSuite):
23  # Sched table
24  def test_synth_1_filter_sched(self):
25    return DiffTestBlueprint(
26        trace=Path('../common/synth_1.py'),
27        query="""
28        SELECT ts, cpu, dur FROM sched
29        WHERE
30          cpu = 1
31          AND dur > 50
32          AND dur <= 100
33          AND ts >= 100
34          AND ts <= 400;
35        """,
36        out=Csv("""
37        "ts","cpu","dur"
38        170,1,80
39        """))
40
41  def test_android_sched_and_ps_b119496959(self):
42    return DiffTestBlueprint(
43        trace=DataPath('android_sched_and_ps.pb'),
44        query="""
45        SELECT ts, cpu FROM sched WHERE ts >= 81473797418963 LIMIT 10;
46        """,
47        out=Csv("""
48        "ts","cpu"
49        81473797824982,3
50        81473797942847,3
51        81473798135399,0
52        81473798786857,2
53        81473798875451,3
54        81473799019930,2
55        81473799079982,0
56        81473800089357,3
57        81473800144461,3
58        81473800441805,3
59        """))
60
61  def test_android_sched_and_ps_b119301023(self):
62    return DiffTestBlueprint(
63        trace=DataPath('android_sched_and_ps.pb'),
64        query="""
65        SELECT ts FROM sched
66        WHERE ts > 0.1 + 1e9
67        LIMIT 10;
68        """,
69        out=Csv("""
70        "ts"
71        81473010031230
72        81473010109251
73        81473010121751
74        81473010179772
75        81473010203886
76        81473010234720
77        81473010278522
78        81473010308470
79        81473010341386
80        81473010352792
81        """))
82