From 1d89d1d6fce7a3f89ce2a984500dede6529c8f53 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Fri, 26 Nov 2021 09:45:20 +0000 Subject: [PATCH 04/14] add new function mock for ut Signed-off-by: haozi007 --- test/mocks/namespace_mock.cc | 10 ++++++++++ test/mocks/namespace_mock.h | 1 + test/specs/specs/specs_ut.cc | 1 + 3 files changed, 12 insertions(+) diff --git a/test/mocks/namespace_mock.cc b/test/mocks/namespace_mock.cc index 5c0cba6c..da24e406 100644 --- a/test/mocks/namespace_mock.cc +++ b/test/mocks/namespace_mock.cc @@ -47,3 +47,13 @@ char *get_container_process_label(const char *path) } return nullptr; } + +int get_network_namespace_path(const host_config *host_spec, + const container_config_v2_common_config_network_settings *network_settings, + const char *type, char **dest_path) +{ + if (g_namespace_mock != nullptr) { + return g_namespace_mock->GetNetworkNamespacePath(host_spec, network_settings, type, dest_path); + } + return 0; +} \ No newline at end of file diff --git a/test/mocks/namespace_mock.h b/test/mocks/namespace_mock.h index b835e028..80e75b0b 100644 --- a/test/mocks/namespace_mock.h +++ b/test/mocks/namespace_mock.h @@ -26,6 +26,7 @@ public: MOCK_METHOD1(ConnectedContainer, char *(const char *mode)); MOCK_METHOD3(GetShareNamespacePath, int(const char *type, const char *src_path, char **dest_path)); MOCK_METHOD1(GetContainerProcessLabel, char *(const char *path)); + MOCK_METHOD4(GetNetworkNamespacePath, int(const host_config *, const container_config_v2_common_config_network_settings *, const char *, char **)); }; void MockNamespace_SetMock(MockNamespace *mock); diff --git a/test/specs/specs/specs_ut.cc b/test/specs/specs/specs_ut.cc index 2f2a2524..c4014e2e 100644 --- a/test/specs/specs/specs_ut.cc +++ b/test/specs/specs/specs_ut.cc @@ -19,6 +19,7 @@ #include "mock.h" #include "isula_libutils/oci_runtime_spec.h" #include "specs_api.h" +#include "specs_namespace.h" #include "isula_libutils/host_config.h" #include "isula_libutils/container_config.h" #include "oci_ut_common.h" -- 2.25.1