diff options
author | gsallam <123525874+gsallam@users.noreply.github.com> | 2023-05-21 10:12:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-21 10:12:24 (GMT) |
commit | be0c106789322273f1f76d232c768c09880a14bd (patch) | |
tree | 5068f5a53ac893d612272fcff8dcaa0c28ee4d69 /Lib/test/test_perfmaps.py | |
parent | 2e91c7e62609ef405901dd5c4cb9d5aa794591ab (diff) | |
download | cpython-be0c106789322273f1f76d232c768c09880a14bd.zip cpython-be0c106789322273f1f76d232c768c09880a14bd.tar.gz cpython-be0c106789322273f1f76d232c768c09880a14bd.tar.bz2 |
gh-103295: expose API for writing perf map files (#103546)
Co-authored-by: Aniket Panse <aniketpanse@fb.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
Diffstat (limited to 'Lib/test/test_perfmaps.py')
-rw-r--r-- | Lib/test/test_perfmaps.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_perfmaps.py b/Lib/test/test_perfmaps.py new file mode 100644 index 0000000..a17adb8 --- /dev/null +++ b/Lib/test/test_perfmaps.py @@ -0,0 +1,19 @@ +import os +import sys +import unittest + +from _testinternalcapi import perf_map_state_teardown, write_perf_map_entry + +if sys.platform != 'linux': + raise unittest.SkipTest('Linux only') + + +class TestPerfMapWriting(unittest.TestCase): + def test_write_perf_map_entry(self): + self.assertEqual(write_perf_map_entry(0x1234, 5678, "entry1"), 0) + self.assertEqual(write_perf_map_entry(0x2345, 6789, "entry2"), 0) + with open(f"/tmp/perf-{os.getpid()}.map") as f: + perf_file_contents = f.read() + self.assertIn("1234 162e entry1", perf_file_contents) + self.assertIn("2345 1a85 entry2", perf_file_contents) + perf_map_state_teardown() |