Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 38cd1f8b authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "init_kill_services_test: log state" am: 159bd295 am: 07be4de2 am: 82e33343

parents ac9a21c0 82e33343
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -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> {};