Merge "init_kill_services_test: log state"

This commit is contained in:
Steven Moreland 2023-05-18 17:08:39 +00:00 committed by Gerrit Code Review
commit 159bd29580
1 changed files with 8 additions and 0 deletions

View File

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