summaryrefslogtreecommitdiff
path: root/simpleperf/cmd_record_test.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2020-10-21 14:12:22 -0700
committerYabin Cui <yabinc@google.com>2020-10-21 14:12:22 -0700
commit54b64a03aae5eb599c4bbb37fbc23b52f03fd0f1 (patch)
treeac96de7836c0a1311588f50195075b54a7430da1 /simpleperf/cmd_record_test.cpp
parent4bc290deff1710dd6ee96e8fb5b8c481df195a0f (diff)
downloadextras-54b64a03aae5eb599c4bbb37fbc23b52f03fd0f1.tar.gz
simpleperf: fix cts tests build for aosp_x86*.
Cts tests built for aosp_x86 or aosp_x86_64 may run on cloud Android. Bug: 171367428 Test: run CtsSimpleperfTestCases. Change-Id: I90f2d7d33dd63c3b71875f1a5c3e9bce94fc2e56
Diffstat (limited to 'simpleperf/cmd_record_test.cpp')
-rw-r--r--simpleperf/cmd_record_test.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index bcb845f2..87cef355 100644
--- a/simpleperf/cmd_record_test.cpp
+++ b/simpleperf/cmd_record_test.cpp
@@ -283,6 +283,14 @@ static bool InCloudAndroid() {
android::base::StartsWith(prop_value, "aosp_cf_x86_64_phone")) {
return true;
}
+ // aosp_x86* builds may also run on cloud Android. Detect it by checking
+ /// if cpu-cycles isn't supported.
+ if (android::base::StartsWith(prop_value, "aosp_x86")) {
+ const EventType* type = FindEventTypeByName("cpu-cycles", false);
+ CHECK(type != nullptr);
+ perf_event_attr attr = CreateDefaultPerfEventAttr(*type);
+ return !IsEventAttrSupported(attr, "cpu-cycles");
+ }
#endif
#endif
return false;