iSulad/0004-run-storage-layers-ut-with-non-root.patch
zhangxiaoyu 97df963d71 add ut and bugfix for device mapper and websocket
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
2022-11-01 20:06:15 +08:00

69 lines
2.5 KiB
Diff

From 8c33633d26ec5d5eb9b5ad415afc114cf6c232f3 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Tue, 11 Oct 2022 20:34:18 +0800
Subject: [PATCH 04/39] run storage layers ut with non-root
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
test/CMakeLists.txt | 2 ++
test/image/oci/storage/layers/storage_layers_ut.cc | 10 ++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 940de5ce..a36f68c5 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,5 +1,7 @@
project(iSulad_UT)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
+
function(gmock_find_library _name)
find_library(${_name}
NAMES ${ARGN}
diff --git a/test/image/oci/storage/layers/storage_layers_ut.cc b/test/image/oci/storage/layers/storage_layers_ut.cc
index 0b481a95..87dfb4a1 100644
--- a/test/image/oci/storage/layers/storage_layers_ut.cc
+++ b/test/image/oci/storage/layers/storage_layers_ut.cc
@@ -153,7 +153,8 @@ protected:
MockDriverQuota_SetMock(&m_driver_quota_mock);
struct storage_module_init_options opts = {0};
- std::string isulad_dir = "/var/lib/isulad/";
+ std::string isulad_dir = "/tmp/isulad/";
+ mkdir(isulad_dir.c_str(), 0755);
std::string root_dir = isulad_dir + "data";
std::string run_dir = isulad_dir + "data/run";
std::string data_dir = GetDirectory() + "/data";
@@ -167,6 +168,9 @@ protected:
ASSERT_STRNE(util_clean_path(run_dir.c_str(), real_run_path, sizeof(real_run_path)), nullptr);
opts.storage_run_root = strdup(real_run_path);
opts.driver_name = strdup("overlay");
+ opts.driver_opts = static_cast<char **>(util_smart_calloc_s(sizeof(char *), 1));
+ opts.driver_opts[0] = strdup("overlay2.skip_mount_home=true");
+ opts.driver_opts_len = 1;
EXPECT_CALL(m_driver_quota_mock, QuotaCtl(_, _, _, _)).WillRepeatedly(Invoke(invokeQuotaCtl));
ASSERT_EQ(layer_store_init(&opts), 0);
@@ -174,6 +178,8 @@ protected:
free(opts.storage_root);
free(opts.storage_run_root);
free(opts.driver_name);
+ free(opts.driver_opts[0]);
+ free(opts.driver_opts);
}
void TearDown() override
@@ -183,7 +189,7 @@ protected:
layer_store_exit();
layer_store_cleanup();
- std::string rm_command = "rm -rf /var/lib/isulad/data";
+ std::string rm_command = "rm -rf /tmp/isulad/";
ASSERT_EQ(system(rm_command.c_str()), 0);
}
--
2.25.1