Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
59ad99ba
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,发现更多精彩内容 >>
提交
59ad99ba
编写于
5月 30, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
5月 30, 2020
浏览文件
操作
浏览文件
下载
差异文件
!391 clean code: add check in util_sub_string
Merge pull request !391 from lifeng_isula/master
上级
bc7486dd
f07e6579
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
71 addition
and
99 deletion
+71
-99
CI/Dockerfile
CI/Dockerfile
+24
-12
CI/install_depends.sh
CI/install_depends.sh
+1
-0
CI/test_cases/basic_cases/check_fd_leakage_of_isulad.bash
CI/test_cases/basic_cases/check_fd_leakage_of_isulad.bash
+1
-1
CI/test_cases/basic_cases/cni_test.bash
CI/test_cases/basic_cases/cni_test.bash
+13
-4
CI/test_cases/basic_cases/create.bash
CI/test_cases/basic_cases/create.bash
+1
-1
CI/test_cases/basic_cases/create_mtab_test.bash
CI/test_cases/basic_cases/create_mtab_test.bash
+1
-1
CI/test_cases/basic_cases/import.bash
CI/test_cases/basic_cases/import.bash
+1
-1
CI/test_cases/basic_cases/ps.bash
CI/test_cases/basic_cases/ps.bash
+1
-1
CI/test_cases/basic_cases/restartpolicy.bash
CI/test_cases/basic_cases/restartpolicy.bash
+1
-1
CI/test_cases/basic_cases/rm.bash
CI/test_cases/basic_cases/rm.bash
+1
-1
CI/test_cases/basic_cases/run.bash
CI/test_cases/basic_cases/run.bash
+1
-1
CI/test_cases/basic_cases/share_ns_test.bash
CI/test_cases/basic_cases/share_ns_test.bash
+1
-1
CI/test_cases/basic_cases/stop.bash
CI/test_cases/basic_cases/stop.bash
+1
-1
CI/test_cases/basic_cases/test_data/pause.tar
CI/test_cases/basic_cases/test_data/pause.tar
+0
-0
CI/test_cases/basic_cases/update.bash
CI/test_cases/basic_cases/update.bash
+1
-1
CI/test_cases/helpers.bash
CI/test_cases/helpers.bash
+2
-41
src/cutils/utils_string.c
src/cutils/utils_string.c
+20
-31
未找到文件。
CI/Dockerfile
浏览文件 @
59ad99ba
...
...
@@ -24,15 +24,17 @@
FROM
centos:7.6.1810
MAINTAINER
LiFeng <lifeng68@huawei.com>
RUN
echo
"nameserver 8.8.8.8"
>
/etc/resolv.conf
&&
\
echo
"nameserver 8.8.4.4"
>>
/etc/resolv.conf
&&
\
echo
"search localdomain"
>>
/etc/resolv.conf
# Install dependency package
RUN
yum clean all
&&
yum swap
-y
fakesystemd systemd
&&
\
yum
install
-y
epel-release
\
RUN
yum clean all
&&
yum makecache
&&
yum
install
-y
epel-release
&&
yum swap
-y
fakesystemd systemd
&&
\
yum update
-y
&&
\
yum
install
-y
automake
\
autoconf
\
libtool
\
make
\
cmake
\
which
\
gdb
\
strace
\
...
...
@@ -48,7 +50,6 @@ RUN yum clean all && yum swap -y fakesystemd systemd && \
libseccomp-devel
\
yajl-devel
\
git
\
bridge-utils
\
dnsmasq
\
libcgroup
\
rsync
\
...
...
@@ -65,9 +66,9 @@ RUN yum clean all && yum swap -y fakesystemd systemd && \
cppcheck
\
python3
\
python3-pip
\
python
\
python-pip
\
device-mapper-devel
\
libarchive
\
libarchive-devel
\
libcurl-devel
\
zlib-devel
\
glibc-headers
\
...
...
@@ -87,8 +88,6 @@ RUN yum clean all && yum swap -y fakesystemd systemd && \
valgrind
\
e2fsprogs
RUN
pip
install
xlrd
RUN
yum clean all
&&
\
(
cd
/lib/systemd/system/sysinit.target.wants/
;
for
i
in
*
;
\
do
[
$i
==
systemd-tmpfiles-setup.service
]
||
rm
-f
$i
;
done
)
;
\
...
...
@@ -109,6 +108,17 @@ RUN echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" >> /
# disalbe sslverify
RUN
git config
--global
http.sslverify
false
# install cmake
RUN
set
-x
&&
\
cd
~
&&
\
git clone https://gitee.com/src-openeuler/cmake.git
&&
\
cd
cmake
&&
\
git checkout origin/openEuler-20.03-LTS
&&
\
tar
-xzvf
cmake-3.12.1.tar.gz
&&
\
cd
cmake-3.12.1
&&
\
./bootstrap
&&
make
-j
&&
make
install
&&
\
ldconfig
# Centos has no protobuf, protobuf-devel, grpc, grpc-devel, grpc-plugin
# and we should install them manually.
# install protobuf
...
...
@@ -170,10 +180,12 @@ RUN export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH && \
cd
~
&&
\
git clone https://gitee.com/src-openeuler/libevhtp.git
&&
\
cd
libevhtp
&&
\
tar
-xzvf
libevhtp-1.2.16.tar.gz
&&
\
cd
libevhtp-1.2.16
&&
\
patch
-p1
-F1
-s
< ../0001-support-dynamic-threads.patch
&&
\
patch
-p1
-F1
-s
< ../0002-close-openssl.patch
&&
\
tar
-xzvf
libevhtp-1.2.18.tar.gz
&&
\
cd
libevhtp-1.2.18
&&
\
patch
-p1
-F1
-s
< ../0001-decrease-numbers-of-fd-for-shared-pipe-mode.patch
&&
\
patch
-p1
-F1
-s
< ../0002-evhtp-enable-dynamic-thread-pool.patch
&&
\
patch
-p1
-F1
-s
< ../0003-close-open-ssl.-we-do-NOT-use-it-in-lcrd.patch
&&
\
patch
-p1
-F1
-s
< ../0004-Use-shared-library-instead-static-one.patch
&&
\
rm
-rf
build
&&
\
mkdir
build
&&
\
cd
build
&&
\
...
...
CI/install_depends.sh
浏览文件 @
59ad99ba
...
...
@@ -102,6 +102,7 @@ do
done
sed
-i
's/fd == STDIN_FILENO || fd == STDOUT_FILENO || fd == STDERR_FILENO/fd == 0 || fd == 1 || fd == 2 || fd >= 1000/g'
./src/lxc/start.c
sed
-i
'/unmount-namespace/d'
./lxc.spec.in
sed
-i
'/bridge-utils/d'
./lxc.spec.in
./autogen.sh
./configure
--sysconfdir
=
/etc
make rpm
...
...
CI/test_cases/basic_cases/check_fd_leakage_of_isulad.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance fd
# concurrent: NO
# spend time:
40
# spend time:
15
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
# - iSulad licensed under the Mulan PSL v2.
...
...
CI/test_cases/basic_cases/cni_test.bash
浏览文件 @
59ad99ba
...
...
@@ -2,16 +2,18 @@
#
# attributes: isulad cri cni
# concurrent: NA
# spend time:
10
# spend time:
28
curr_path
=
$(
dirname
$(
readlink
-f
"
$0
"
))
data_path
=
$(
realpath
$curr_path
/criconfigs
)
pause_img_path
=
$(
realpath
$curr_path
/test_data
)
source
../helpers.bash
function
do_pre
()
{
systemctl stop firewalld.service
cp
/etc/isulad/daemon.json /etc/isulad/daemon.bak
sed
-i
"s#
\"
pod-sandbox-image
\"
:
\"\"
#
\"
pod-sandbox-image
\"
:
\"
rancher
/pause-amd64:3.0
\"
#g"
/etc/isulad/daemon.json
sed
-i
"s#
\"
pod-sandbox-image
\"
:
\"\"
#
\"
pod-sandbox-image
\"
:
\"
mirrorgooglecontainers
/pause-amd64:3.0
\"
#g"
/etc/isulad/daemon.json
init_cni_conf
$data_path
if
[
$?
-ne
0
]
;
then
...
...
@@ -19,13 +21,20 @@ function do_pre()
TC_RET_T
=
$((
$TC_RET_T
+
1
))
return
$TC_RET_T
fi
isula load
-i
${
pause_img_path
}
/pause.tar
if
[
$?
-ne
0
]
;
then
ERROR
"Failed to load pause image"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
return
$TC_RET_T
fi
}
function
do_post
()
{
cp
-f
/etc/isulad/daemon.bak /etc/isulad/daemon.json
stop_isulad_without_valgrind
start_isulad_with
out
_valgrind
check_valgrind_log
start_isulad_with_valgrind
}
function
do_test_help
()
...
...
CI/test_cases/basic_cases/create.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance create
# concurrent: YES
# spend time:
8
# spend time:
6
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/create_mtab_test.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance start
# concurrent: YES
# spend time:
11
# spend time:
2
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/import.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance import
# concurrent: YES
# spend time:
14
# spend time:
3
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/ps.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance ps list
# concurrent: NO
# spend time: 1
4
# spend time: 1
3
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/restartpolicy.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance restartpolicy
# concurrent: NO
# spend time: 2
5
# spend time: 2
4
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/rm.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance rm
# concurrent: YES
# spend time: 1
4
# spend time: 1
3
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/run.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance run
# concurrent: YES
# spend time:
12
# spend time:
3
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/share_ns_test.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad share namepaces
# concurrent: NO
# spend time:
6
# spend time:
21
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/stop.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance stop
# concurrent: YES
# spend time: 2
4
# spend time: 2
9
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/basic_cases/test_data/pause.tar
0 → 100644
浏览文件 @
59ad99ba
文件已添加
CI/test_cases/basic_cases/update.bash
浏览文件 @
59ad99ba
...
...
@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance update
# concurrent: YES
# spend time: 1
7
# spend time: 1
5
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
...
...
CI/test_cases/helpers.bash
浏览文件 @
59ad99ba
...
...
@@ -9,7 +9,6 @@ TC_RET_T=0
# image to pull and run container
BUSYBOX_IMAGE
=
"busybox:latest"
PAUSE_IMAGE
=
"rancher/pause-amd64:3.0"
valgrind_log
=
"/tmp/valgrind.log"
ISUALD_LOG
=
"/var/lib/isulad/isulad.log"
ISULAD_ROOT_DIR
=
"/var/lib/isulad"
...
...
@@ -121,11 +120,6 @@ function start_isulad_with_valgrind() {
wait_isulad_running
}
function
start_isulad_without_valgrind
()
{
isulad
$@
-l
DEBUG
>
/dev/null 2>&1 &
wait_isulad_running
}
function
check_isulad_stopped
()
{
maxtimes
=
15
curcnt
=
0
...
...
@@ -143,17 +137,6 @@ function check_isulad_stopped() {
return
1
}
function
stop_isulad_without_valgrind
()
{
pid
=
`
cat
/var/run/isulad.pid
`
kill
-15
$pid
check_isulad_stopped
$pid
if
[
$?
-ne
0
]
;
then
echo
"iSulad process is still alive"
return
1
fi
return
0
}
function
check_valgrind_log
()
{
pid
=
`
cat
/var/run/isulad.pid
`
kill
-15
$pid
...
...
@@ -233,13 +216,13 @@ function init_cni_conf()
cp
$dtpath
/bins/isulad-cni /opt/cni/bin
cp
$dtpath
/good.conflist /etc/cni/net.d/
stop_isulad_without_valgrind
check_valgrind_log
if
[
$?
-ne
0
]
;
then
echo
"stop isulad failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
start_isulad_with
out
_valgrind
--network-plugin
cni
start_isulad_with_valgrind
--network-plugin
cni
if
[
$?
-ne
0
]
;
then
echo
"start failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
...
...
@@ -260,25 +243,3 @@ function wait_container_state()
done
}
function
pull_images
()
{
isula inspect
$BUSYBOX_IMAGE
>
/dev/null
if
[
$?
-ne
0
]
;
then
isula pull
$BUSYBOX_IMAGE
if
[
$?
-ne
0
]
;
then
echo
"failed pull busybox image"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
fi
isula inspect
$PAUSE_IMAGE
>
/dev/null
if
[
$?
-ne
0
]
;
then
isula pull
$PAUSE_IMAGE
if
[
$?
-ne
0
]
;
then
echo
"failed pull pause image"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
fi
return
$TC_RET_T
}
pull_images
src/cutils/utils_string.c
浏览文件 @
59ad99ba
...
...
@@ -28,29 +28,14 @@ struct unit_map_def {
};
static
struct
unit_map_def
const
g_unit_map
[]
=
{
{.
mltpl
=
1
,
.
name
=
"I"
},
{.
mltpl
=
1
,
.
name
=
"B"
},
{.
mltpl
=
1
,
.
name
=
"IB"
},
{.
mltpl
=
SIZE_KB
,
.
name
=
"K"
},
{.
mltpl
=
SIZE_KB
,
.
name
=
"KI"
},
{.
mltpl
=
SIZE_KB
,
.
name
=
"KB"
},
{.
mltpl
=
SIZE_KB
,
.
name
=
"KIB"
},
{.
mltpl
=
SIZE_MB
,
.
name
=
"M"
},
{.
mltpl
=
SIZE_MB
,
.
name
=
"MI"
},
{.
mltpl
=
SIZE_MB
,
.
name
=
"MB"
},
{.
mltpl
=
SIZE_MB
,
.
name
=
"MIB"
},
{.
mltpl
=
SIZE_GB
,
.
name
=
"G"
},
{.
mltpl
=
SIZE_GB
,
.
name
=
"GI"
},
{.
mltpl
=
SIZE_GB
,
.
name
=
"GB"
},
{.
mltpl
=
SIZE_GB
,
.
name
=
"GIB"
},
{.
mltpl
=
SIZE_TB
,
.
name
=
"T"
},
{.
mltpl
=
SIZE_TB
,
.
name
=
"TI"
},
{.
mltpl
=
SIZE_TB
,
.
name
=
"TB"
},
{.
mltpl
=
SIZE_TB
,
.
name
=
"TIB"
},
{.
mltpl
=
SIZE_PB
,
.
name
=
"P"
},
{.
mltpl
=
SIZE_PB
,
.
name
=
"PI"
},
{.
mltpl
=
SIZE_PB
,
.
name
=
"PB"
},
{.
mltpl
=
SIZE_PB
,
.
name
=
"PIB"
}
{
.
mltpl
=
1
,
.
name
=
"I"
},
{
.
mltpl
=
1
,
.
name
=
"B"
},
{
.
mltpl
=
1
,
.
name
=
"IB"
},
{
.
mltpl
=
SIZE_KB
,
.
name
=
"K"
},
{
.
mltpl
=
SIZE_KB
,
.
name
=
"KI"
},
{
.
mltpl
=
SIZE_KB
,
.
name
=
"KB"
},
{
.
mltpl
=
SIZE_KB
,
.
name
=
"KIB"
},
{
.
mltpl
=
SIZE_MB
,
.
name
=
"M"
},
{
.
mltpl
=
SIZE_MB
,
.
name
=
"MI"
},
{
.
mltpl
=
SIZE_MB
,
.
name
=
"MB"
},
{
.
mltpl
=
SIZE_MB
,
.
name
=
"MIB"
},
{
.
mltpl
=
SIZE_GB
,
.
name
=
"G"
},
{
.
mltpl
=
SIZE_GB
,
.
name
=
"GI"
},
{
.
mltpl
=
SIZE_GB
,
.
name
=
"GB"
},
{
.
mltpl
=
SIZE_GB
,
.
name
=
"GIB"
},
{
.
mltpl
=
SIZE_TB
,
.
name
=
"T"
},
{
.
mltpl
=
SIZE_TB
,
.
name
=
"TI"
},
{
.
mltpl
=
SIZE_TB
,
.
name
=
"TB"
},
{
.
mltpl
=
SIZE_TB
,
.
name
=
"TIB"
},
{
.
mltpl
=
SIZE_PB
,
.
name
=
"P"
},
{
.
mltpl
=
SIZE_PB
,
.
name
=
"PI"
},
{
.
mltpl
=
SIZE_PB
,
.
name
=
"PB"
},
{
.
mltpl
=
SIZE_PB
,
.
name
=
"PIB"
}
};
static
size_t
const
g_unit_map_len
=
sizeof
(
g_unit_map
)
/
sizeof
(
g_unit_map
[
0
]);
...
...
@@ -190,7 +175,6 @@ static int parse_unit_multiple(const char *unit, int64_t *mltpl)
return
-
EINVAL
;
}
static
int
util_parse_size_int_and_float
(
const
char
*
numstr
,
int64_t
mlt
,
int64_t
*
converted
)
{
long
long
int_size
=
0
;
...
...
@@ -294,8 +278,8 @@ int util_parse_percent_string(const char *s, long *converted)
dup
[
strlen
(
dup
)
-
1
]
=
0
;
*
converted
=
strtol
(
dup
,
NULL
,
10
);
if
((
errno
==
ERANGE
&&
(
*
converted
==
LONG_MAX
||
*
converted
==
LONG_MIN
))
||
(
errno
!=
0
&&
*
converted
==
0
)
||
*
converted
<
0
||
*
converted
>
100
)
{
if
((
errno
==
ERANGE
&&
(
*
converted
==
LONG_MAX
||
*
converted
==
LONG_MIN
))
||
(
errno
!=
0
&&
*
converted
==
0
)
||
*
converted
<
0
||
*
converted
>
100
)
{
free
(
dup
);
return
-
EINVAL
;
}
...
...
@@ -476,7 +460,7 @@ const char *str_skip_str(const char *str, const char *skip)
return
NULL
;
}
for
(;
;
str
++
,
skip
++
)
{
for
(;;
str
++
,
skip
++
)
{
if
(
*
skip
==
0
)
{
return
str
;
}
else
if
(
*
str
!=
*
skip
)
{
...
...
@@ -485,7 +469,6 @@ const char *str_skip_str(const char *str, const char *skip)
}
}
static
char
*
util_string_delchar_inplace
(
char
*
s
,
unsigned
char
c
)
{
size_t
i
=
0
;
...
...
@@ -548,7 +531,8 @@ static char *util_left_trim_space(char *str)
while
(
isspace
(
*
begin
))
{
begin
++
;
}
while
((
*
tmp
++
=
*
begin
++
))
{}
while
((
*
tmp
++
=
*
begin
++
))
{
}
return
str
;
}
...
...
@@ -590,7 +574,8 @@ static char *util_left_trim_quotation(char *str)
while
((
*
begin
)
==
'\"'
)
{
begin
++
;
}
while
((
*
tmp
++
=
*
begin
++
))
{}
while
((
*
tmp
++
=
*
begin
++
))
{
}
return
str
;
}
...
...
@@ -759,6 +744,11 @@ char *util_sub_string(const char *source, size_t offset, size_t length)
}
total_len
=
strlen
(
source
);
if
(
offset
>
total_len
)
{
return
NULL
;
}
substr_len
=
((
total_len
-
offset
)
>=
length
?
length
:
(
total_len
-
offset
))
+
1
;
substring
=
(
char
*
)
util_common_calloc_s
(
substr_len
*
sizeof
(
char
));
if
(
substring
==
NULL
)
{
...
...
@@ -787,4 +777,3 @@ bool util_is_space_string(const char *str)
return
true
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录