diff options
author | Andreas Gampe <agampe@google.com> | 2018-03-13 20:55:56 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2018-03-23 19:51:09 -0700 |
commit | 50dcbac7ac6837c05e2fa4486e4b2ccf5c8579d1 (patch) | |
tree | b3b00b8d6e8c71d2c4864cf407e2c090b375d680 /perfprofd | |
parent | b73bc962b85c9fdcf9bc4e7a8479885a18974b07 (diff) | |
download | extras-50dcbac7ac6837c05e2fa4486e4b2ccf5c8579d1.tar.gz |
Perfprofd: Support host tests
Support host gtests where it makes sense.
(cherry picked from commit 51389ceb22c1833a0c6f3b488fff47d4c7287380)
Bug: 73175642
Test: mmma system/extras/perfprofd
Test: perfprofd_test (host, target)
Merged-In: If56a3eb6addc81b0287ce984d4e2284f28bc675b
Change-Id: If56a3eb6addc81b0287ce984d4e2284f28bc675b
Diffstat (limited to 'perfprofd')
-rw-r--r-- | perfprofd/Android.bp | 1 | ||||
-rw-r--r-- | perfprofd/cpuconfig.cc | 10 | ||||
-rw-r--r-- | perfprofd/perfprofdcore.cc | 18 | ||||
-rw-r--r-- | perfprofd/tests/Android.bp | 12 | ||||
-rw-r--r-- | perfprofd/tests/perfprofd_test.cc | 13 |
5 files changed, 52 insertions, 2 deletions
diff --git a/perfprofd/Android.bp b/perfprofd/Android.bp index 498b6452..71186cf8 100644 --- a/perfprofd/Android.bp +++ b/perfprofd/Android.bp @@ -50,6 +50,7 @@ cc_library_static { defaults: [ "perfprofd_defaults", ], + host_supported: true, static_libs: [ "libbase", diff --git a/perfprofd/cpuconfig.cc b/perfprofd/cpuconfig.cc index 337da56e..0f23fd0f 100644 --- a/perfprofd/cpuconfig.cc +++ b/perfprofd/cpuconfig.cc @@ -25,7 +25,9 @@ #include <sys/wait.h> #include <android-base/logging.h> +#ifdef __BIONIC__ #include <android-base/properties.h> +#endif #include "cpuconfig.h" @@ -53,7 +55,11 @@ HardwireCpuHelper::~HardwireCpuHelper() bool HardwireCpuHelper::GetMpdecisionRunning() { +#ifdef __BIONIC__ return android::base::GetProperty("init.svc.mpdecision", "") == "running"; +#else + return false; +#endif } @@ -87,17 +93,21 @@ void HardwireCpuHelper::OnlineCore(int i, int onoff) void HardwireCpuHelper::StopMpdecision() { +#ifdef __BIONIC__ if (!android::base::SetProperty("ctl.stop", "mpdecision")) { LOG(ERROR) << "setprop ctl.stop mpdecision failed"; } +#endif } void HardwireCpuHelper::RestartMpdecision() { +#ifdef __BIONIC__ // Don't try to offline the cores we previously onlined -- let // mpdecision figure out what to do if (!android::base::SetProperty("ctl.start", "mpdecision")) { LOG(ERROR) << "setprop ctl.start mpdecision failed"; } +#endif } diff --git a/perfprofd/perfprofdcore.cc b/perfprofd/perfprofdcore.cc index d1a9d3c7..3d38a39e 100644 --- a/perfprofd/perfprofdcore.cc +++ b/perfprofd/perfprofdcore.cc @@ -39,10 +39,13 @@ #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/macros.h> -#include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/unique_fd.h> +#ifdef __BIONIC__ +#include <android-base/properties.h> +#endif + #include "perfprofd_record.pb.h" #include "configreader.h" @@ -233,7 +236,11 @@ static CKPROFILE_RESULT check_profiling_enabled(const Config& config) bool get_booting() { +#ifdef __BIONIC__ return android::base::GetBoolProperty("sys.boot_completed", false) != true; +#else + return false; +#endif } // @@ -852,7 +859,11 @@ static void set_seed(uint32_t use_fixed_seed) // // Randomized seed // +#ifdef __BIONIC__ seed = arc4random(); +#else + seed = 12345678u; +#endif } LOG(INFO) << "random seed set to " << seed; // Distribute the 32-bit seed into the three 16-bit array @@ -878,8 +889,13 @@ static void CommonInit(uint32_t use_fixed_seed, const char* dest_dir) { cleanup_destination_dir(dest_dir); } +#ifdef __BIONIC__ running_in_emulator = android::base::GetBoolProperty("ro.kernel.qemu", false); is_debug_build = android::base::GetBoolProperty("ro.debuggable", false); +#else + running_in_emulator = false; + is_debug_build = true; +#endif } // diff --git a/perfprofd/tests/Android.bp b/perfprofd/tests/Android.bp index 861ef3a4..dec91d5d 100644 --- a/perfprofd/tests/Android.bp +++ b/perfprofd/tests/Android.bp @@ -28,17 +28,29 @@ cc_test { "perfprofd_test_defaults", ], test_suites: ["device-tests"], + host_supported: true, stl: "libc++", static_libs: [ "libperfprofdcore", "libsimpleperf_elf_read", "libbase", + "libutils", ], shared_libs: [ "libprotobuf-cpp-lite", "liblog", ], + target: { + darwin: { + enabled: false, + }, + host: { + host_ldlibs: [ + "-lncurses", + ], + }, + }, srcs: [ "perfprofd_test.cc", ], diff --git a/perfprofd/tests/perfprofd_test.cc b/perfprofd/tests/perfprofd_test.cc index 8b0f640a..ba606861 100644 --- a/perfprofd/tests/perfprofd_test.cc +++ b/perfprofd/tests/perfprofd_test.cc @@ -32,7 +32,6 @@ #include <android-base/file.h> #include <android-base/logging.h> #include <android-base/macros.h> -#include <android-base/properties.h> #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/test_utils.h> @@ -154,6 +153,7 @@ static std::string replaceAll(const std::string &str, // // Replace occurrences of special variables in the string. // +#ifdef __ANDROID__ static std::string expandVars(const std::string &str) { #ifdef __LP64__ return replaceAll(str, "$NATIVE_TESTS", "/data/nativetest64"); @@ -161,6 +161,7 @@ static std::string expandVars(const std::string &str) { return replaceAll(str, "$NATIVE_TESTS", "/data/nativetest"); #endif } +#endif class PerfProfdTest : public testing::Test { protected: @@ -549,7 +550,11 @@ TEST_F(PerfProfdTest, BadPerfRun) runner.addToConfig("main_loop_iterations=1"); runner.addToConfig("use_fixed_seed=1"); runner.addToConfig("collection_interval=100"); +#ifdef __ANDROID__ runner.addToConfig("perf_path=/system/bin/false"); +#else + runner.addToConfig("perf_path=/bin/false"); +#endif // Create semaphore file runner.create_semaphore_file(); @@ -618,7 +623,9 @@ TEST_F(PerfProfdTest, ProfileCollectionAnnotations) // completed booted, will be on charger, and will not have the camera // active. EXPECT_FALSE(get_booting()); +#ifdef __ANDROID__ EXPECT_TRUE(get_charging()); +#endif EXPECT_FALSE(get_camera_active()); } @@ -1073,6 +1080,8 @@ TEST_F(PerfProfdTest, CallchainRunWithCannedPerf) } } +#ifdef __ANDROID__ + TEST_F(PerfProfdTest, BasicRunWithLivePerf) { // @@ -1258,6 +1267,8 @@ TEST_F(PerfProfdTest, CallChainRunWithLivePerf) EXPECT_TRUE(found_callchain) << CreateStats(encodedProfile.perf_data()); } +#endif + int main(int argc, char **argv) { // Always log to cerr, so that device failures are visible. android::base::SetLogger(android::base::StderrLogger); |