Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
b08e986e
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b08e986e
编写于
2月 22, 2020
作者:
L
LiFeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
iSulad: add testcases for specs_extend
Signed-off-by:
N
LiFeng
<
lifeng68@huawei.com
>
上级
af92f7ea
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
1168 addition
and
0 deletion
+1168
-0
src/json/oci_runtime_hooks.h
src/json/oci_runtime_hooks.h
+8
-0
src/services/execution/spec/specs_extend.c
src/services/execution/spec/specs_extend.c
+4
-0
test/specs/CMakeLists.txt
test/specs/CMakeLists.txt
+1
-0
test/specs/specs_extend/CMakeLists.txt
test/specs/specs_extend/CMakeLists.txt
+82
-0
test/specs/specs_extend/hooks.json
test/specs/specs_extend/hooks.json
+38
-0
test/specs/specs_extend/hostconfig.json
test/specs/specs_extend/hostconfig.json
+6
-0
test/specs/specs_extend/oci_runtime_spec.json
test/specs/specs_extend/oci_runtime_spec.json
+741
-0
test/specs/specs_extend/specs_extend_llt.cc
test/specs/specs_extend/specs_extend_llt.cc
+288
-0
未找到文件。
src/json/oci_runtime_hooks.h
浏览文件 @
b08e986e
...
...
@@ -18,8 +18,16 @@
# include "oci_runtime_spec.h"
#ifdef __cplusplus
extern
"C"
{
#endif
oci_runtime_spec_hooks
*
oci_runtime_spec_hooks_parse_file
(
const
char
*
filename
,
const
struct
parser_context
*
ctx
,
parser_error
*
err
);
#ifdef __cplusplus
}
#endif
#endif
src/services/execution/spec/specs_extend.c
浏览文件 @
b08e986e
...
...
@@ -88,6 +88,10 @@ MERGE_HOOKS_ITEM_DEF(poststop)
int
merge_hooks
(
oci_runtime_spec_hooks
*
dest
,
oci_runtime_spec_hooks
*
src
)
{
if
(
dest
==
NULL
||
src
==
NULL
)
{
return
-
1
;
}
if
(
merge_prestart_conf
(
dest
,
src
)
||
merge_poststart_conf
(
dest
,
src
)
||
merge_poststop_conf
(
dest
,
src
))
{
return
-
1
;
}
...
...
test/specs/CMakeLists.txt
浏览文件 @
b08e986e
project
(
iSulad_LLT
)
add_subdirectory
(
specs
)
add_subdirectory
(
specs_extend
)
test/specs/specs_extend/CMakeLists.txt
0 → 100644
浏览文件 @
b08e986e
project
(
iSulad_LLT
)
SET
(
EXE specs_extend_llt
)
add_executable
(
${
EXE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils/utils.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils/utils_regex.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils/utils_verify.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils/utils_array.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils/utils_string.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils/utils_convert.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils/utils_file.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils/util_atomic.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/log.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/sha256/sha256.c
${
CMAKE_BINARY_DIR
}
/json/json_common.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/path.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/spec/specs.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/spec/specs_mount.c
${
CMAKE_BINARY_DIR
}
/json/host_config.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/spec/specs_extend.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/spec/specs_security.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/libisulad.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/json/oci_runtime_hooks.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/json/parse_common.c
${
CMAKE_BINARY_DIR
}
/json/defs.c
${
CMAKE_BINARY_DIR
}
/json/container_config_v2.c
${
CMAKE_BINARY_DIR
}
/json/container_config.c
${
CMAKE_BINARY_DIR
}
/json/oci_runtime_spec.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/spec/sysinfo.c
${
CMAKE_BINARY_DIR
}
/json/oci_runtime_config_linux.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cmd/commander.c
${
CMAKE_BINARY_DIR
}
/json/isulad_daemon_configs.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/json/schema/src/read_file.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cmd/isulad/arguments.c
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/image/oci/oci_llt_common.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/mocks/containers_store_mock.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/mocks/namespace_mock.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/mocks/container_unix_mock.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/mocks/engine_mock.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/mocks/selinux_label_mock.cc
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/mocks/isulad_config_mock.cc
${
CMAKE_BINARY_DIR
}
/json/imagetool_image.c
${
CMAKE_BINARY_DIR
}
/json/oci_image_spec.c
${
CMAKE_BINARY_DIR
}
/json/docker_seccomp.c
specs_extend_llt.cc
)
target_include_directories
(
${
EXE
}
PUBLIC
${
GTEST_INCLUDE_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../include
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/image/oci
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/image
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cutils
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/json
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/map
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/spec
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/manager
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/events
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/execution/execute
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/tar
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/plugin
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/http
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/engines
${
ENGINES_INCS
}
${
RUNTIME_INCS
}
${
IMAGE_INCS
}
${
CMAKE_BINARY_DIR
}
/json
${
CMAKE_BINARY_DIR
}
/conf
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/sha256
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/config
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/cmd
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/services/graphdriver
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/json/schema/src
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../src/console
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/image/oci
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../../test/mocks
)
target_link_libraries
(
${
EXE
}
${
GTEST_BOTH_LIBRARIES
}
${
GMOCK_LIBRARY
}
${
GMOCK_MAIN_LIBRARY
}
${
CMAKE_THREAD_LIBS_INIT
}
-lgrpc++ -lprotobuf -lcrypto -lyajl -lz
)
test/specs/specs_extend/hooks.json
0 → 100644
浏览文件 @
b08e986e
{
"prestart"
:
[
{
"path"
:
"/home/hooks/start.bash"
,
"args"
:
[
"arg0"
,
"arg1"
,
"arg2"
],
"timeout"
:
40
,
"env"
:
[
"key1=value1"
]
}
],
"poststart"
:
[
{
"path"
:
"/home/hooks/post1.bash"
,
"args"
:
[
"arg5"
,
"arg6"
,
"arg7"
],
"timeout"
:
60
,
"env"
:
[
"key2=value221"
]
},
{
"path"
:
"/home/hooks/post2.bash"
,
"args"
:
[
"arg51"
,
"arg61"
,
"arg71"
],
"timeout"
:
61
,
"env"
:
[
"key3=value3"
]
}
],
"poststop"
:
[
{
"path"
:
"/home/hooks/stop1.bash"
,
"args"
:
[
"arg11"
,
"arg12"
,
"arg13"
],
"timeout"
:
60
,
"env"
:
[
"key2=value221"
]
},
{
"path"
:
"/home/hooks/stop2.bash"
,
"args"
:
[
"arg52"
,
"arg62"
,
"arg72"
],
"timeout"
:
62
,
"env"
:
[
"key4=value4"
]
}
]
}
test/specs/specs_extend/hostconfig.json
0 → 100644
浏览文件 @
b08e986e
{
"ShmSize"
:
67108864
,
"RestartPolicy"
:
{
"Name"
:
"no"
}
}
test/specs/specs_extend/oci_runtime_spec.json
0 → 100644
浏览文件 @
b08e986e
此差异已折叠。
点击以展开。
test/specs/specs_extend/specs_extend_llt.cc
0 → 100644
浏览文件 @
b08e986e
/*
* 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.
* Description: specs extend llt
* Author: lifeng
* Create: 2020-02-18
*/
#include <stdlib.h>
#include <stdio.h>
#include <gtest/gtest.h>
#include "mock.h"
#include "oci_runtime_spec.h"
#include "specs.h"
#include "host_config.h"
#include "container_config.h"
#include "oci_llt_common.h"
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "isulad_config_mock.h"
#include "oci_runtime_hooks.h"
#include "utils.h"
#include "specs_extend.h"
using
::
testing
::
Args
;
using
::
testing
::
ByRef
;
using
::
testing
::
SetArgPointee
;
using
::
testing
::
DoAll
;
using
::
testing
::
NiceMock
;
using
::
testing
::
Return
;
using
::
testing
::
NotNull
;
using
::
testing
::
AtLeast
;
using
::
testing
::
Invoke
;
using
::
testing
::
_
;
using
namespace
std
;
#define HOOKS_CONFIG_FILE "specs/specs_extend/hooks.json"
TEST
(
make_sure_oci_spec_linux_llt
,
test_make_sure_oci_spec_linux
)
{
oci_runtime_spec
*
oci_spec
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
ASSERT_EQ
(
make_sure_oci_spec_linux
(
oci_spec
),
0
);
ASSERT_TRUE
(
oci_spec
->
linux
!=
NULL
);
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
TEST
(
make_sure_oci_spec_process_llt
,
test_make_sure_oci_spec_process
)
{
oci_runtime_spec
*
oci_spec
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
ASSERT_EQ
(
make_sure_oci_spec_process
(
oci_spec
),
0
);
ASSERT_TRUE
(
oci_spec
->
process
!=
NULL
);
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
TEST
(
make_sure_oci_spec_linux_resources_llt
,
test_make_sure_oci_spec_linux_resources
)
{
oci_runtime_spec
*
oci_spec
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
ASSERT_EQ
(
make_sure_oci_spec_linux_resources
(
oci_spec
),
0
);
ASSERT_TRUE
(
oci_spec
->
linux
!=
NULL
);
ASSERT_TRUE
(
oci_spec
->
linux
->
resources
!=
NULL
);
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
TEST
(
make_sure_oci_spec_linux_resources_blkio_llt
,
test_make_sure_oci_spec_linux_resources_blkio
)
{
oci_runtime_spec
*
oci_spec
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
ASSERT_EQ
(
make_sure_oci_spec_linux_resources_blkio
(
oci_spec
),
0
);
ASSERT_TRUE
(
oci_spec
->
linux
!=
NULL
);
ASSERT_TRUE
(
oci_spec
->
linux
->
resources
!=
NULL
);
ASSERT_TRUE
(
oci_spec
->
linux
->
resources
->
block_io
!=
NULL
);
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
TEST
(
merge_hooks_llt
,
test_merge_hooks_invalid
)
{
ASSERT_NE
(
merge_hooks
(
nullptr
,
nullptr
),
0
);
}
TEST
(
merge_hooks_llt
,
test_merge_hooks_llt_2
)
{
oci_runtime_spec
*
oci_spec
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
oci_spec
->
hooks
=
(
oci_runtime_spec_hooks
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec_hooks
));
ASSERT_NE
(
merge_hooks
(
oci_spec
->
hooks
,
NULL
),
0
);
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
TEST
(
merge_hooks_llt
,
test_merge_hooks_llt_3
)
{
char
*
hooks_config_file
=
NULL
;
oci_runtime_spec_hooks
*
hooks_spec
=
NULL
;
char
*
err
=
NULL
;
hooks_config_file
=
json_path
(
HOOKS_CONFIG_FILE
);
ASSERT_TRUE
(
hooks_config_file
!=
NULL
);
hooks_spec
=
oci_runtime_spec_hooks_parse_file
(
hooks_config_file
,
NULL
,
&
err
);
ASSERT_TRUE
(
hooks_spec
!=
NULL
);
free
(
err
);
err
=
NULL
;
free
(
hooks_config_file
);
hooks_config_file
=
NULL
;
ASSERT_NE
(
merge_hooks
(
NULL
,
hooks_spec
),
0
);
free_oci_runtime_spec_hooks
(
hooks_spec
);
hooks_spec
=
NULL
;
}
TEST
(
merge_hooks_llt
,
test_merge_hooks_llt_4
)
{
char
*
hooks_config_file
=
NULL
;
oci_runtime_spec_hooks
*
hooks_spec
=
NULL
;
oci_runtime_spec
*
oci_spec
=
NULL
;
char
*
err
=
NULL
;
// All parameter correct
hooks_config_file
=
json_path
(
HOOKS_CONFIG_FILE
);
ASSERT_TRUE
(
hooks_config_file
!=
NULL
);
hooks_spec
=
oci_runtime_spec_hooks_parse_file
(
hooks_config_file
,
NULL
,
&
err
);
ASSERT_TRUE
(
hooks_spec
!=
NULL
);
free
(
err
);
err
=
NULL
;
free
(
hooks_config_file
);
hooks_config_file
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
oci_spec
->
hooks
=
(
oci_runtime_spec_hooks
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec_hooks
));
ASSERT_EQ
(
merge_hooks
(
oci_spec
->
hooks
,
hooks_spec
),
0
);
free_oci_runtime_spec_hooks
(
hooks_spec
);
hooks_spec
=
NULL
;
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
TEST
(
merge_hooks_llt
,
test_merge_hooks_llt_prestart
)
{
char
*
hooks_config_file
=
NULL
;
oci_runtime_spec_hooks
*
hooks_spec
=
NULL
;
oci_runtime_spec
*
oci_spec
=
NULL
;
char
*
err
=
NULL
;
// All parameter correct
hooks_config_file
=
json_path
(
HOOKS_CONFIG_FILE
);
ASSERT_TRUE
(
hooks_config_file
!=
NULL
);
hooks_spec
=
oci_runtime_spec_hooks_parse_file
(
hooks_config_file
,
NULL
,
&
err
);
ASSERT_TRUE
(
hooks_spec
!=
NULL
);
free
(
err
);
err
=
NULL
;
free
(
hooks_config_file
);
hooks_config_file
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
oci_spec
->
hooks
=
(
oci_runtime_spec_hooks
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec_hooks
));
ASSERT_EQ
(
merge_hooks
(
oci_spec
->
hooks
,
hooks_spec
),
0
);
ASSERT_EQ
(
oci_spec
->
hooks
->
prestart_len
,
1
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
prestart
[
0
]
->
path
,
"/home/hooks/start.bash"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
prestart
[
0
]
->
args_len
,
3
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
prestart
[
0
]
->
args
[
0
],
"arg0"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
prestart
[
0
]
->
args
[
1
],
"arg1"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
prestart
[
0
]
->
args
[
2
],
"arg2"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
prestart
[
0
]
->
env_len
,
1
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
prestart
[
0
]
->
env
[
0
],
"key1=value1"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
prestart
[
0
]
->
timeout
,
40
);
free_oci_runtime_spec_hooks
(
hooks_spec
);
hooks_spec
=
NULL
;
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
TEST
(
merge_hooks_llt
,
test_merge_hooks_llt_poststart
)
{
char
*
hooks_config_file
=
NULL
;
oci_runtime_spec_hooks
*
hooks_spec
=
NULL
;
oci_runtime_spec
*
oci_spec
=
NULL
;
char
*
err
=
NULL
;
// All parameter correct
hooks_config_file
=
json_path
(
HOOKS_CONFIG_FILE
);
ASSERT_TRUE
(
hooks_config_file
!=
NULL
);
hooks_spec
=
oci_runtime_spec_hooks_parse_file
(
hooks_config_file
,
NULL
,
&
err
);
ASSERT_TRUE
(
hooks_spec
!=
NULL
);
free
(
err
);
err
=
NULL
;
free
(
hooks_config_file
);
hooks_config_file
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
oci_spec
->
hooks
=
(
oci_runtime_spec_hooks
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec_hooks
));
ASSERT_EQ
(
merge_hooks
(
oci_spec
->
hooks
,
hooks_spec
),
0
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststart_len
,
2
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
0
]
->
path
,
"/home/hooks/post1.bash"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststart
[
0
]
->
args_len
,
3
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
0
]
->
args
[
0
],
"arg5"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
0
]
->
args
[
1
],
"arg6"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
0
]
->
args
[
2
],
"arg7"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststart
[
0
]
->
env_len
,
1
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
0
]
->
env
[
0
],
"key2=value221"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststart
[
0
]
->
timeout
,
60
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
1
]
->
path
,
"/home/hooks/post2.bash"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststart
[
1
]
->
args_len
,
3
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
1
]
->
args
[
0
],
"arg51"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
1
]
->
args
[
1
],
"arg61"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
1
]
->
args
[
2
],
"arg71"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststart
[
1
]
->
env_len
,
1
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststart
[
1
]
->
env
[
0
],
"key3=value3"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststart
[
1
]
->
timeout
,
61
);
free_oci_runtime_spec_hooks
(
hooks_spec
);
hooks_spec
=
NULL
;
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
TEST
(
merge_hooks_llt
,
test_merge_hooks_llt_poststop
)
{
char
*
hooks_config_file
=
NULL
;
oci_runtime_spec_hooks
*
hooks_spec
=
NULL
;
oci_runtime_spec
*
oci_spec
=
NULL
;
char
*
err
=
NULL
;
// All parameter correct
hooks_config_file
=
json_path
(
HOOKS_CONFIG_FILE
);
ASSERT_TRUE
(
hooks_config_file
!=
NULL
);
hooks_spec
=
oci_runtime_spec_hooks_parse_file
(
hooks_config_file
,
NULL
,
&
err
);
ASSERT_TRUE
(
hooks_spec
!=
NULL
);
free
(
err
);
err
=
NULL
;
free
(
hooks_config_file
);
hooks_config_file
=
NULL
;
oci_spec
=
(
oci_runtime_spec
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec
));
ASSERT_TRUE
(
oci_spec
!=
NULL
);
oci_spec
->
hooks
=
(
oci_runtime_spec_hooks
*
)
util_common_calloc_s
(
sizeof
(
oci_runtime_spec_hooks
));
ASSERT_EQ
(
merge_hooks
(
oci_spec
->
hooks
,
hooks_spec
),
0
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststop_len
,
2
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
0
]
->
path
,
"/home/hooks/stop1.bash"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststop
[
0
]
->
args_len
,
3
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
0
]
->
args
[
0
],
"arg11"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
0
]
->
args
[
1
],
"arg12"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
0
]
->
args
[
2
],
"arg13"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststop
[
0
]
->
env_len
,
1
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
0
]
->
env
[
0
],
"key2=value221"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststop
[
0
]
->
timeout
,
60
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
1
]
->
path
,
"/home/hooks/stop2.bash"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststop
[
1
]
->
args_len
,
3
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
1
]
->
args
[
0
],
"arg52"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
1
]
->
args
[
1
],
"arg62"
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
1
]
->
args
[
2
],
"arg72"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststop
[
1
]
->
env_len
,
1
);
ASSERT_STREQ
(
oci_spec
->
hooks
->
poststop
[
1
]
->
env
[
0
],
"key4=value4"
);
ASSERT_EQ
(
oci_spec
->
hooks
->
poststop
[
1
]
->
timeout
,
62
);
free_oci_runtime_spec_hooks
(
hooks_spec
);
hooks_spec
=
NULL
;
free_oci_runtime_spec
(
oci_spec
);
oci_spec
=
NULL
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录