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

Commit cd9f674c authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-957cd691-fb71-4770-8ff7-a3b9602655a5-for-git_oc-mr1-release-43...

release-request-957cd691-fb71-4770-8ff7-a3b9602655a5-for-git_oc-mr1-release-4314464 snap-temp-L54400000099147910

Change-Id: I470af98bcb1d93e16dba4f8def81af7bded41524
parents 4d79edc6 c40416d0
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ using ::testing::DoAll;
using ::testing::Eq;
using ::testing::HasSubstr;
using ::testing::MakeAction;
using ::testing::Mock;
using ::testing::Not;
using ::testing::Return;
using ::testing::StrEq;
@@ -155,10 +156,11 @@ class DumpsysTest : public Test {
            .WillRepeatedly(DoAll(WithArg<0>(WriteOnFd(output)), Return(0)));
    }

    void ExpectDumpAndHang(const char* name, int timeout_s, const std::string& output) {
    sp<BinderMock> ExpectDumpAndHang(const char* name, int timeout_s, const std::string& output) {
        sp<BinderMock> binder_mock = ExpectCheckService(name);
        EXPECT_CALL(*binder_mock, dump(_, _))
            .WillRepeatedly(DoAll(Sleep(timeout_s), WithArg<0>(WriteOnFd(output)), Return(0)));
        return binder_mock;
    }

    void CallMain(const std::vector<std::string>& args) {
@@ -245,15 +247,15 @@ TEST_F(DumpsysTest, DumpRunningService) {

// Tests 'dumpsys -t 1 service_name' on a service that times out after 2s
TEST_F(DumpsysTest, DumpRunningServiceTimeout) {
    ExpectDumpAndHang("Valet", 2, "Here's your car");
    sp<BinderMock> binder_mock = ExpectDumpAndHang("Valet", 2, "Here's your car");

    CallMain({"-t", "1", "Valet"});

    AssertOutputContains("SERVICE 'Valet' DUMP TIMEOUT (1s) EXPIRED");
    AssertNotDumped("Here's your car");

    // Must wait so binder mock is deleted, otherwise test will fail with a leaked object
    sleep(1);
    // TODO(b/65056227): BinderMock is not destructed because thread is detached on dumpsys.cpp
    Mock::AllowLeak(binder_mock.get());
}

// Tests 'dumpsys service_name Y U NO HAVE ARGS' on a service that is running
+42 −28
Original line number Diff line number Diff line
@@ -1811,14 +1811,25 @@ bool reconcile_secondary_dex_file(const std::string& dex_path,
        return false;
    }

    // As a security measure we want to unlink art artifacts with the reduced capabilities
    // of the package user id. So we fork and drop capabilities in the child.
    pid_t pid = fork();
    if (pid == 0) {
        // The secondary dex does not exist anymore. Clear any generated files.
        char oat_path[PKG_PATH_MAX];
        char oat_dir[PKG_PATH_MAX];
        char oat_isa_dir[PKG_PATH_MAX];
        bool result = true;
        /* child -- drop privileges before continuing */
        drop_capabilities(uid);
        for (size_t i = 0; i < isas.size(); i++) {
        if (!create_secondary_dex_oat_layout(dex_path, isas[i], oat_dir, oat_isa_dir, oat_path)) {
            LOG(ERROR) << "Could not create secondary odex layout: " << dex_path;
            if (!create_secondary_dex_oat_layout(dex_path,
                                                 isas[i],
                                                 oat_dir,
                                                 oat_isa_dir,
                                                 oat_path)) {
                LOG(ERROR) << "Could not create secondary odex layout: "
                           << dex_path;
                result = false;
                continue;
            }
@@ -1845,8 +1856,11 @@ bool reconcile_secondary_dex_file(const std::string& dex_path,
            result = rmdir_if_empty(oat_isa_dir) && result;
            result = rmdir_if_empty(oat_dir) && result;
        }
        result ? _exit(0) : _exit(1);
    }

    return result;
    int return_code = wait_child(pid);
    return return_code == 0;
}

// Helper for move_ab, so that we can have common failure-case cleanup.
+6 −0
Original line number Diff line number Diff line
@@ -108,4 +108,10 @@ cc_library_shared {
    ],
}

cc_library_headers {
    name: "libui_headers",
    export_include_dirs: ["include"],
    vendor_available: true,
}

subdirs = ["tests"]