summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_perfmaps.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_perfmaps.py')
-rw-r--r--Lib/test/test_perfmaps.py19
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()