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 SpanJoinSmoke(TestSuite): 23 24 def test_span_join_unordered_cols_synth_1(self): 25 return DiffTestBlueprint( 26 trace=Path('../../common/synth_1.py'), 27 query=Path('span_join_unordered_cols_test.sql'), 28 out=Csv(""" 29 "ts","dur","part","b1","b2","b3","a1","a2","a3" 30 10,90,0,"A",10,100,"B",2,101 31 100,1,0,"B",90,200,"C",3,102 32 5,5,1,"A",10,100,"A",1,100 33 10,40,1,"A",10,100,"B",2,101 34 50,40,1,"B",90,200,"B",2,101 35 90,10,1,"C",1,300,"B",2,101 36 100,1,1,"C",1,300,"C",3,102 37 """)) 38 39 def test_span_join_unordered_cols_synth_1_2(self): 40 return DiffTestBlueprint( 41 trace=Path('../../common/synth_1.py'), 42 query=Path('span_join_unordered_cols_reverse_test.sql'), 43 out=Csv(""" 44 "ts","dur","part","b1","b2","b3","a1","a2","a3" 45 10,90,0,"A",10,100,"B",2,101 46 100,1,0,"B",90,200,"C",3,102 47 5,5,1,"A",10,100,"A",1,100 48 10,40,1,"A",10,100,"B",2,101 49 50,40,1,"B",90,200,"B",2,101 50 90,10,1,"C",1,300,"B",2,101 51 100,1,1,"C",1,300,"C",3,102 52 """)) 53 54 def test_span_join_zero_negative_dur(self): 55 return DiffTestBlueprint( 56 trace=DataPath('android_sched_and_ps.pb'), 57 query=Path('span_join_zero_negative_dur_test.sql'), 58 out=Csv(""" 59 "ts","dur","part" 60 1,0,0 61 1,2,0 62 5,-1,0 63 5,-1,0 64 1,1,1 65 2,0,1 66 """)) 67