1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <gtest/gtest.h> 18 #include <algorithm> 19 #include <cctype> 20 #include <string> 21 #include <regex> 22 #include <stdio.h> 23 #include <sys/types.h> 24 #include <sys/stat.h> 25 #include <fcntl.h> 26 27 #include <android-base/stringprintf.h> 28 29 #include "perfprofdcore.h" 30 #include "configreader.h" 31 #include "perfprofdutils.h" 32 #include "perfprofdmockutils.h" 33 34 #include "perf_profile.pb.h" 35 #include "google/protobuf/text_format.h" 36 37 // 38 // Set to argv[0] on startup 39 // 40 static const char *executable_path; 41 42 // 43 // test_dir is the directory containing the test executable and 44 // any files associated with the test (will be created by the harness). 45 // 46 // dest_dir is a subdirectory of test_dir that we'll create on the fly 47 // at the start of each testpoint (into which new files can be written), 48 // then delete at end of testpoint. 49 // 50 static std::string test_dir; 51 static std::string dest_dir; 52 53 // Path to perf executable on device 54 #define PERFPATH "/system/bin/perf" 55 56 // Temporary config file that we will emit for the daemon to read 57 #define CONFIGFILE "perfprofd.conf" 58 59 static std::string encoded_file_path(int seq) 60 { 61 return android::base::StringPrintf("%s/perf.data.encoded.%d", 62 dest_dir.c_str(), seq); 63 } 64 65 class PerfProfdTest : public testing::Test { 66 protected: 67 virtual void SetUp() { 68 mock_perfprofdutils_init(); 69 create_dest_dir(); 70 yesclean(); 71 } 72 73 virtual void TearDown() { 74 mock_perfprofdutils_finish(); 75 } 76 77 void noclean() { 78 clean_ = false; 79 } 80 void yesclean() { 81 clean_ = true; 82 } 83 84 private: 85 bool clean_; 86 87 void create_dest_dir() { 88 setup_dirs(); 89 ASSERT_FALSE(dest_dir == ""); 90 if (clean_) { 91 std::string cmd("rm -rf "); 92 cmd += dest_dir; 93 system(cmd.c_str()); 94 } 95 std::string cmd("mkdir -p "); 96 cmd += dest_dir; 97 system(cmd.c_str()); 98 } 99 100 void setup_dirs() 101 { 102 if (test_dir == "") { 103 ASSERT_TRUE(executable_path != nullptr); 104 std::string s(executable_path); 105 auto found = s.find_last_of("/"); 106 test_dir = s.substr(0,found); 107 dest_dir = test_dir; 108 dest_dir += "/tmp"; 109 } 110 } 111 112 }; 113 114 static bool bothWhiteSpace(char lhs, char rhs) 115 { 116 return (std::isspace(lhs) && std::isspace(rhs)); 117 } 118 119 // 120 // Squeeze out repeated whitespace from expected/actual logs. 121 // 122 static std::string squeezeWhite(const std::string &str, 123 const char *tag, 124 bool dump=false) 125 { 126 if (dump) { fprintf(stderr, "raw %s is %s\n", tag, str.c_str()); } 127 std::string result(str); 128 std::replace( result.begin(), result.end(), '\n', ' '); 129 auto new_end = std::unique(result.begin(), result.end(), bothWhiteSpace); 130 result.erase(new_end, result.end()); 131 while (result.begin() != result.end() && std::isspace(*result.rbegin())) { 132 result.pop_back(); 133 } 134 if (dump) { fprintf(stderr, "squeezed %s is %s\n", tag, result.c_str()); } 135 return result; 136 } 137 138 /// 139 /// Helper class to kick off a run of the perfprofd daemon with a specific 140 /// config file. 141 /// 142 class PerfProfdRunner { 143 public: 144 PerfProfdRunner() 145 : config_path_(test_dir) 146 { 147 config_path_ += "/" CONFIGFILE; 148 } 149 150 ~PerfProfdRunner() 151 { 152 remove_processed_file(); 153 } 154 155 void addToConfig(const std::string &line) 156 { 157 config_text_ += line; 158 config_text_ += "\n"; 159 } 160 161 void remove_semaphore_file() 162 { 163 std::string semaphore(test_dir); 164 semaphore += "/" SEMAPHORE_FILENAME; 165 unlink(semaphore.c_str()); 166 } 167 168 void create_semaphore_file() 169 { 170 std::string semaphore(test_dir); 171 semaphore += "/" SEMAPHORE_FILENAME; 172 close(open(semaphore.c_str(), O_WRONLY|O_CREAT)); 173 } 174 175 void write_processed_file(int start_seq, int end_seq) 176 { 177 std::string processed = test_dir + "/" PROCESSED_FILENAME; 178 FILE *fp = fopen(processed.c_str(), "w"); 179 for (int i = start_seq; i < end_seq; i++) { 180 fprintf(fp, "%d\n", i); 181 } 182 fclose(fp); 183 } 184 185 void remove_processed_file() 186 { 187 std::string processed = test_dir + "/" PROCESSED_FILENAME; 188 unlink(processed.c_str()); 189 } 190 191 int invoke() 192 { 193 static const char *argv[3] = { "perfprofd", "-c", "" }; 194 argv[2] = config_path_.c_str(); 195 196 writeConfigFile(config_path_, config_text_); 197 198 // execute daemon main 199 return perfprofd_main(3, (char **) argv); 200 } 201 202 private: 203 std::string config_path_; 204 std::string config_text_; 205 206 void writeConfigFile(const std::string &config_path, 207 const std::string &config_text) 208 { 209 FILE *fp = fopen(config_path.c_str(), "w"); 210 ASSERT_TRUE(fp != nullptr); 211 fprintf(fp, "%s\n", config_text.c_str()); 212 fclose(fp); 213 } 214 }; 215 216 //...................................................................... 217 218 static void readEncodedProfile(const char *testpoint, 219 wireless_android_play_playlog::AndroidPerfProfile &encodedProfile) 220 { 221 struct stat statb; 222 int perf_data_stat_result = stat(encoded_file_path(0).c_str(), &statb); 223 ASSERT_NE(-1, perf_data_stat_result); 224 225 // read 226 std::string encoded; 227 encoded.resize(statb.st_size); 228 FILE *ifp = fopen(encoded_file_path(0).c_str(), "r"); 229 ASSERT_NE(nullptr, ifp); 230 size_t items_read = fread((void*) encoded.data(), statb.st_size, 1, ifp); 231 ASSERT_EQ(1, items_read); 232 fclose(ifp); 233 234 // decode 235 encodedProfile.ParseFromString(encoded); 236 } 237 238 static std::string encodedLoadModuleToString(const wireless_android_play_playlog::LoadModule &lm) 239 { 240 std::stringstream ss; 241 ss << "name: \"" << lm.name() << "\"\n"; 242 if (lm.build_id() != "") { 243 ss << "build_id: \"" << lm.build_id() << "\"\n"; 244 } 245 return ss.str(); 246 } 247 248 static std::string encodedModuleSamplesToString(const wireless_android_play_playlog::LoadModuleSamples &mod) 249 { 250 std::stringstream ss; 251 252 ss << "load_module_id: " << mod.load_module_id() << "\n"; 253 for (size_t k = 0; k < mod.address_samples_size(); k++) { 254 const auto &sample = mod.address_samples(k); 255 ss << " address_samples {\n"; 256 for (size_t l = 0; l < mod.address_samples(k).address_size(); 257 l++) { 258 auto address = mod.address_samples(k).address(l); 259 ss << " address: " << address << "\n"; 260 } 261 ss << " count: " << sample.count() << "\n"; 262 ss << " }\n"; 263 } 264 return ss.str(); 265 } 266 267 #define RAW_RESULT(x) #x 268 269 // 270 // Check to see if the log messages emitted by the daemon 271 // match the expected result. By default we use a partial 272 // match, e.g. if we see the expected excerpt anywhere in the 273 // result, it's a match (for exact match, set exact to true) 274 // 275 static void compareLogMessages(const std::string &actual, 276 const std::string &expected, 277 const char *testpoint, 278 bool exactMatch=false) 279 { 280 std::string sqexp = squeezeWhite(expected, "expected"); 281 std::string sqact = squeezeWhite(actual, "actual"); 282 if (exactMatch) { 283 EXPECT_STREQ(sqexp.c_str(), sqact.c_str()); 284 } else { 285 std::size_t foundpos = sqact.find(sqexp); 286 bool wasFound = true; 287 if (foundpos == std::string::npos) { 288 std::cerr << testpoint << ": expected result not found\n"; 289 std::cerr << " Actual: \"" << sqact << "\"\n"; 290 std::cerr << " Expected: \"" << sqexp << "\"\n"; 291 wasFound = false; 292 } 293 EXPECT_TRUE(wasFound); 294 } 295 } 296 297 TEST_F(PerfProfdTest, MissingGMS) 298 { 299 // 300 // AWP requires cooperation between the daemon and the GMS core 301 // piece. If we're running on a device that has an old or damaged 302 // version of GMS core, then the config directory we're interested in 303 // may not be there. This test insures that the daemon does the 304 // right thing in this case. 305 // 306 PerfProfdRunner runner; 307 runner.addToConfig("only_debug_build=0"); 308 runner.addToConfig("trace_config_read=0"); 309 runner.addToConfig("config_directory=/does/not/exist"); 310 runner.addToConfig("main_loop_iterations=1"); 311 runner.addToConfig("use_fixed_seed=1"); 312 runner.addToConfig("collection_interval=100"); 313 314 // Kick off daemon 315 int daemon_main_return_code = runner.invoke(); 316 317 // Check return code from daemon 318 EXPECT_EQ(0, daemon_main_return_code); 319 320 // Verify log contents 321 const std::string expected = RAW_RESULT( 322 I: sleep 90 seconds 323 W: unable to open config directory /does/not/exist: (No such file or directory) 324 I: profile collection skipped (missing config directory) 325 ); 326 327 // check to make sure entire log matches 328 compareLogMessages(mock_perfprofdutils_getlogged(), 329 expected, "MissingGMS"); 330 } 331 332 333 TEST_F(PerfProfdTest, MissingOptInSemaphoreFile) 334 { 335 // 336 // Android device owners must opt in to "collect and report usage 337 // data" in order for us to be able to collect profiles. The opt-in 338 // check is performed in the GMS core component; if the check 339 // passes, then it creates a semaphore file for the daemon to pick 340 // up on. 341 // 342 PerfProfdRunner runner; 343 runner.addToConfig("only_debug_build=0"); 344 std::string cfparam("config_directory="); cfparam += test_dir; 345 runner.addToConfig(cfparam); 346 std::string ddparam("destination_directory="); ddparam += dest_dir; 347 runner.addToConfig(ddparam); 348 runner.addToConfig("main_loop_iterations=1"); 349 runner.addToConfig("use_fixed_seed=1"); 350 runner.addToConfig("collection_interval=100"); 351 352 runner.remove_semaphore_file(); 353 354 // Kick off daemon 355 int daemon_main_return_code = runner.invoke(); 356 357 // Check return code from daemon 358 EXPECT_EQ(0, daemon_main_return_code); 359 360 // Verify log contents 361 const std::string expected = RAW_RESULT( 362 I: profile collection skipped (missing semaphore file) 363 ); 364 // check to make sure log excerpt matches 365 compareLogMessages(mock_perfprofdutils_getlogged(), 366 expected, "MissingOptInSemaphoreFile"); 367 } 368 369 TEST_F(PerfProfdTest, MissingPerfExecutable) 370 { 371 // 372 // Perfprofd uses the 'simpleperf' tool to collect profiles 373 // (although this may conceivably change in the future). This test 374 // checks to make sure that if 'simpleperf' is not present we bail out 375 // from collecting profiles. 376 // 377 PerfProfdRunner runner; 378 runner.addToConfig("only_debug_build=0"); 379 runner.addToConfig("trace_config_read=1"); 380 std::string cfparam("config_directory="); cfparam += test_dir; 381 runner.addToConfig(cfparam); 382 std::string ddparam("destination_directory="); ddparam += dest_dir; 383 runner.addToConfig(ddparam); 384 runner.addToConfig("main_loop_iterations=1"); 385 runner.addToConfig("use_fixed_seed=1"); 386 runner.addToConfig("collection_interval=100"); 387 runner.addToConfig("perf_path=/does/not/exist"); 388 389 // Create semaphore file 390 runner.create_semaphore_file(); 391 392 // Kick off daemon 393 int daemon_main_return_code = runner.invoke(); 394 395 // Check return code from daemon 396 EXPECT_EQ(0, daemon_main_return_code); 397 398 // expected log contents 399 const std::string expected = RAW_RESULT( 400 I: profile collection skipped (missing 'perf' executable) 401 ); 402 // check to make sure log excerpt matches 403 compareLogMessages(mock_perfprofdutils_getlogged(), 404 expected, "MissingPerfExecutable"); 405 } 406 407 TEST_F(PerfProfdTest, BadPerfRun) 408 { 409 // 410 // Perf tools tend to be tightly coupled with a specific kernel 411 // version -- if things are out of sync perf could fail or 412 // crash. This test makes sure that we detect such a case and log 413 // the error. 414 // 415 PerfProfdRunner runner; 416 runner.addToConfig("only_debug_build=0"); 417 std::string cfparam("config_directory="); cfparam += test_dir; 418 runner.addToConfig(cfparam); 419 std::string ddparam("destination_directory="); ddparam += dest_dir; 420 runner.addToConfig(ddparam); 421 runner.addToConfig("main_loop_iterations=1"); 422 runner.addToConfig("use_fixed_seed=1"); 423 runner.addToConfig("collection_interval=100"); 424 runner.addToConfig("perf_path=/system/bin/false"); 425 426 // Create semaphore file 427 runner.create_semaphore_file(); 428 429 // Kick off daemon 430 int daemon_main_return_code = runner.invoke(); 431 432 // Check return code from daemon 433 EXPECT_EQ(0, daemon_main_return_code); 434 435 // Verify log contents 436 const std::string expected = RAW_RESULT( 437 I: profile collection failed (perf record returned bad exit status) 438 ); 439 440 // check to make sure log excerpt matches 441 compareLogMessages(mock_perfprofdutils_getlogged(), 442 expected, "BadPerfRun"); 443 } 444 445 TEST_F(PerfProfdTest, ConfigFileParsing) 446 { 447 // 448 // Gracefully handly malformed items in the config file 449 // 450 PerfProfdRunner runner; 451 runner.addToConfig("only_debug_build=0"); 452 runner.addToConfig("main_loop_iterations=1"); 453 runner.addToConfig("collection_interval=100"); 454 runner.addToConfig("use_fixed_seed=1"); 455 runner.addToConfig("destination_directory=/does/not/exist"); 456 457 // assorted bad syntax 458 runner.addToConfig("collection_interval=0"); 459 runner.addToConfig("collection_interval=-1"); 460 runner.addToConfig("collection_interval=2"); 461 runner.addToConfig("nonexistent_key=something"); 462 runner.addToConfig("no_equals_stmt"); 463 464 // Kick off daemon 465 int daemon_main_return_code = runner.invoke(); 466 467 // Check return code from daemon 468 EXPECT_EQ(0, daemon_main_return_code); 469 470 // Verify log contents 471 const std::string expected = RAW_RESULT( 472 W: line 6: specified value 0 for 'collection_interval' outside permitted range [100 4294967295] (ignored) 473 W: line 7: malformed unsigned value (ignored) 474 W: line 8: specified value 2 for 'collection_interval' outside permitted range [100 4294967295] (ignored) 475 W: line 9: unknown option 'nonexistent_key' ignored 476 W: line 10: line malformed (no '=' found) 477 ); 478 479 // check to make sure log excerpt matches 480 compareLogMessages(mock_perfprofdutils_getlogged(), 481 expected, "ConfigFileParsing"); 482 } 483 484 TEST_F(PerfProfdTest, ProfileCollectionAnnotations) 485 { 486 unsigned util1 = collect_cpu_utilization(); 487 EXPECT_LE(util1, 100); 488 EXPECT_GE(util1, 0); 489 490 // NB: expectation is that when we run this test, the device will be 491 // completed booted, will be on charger, and will not have the camera 492 // active. 493 EXPECT_FALSE(get_booting()); 494 EXPECT_TRUE(get_charging()); 495 EXPECT_FALSE(get_camera_active()); 496 } 497 498 TEST_F(PerfProfdTest, BasicRunWithCannedPerf) 499 { 500 // 501 // Verify the portion of the daemon that reads and encodes 502 // perf.data files. Here we run the encoder on a canned perf.data 503 // file and verify that the resulting protobuf contains what 504 // we think it should contain. 505 // 506 std::string input_perf_data(test_dir); 507 input_perf_data += "/canned.perf.data"; 508 509 // Set up config to avoid these annotations (they are tested elsewhere) 510 ConfigReader config; 511 config.overrideUnsignedEntry("collect_cpu_utilization", 0); 512 config.overrideUnsignedEntry("collect_charging_state", 0); 513 config.overrideUnsignedEntry("collect_camera_active", 0); 514 515 // Kick off encoder and check return code 516 PROFILE_RESULT result = 517 encode_to_proto(input_perf_data, encoded_file_path(0).c_str(), config, 0); 518 EXPECT_EQ(OK_PROFILE_COLLECTION, result); 519 520 // Read and decode the resulting perf.data.encoded file 521 wireless_android_play_playlog::AndroidPerfProfile encodedProfile; 522 readEncodedProfile("BasicRunWithCannedPerf", 523 encodedProfile); 524 525 // Expect 29 load modules 526 EXPECT_EQ(29, encodedProfile.programs_size()); 527 528 // Check a couple of load modules 529 { const auto &lm0 = encodedProfile.load_modules(0); 530 std::string act_lm0 = encodedLoadModuleToString(lm0); 531 std::string sqact0 = squeezeWhite(act_lm0, "actual for lm 0"); 532 const std::string expected_lm0 = RAW_RESULT( 533 name: "/data/app/com.google.android.apps.plus-1/lib/arm/libcronet.so" 534 ); 535 std::string sqexp0 = squeezeWhite(expected_lm0, "expected_lm0"); 536 EXPECT_STREQ(sqexp0.c_str(), sqact0.c_str()); 537 } 538 { const auto &lm9 = encodedProfile.load_modules(9); 539 std::string act_lm9 = encodedLoadModuleToString(lm9); 540 std::string sqact9 = squeezeWhite(act_lm9, "actual for lm 9"); 541 const std::string expected_lm9 = RAW_RESULT( 542 name: "/system/lib/libandroid_runtime.so" build_id: "8164ed7b3a8b8f5a220d027788922510" 543 ); 544 std::string sqexp9 = squeezeWhite(expected_lm9, "expected_lm9"); 545 EXPECT_STREQ(sqexp9.c_str(), sqact9.c_str()); 546 } 547 548 // Examine some of the samples now 549 { const auto &p1 = encodedProfile.programs(0); 550 const auto &lm1 = p1.modules(0); 551 std::string act_lm1 = encodedModuleSamplesToString(lm1); 552 std::string sqact1 = squeezeWhite(act_lm1, "actual for lm1"); 553 const std::string expected_lm1 = RAW_RESULT( 554 load_module_id: 9 address_samples { address: 296100 count: 1 } 555 ); 556 std::string sqexp1 = squeezeWhite(expected_lm1, "expected_lm1"); 557 EXPECT_STREQ(sqexp1.c_str(), sqact1.c_str()); 558 } 559 { const auto &p1 = encodedProfile.programs(2); 560 const auto &lm2 = p1.modules(0); 561 std::string act_lm2 = encodedModuleSamplesToString(lm2); 562 std::string sqact2 = squeezeWhite(act_lm2, "actual for lm2"); 563 const std::string expected_lm2 = RAW_RESULT( 564 load_module_id: 2 565 address_samples { address: 28030244 count: 1 } 566 address_samples { address: 29657840 count: 1 } 567 ); 568 std::string sqexp2 = squeezeWhite(expected_lm2, "expected_lm2"); 569 EXPECT_STREQ(sqexp2.c_str(), sqact2.c_str()); 570 } 571 } 572 573 TEST_F(PerfProfdTest, BasicRunWithLivePerf) 574 { 575 // 576 // Basic test to exercise the main loop of the daemon. It includes 577 // a live 'perf' run 578 // 579 PerfProfdRunner runner; 580 runner.addToConfig("only_debug_build=0"); 581 std::string ddparam("destination_directory="); ddparam += dest_dir; 582 runner.addToConfig(ddparam); 583 std::string cfparam("config_directory="); cfparam += test_dir; 584 runner.addToConfig(cfparam); 585 runner.addToConfig("main_loop_iterations=1"); 586 runner.addToConfig("use_fixed_seed=12345678"); 587 runner.addToConfig("max_unprocessed_profiles=100"); 588 runner.addToConfig("collection_interval=9999"); 589 runner.addToConfig("sample_duration=2"); 590 591 // Create semaphore file 592 runner.create_semaphore_file(); 593 594 // Kick off daemon 595 int daemon_main_return_code = runner.invoke(); 596 597 // Check return code from daemon 598 EXPECT_EQ(0, daemon_main_return_code); 599 600 // Read and decode the resulting perf.data.encoded file 601 wireless_android_play_playlog::AndroidPerfProfile encodedProfile; 602 readEncodedProfile("BasicRunWithLivePerf", encodedProfile); 603 604 // Examine what we get back. Since it's a live profile, we can't 605 // really do much in terms of verifying the contents. 606 EXPECT_LT(0, encodedProfile.programs_size()); 607 608 // Verify log contents 609 const std::string expected = RAW_RESULT( 610 I: starting Android Wide Profiling daemon 611 I: config file path set to /data/nativetest/perfprofd_test/perfprofd.conf 612 I: random seed set to 12345678 613 I: sleep 674 seconds 614 I: initiating profile collection 615 I: profile collection complete 616 I: sleep 9325 seconds 617 I: finishing Android Wide Profiling daemon 618 ); 619 // check to make sure log excerpt matches 620 compareLogMessages(mock_perfprofdutils_getlogged(), 621 expected, "BasicRunWithLivePerf", true); 622 } 623 624 TEST_F(PerfProfdTest, MultipleRunWithLivePerf) 625 { 626 // 627 // Basic test to exercise the main loop of the daemon. It includes 628 // a live 'perf' run 629 // 630 PerfProfdRunner runner; 631 runner.addToConfig("only_debug_build=0"); 632 std::string ddparam("destination_directory="); ddparam += dest_dir; 633 runner.addToConfig(ddparam); 634 std::string cfparam("config_directory="); cfparam += test_dir; 635 runner.addToConfig(cfparam); 636 runner.addToConfig("main_loop_iterations=3"); 637 runner.addToConfig("use_fixed_seed=12345678"); 638 runner.addToConfig("collection_interval=9999"); 639 runner.addToConfig("sample_duration=2"); 640 runner.write_processed_file(1, 2); 641 642 // Create semaphore file 643 runner.create_semaphore_file(); 644 645 // Kick off daemon 646 int daemon_main_return_code = runner.invoke(); 647 648 // Check return code from daemon 649 EXPECT_EQ(0, daemon_main_return_code); 650 651 // Read and decode the resulting perf.data.encoded file 652 wireless_android_play_playlog::AndroidPerfProfile encodedProfile; 653 readEncodedProfile("BasicRunWithLivePerf", encodedProfile); 654 655 // Examine what we get back. Since it's a live profile, we can't 656 // really do much in terms of verifying the contents. 657 EXPECT_LT(0, encodedProfile.programs_size()); 658 659 // Examine that encoded.1 file is removed while encoded.{0|2} exists. 660 EXPECT_EQ(0, access(encoded_file_path(0).c_str(), F_OK)); 661 EXPECT_NE(0, access(encoded_file_path(1).c_str(), F_OK)); 662 EXPECT_EQ(0, access(encoded_file_path(2).c_str(), F_OK)); 663 664 // Verify log contents 665 const std::string expected = RAW_RESULT( 666 I: starting Android Wide Profiling daemon 667 I: config file path set to /data/nativetest/perfprofd_test/perfprofd.conf 668 I: random seed set to 12345678 669 I: sleep 674 seconds 670 I: initiating profile collection 671 I: profile collection complete 672 I: sleep 9325 seconds 673 I: sleep 4974 seconds 674 I: initiating profile collection 675 I: profile collection complete 676 I: sleep 5025 seconds 677 I: sleep 501 seconds 678 I: initiating profile collection 679 I: profile collection complete 680 I: sleep 9498 seconds 681 I: finishing Android Wide Profiling daemon 682 ); 683 // check to make sure log excerpt matches 684 compareLogMessages(mock_perfprofdutils_getlogged(), 685 expected, "BasicRunWithLivePerf", true); 686 } 687 688 int main(int argc, char **argv) { 689 executable_path = argv[0]; 690 // switch to / before starting testing (perfprofd 691 // should be location-independent) 692 chdir("/"); 693 testing::InitGoogleTest(&argc, argv); 694 return RUN_ALL_TESTS(); 695 } 696