1# Copyright 2024 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from crossbench.cli.config.probe import ProbeListConfig 6from crossbench.probes.dtrace import DTraceProbe 7from tests import test_helper 8from tests.crossbench.base import CrossbenchFakeFsTestCase 9 10 11class DTraceProbeTestCase(CrossbenchFakeFsTestCase): 12 13 def test_parse_example_config(self): 14 config_file = test_helper.config_dir() / "doc/probe/dtrace.config.hjson" 15 self.fs.add_real_file(config_file) 16 self.assertTrue(config_file.is_file()) 17 example_script_file = config_file.parent / "dtrace.config.example.d" 18 self.fs.create_file(example_script_file, st_size=100) 19 self.assertTrue(example_script_file.is_file()) 20 probes = ProbeListConfig.parse_path(config_file).probes 21 self.assertEqual(len(probes), 1) 22 probe = probes[0] 23 self.assertIsInstance(probe, DTraceProbe) 24 isinstance(probe, DTraceProbe) 25 self.assertEqual(probe.script_path, example_script_file) 26 27 28if __name__ == "__main__": 29 test_helper.run_pytest(__file__) 30