summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2022-01-26 02:05:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2022-01-26 02:05:48 +0000
commit8f71c9629dd12044a147eb76ff12fe3be5819376 (patch)
tree06ccb55b744a7045220ed0fce219a02bb5859bad
parent299c08ac419e0aa8f6c1d388fac10d5ec4bc4212 (diff)
parent1c1cb93d5d2da01e9951ae4edb31a8eadbcc222d (diff)
downloadextras-8f71c9629dd12044a147eb76ff12fe3be5819376.tar.gz
Merge changes I72edc4dc,Iead7bd25
* changes: simpleperf: fix python tests on windows. simpleperf: fix sample filter tests on windows.
-rw-r--r--simpleperf/scripts/test/annotate_test.py4
-rw-r--r--simpleperf/scripts/test/gecko_profile_generator_test.py4
-rw-r--r--simpleperf/scripts/test/inferno_test.py4
-rw-r--r--simpleperf/scripts/test/pprof_proto_generator_test.py5
-rw-r--r--simpleperf/scripts/test/report_html_test.py4
-rw-r--r--simpleperf/scripts/test/report_lib_test.py4
-rw-r--r--simpleperf/scripts/test/report_sample_test.py8
-rw-r--r--simpleperf/scripts/test/stackcollapse_test.py11
8 files changed, 36 insertions, 8 deletions
diff --git a/simpleperf/scripts/test/annotate_test.py b/simpleperf/scripts/test/annotate_test.py
index b7e06b47..eef5133a 100644
--- a/simpleperf/scripts/test/annotate_test.py
+++ b/simpleperf/scripts/test/annotate_test.py
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
from pathlib import Path
import re
import tempfile
@@ -68,7 +69,8 @@ class TestAnnotate(TestBase):
get_report('--exclude-thread-name com.example.android.displayingbitmaps')
get_report('--include-thread-name com.example.android.displayingbitmaps')
- with tempfile.NamedTemporaryFile('w') as filter_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as filter_file:
filter_file.write('GLOBAL_BEGIN 684943449406175\nGLOBAL_END 684943449406176')
filter_file.flush()
get_report('--filter-file ' + filter_file.name)
+ os.unlink(filter_file.name)
diff --git a/simpleperf/scripts/test/gecko_profile_generator_test.py b/simpleperf/scripts/test/gecko_profile_generator_test.py
index e0a00b3b..54bde746 100644
--- a/simpleperf/scripts/test/gecko_profile_generator_test.py
+++ b/simpleperf/scripts/test/gecko_profile_generator_test.py
@@ -15,6 +15,7 @@
# limitations under the License.
import json
+import os
import re
import tempfile
from typing import Set
@@ -63,9 +64,10 @@ class TestGeckoProfileGenerator(TestBase):
self.assertIn(31850, get_threads_for_filter(
'--include-thread-name com.example.android.displayingbitmaps'))
- with tempfile.NamedTemporaryFile('w') as filter_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as filter_file:
filter_file.write('GLOBAL_BEGIN 684943449406175\nGLOBAL_END 684943449406176')
filter_file.flush()
threads = get_threads_for_filter('--filter-file ' + filter_file.name)
self.assertIn(31881, threads)
self.assertNotIn(31850, threads)
+ os.unlink(filter_file.name)
diff --git a/simpleperf/scripts/test/inferno_test.py b/simpleperf/scripts/test/inferno_test.py
index 00ec8c50..bddb2200 100644
--- a/simpleperf/scripts/test/inferno_test.py
+++ b/simpleperf/scripts/test/inferno_test.py
@@ -16,6 +16,7 @@
import collections
import json
+import os
import re
import tempfile
from typing import Any, Dict, List, Set
@@ -73,9 +74,10 @@ class TestInferno(TestBase):
self.assertIn(31850, get_threads_for_filter(
'--include-thread-name com.example.android.displayingbitmaps'))
- with tempfile.NamedTemporaryFile('w') as filter_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as filter_file:
filter_file.write('GLOBAL_BEGIN 684943449406175\nGLOBAL_END 684943449406176')
filter_file.flush()
threads = get_threads_for_filter('--filter-file ' + filter_file.name)
self.assertIn(31881, threads)
self.assertNotIn(31850, threads)
+ os.unlink(filter_file.name)
diff --git a/simpleperf/scripts/test/pprof_proto_generator_test.py b/simpleperf/scripts/test/pprof_proto_generator_test.py
index ddee18ce..0d964841 100644
--- a/simpleperf/scripts/test/pprof_proto_generator_test.py
+++ b/simpleperf/scripts/test/pprof_proto_generator_test.py
@@ -16,6 +16,7 @@
from collections import namedtuple
import google.protobuf
+import os
import re
import tempfile
from typing import List, Optional, Set
@@ -248,6 +249,7 @@ class TestPprofProtoGenerator(TestBase):
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
@@ -280,9 +282,10 @@ class TestPprofProtoGenerator(TestBase):
self.assertIn(31850, get_threads_for_filter(
'--include-thread-name com.example.android.displayingbitmaps'))
- with tempfile.NamedTemporaryFile('w') as filter_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as filter_file:
filter_file.write('GLOBAL_BEGIN 684943449406175\nGLOBAL_END 684943449406176')
filter_file.flush()
threads = get_threads_for_filter('--filter-file ' + filter_file.name)
self.assertIn(31881, threads)
self.assertNotIn(31850, threads)
+ os.unlink(filter_file.name)
diff --git a/simpleperf/scripts/test/report_html_test.py b/simpleperf/scripts/test/report_html_test.py
index 73dc8624..0ae99e95 100644
--- a/simpleperf/scripts/test/report_html_test.py
+++ b/simpleperf/scripts/test/report_html_test.py
@@ -16,6 +16,7 @@
import collections
import json
+import os
import tempfile
from typing import Any, Dict, List, Set
@@ -235,9 +236,10 @@ class TestReportHtml(TestBase):
self.assertIn(31850, get_threads_for_filter(
'--include-thread-name com.example.android.displayingbitmaps'))
- with tempfile.NamedTemporaryFile('w') as filter_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as filter_file:
filter_file.write('GLOBAL_BEGIN 684943449406175\nGLOBAL_END 684943449406176')
filter_file.flush()
threads = get_threads_for_filter('--filter-file ' + filter_file.name)
self.assertIn(31881, threads)
self.assertNotIn(31850, threads)
+ os.unlink(filter_file.name)
diff --git a/simpleperf/scripts/test/report_lib_test.py b/simpleperf/scripts/test/report_lib_test.py
index 61899459..ba7ae466 100644
--- a/simpleperf/scripts/test/report_lib_test.py
+++ b/simpleperf/scripts/test/report_lib_test.py
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
import tempfile
from typing import Set
@@ -298,9 +299,10 @@ class TestReportLib(TestBase):
self.assertIn(31850, get_threads_for_filter(
'--include-thread-name com.example.android.displayingbitmaps'))
- with tempfile.NamedTemporaryFile('w') as filter_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as filter_file:
filter_file.write('GLOBAL_BEGIN 684943449406175\nGLOBAL_END 684943449406176')
filter_file.flush()
threads = get_threads_for_filter('--filter-file ' + filter_file.name)
self.assertIn(31881, threads)
self.assertNotIn(31850, threads)
+ os.unlink(filter_file.name)
diff --git a/simpleperf/scripts/test/report_sample_test.py b/simpleperf/scripts/test/report_sample_test.py
index 5f1e0aa3..4b09f82f 100644
--- a/simpleperf/scripts/test/report_sample_test.py
+++ b/simpleperf/scripts/test/report_sample_test.py
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
import re
import tempfile
from typing import Set
@@ -29,6 +30,7 @@ class TestReportSample(TestBase):
'-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)
@@ -40,6 +42,7 @@ class TestReportSample(TestBase):
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)
@@ -54,6 +57,7 @@ class TestReportSample(TestBase):
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:
@@ -67,6 +71,7 @@ class TestReportSample(TestBase):
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)
@@ -104,9 +109,10 @@ class TestReportSample(TestBase):
self.assertIn(31850, get_threads_for_filter(
'--include-thread-name com.example.android.displayingbitmaps'))
- with tempfile.NamedTemporaryFile('w') as filter_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as filter_file:
filter_file.write('GLOBAL_BEGIN 684943449406175\nGLOBAL_END 684943449406176')
filter_file.flush()
threads = get_threads_for_filter('--filter-file ' + filter_file.name)
self.assertIn(31881, threads)
self.assertNotIn(31850, threads)
+ os.unlink(filter_file.name)
diff --git a/simpleperf/scripts/test/stackcollapse_test.py b/simpleperf/scripts/test/stackcollapse_test.py
index 91c9b6a2..fee39222 100644
--- a/simpleperf/scripts/test/stackcollapse_test.py
+++ b/simpleperf/scripts/test/stackcollapse_test.py
@@ -15,6 +15,7 @@
# limitations under the License.
import json
+import os
from pathlib import Path
import re
import tempfile
@@ -31,6 +32,7 @@ class TestStackCollapse(TestBase):
'-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())
@@ -40,6 +42,7 @@ class TestStackCollapse(TestBase):
'-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())
@@ -50,6 +53,7 @@ class TestStackCollapse(TestBase):
'--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())
@@ -60,6 +64,7 @@ class TestStackCollapse(TestBase):
'--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())
@@ -68,6 +73,7 @@ class TestStackCollapse(TestBase):
'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())
@@ -77,6 +83,7 @@ class TestStackCollapse(TestBase):
'-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())
@@ -86,6 +93,7 @@ class TestStackCollapse(TestBase):
'-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())
@@ -114,9 +122,10 @@ class TestStackCollapse(TestBase):
self.assertIn(31850, get_threads_for_filter(
'--include-thread-name com.example.android.displayingbitmaps'))
- with tempfile.NamedTemporaryFile('w') as filter_file:
+ with tempfile.NamedTemporaryFile('w', delete=False) as filter_file:
filter_file.write('GLOBAL_BEGIN 684943449406175\nGLOBAL_END 684943449406176')
filter_file.flush()
threads = get_threads_for_filter('--filter-file ' + filter_file.name)
self.assertIn(31881, threads)
self.assertNotIn(31850, threads)
+ os.unlink(filter_file.name)