Merge "init_kill_services_test: log state"
This commit is contained in:
commit
159bd29580
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
|
||||
#include <iostream>
|
||||
|
@ -24,6 +25,7 @@ using ::android::base::GetProperty;
|
|||
using ::android::base::SetProperty;
|
||||
|
||||
void ExpectKillingServiceRecovers(const std::string& service_name) {
|
||||
LOG(INFO) << "hello " << service_name << "!";
|
||||
const std::string status_prop = "init.svc." + service_name;
|
||||
const std::string pid_prop = "init.svc_debug_pid." + service_name;
|
||||
|
||||
|
@ -32,6 +34,7 @@ void ExpectKillingServiceRecovers(const std::string& service_name) {
|
|||
ASSERT_EQ("running", GetProperty(status_prop, "")) << status_prop;
|
||||
ASSERT_NE("", initial_pid) << pid_prop;
|
||||
|
||||
LOG(INFO) << "okay, now goodbye " << service_name;
|
||||
EXPECT_EQ(0, system(("kill -9 " + initial_pid).c_str()));
|
||||
|
||||
constexpr size_t kMaxWaitMilliseconds = 10000;
|
||||
|
@ -42,11 +45,16 @@ void ExpectKillingServiceRecovers(const std::string& service_name) {
|
|||
for (size_t retry = 0; retry < kRetryTimes; retry++) {
|
||||
const std::string& pid = GetProperty(pid_prop, "");
|
||||
if (pid != initial_pid && pid != "") break;
|
||||
LOG(INFO) << "I said goodbye " << service_name << "!";
|
||||
usleep(kRetryWaitMilliseconds * 1000);
|
||||
}
|
||||
|
||||
LOG(INFO) << "are you still there " << service_name << "?";
|
||||
|
||||
// svc_debug_pid is set after svc property
|
||||
EXPECT_EQ("running", GetProperty(status_prop, ""));
|
||||
|
||||
LOG(INFO) << "I'm done with " << service_name;
|
||||
}
|
||||
|
||||
class InitKillServicesTest : public ::testing::TestWithParam<std::string> {};
|
||||
|
|
Loading…
Reference in New Issue