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
44
45
46
47
48
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
From 80de8ca6b9bdd56d0e53d73a631fefb2e170b3c3 Mon Sep 17 00:00:00 2001
From: liuxu <liuxu156@huawei.com>
Date: Fri, 7 Feb 2025 16:51:42 +0800
Subject: [PATCH 186/198] UT:sandboxer code isolation
Signed-off-by: liuxu <liuxu156@huawei.com>
---
test/mocks/sandbox_mock.cc | 2 ++
test/mocks/sandbox_mock.h | 2 ++
test/mocks/sandboxer_sandbox_mock.cc | 5 ++++-
test/mocks/sandboxer_sandbox_mock.h | 3 +++
test/sandbox/sandbox/CMakeLists.txt | 1 -
5 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/test/mocks/sandbox_mock.cc b/test/mocks/sandbox_mock.cc
index cce5a1b6..e14473bb 100644
--- a/test/mocks/sandbox_mock.cc
+++ b/test/mocks/sandbox_mock.cc
@@ -222,6 +222,7 @@ bool Sandbox::Remove(Errors &error)
return true;
}
+#ifdef ENABLE_SANDBOXER
void Sandbox::LoadSandboxTasks() {}
auto Sandbox::PrepareContainer(const char *containerId, const char *baseFs,
@@ -246,5 +247,6 @@ auto Sandbox::PurgeExec(const char *containerId, const char *execId) -> int
{
return 0;
}
+#endif
}
\ No newline at end of file
diff --git a/test/mocks/sandbox_mock.h b/test/mocks/sandbox_mock.h
index 4908bcd9..3c776f69 100644
--- a/test/mocks/sandbox_mock.h
+++ b/test/mocks/sandbox_mock.h
@@ -59,6 +59,7 @@ public:
MOCK_METHOD1(Remove, bool(Errors &error));
MOCK_METHOD1(Status, void(runtime::v1::PodSandboxStatus &status));
+#ifdef ENABLE_SANDBOXER
MOCK_METHOD0(LoadSandboxTasks, void());
MOCK_METHOD4(PrepareContainer, int(const char *containerId, const char *baseFs,
const oci_runtime_spec *ociSpec,
@@ -67,6 +68,7 @@ public:
defs_process *processSpec, const char *consoleFifos[]));
MOCK_METHOD1(PurgeContainer, int(const char *containerId));
MOCK_METHOD2(PurgeExec, int(const char *containerId, const char *execId));
+#endif
};
void MockSandbox_SetMock(MockSandbox *mock);
diff --git a/test/mocks/sandboxer_sandbox_mock.cc b/test/mocks/sandboxer_sandbox_mock.cc
index 6ebe2820..9366c738 100644
--- a/test/mocks/sandboxer_sandbox_mock.cc
+++ b/test/mocks/sandboxer_sandbox_mock.cc
@@ -13,6 +13,8 @@
* Description: provide sandbox mock
******************************************************************************/
+#ifdef ENABLE_SANDBOXER
+
#include <gmock/gmock.h>
#include "sandboxer_sandbox_mock.h"
@@ -68,4 +70,5 @@ auto SandboxerSandbox::PurgeExec(const char *containerId, const char *execId) ->
return 0;
}
-}
\ No newline at end of file
+}
+#endif
\ No newline at end of file
diff --git a/test/mocks/sandboxer_sandbox_mock.h b/test/mocks/sandboxer_sandbox_mock.h
index 020fe4d6..69bea078 100644
--- a/test/mocks/sandboxer_sandbox_mock.h
+++ b/test/mocks/sandboxer_sandbox_mock.h
@@ -16,6 +16,8 @@
#ifndef _ISULAD_TEST_MOCKS_SANDBOXER_SANDBOX_MOCK_H
#define _ISULAD_TEST_MOCKS_SANDBOXER_SANDBOX_MOCK_H
+#ifdef ENABLE_SANDBOXER
+
#include <gmock/gmock.h>
#include "sandbox_mock.h"
#include "sandboxer_sandbox.h"
@@ -40,5 +42,6 @@ public:
void MockSandboxerSandbox_SetMock(MockSandboxerSandbox *mock);
}
+#endif
#endif
diff --git a/test/sandbox/sandbox/CMakeLists.txt b/test/sandbox/sandbox/CMakeLists.txt
index d033c93f..358633dc 100644
--- a/test/sandbox/sandbox/CMakeLists.txt
+++ b/test/sandbox/sandbox/CMakeLists.txt
@@ -29,7 +29,6 @@ add_executable(${EXE}
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cpputils/transform.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cpputils/cxxutils.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/sandbox/sandbox.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/sandbox/sandbox_task.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/sandbox/controller_manager.cc
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/common/id_name_manager.c
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/config/isulad_config.c
--
2.34.1
|