1#!/usr/bin/env python3 2# Copyright (C) 2024 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 Csv, TextProto 17from python.generators.diff_tests.testing import DiffTestBlueprint 18from python.generators.diff_tests.testing import TestSuite 19 20 21class PixelStdlib(TestSuite): 22 def test_android_camera_frames(self): 23 return DiffTestBlueprint( 24 trace=TextProto(r""" 25 packet { ftrace_events { 26 cpu: 0 27 previous_bundle_end_timestamp: 2000 28 event { 29 timestamp: 2200 30 pid: 42 31 print { buf: "B|42|cam1_filter:output (frame 123)\n" } 32 } 33 event { 34 timestamp: 2700 35 pid: 42 36 print { buf: "E|42\n" } 37 } 38 }} 39 """), 40 query=""" 41 INCLUDE PERFETTO MODULE pixel.camera; 42 43 SELECT 44 ts, 45 node, 46 port_group, 47 frame_number, 48 cam_id, 49 dur 50 FROM pixel_camera_frames 51 ORDER BY ts 52 """, 53 out=Csv(""" 54 "ts","node","port_group","frame_number","cam_id","dur" 55 2200,"filter","output",123,1,500 56 """)) 57