init_kill_services_test: log state

It can be difficult to figure out where this test
is while it's executing, so I've added logs.

Bug: 280514080
Test: init_kill_services_test (w/o tradefed to avoid reboot), then:
:) adb logcat -d | grep init_kill_services_test
... I init_kill_services_test: hello lmkd!
... I init_kill_services_test: okay, now goodbye lmkd
... I init_kill_services_test: I said goodbye lmkd!
... I init_kill_services_test: are you still there lmkd?
... I init_kill_services_test: I'm done with lmkd
... I init_kill_services_test: hello ueventd!
... I init_kill_services_test: okay, now goodbye ueventd
... I init_kill_services_test: I said goodbye ueventd!
... I init_kill_services_test: are you still there ueventd?
... I init_kill_services_test: I'm done with ueventd
... I init_kill_services_test: hello hwservicemanager!
... I init_kill_services_test: okay, now goodbye hwservicemanager
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: I said goodbye hwservicemanager!
... I init_kill_services_test: are you still there hwservicemanager?
... I init_kill_services_test: I'm done with hwservicemanager
... I init_kill_services_test: hello servicemanager!
... I init_kill_services_test: okay, now goodbye servicemanager
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: I said goodbye servicemanager!
... I init_kill_services_test: are you still there servicemanager?
... I init_kill_services_test: I'm done with servicemanager

Change-Id: I2466f574fc06cdf1b01db82f89649f39b0f34345
This commit is contained in:
Steven Moreland 2023-05-17 23:18:48 +00:00
parent b8304d1502
commit 16e08075ba

View file

@ -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> {};