提交 59ad99ba 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!391 clean code: add check in util_sub_string

Merge pull request !391 from lifeng_isula/master
......@@ -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 && \
......
......@@ -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
......
......@@ -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.
......
......@@ -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_without_valgrind
check_valgrind_log
start_isulad_with_valgrind
}
function do_test_help()
......
......@@ -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.
......
......@@ -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.
......
......@@ -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.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance ps list
# concurrent: NO
# spend time: 14
# spend time: 13
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance restartpolicy
# concurrent: NO
# spend time: 25
# spend time: 24
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance rm
# concurrent: YES
# spend time: 14
# spend time: 13
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -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.
......
......@@ -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.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance stop
# concurrent: YES
# spend time: 24
# spend time: 29
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance update
# concurrent: YES
# spend time: 17
# spend time: 15
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -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_without_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
......@@ -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;
}
......@@ -734,7 +734,7 @@ static host_config_host_channel *dup_host_channel(const host_config_host_channel
dup_channel->path_on_host = channel->path_on_host != NULL ? util_strdup_s(channel->path_on_host) : NULL;
dup_channel->path_in_container = channel->path_in_container != NULL ? util_strdup_s(channel->path_in_container) :
NULL;
NULL;
dup_channel->permissions = channel->permissions != NULL ? util_strdup_s(channel->permissions) : NULL;
dup_channel->size = channel->size;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册