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

Commit 93c24d7e authored by Jooyung Han's avatar Jooyung Han
Browse files

Only run Service::Start() under root

Tests using Service::Start() should run under root. Otherwise tests fail
to start services from the test binary due to lack of permission.

Bug: 244748231
Test: CtsInitTestCases
Change-Id: Ia4eb8457cfad7d44da6b171e44f64238e08af9f7
parent 9a0a9db6
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -280,6 +280,10 @@ void TestApexServicesInit(const std::vector<std::string>& apex_services,
}

TEST(init, StopServiceByApexName) {
    if (getuid() != 0) {
        GTEST_SKIP() << "Must be run as root.";
        return;
    }
    std::string_view script_template = R"init(
service apex_test_service /system/bin/yes
    user shell
@@ -291,6 +295,10 @@ service apex_test_service /system/bin/yes
}

TEST(init, StopMultipleServicesByApexName) {
    if (getuid() != 0) {
        GTEST_SKIP() << "Must be run as root.";
        return;
    }
    std::string_view script_template = R"init(
service apex_test_service_multiple_a /system/bin/yes
    user shell
@@ -307,6 +315,10 @@ service apex_test_service_multiple_b /system/bin/id
}

TEST(init, StopServicesFromMultipleApexes) {
    if (getuid() != 0) {
        GTEST_SKIP() << "Must be run as root.";
        return;
    }
    std::string_view apex_script_template = R"init(
service apex_test_service_multi_apex_a /system/bin/yes
    user shell
@@ -332,6 +344,10 @@ service apex_test_service_multi_apex_c /system/bin/yes
}

TEST(init, StopServicesFromApexAndNonApex) {
    if (getuid() != 0) {
        GTEST_SKIP() << "Must be run as root.";
        return;
    }
    std::string_view apex_script_template = R"init(
service apex_test_service_apex_a /system/bin/yes
    user shell
@@ -357,6 +373,10 @@ service apex_test_service_non_apex /system/bin/yes
}

TEST(init, StopServicesFromApexMixed) {
    if (getuid() != 0) {
        GTEST_SKIP() << "Must be run as root.";
        return;
    }
    std::string_view script_template = R"init(
service apex_test_service_mixed_a /system/bin/yes
    user shell