From 7e4b7304134eb0f85b83b02aeeee3c10b2303446 Mon Sep 17 00:00:00 2001
From: chengzrz <czrzrichard@gmail.com>
Date: Mon, 29 Nov 2021 14:41:47 +0800
Subject: [PATCH 10/14] Modified cmakelist of storage_layer and added a new
 mock function in isulad_config_mock to fix errors that happen when compiling
 with UT option turned on

Signed-off-by: chengzrz <czrzrichard@gmail.com>
---
 test/image/oci/storage/layers/CMakeLists.txt | 4 ++++
 test/mocks/isulad_config_mock.cc             | 8 ++++++++
 test/mocks/isulad_config_mock.h              | 1 +
 3 files changed, 13 insertions(+)

diff --git a/test/image/oci/storage/layers/CMakeLists.txt b/test/image/oci/storage/layers/CMakeLists.txt
index 4cae382c..3fe8ab7c 100644
--- a/test/image/oci/storage/layers/CMakeLists.txt
+++ b/test/image/oci/storage/layers/CMakeLists.txt
@@ -22,6 +22,8 @@ add_executable(${DRIVER_EXE}
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/utils/sha256/sha256.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/common/err_msg.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/common/selinux_label.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/config/daemon_arguments.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/config/isulad_config.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/driver.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/deviceset.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/driver_devmapper.c
@@ -89,6 +91,8 @@ add_executable(${LAYER_EXE}
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/utils/tar/util_archive.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/utils/tar/util_gzip.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/utils/sha256/sha256.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/config/daemon_arguments.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/config/isulad_config.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/common/err_msg.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/common/selinux_label.c
     ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/layer_store/layer.c
diff --git a/test/mocks/isulad_config_mock.cc b/test/mocks/isulad_config_mock.cc
index a333c176..eb6970d7 100644
--- a/test/mocks/isulad_config_mock.cc
+++ b/test/mocks/isulad_config_mock.cc
@@ -170,3 +170,11 @@ isulad_daemon_constants *get_isulad_daemon_constants()
     }
     return &g_isulad_daemon_constants;
 }
+
+char *conf_get_isulad_userns_remap()
+{
+    if (g_isulad_conf_mock != nullptr) {
+        return g_isulad_conf_mock->ConfGetIsuladUsernsRemap();
+    }
+    return nullptr;
+}
\ No newline at end of file
diff --git a/test/mocks/isulad_config_mock.h b/test/mocks/isulad_config_mock.h
index b91b5465..7af20ca5 100644
--- a/test/mocks/isulad_config_mock.h
+++ b/test/mocks/isulad_config_mock.h
@@ -39,6 +39,7 @@ public:
     MOCK_METHOD0(ConfGetUseDecryptedKeyFlag, bool (void));
     MOCK_METHOD0(InitIsuladDaemonConstants, int (void));
     MOCK_METHOD0(GetIsuladDaemonConstants, isulad_daemon_constants * (void));
+    MOCK_METHOD0(ConfGetIsuladUsernsRemap, char *(void));
 };
 
 void MockIsuladConf_SetMock(MockIsuladConf *mock);
-- 
2.25.1

