1 # Copyright (C) 2023 The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 import unittest 15 from pathlib import Path 16 17 from plot_metrics import prepare_script 18 19 20 class PlotMetricsTest(unittest.TestCase): 21 def setUp(self) -> None: 22 self.csv_data = [ 23 "cuj,targets,SOONG_ONLY,MIXED_PROD,MIXED_STAGING", 24 "c1 WARMUP,libc adbd,5:01,7:23,9:01", 25 "c1,libc adbd,5:01,7:23,9:01", 26 "c1 rebuild,libc adbd,5:01,7:23,9:01", 27 ] 28 self.script = prepare_script("\n".join(self.csv_data), Path("blah")) 29 30 def test_prepare_script_filters_data(self): 31 filtered = "\n".join([self.csv_data[0], self.csv_data[2]]) 32 self.assertTrue(f"$data << EOD\n{filtered}\nEOD" in self.script) 33 34 def test_prepare_script_covers_each_build_type_column(self): 35 self.assertTrue(r"plot for[i=3:5] $data using" in self.script) 36 37 38 if __name__ == "__main__": 39 unittest.main() 40