From 44b4a19b44c4e1d791c60df763820729d2ca5c63 Mon Sep 17 00:00:00 2001 From: "pmc.waiver" Date: Thu, 7 Nov 2019 16:54:38 +0900 Subject: simpleperf:add MSM8909 into whitelist, omit tests requireing hw counters. Test: run cts -m CtsSimpleperfTestCases -t record_cmd#generate_samples_by_hw_counters Test: hw counters. Bug: 144472902 (cherry picked from commit 8a0a1ebb671bed0c910d35e71bbc083a031f7331) Change-Id: I4f5391efc96a07a26564e1c373ead202edf4c8ad --- simpleperf/cmd_record_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index fdc26e60..4db0b072 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -268,7 +268,8 @@ bool HasHardwareCounter() { if (android::base::ReadFileToString("/proc/cpuinfo", &cpu_info)) { std::string hardware = GetHardwareFromCpuInfo(cpu_info); if (std::regex_search(hardware, std::regex(R"(i\.MX6.*Quad)")) || - std::regex_search(hardware, std::regex(R"(SC7731e)")) ) { + std::regex_search(hardware, std::regex(R"(SC7731e)")) || + std::regex_search(hardware, std::regex(R"(Qualcomm Technologies, Inc MSM8909)"))) { has_hw_counter = 0; } } -- cgit v1.2.3 From eca51cbba4d36ad39625bb54ebdd88813129430a Mon Sep 17 00:00:00 2001 From: Dmytro Chystiakov Date: Tue, 7 Jan 2020 14:52:44 -0800 Subject: simpleperf: Omit dwarf-callgraph tests running on ARM binary translation Bug: b/144472912 Test: Run ARM CtsSimpleperfTestCases module Change-Id: Ia8eef58d6408532943baf5d848a77644a0adcf04 Signed-off-by: Dmytro Chystiakov (cherry picked from commit 709ee2f95cbb75512c352a1d9aafcc5296ba948d) --- simpleperf/cmd_record_test.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index 4db0b072..70e6bb37 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -688,6 +688,7 @@ TEST(record_cmd, kernel_bug_making_zero_dyn_size) { // Test a kernel bug that makes zero dyn_size in kernel < 3.13. If it fails, please cherry pick // below kernel patch: 0a196848ca365e perf: Fix arch_perf_out_copy_user default TEST_REQUIRE_HW_COUNTER(); + OMIT_TEST_ON_NON_NATIVE_ABIS(); std::vector> workloads; CreateProcesses(1, &workloads); std::string pid = std::to_string(workloads[0]->GetPid()); @@ -715,6 +716,7 @@ TEST(record_cmd, kernel_bug_making_zero_dyn_size_for_kernel_samples) { // kernels. If it fails, please cherry pick below kernel patch: // 02e184476eff8 perf/core: Force USER_DS when recording user stack data TEST_REQUIRE_HW_COUNTER(); + OMIT_TEST_ON_NON_NATIVE_ABIS(); TEST_REQUIRE_HOST_ROOT(); std::vector> workloads; CreateProcesses(1, &workloads); -- cgit v1.2.3 From 572c226db410b2c3b20e3a63cc6c5e9f0aeed65c Mon Sep 17 00:00:00 2001 From: Natalie Chiu Date: Fri, 17 Apr 2020 13:51:12 +0800 Subject: simpleperf: add Broadcom STB into whitelist, omit tests requiring hw counters. Some Socs like Broadcom STB will not be available when disable jtag(non-invasive debug), so omit tests requiring hw counters on them. Bug: 154157678 Test: run cts -m CtsSimpleperfTestCases -t record_cmd#generate_samples_by_hw_counters Test: hw counters. Change-Id: Iddfb34bfa1d66e37398bb162f8e1cfa645d756f4 --- simpleperf/cmd_record_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index 70e6bb37..b0c74674 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -269,7 +269,8 @@ bool HasHardwareCounter() { std::string hardware = GetHardwareFromCpuInfo(cpu_info); if (std::regex_search(hardware, std::regex(R"(i\.MX6.*Quad)")) || std::regex_search(hardware, std::regex(R"(SC7731e)")) || - std::regex_search(hardware, std::regex(R"(Qualcomm Technologies, Inc MSM8909)"))) { + std::regex_search(hardware, std::regex(R"(Qualcomm Technologies, Inc MSM8909)")) || + std::regex_search(hardware, std::regex(R"(Broadcom STB \(Flattened Device Tree\))"))) { has_hw_counter = 0; } } -- cgit v1.2.3 From 96765bda380b318eeaa49441d911d8a64c8e1ffc Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Tue, 18 Feb 2020 14:32:33 -0800 Subject: simpleperf: force testing run-as and app_runner separately. In CtsSimpleperfTestCases, two methods are used to record an app: through run-as and through simpleperf_app_runner. Tests don't fail unless both methods fail. This can't detect the situation when only one method fails. So change to test run-as and simpleperf_app_runner separately. Bug: 154862631 Test: run CtsSimpleperfTestCases. Change-Id: I023aa7793f748e695f809c153ed23f006e13ea12 (cherry picked from commit 94c148de3309a5510dc3d2cf820d2cb51eb07357) --- simpleperf/cmd_record_test.cpp | 8 +++++--- simpleperf/cmd_stat_test.cpp | 4 ++++ simpleperf/environment.cpp | 27 ++++++++++++++++++++++----- simpleperf/environment.h | 1 + 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index b0c74674..7ae589d7 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -792,13 +792,15 @@ static void TestRecordingApps(const std::string& app_name) { } TEST(record_cmd, app_option_for_debuggable_app) { - TEST_REQUIRE_HW_COUNTER(); TEST_REQUIRE_APPS(); + SetRunInAppToolForTesting(true, false); + TestRecordingApps("com.android.simpleperf.debuggable"); + SetRunInAppToolForTesting(false, true); TestRecordingApps("com.android.simpleperf.debuggable"); } TEST(record_cmd, app_option_for_profileable_app) { - TEST_REQUIRE_HW_COUNTER(); TEST_REQUIRE_APPS(); + SetRunInAppToolForTesting(false, true); TestRecordingApps("com.android.simpleperf.profileable"); -} +} \ No newline at end of file diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp index ecc7404e..eb0fa2f7 100644 --- a/simpleperf/cmd_stat_test.cpp +++ b/simpleperf/cmd_stat_test.cpp @@ -296,10 +296,14 @@ static void TestStatingApps(const std::string& app_name) { TEST(stat_cmd, app_option_for_debuggable_app) { TEST_REQUIRE_APPS(); + SetRunInAppToolForTesting(true, false); + TestStatingApps("com.android.simpleperf.debuggable"); + SetRunInAppToolForTesting(false, true); TestStatingApps("com.android.simpleperf.debuggable"); } TEST(stat_cmd, app_option_for_profileable_app) { TEST_REQUIRE_APPS(); + SetRunInAppToolForTesting(false, true); TestStatingApps("com.android.simpleperf.profileable"); } diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp index 3591626e..ab537dcc 100644 --- a/simpleperf/environment.cpp +++ b/simpleperf/environment.cpp @@ -808,18 +808,35 @@ class SimpleperfAppRunner : public InAppRunner { } // namespace +static bool allow_run_as = true; +static bool allow_simpleperf_app_runner = true; + +void SetRunInAppToolForTesting(bool run_as, bool simpleperf_app_runner) { + allow_run_as = run_as; + allow_simpleperf_app_runner = simpleperf_app_runner; +} + bool RunInAppContext(const std::string& app_package_name, const std::string& cmd, const std::vector& args, size_t workload_args_size, const std::string& output_filepath, bool need_tracepoint_events) { - std::unique_ptr in_app_runner(new RunAs(app_package_name)); - if (!in_app_runner->Prepare()) { + std::unique_ptr in_app_runner; + if (allow_run_as) { + in_app_runner.reset(new RunAs(app_package_name)); + if (!in_app_runner->Prepare()) { + in_app_runner = nullptr; + } + } + if (!in_app_runner && allow_simpleperf_app_runner) { in_app_runner.reset(new SimpleperfAppRunner(app_package_name)); if (!in_app_runner->Prepare()) { - LOG(ERROR) << "Package " << app_package_name - << " doesn't exist or isn't debuggable/profileable."; - return false; + in_app_runner = nullptr; } } + if (!in_app_runner) { + LOG(ERROR) << "Package " << app_package_name + << " doesn't exist or isn't debuggable/profileable."; + return false; + } return in_app_runner->RunCmdInApp(cmd, args, workload_args_size, output_filepath, need_tracepoint_events); } diff --git a/simpleperf/environment.h b/simpleperf/environment.h index 173cdcc6..074c2320 100644 --- a/simpleperf/environment.h +++ b/simpleperf/environment.h @@ -104,6 +104,7 @@ void PrepareVdsoFile(); std::set WaitForAppProcesses(const std::string& package_name); bool IsAppDebuggable(const std::string& package_name); +void SetRunInAppToolForTesting(bool run_as, bool simpleperf_app_runner); // for testing only bool RunInAppContext(const std::string& app_package_name, const std::string& cmd, const std::vector& args, size_t workload_args_size, const std::string& output_filepath, bool need_tracepoint_events); -- cgit v1.2.3 From 753493ad3feba1857359c9e9b11d0a7331482c28 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Thu, 8 Apr 2021 16:18:28 -0700 Subject: simpleperf: update test apk to run on wear devices. Bug: 184793688 Test: run simpleperf_unit_test. Change-Id: I86fb73817c95f351e453b2e75fff9f682ee7ca60 --- simpleperf/testdata/DisplayBitmaps.apk | Bin 2233798 -> 2364912 bytes simpleperf/testdata/DisplayBitmapsTest.apk | Bin 2835879 -> 2932413 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/simpleperf/testdata/DisplayBitmaps.apk b/simpleperf/testdata/DisplayBitmaps.apk index 681d0663..5b6f6967 100644 Binary files a/simpleperf/testdata/DisplayBitmaps.apk and b/simpleperf/testdata/DisplayBitmaps.apk differ diff --git a/simpleperf/testdata/DisplayBitmapsTest.apk b/simpleperf/testdata/DisplayBitmapsTest.apk index c5243ed0..91a0abf2 100644 Binary files a/simpleperf/testdata/DisplayBitmapsTest.apk and b/simpleperf/testdata/DisplayBitmapsTest.apk differ -- cgit v1.2.3 From f4c5261d008fd0726e05c2d46a43a0bc5e9f4ee5 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Wed, 28 Apr 2021 14:42:24 +0200 Subject: simpleperf: increase record duration Fixes CTS tests in CtsSimpleperfTestCases: * record_cmd#app_option_for_debuggable_app * record_cmd#app_option_for_profileable_app Bug: 189726439 Change-Id: Iedac3d8a1817043b82d320b57b8c5b89b9b4defd --- simpleperf/cmd_record_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index 7ae589d7..748fdf24 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -752,7 +752,7 @@ static void TestRecordingApps(const std::string& app_name) { // Bring the app to foreground to avoid no samples. ASSERT_TRUE(Workload::RunCmd({"am", "start", app_name + "/.MainActivity"})); TemporaryFile tmpfile; - ASSERT_TRUE(RecordCmd()->Run({"-o", tmpfile.path, "--app", app_name, "-g", "--duration", "3"})); + ASSERT_TRUE(RecordCmd()->Run({"-o", tmpfile.path, "--app", app_name, "-g", "--duration", "10"})); std::unique_ptr reader = RecordFileReader::CreateInstance(tmpfile.path); ASSERT_TRUE(reader); // Check if having samples. -- cgit v1.2.3 From 5c1ac9914a180a654680c24892ccc7f66ed14e98 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Tue, 1 Jun 2021 16:23:24 +0200 Subject: simpleperf: increase record duration Fixes CTS tests in CtsSimpleperfTestCases: * record_cmd#app_option_for_debuggable_app * record_cmd#app_option_for_profileable_app Bug: 189726439 Test: run CtsSimpleperfTestCases. Change-Id: Iedac3d8a1817043b82d320b57b8c5b89b9b4defd (cherry picked from commit 0f18a172b772f0c57ea38f36ea514ac64c9a1cce) --- simpleperf/cmd_record_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp index fdb6f5e3..50730e22 100644 --- a/simpleperf/cmd_record_test.cpp +++ b/simpleperf/cmd_record_test.cpp @@ -806,7 +806,7 @@ static void TestRecordingApps(const std::string& app_name) { // Bring the app to foreground to avoid no samples. ASSERT_TRUE(helper.StartApp("am start " + app_name + "/.MainActivity")); - ASSERT_TRUE(helper.RecordData("--app " + app_name + " -g --duration 3 -e " + GetDefaultEvent())); + ASSERT_TRUE(helper.RecordData("--app " + app_name + " -g --duration 10 -e " + GetDefaultEvent())); // Check if we can profile Java code by looking for a Java method name in dumped symbols, which // is app_name + ".MainActivity$1.run". -- cgit v1.2.3