container_unix_mock.cc 2.1 KB
Newer Older
L
LiFeng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
/******************************************************************************
 * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
 * iSulad licensed under the Mulan PSL v1.
 * You can use this software according to the terms and conditions of the Mulan PSL v1.
 * You may obtain a copy of Mulan PSL v1 at:
 *     http://license.coscl.org.cn/MulanPSL
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 * PURPOSE.
 * See the Mulan PSL v1 for more details.
 * Author: lifeng
 * Create: 2020-02-14
 * Description: provide container unix mock
 ******************************************************************************/

#include "container_unix_mock.h"

namespace {
MockContainerUnix *g_container_unix_mock = NULL;
}

void MockContainerUnix_SetMock(MockContainerUnix* mock)
{
    g_container_unix_mock = mock;
}


/* container unref */
void container_unref(container_t *cont)
{
    if (g_container_unix_mock != nullptr) {
        return g_container_unix_mock->ContainerUnref(cont);
    }
    return;
}

bool has_mount_for(container_t *cont, const char *mpath)
{
    if (g_container_unix_mock != nullptr) {
        return g_container_unix_mock->HasMountFor(cont, mpath);
    }
    return false;
}
J
jingrui 已提交
44 45 46 47 48

int container_read_proc(uint32_t pid, container_pid_t *pid_info)
{
    return 0;
}
J
j00502727 已提交
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

int container_to_disk(const container_t *cont)
{
    if (g_container_unix_mock != nullptr) {
        return g_container_unix_mock->ContainerToDisk(cont);
    }
    return 0;
}

void container_unlock(container_t *cont)
{
    if (g_container_unix_mock != nullptr) {
        return g_container_unix_mock->ContainerUnlock(cont);
    }
}

void container_lock(container_t *cont)
{
    if (g_container_unix_mock != nullptr) {
        return g_container_unix_mock->ContainerLock(cont);
    }
}

void container_update_restart_manager(container_t *cont, const host_config_restart_policy *policy)
{
    if (g_container_unix_mock != nullptr) {
        return g_container_unix_mock->ContainerUpdateRestartManager(cont, policy);
    }
}