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 ParsingDebugAnnotation(TestSuite): 23 # Verify parsing of interned_string_value in DebugAnnotation proto. 24 def test_interned_string_value(self): 25 return DiffTestBlueprint( 26 trace=TextProto(r""" 27 packet { 28 trusted_packet_sequence_id: 1 29 incremental_state_cleared: true 30 track_descriptor { 31 uuid: 1 32 thread { 33 pid: 5 34 tid: 1 35 } 36 } 37 } 38 packet { 39 trusted_packet_sequence_id: 1 40 timestamp: 2000 41 interned_data { 42 debug_annotation_names { 43 iid: 1 44 name: "key" 45 } 46 debug_annotation_string_values { 47 iid: 1 48 str: "value" 49 } 50 } 51 track_event { 52 track_uuid: 1 53 type: TYPE_INSTANT 54 name: "slice1" 55 debug_annotations { 56 name_iid: 1 57 string_value_iid: 1 58 } 59 } 60 } 61 """), 62 query=""" 63 SELECT EXTRACT_ARG(s.arg_set_id, 'debug.key') AS value 64 FROM slice s; 65 """, 66 out=Csv(""" 67 "value" 68 "value" 69 """)) 70