1#!/usr/bin/env python3 2# Copyright 2023 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5"""Tests for benchmark_pgo_profiles.""" 6 7import io 8import json 9import unittest 10 11import benchmark_pgo_profiles 12 13 14class Test(unittest.TestCase): 15 """Tests for benchmark_pgo_profiles.""" 16 17 def test_run_data_parsing_succeeds(self): 18 run_data = benchmark_pgo_profiles.RunData.from_json( 19 "foo", 20 io.StringIO( 21 json.dumps( 22 { 23 "results": [ 24 { 25 "user": 1.2, 26 "system": 1.3, 27 }, 28 ], 29 } 30 ) 31 ), 32 ) 33 34 self.assertEqual( 35 run_data, 36 benchmark_pgo_profiles.RunData( 37 tag="foo", 38 user_time=1.2, 39 system_time=1.3, 40 ), 41 ) 42 43 def test_special_profile_parsing_succeeds(self): 44 for profile in benchmark_pgo_profiles.SpecialProfile: 45 self.assertIs( 46 profile, benchmark_pgo_profiles.parse_profile_path(str(profile)) 47 ) 48 49 50if __name__ == "__main__": 51 unittest.main() 52