提交 848008ad 编写于 作者: L lifeng68

CI: fix testcases error

Signed-off-by: Nlifeng68 <lifeng68@huawei.com>
上级 7c34fd25
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance fd
# concurrent: NO
# spend time: 16
# spend time: 14
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
# - iSulad licensed under the Mulan PSL v2.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad cri cni
# concurrent: NA
# spend time: 45
# spend time: 43
curr_path=$(dirname $(readlink -f "$0"))
data_path=$(realpath $curr_path/criconfigs)
......@@ -41,9 +41,15 @@ function do_test_help()
{
msg_info "this is $0 do_test"
crictl images | grep busybox
crictl pull busybox
if [ $? -ne 0 ]; then
msg_err "Failed to find busybox image"
msg_err "Failed to pull busybox image"
TC_RET_T=$(($TC_RET_T+1))
fi
crictl images | grep "mirrorgooglecontainers/pause-amd64"
if [ $? -ne 0 ]; then
msg_err "Failed to find mirrorgooglecontainers/pause-amd64 image"
TC_RET_T=$(($TC_RET_T+1))
fi
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance create
# concurrent: YES
# spend time: 23
# spend time: 5
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance start
# concurrent: YES
# spend time: 6
# spend time: 2
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad basic export container
# concurrent: NA
# spend time: 5
# spend time: 6
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......@@ -47,6 +47,8 @@ function test_image_export()
isula export -o nonexistdir/export.tar ${CONT}
[[ $? -eq 0 ]] && msg_err "${FUNCNAME[0]}:${LINENO} - export to nonexist directory success" && ((ret++))
isula rm -f ${CONT}
msg_info "${test} finished with return ${ret}..."
return ${ret}
}
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance kill
# concurrent: YES
# spend time: 4
# spend time: 9
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance ps list
# concurrent: NO
# spend time: 13
# spend time: 11
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance restart
# concurrent: YES
# spend time: 38
# spend time: 32
#######################################################################
##- @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: 15
# spend time: 12
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance run
# concurrent: YES
# spend time: 5
# spend time: 3
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad share namepaces
# concurrent: NO
# spend time: 45
# spend time: 25
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......@@ -36,14 +36,13 @@ function do_test_t()
cid[$i]=`isula create -ti busybox /bin/sh`
fn_check_eq "$?" "0" "create ${cid[$i]}"
msg=`isula run -tid ${arr_ns_type[$i]}="container:${cid[$i]}" busybox /bin/sh 2>&1`
msg=`isula run --name test1 -tid ${arr_ns_type[$i]}="container:${cid[$i]}" busybox /bin/sh 2>&1`
echo $msg | grep "Can not join namespace of a non running container"
fn_check_eq "$?" "0" "share ipc fail test"
isula rm -f ${cid[$i]}
isula rm -f test1
rid[$i]=`isula run -tid busybox /bin/sh`
fn_check_eq "$?" "0" "run ${rid[$i]}"
isula rm -f ${cid[$i]}
id=`isula run -tid busybox /bin/sh`
fn_check_eq "$?" "0" "run $id"
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance update
# concurrent: YES
# spend time: 14
# spend time: 15
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -24,7 +24,7 @@ LCR_ROOT_PATH="/var/lib/isulad/engines/lcr"
valgrind_log="/tmp/valgrind.log"
ISUALD_LOG="/var/lib/isulad/isulad.log"
declare -r -i FAILURE=-1
declare -r -i FAILURE=1
function cut_output_lines() {
message=`$@ 2>&1`
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad basic image list ps inspect
# concurrent: NA
# spend time: 8
# spend time: 4
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad basic remove image
# concurrent: NA
# spend time: 12
# spend time: 8
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance tag
# concurrent: YES
# spend time: 59
# spend time: 33
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad basic image
# concurrent: NA
# spend time: 7
# spend time: 11
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad basic image
# concurrent: NA
# spend time: 5
# spend time: 3
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -2,7 +2,7 @@
#
# attributes: isulad inheritance version
# concurrent: YES
# spend time: 22
# spend time: 9
#######################################################################
##- @Copyright (C) Huawei Technologies., Ltd. 2020. All rights reserved.
......
......@@ -24,7 +24,7 @@
#define MANIFEST_BIG_DATA_KEY "manifest"
#define OCI_SCHEMA_VERSION 2
#define OCI_LOAD_TMP_DIR OCI_LOAD_TMP_WORK_DIR"/oci-image-load-XXXXXX"
#define OCI_LOAD_TMP_DIR OCI_LOAD_TMP_WORK_DIR "/oci-image-load-XXXXXX"
static image_manifest_items_element **load_manifest(const char *fname, size_t *length)
{
......@@ -358,6 +358,7 @@ static int oci_load_create_image(load_image_t *desc)
struct storage_img_create_options opts = { 0 };
char *top_layer_id = NULL;
char *pre_top_layer = NULL;
char *normalized_name = NULL;
oci_image_spec *conf = NULL;
types_timestamp_t timestamp = { 0 };
......@@ -403,16 +404,25 @@ static int oci_load_create_image(load_image_t *desc)
}
for (; i < desc->repo_tags_len; i++) {
ret = storage_img_add_name(desc->im_id, desc->repo_tags[i]);
normalized_name = oci_normalize_image_name(desc->repo_tags[i]);
if (normalized_name == NULL) {
ret = -1;
ERROR("Failed to normalized name %s", desc->repo_tags[i]);
goto out;
}
ret = storage_img_add_name(desc->im_id, normalized_name);
if (ret != 0) {
ERROR("add image name failed");
goto out;
}
free(normalized_name);
normalized_name = NULL;
}
out:
free_oci_image_spec(conf);
free(pre_top_layer);
free(normalized_name);
return ret;
}
......
......@@ -667,6 +667,7 @@ static int fetch_data(pull_descriptor *desc, char *path, char *file, char *conte
if (strcmp(content_type, DOCKER_MANIFEST_SCHEMA1_PRETTYJWS) && digest != NULL) {
if (!util_valid_digest_file(file, digest)) {
ERROR("data from %s does not have digest %s", path, digest);
ret = -1;
goto out;
}
}
......
......@@ -1931,7 +1931,7 @@ bool image_store_exists(const char *id)
img = lookup(id);
if (img == NULL) {
ERROR("Image not known");
ERROR("Image %s not known", id);
ret = false;
goto out;
}
......
......@@ -487,7 +487,7 @@ static defs_process *make_exec_process_spec(const container_config *container_sp
}
spec->terminal = request->tty;
spec->cwd = util_strdup_s(container_spec->working_dir ? container_spec->working_dir : "/");
spec->cwd = util_strdup_s(util_valid_str(container_spec->working_dir) ? container_spec->working_dir : "/");
return spec;
......
......@@ -49,31 +49,31 @@
#include "selinux_label.h"
#ifndef CLONE_NEWUTS
#define CLONE_NEWUTS 0x04000000
#define CLONE_NEWUTS 0x04000000
#endif
#ifndef CLONE_NEWUSER
#define CLONE_NEWUSER 0x10000000
#define CLONE_NEWUSER 0x10000000
#endif
#ifndef CLONE_NEWNET
#define CLONE_NEWNET 0x40000000
#define CLONE_NEWNET 0x40000000
#endif
#ifndef CLONE_NEWNS
#define CLONE_NEWNS 0x00020000
#define CLONE_NEWNS 0x00020000
#endif
#ifndef CLONE_NEWPID
#define CLONE_NEWPID 0x20000000
#define CLONE_NEWPID 0x20000000
#endif
#ifndef CLONE_NEWIPC
#define CLONE_NEWIPC 0x08000000
#define CLONE_NEWIPC 0x08000000
#endif
#ifndef CLONE_NEWCGROUP
#define CLONE_NEWCGROUP 0x02000000
#define CLONE_NEWCGROUP 0x02000000
#endif
static int make_sure_oci_spec_annotations(oci_runtime_spec *oci_spec)
......@@ -274,7 +274,8 @@ static int add_native_umask(const container_config *container_spec)
if (strcmp(container_spec->annotations->keys[i], ANNOTATION_UMAKE_KEY) == 0) {
if (!is_valid_umask_value(container_spec->annotations->values[i])) {
ERROR("native.umask option %s not supported", container_spec->annotations->values[i]);
isulad_set_error_message("native.umask option %s not supported", container_spec->annotations->values[i]);
isulad_set_error_message("native.umask option %s not supported",
container_spec->annotations->values[i]);
ret = -1;
}
goto out;
......@@ -668,18 +669,16 @@ static int merge_hugetlbs(oci_runtime_spec *oci_spec, host_config_hugetlbs_eleme
goto out;
}
if (hugetlbs_len > SIZE_MAX / sizeof(defs_resources_hugepage_limits_element *) -
oci_spec->linux->resources->hugepage_limits_len) {
if (hugetlbs_len >
SIZE_MAX / sizeof(defs_resources_hugepage_limits_element *) - oci_spec->linux->resources->hugepage_limits_len) {
ERROR("Too many hugetlbs to merge!");
ret = -1;
goto out;
}
old_size = oci_spec->linux->resources->hugepage_limits_len *
old_size = oci_spec->linux->resources->hugepage_limits_len * sizeof(defs_resources_hugepage_limits_element *);
new_size = (oci_spec->linux->resources->hugepage_limits_len + hugetlbs_len) *
sizeof(defs_resources_hugepage_limits_element *);
new_size = (oci_spec->linux->resources->hugepage_limits_len + hugetlbs_len)
* sizeof(defs_resources_hugepage_limits_element *);
ret = mem_realloc((void **)&hugepage_limits_temp, new_size,
oci_spec->linux->resources->hugepage_limits, old_size);
ret = mem_realloc((void **)&hugepage_limits_temp, new_size, oci_spec->linux->resources->hugepage_limits, old_size);
if (ret != 0) {
ERROR("Failed to realloc memory for hugepage limits");
ret = -1;
......@@ -689,17 +688,17 @@ static int merge_hugetlbs(oci_runtime_spec *oci_spec, host_config_hugetlbs_eleme
oci_spec->linux->resources->hugepage_limits = hugepage_limits_temp;
for (i = 0; i < hugetlbs_len; i++) {
oci_spec->linux->resources->hugepage_limits[oci_spec->linux->resources->hugepage_limits_len]
= util_common_calloc_s(sizeof(defs_resources_hugepage_limits_element));
oci_spec->linux->resources->hugepage_limits[oci_spec->linux->resources->hugepage_limits_len] =
util_common_calloc_s(sizeof(defs_resources_hugepage_limits_element));
if (oci_spec->linux->resources->hugepage_limits[oci_spec->linux->resources->hugepage_limits_len] == NULL) {
ERROR("Failed to malloc memory for hugepage limits");
ret = -1;
goto out;
}
oci_spec->linux->resources->hugepage_limits[oci_spec->linux->resources->hugepage_limits_len]->limit
= hugetlbs[i]->limit;
oci_spec->linux->resources->hugepage_limits[oci_spec->linux->resources->hugepage_limits_len]->page_size
= util_strdup_s(hugetlbs[i]->page_size);
oci_spec->linux->resources->hugepage_limits[oci_spec->linux->resources->hugepage_limits_len]->limit =
hugetlbs[i]->limit;
oci_spec->linux->resources->hugepage_limits[oci_spec->linux->resources->hugepage_limits_len]->page_size =
util_strdup_s(hugetlbs[i]->page_size);
oci_spec->linux->resources->hugepage_limits_len++;
}
out:
......@@ -896,8 +895,7 @@ out:
return ret;
}
static int merge_hostname(oci_runtime_spec *oci_spec, const host_config *host_spec,
container_config *container_spec)
static int merge_hostname(oci_runtime_spec *oci_spec, const host_config *host_spec, container_config *container_spec)
{
free(oci_spec->hostname);
oci_spec->hostname = util_strdup_s(container_spec->hostname);
......@@ -1086,8 +1084,7 @@ out:
return ret;
}
static int do_merge_one_ulimit_override(const oci_runtime_spec *oci_spec,
defs_process_rlimits_element *rlimit)
static int do_merge_one_ulimit_override(const oci_runtime_spec *oci_spec, defs_process_rlimits_element *rlimit)
{
size_t j;
bool exists = false;
......@@ -1386,8 +1383,8 @@ static int merge_share_namespace_helper(const oci_runtime_spec *oci_spec, const
goto out;
}
ret = mem_realloc((void **)&work_ns, (len + 1) * sizeof(defs_namespace_reference *),
(void *)work_ns, len * sizeof(defs_namespace_reference *));
ret = mem_realloc((void **)&work_ns, (len + 1) * sizeof(defs_namespace_reference *), (void *)work_ns,
len * sizeof(defs_namespace_reference *));
if (ret != 0) {
ERROR("Out of memory");
goto out;
......@@ -1480,7 +1477,7 @@ static int merge_working_dir(oci_runtime_spec *oci_spec, const char *working_dir
{
int ret = 0;
if (working_dir == NULL) {
if (!util_valid_str(working_dir)) {
return 0;
}
......@@ -1519,8 +1516,8 @@ static int change_tmpfs_mount_size(const oci_runtime_spec *oci_spec, int64_t mem
if (strcmp("tmpfs", oci_spec->mounts[i]->type) != 0) {
continue;
}
if (strcmp("/run", oci_spec->mounts[i]->destination) == 0 || \
strcmp("/run/lock", oci_spec->mounts[i]->destination) == 0 || \
if (strcmp("/run", oci_spec->mounts[i]->destination) == 0 ||
strcmp("/run/lock", oci_spec->mounts[i]->destination) == 0 ||
strcmp("/tmp", oci_spec->mounts[i]->destination) == 0) {
ret = util_array_append(&oci_spec->mounts[i]->options, size_opt);
if (ret != 0) {
......@@ -1687,9 +1684,8 @@ out:
return ret;
}
int parse_security_opt(const host_config *host_spec, bool *no_new_privileges,
char ***label_opts, size_t *label_opts_len,
char **seccomp_profile)
int parse_security_opt(const host_config *host_spec, bool *no_new_privileges, char ***label_opts,
size_t *label_opts_len, char **seccomp_profile)
{
int ret = 0;
size_t i;
......@@ -1794,8 +1790,8 @@ static int handle_host_or_privileged_mode(host_config *hc)
goto out;
}
if (to_host_config_selinux_labels((const char **)labels, labels_len,
&hc->security_opt, &hc->security_opt_len) != 0) {
if (to_host_config_selinux_labels((const char **)labels, labels_len, &hc->security_opt, &hc->security_opt_len) !=
0) {
ret = -1;
goto out;
}
......@@ -1805,8 +1801,8 @@ out:
return ret;
}
static int handle_ipc_pid_label(host_config *hc, const char **ipc_label, size_t ipc_label_len,
const char **pid_label, size_t pid_label_len)
static int handle_ipc_pid_label(host_config *hc, const char **ipc_label, size_t ipc_label_len, const char **pid_label,
size_t pid_label_len)
{
int ret = 0;
size_t i;
......@@ -1824,8 +1820,8 @@ static int handle_ipc_pid_label(host_config *hc, const char **ipc_label, size_t
goto out;
}
}
if (to_host_config_selinux_labels((const char **)pid_label, pid_label_len,
&hc->security_opt, &hc->security_opt_len) != 0) {
if (to_host_config_selinux_labels((const char **)pid_label, pid_label_len, &hc->security_opt,
&hc->security_opt_len) != 0) {
ret = -1;
goto out;
}
......@@ -1882,8 +1878,8 @@ static int handle_connected_container_mode(host_config *hc)
free(pid_process_label);
}
if (handle_ipc_pid_label(hc, (const char **)ipc_label, ipc_label_len,
(const char **)pid_label, pid_label_len) != 0) {
if (handle_ipc_pid_label(hc, (const char **)ipc_label, ipc_label_len, (const char **)pid_label, pid_label_len) !=
0) {
ret = -1;
goto out;
}
......@@ -1921,7 +1917,6 @@ static int generate_security_opt(host_config *hc)
return handle_connected_container_mode(hc);
}
static int merge_security_conf(oci_runtime_spec *oci_spec, host_config *host_spec,
container_config_v2_common_config *v2_spec)
{
......@@ -1950,8 +1945,7 @@ static int merge_security_conf(oci_runtime_spec *oci_spec, host_config *host_spe
goto out;
}
ret = parse_security_opt(host_spec, &no_new_privileges, &label_opts,
&label_opts_len, &seccomp_profile);
ret = parse_security_opt(host_spec, &no_new_privileges, &label_opts, &label_opts_len, &seccomp_profile);
if (ret != 0) {
ERROR("Failed to parse security opt");
goto out;
......@@ -1984,9 +1978,8 @@ out:
return ret;
}
int merge_all_specs(host_config *host_spec, const char *real_rootfs,
container_config_v2_common_config *v2_spec, oci_runtime_spec *oci_spec)
int merge_all_specs(host_config *host_spec, const char *real_rootfs, container_config_v2_common_config *v2_spec,
oci_runtime_spec *oci_spec)
{
int ret = 0;
......@@ -2174,5 +2167,3 @@ out_free:
free(json_container);
return ret;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册