Also fix a problem that binary_cache_builder.py tries to pull /dev/zero.
Bug: None.
Test: run test.py TestExamplePureJava.test_app_profiler_with_ctrl_c.
Change-Id: Ie99af6795bb1e81ae6e93f8b7a8907d49c048694
exclude_kernel_callchain_(false) {
// Stop profiling if parent exits.
prctl(PR_SET_PDEATHSIG, SIGHUP, 0, 0, 0);
+ // If we run `adb shell simpleperf record xxx` and stop profiling by ctrl-c, adb closes
+ // sockets connecting simpleperf. After that, simpleperf will receive SIGPIPE when writing
+ // to stdout/stderr, which is a problem when we use '--app' option. So ignore SIGPIPE to
+ // finish properly.
+ signal(SIGPIPE, SIG_IGN);
app_package_name_ = GetDefaultAppPackageName();
}
"""pull binaries needed in perf.data to binary_cache."""
for binary in self.binaries:
build_id = self.binaries[binary]
- if binary[0] != '/' or binary == "//anon":
+ if binary[0] != '/' or binary == "//anon" or binary.startswith("/dev/"):
# [kernel.kallsyms] or unknown, or something we can't find binary.
continue
binary_cache_file = binary[1:].replace('/', os.sep)
import os
import re
import shutil
+import signal
import sys
import tempfile
+import time
import unittest
from utils import *
from simpleperf_report_lib import ReportLib
def test_app_profiler(self):
self.common_test_app_profiler()
+ def test_app_profiler_with_ctrl_c(self):
+ if is_windows():
+ return
+ args = [sys.executable, "app_profiler.py", "--app", self.package_name,
+ "-r", "--duration 10000", "-nc"]
+ subproc = subprocess.Popen(args)
+ time.sleep(3)
+
+ subproc.send_signal(signal.SIGINT)
+ subproc.wait()
+ self.assertEqual(subproc.returncode, 0)
+ self.run_cmd(["report.py"])
+
def test_report(self):
self.common_test_report()
self.run_cmd(["report.py", "-g", "-o", "report.txt"])