simpleperf: fix python tests on windows.
Bug: none
Test: run scripts/test/test.py.
Change-Id: I72edc4dcc66208821c14438b2710d6f132700fc5
diff --git a/simpleperf/scripts/test/pprof_proto_generator_test.py b/simpleperf/scripts/test/pprof_proto_generator_test.py
index 4337d70..0d96484 100644
--- a/simpleperf/scripts/test/pprof_proto_generator_test.py
+++ b/simpleperf/scripts/test/pprof_proto_generator_test.py
@@ -249,6 +249,7 @@
def test_comments(self):
profile = self.generate_profile(None, ['perf_with_interpreter_frames.data'])
comments = "\n".join([profile.string_table[i] for i in profile.comment])
+ comments = comments.replace('\\', '/')
self.assertIn('Simpleperf Record Command:\n/data/data/com.google.sample.tunnel/simpleperf record --in-app --tracepoint-events /data/local/tmp/tracepoint_events --app com.google.sample.tunnel -g --no-post-unwind --duration 30', comments)
self.assertIn('Converted to pprof with:', comments)
# The full path changes per-machine, so only assert on a subset of the
diff --git a/simpleperf/scripts/test/report_sample_test.py b/simpleperf/scripts/test/report_sample_test.py
index a29e677..4b09f82 100644
--- a/simpleperf/scripts/test/report_sample_test.py
+++ b/simpleperf/scripts/test/report_sample_test.py
@@ -30,6 +30,7 @@
'-i',
TestHelper.testdata_path('perf_display_bitmaps.data')],
return_output=True)
+ got = got.replace('\r', '')
with open(TestHelper.testdata_path('perf_display_bitmaps.perf-script')) as f:
want = f.read()
self.assertEqual(got, want)
@@ -41,6 +42,7 @@
TestHelper.testdata_path('perf_display_bitmaps.data'),
'--comm', 'RenderThread'],
return_output=True)
+ got = got.replace('\r', '')
self.assertIn('RenderThread', got)
self.assertNotIn('com.example.android.displayingbitmaps', got)
@@ -55,6 +57,7 @@
TestHelper.testdata_path('perf_display_bitmaps.data'),
'--comm', 'com.example.android.displayingbitmaps'],
return_output=True)
+ got = got.replace('\r', '')
self.assertIn('com.example.android.displayingbitmaps', got)
self.assertNotIn('RenderThread', got)
with open(TestHelper.testdata_path('perf_display_bitmaps.UiThread.perf-script')) as f:
@@ -68,6 +71,7 @@
TestHelper.testdata_path('perf_display_bitmaps.data'),
'--header'],
return_output=True)
+ got = got.replace('\r', '')
with open(TestHelper.testdata_path('perf_display_bitmaps.header.perf-script')) as f:
want = f.read()
self.assertEqual(got, want)
diff --git a/simpleperf/scripts/test/stackcollapse_test.py b/simpleperf/scripts/test/stackcollapse_test.py
index 02f489f..fee3922 100644
--- a/simpleperf/scripts/test/stackcollapse_test.py
+++ b/simpleperf/scripts/test/stackcollapse_test.py
@@ -32,6 +32,7 @@
'-i', TestHelper.testdata_path('perf_with_jit_symbol.data'),
'--jit',
], return_output=True)
+ got = got.replace('\r', '')
golden_path = TestHelper.testdata_path('perf_with_jit_symbol.foldedstack')
self.assertEqual(got, Path(golden_path).read_text())
@@ -41,6 +42,7 @@
'-i', TestHelper.testdata_path('perf_with_jit_symbol.data'),
'--kernel',
], return_output=True)
+ got = got.replace('\r', '')
golden_path = TestHelper.testdata_path('perf_with_jit_symbol.foldedstack_with_kernel')
self.assertEqual(got, Path(golden_path).read_text())
@@ -51,6 +53,7 @@
'--jit',
'--pid',
], return_output=True)
+ got = got.replace('\r', '')
golden_path = TestHelper.testdata_path('perf_with_jit_symbol.foldedstack_with_pid')
self.assertEqual(got, Path(golden_path).read_text())
@@ -61,6 +64,7 @@
'--jit',
'--tid',
], return_output=True)
+ got = got.replace('\r', '')
golden_path = TestHelper.testdata_path('perf_with_jit_symbol.foldedstack_with_tid')
self.assertEqual(got, Path(golden_path).read_text())
@@ -69,6 +73,7 @@
'stackcollapse.py',
'-i', TestHelper.testdata_path('perf_with_two_event_types.data'),
], return_output=True)
+ got = got.replace('\r', '')
golden_path = TestHelper.testdata_path('perf_with_two_event_types.foldedstack')
self.assertEqual(got, Path(golden_path).read_text())
@@ -78,6 +83,7 @@
'-i', TestHelper.testdata_path('perf_with_two_event_types.data'),
'--event-filter', 'cpu-clock',
], return_output=True)
+ got = got.replace('\r', '')
golden_path = TestHelper.testdata_path('perf_with_two_event_types.foldedstack_cpu_clock')
self.assertEqual(got, Path(golden_path).read_text())
@@ -87,6 +93,7 @@
'-i', TestHelper.testdata_path('perf_with_jit_symbol.data'),
'--addrs',
], return_output=True)
+ got = got.replace('\r', '')
golden_path = TestHelper.testdata_path('perf_with_jit_symbol.foldedstack_addrs')
self.assertEqual(got, Path(golden_path).read_text())