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

Commit 3b21d95a authored by Bart Van Assche's avatar Bart Van Assche
Browse files

init: Fix and re-enable the init#StartConsole test



Skip the test if /dev/console does not exist. Fix the console service
security label. Fix the getsid() test.

Bug: 260104465
Test: atest 'CtsInitTestCases:init#StartConsole' on a P2023 development board
Change-Id: If2533a3f205f922a9b04a748cb558a09c5925986
Signed-off-by: default avatarBart Van Assche <bvanassche@google.com>
parent a3e60548
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -194,10 +194,9 @@ service A something
}

TEST(init, StartConsole) {
    // Two different failures have been observed for this test: (1) No
    // permission to open /dev/console and (2) getsid() != pid. Skip this test
    // until these failures have been root-caused and fixed.
    GTEST_SKIP() << "This test needs to be improved";
    if (access("/dev/console", F_OK) < 0) {
        GTEST_SKIP() << "/dev/console not found";
    }
    std::string init_script = R"init(
service console /system/bin/sh
    class core
@@ -205,7 +204,7 @@ service console /system/bin/sh
    disabled
    user root
    group root shell log readproc
    seclabel u:r:su:s0
    seclabel u:r:shell:s0
    setenv HOSTNAME console
)init";

@@ -219,7 +218,7 @@ service console /system/bin/sh
    ASSERT_RESULT_OK(service->Start());
    const pid_t pid = service->pid();
    ASSERT_GT(pid, 0);
    EXPECT_EQ(getsid(pid), pid);
    EXPECT_NE(getsid(pid), 0);
    service->Stop();
}