diff --git a/test/cmd/isula/extend/pause/CMakeLists.txt b/test/cmd/isula/extend/pause/CMakeLists.txt index 9df2958bdd9ec5f3b58157ee47d2a92e157029a8..9bc48e9c42756c4624087ba9cee0e534a4438ee0 100644 --- a/test/cmd/isula/extend/pause/CMakeLists.txt +++ b/test/cmd/isula/extend/pause/CMakeLists.txt @@ -25,7 +25,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/client/connect/isula_connect.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cmd/isula/extend/pause.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/grpc_client_mock.cc - pause_ut.cpp) + pause_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cmd/isula/extend/pause/pause_ut.cpp b/test/cmd/isula/extend/pause/pause_ut.cc similarity index 100% rename from test/cmd/isula/extend/pause/pause_ut.cpp rename to test/cmd/isula/extend/pause/pause_ut.cc diff --git a/test/cmd/isula/extend/resume/CMakeLists.txt b/test/cmd/isula/extend/resume/CMakeLists.txt index f2ce5f06095a388d9ef9faeeba3deba56289b2b1..6e751ce2476fab91ea44fce8a0f2593c2ecf8ec3 100644 --- a/test/cmd/isula/extend/resume/CMakeLists.txt +++ b/test/cmd/isula/extend/resume/CMakeLists.txt @@ -25,7 +25,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/client/connect/isula_connect.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cmd/isula/extend/resume.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/grpc_client_mock.cc - resume_ut.cpp) + resume_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cmd/isula/extend/resume/resume_ut.cpp b/test/cmd/isula/extend/resume/resume_ut.cc similarity index 100% rename from test/cmd/isula/extend/resume/resume_ut.cpp rename to test/cmd/isula/extend/resume/resume_ut.cc diff --git a/test/cmd/isula/infomation/info/CMakeLists.txt b/test/cmd/isula/infomation/info/CMakeLists.txt index d7955789a4118996c551ff4d6226e7a5d764dcc4..83a51d44ff0ef5d42a14e35122bf328c390f3fd9 100644 --- a/test/cmd/isula/infomation/info/CMakeLists.txt +++ b/test/cmd/isula/infomation/info/CMakeLists.txt @@ -26,7 +26,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/client/connect/isula_connect.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cmd/isula/information/info.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/grpc_client_mock.cc - info_ut.cpp) + info_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cmd/isula/infomation/info/info_ut.cpp b/test/cmd/isula/infomation/info/info_ut.cc similarity index 100% rename from test/cmd/isula/infomation/info/info_ut.cpp rename to test/cmd/isula/infomation/info/info_ut.cc diff --git a/test/cmd/isula/infomation/ps/CMakeLists.txt b/test/cmd/isula/infomation/ps/CMakeLists.txt index a8af6b4cd2c2c78c298248d74ab6e3f611f33ef9..2aee9d4f3c620e773586e65507bfb628652b6e2d 100644 --- a/test/cmd/isula/infomation/ps/CMakeLists.txt +++ b/test/cmd/isula/infomation/ps/CMakeLists.txt @@ -25,7 +25,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/client/connect/isula_connect.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/cmd/isula/information/ps.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/grpc_client_mock.cc - ps_ut.cpp) + ps_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cmd/isula/infomation/ps/ps_ut.cpp b/test/cmd/isula/infomation/ps/ps_ut.cc similarity index 100% rename from test/cmd/isula/infomation/ps/ps_ut.cpp rename to test/cmd/isula/infomation/ps/ps_ut.cc diff --git a/test/cmd/isulad-shim/CMakeLists.txt b/test/cmd/isulad-shim/CMakeLists.txt index 1265495ae5bcb0e9f22ce93958b8b707c5ba0768..0f2f637a62932c16dd6cf52a3f1368b2177ab894 100644 --- a/test/cmd/isulad-shim/CMakeLists.txt +++ b/test/cmd/isulad-shim/CMakeLists.txt @@ -6,7 +6,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/isulad-shim/process.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/isulad-shim/common.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/isulad-shim/terminal.c - isulad-shim_ut.cpp) + isulad-shim_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cmd/isulad-shim/isulad-shim_ut.cpp b/test/cmd/isulad-shim/isulad-shim_ut.cc similarity index 100% rename from test/cmd/isulad-shim/isulad-shim_ut.cpp rename to test/cmd/isulad-shim/isulad-shim_ut.cc diff --git a/test/cutils/utils_array/CMakeLists.txt b/test/cutils/utils_array/CMakeLists.txt index 91306b78f2acd083b4fc6b01fd63c23c76df1ba7..4d3a0941a7bd6bbe942144ba47497a817efee29a 100644 --- a/test/cutils/utils_array/CMakeLists.txt +++ b/test/cutils/utils_array/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/map/map.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/map/rb_tree.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/path.c - utils_array_ut.cpp) + utils_array_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cutils/utils_array/utils_array_ut.cpp b/test/cutils/utils_array/utils_array_ut.cc similarity index 100% rename from test/cutils/utils_array/utils_array_ut.cpp rename to test/cutils/utils_array/utils_array_ut.cc diff --git a/test/cutils/utils_base64/CMakeLists.txt b/test/cutils/utils_base64/CMakeLists.txt index 5206ed1c5829da24ef056070004a023f4aa45447..3c7b72dc600d5fef13432a4b63f98c4743793930 100644 --- a/test/cutils/utils_base64/CMakeLists.txt +++ b/test/cutils/utils_base64/CMakeLists.txt @@ -15,7 +15,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/path.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/map/map.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/map/rb_tree.c - utils_base64_ut.cpp) + utils_base64_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cutils/utils_base64/utils_base64_ut.cpp b/test/cutils/utils_base64/utils_base64_ut.cc similarity index 82% rename from test/cutils/utils_base64/utils_base64_ut.cpp rename to test/cutils/utils_base64/utils_base64_ut.cc index 9a6b97800ca61a13e8827debc481e9d635d2a43a..103c52dd1364eeb133816bc8faae95d0b9b71f15 100644 --- a/test/cutils/utils_base64/utils_base64_ut.cpp +++ b/test/cutils/utils_base64/utils_base64_ut.cc @@ -21,14 +21,16 @@ TEST(utils_base64, test_util_base64) { - char *plain_text = (char*)"^cvdgfdgghaswere3575676y&*`~cx,xfdgdvcvdfd][';./?.,<>|\\!@#$%^&*()_+=-090wvvs3sdfel33cxvdf***$"; + char *plain_text = (char*) + "^cvdgfdgghaswere3575676y&*`~cx,xfdgdvcvdfd][';./?.,<>|\\!@#$%^&*()_+=-090wvvs3sdfel33cxvdf***$"; char *encoded = NULL; char *decoded = NULL; size_t decoded_len = 0; // check long base64 encode/decode ASSERT_EQ(util_base64_encode((unsigned char*)plain_text, strlen(plain_text), &encoded), 0); - ASSERT_STREQ(encoded, "XmN2ZGdmZGdnaGFzd2VyZTM1NzU2NzZ5JipgfmN4LHhmZGdkdmN2ZGZkXVsnOy4vPy4sPD58XCFAIyQlXiYqKClfKz0tMDkwd3Z2czNzZGZlbDMzY3h2ZGYqKiok"); + ASSERT_STREQ(encoded, + "XmN2ZGdmZGdnaGFzd2VyZTM1NzU2NzZ5JipgfmN4LHhmZGdkdmN2ZGZkXVsnOy4vPy4sPD58XCFAIyQlXiYqKClfKz0tMDkwd3Z2czNzZGZlbDMzY3h2ZGYqKiok"); ASSERT_EQ(util_base64_decode((const char*)encoded, strlen(encoded), (unsigned char**)&decoded, &decoded_len), 0); ASSERT_STREQ(decoded, plain_text); ASSERT_EQ(strlen(plain_text), decoded_len); diff --git a/test/cutils/utils_convert/CMakeLists.txt b/test/cutils/utils_convert/CMakeLists.txt index 07ef10185f761d9c299094f60e1958804a7da1bc..809a798e4129179c1a5addc5f17a5a1db7891ed1 100644 --- a/test/cutils/utils_convert/CMakeLists.txt +++ b/test/cutils/utils_convert/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/map/map.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/map/rb_tree.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/path.c - utils_convert_ut.cpp) + utils_convert_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cutils/utils_convert/utils_convert_ut.cpp b/test/cutils/utils_convert/utils_convert_ut.cc similarity index 100% rename from test/cutils/utils_convert/utils_convert_ut.cpp rename to test/cutils/utils_convert/utils_convert_ut.cc diff --git a/test/cutils/utils_string/CMakeLists.txt b/test/cutils/utils_string/CMakeLists.txt index 81dca1e4ac581d3bf2cdc062eb193393cb048ae8..c86141efa328992eaf86dfd6acb566fa7c6b5be9 100644 --- a/test/cutils/utils_string/CMakeLists.txt +++ b/test/cutils/utils_string/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/path.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/map/map.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/utils/cutils/map/rb_tree.c - utils_string_ut.cpp) + utils_string_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/cutils/utils_string/utils_string_ut.cpp b/test/cutils/utils_string/utils_string_ut.cc similarity index 100% rename from test/cutils/utils_string/utils_string_ut.cpp rename to test/cutils/utils_string/utils_string_ut.cc diff --git a/test/fuzz/CMakeLists.txt b/test/fuzz/CMakeLists.txt index 340cf751a8cf4dc4c6dde3077ff943e701fab881..80e84e937fcb6a042136d5f2ac301e9495df9059 100644 --- a/test/fuzz/CMakeLists.txt +++ b/test/fuzz/CMakeLists.txt @@ -18,9 +18,9 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) SET(EXE0 im_oci_image_exist_fuzz) SET(EXE1 im_config_image_exist_fuzz) SET(EXE2 im_get_image_count_fuzz) -add_executable(${EXE0} im_oci_image_exist_fuzz.cpp) -add_executable(${EXE1} im_config_image_exist_fuzz.cpp) -add_executable(${EXE2} im_get_image_count_fuzz.cpp) +add_executable(${EXE0} im_oci_image_exist_fuzz.cc) +add_executable(${EXE1} im_config_image_exist_fuzz.cc) +add_executable(${EXE2} im_get_image_count_fuzz.cc) SET(IMAGE_FUZZ_INCLUDE_DIRS ${GTEST_INCLUDE_DIR} diff --git a/test/fuzz/im_config_image_exist_fuzz.cpp b/test/fuzz/im_config_image_exist_fuzz.cc similarity index 100% rename from test/fuzz/im_config_image_exist_fuzz.cpp rename to test/fuzz/im_config_image_exist_fuzz.cc diff --git a/test/fuzz/im_get_image_count_fuzz.cpp b/test/fuzz/im_get_image_count_fuzz.cc similarity index 100% rename from test/fuzz/im_get_image_count_fuzz.cpp rename to test/fuzz/im_get_image_count_fuzz.cc diff --git a/test/fuzz/im_oci_image_exist_fuzz.cpp b/test/fuzz/im_oci_image_exist_fuzz.cc similarity index 100% rename from test/fuzz/im_oci_image_exist_fuzz.cpp rename to test/fuzz/im_oci_image_exist_fuzz.cc diff --git a/test/image/oci/oci_config_merge/CMakeLists.txt b/test/image/oci/oci_config_merge/CMakeLists.txt index 2aa69c5cdf8eaf5e3ac1aa18a3c78512fc644f5f..7ecce47ed58137669a8db432070fc92fbee78e76 100644 --- a/test/image/oci/oci_config_merge/CMakeLists.txt +++ b/test/image/oci/oci_config_merge/CMakeLists.txt @@ -22,13 +22,13 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/common/sysinfo.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/cmd/command_parser.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/config/daemon_arguments.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../../test/image/oci/oci_ut_common.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../test/image/oci/oci_ut_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}/../../../../src/daemon/modules/spec//specs_mount.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../test/mocks/selinux_label_mock.cc - oci_config_merge_ut.cpp) + oci_config_merge_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/image/oci/oci_config_merge/oci_config_merge_ut.cpp b/test/image/oci/oci_config_merge/oci_config_merge_ut.cc similarity index 100% rename from test/image/oci/oci_config_merge/oci_config_merge_ut.cpp rename to test/image/oci/oci_config_merge/oci_config_merge_ut.cc diff --git a/test/image/oci/oci_ut_common.cpp b/test/image/oci/oci_ut_common.cc similarity index 100% rename from test/image/oci/oci_ut_common.cpp rename to test/image/oci/oci_ut_common.cc diff --git a/test/image/oci/registry/CMakeLists.txt b/test/image/oci/registry/CMakeLists.txt index 60ada58300922ff7cf3127c0ac2d5f0293bab58a..9e34103c9d987e094f9af4251a007c10eb58dcfb 100644 --- a/test/image/oci/registry/CMakeLists.txt +++ b/test/image/oci/registry/CMakeLists.txt @@ -37,7 +37,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/storage_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/oci_image_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/http_mock.cc - registry_ut.cpp) + registry_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/image/oci/registry/registry_ut.cpp b/test/image/oci/registry/registry_ut.cc similarity index 75% rename from test/image/oci/registry/registry_ut.cpp rename to test/image/oci/registry/registry_ut.cc index 9ab1672c9db0a6077b5d79c999c20cdc72da839d..cc51818589a37e75aac1cbc0239424ecd3a0ce7a 100644 --- a/test/image/oci/registry/registry_ut.cpp +++ b/test/image/oci/registry/registry_ut.cc @@ -70,7 +70,6 @@ std::string get_dir() } return static_cast(abs_path) + "../../../../../test/image/oci/registry"; - return static_cast(abs_path); } class RegistryUnitTest : public testing::Test { @@ -104,45 +103,45 @@ int invokeHttpRequestV1(const char *url, struct http_get_options *options, long std::string data_path = get_dir() + "/data/v1/"; if (!strcmp(url, "https://quay.io/v2/")) { ping_count++; - if (ping_count == 1) { - file = data_path + "ping_head1"; - } else { - file = data_path + "ping_head"; - } + if (ping_count == 1) { + file = data_path + "ping_head1"; + } else { + file = data_path + "ping_head"; + } } else if (!strcmp(url, "https://quay.io/v2/coreos/etcd/manifests/v3.3.17-arm64")) { - file = data_path + "manifest"; + file = data_path + "manifest"; } else if (util_has_prefix(url, "https://auth.quay.io")) { - token_count++; - if (token_count == 2) { - file = data_path + "token_body2"; - } else { - file = data_path + "token_body"; - } + token_count++; + if (token_count == 2) { + file = data_path + "token_body2"; + } else { + file = data_path + "token_body"; + } } else if (util_has_prefix(url, "https://quay.io/v2/coreos/etcd/blobs/sha256")) { - file = std::string(""); + file = std::string(""); } else { - ERROR("%s not match failed", url); - return -1; + ERROR("%s not match failed", url); + return -1; } if (file == std::string("")) { - data = util_strdup_s("test"); + data = util_strdup_s("test"); } else { - data = util_read_text_file(file.c_str()); - if (data == NULL) { - ERROR("read file %s failed", file.c_str()); - return -1; - } + data = util_read_text_file(file.c_str()); + if (data == NULL) { + ERROR("read file %s failed", file.c_str()); + return -1; + } } if (options->outputtype == HTTP_REQUEST_STRBUF) { - free(output_buffer->contents); - output_buffer->contents = util_strdup_s(data); + free(output_buffer->contents); + output_buffer->contents = util_strdup_s(data); } else { - if (util_write_file((const char *)options->output, data, strlen(data), 0600) != 0) { - free(data); - ERROR("write file %s failed", (char *)options->output); - return -1; - } + if (util_write_file((const char *)options->output, data, strlen(data), 0600) != 0) { + free(data); + ERROR("write file %s failed", (char *)options->output); + return -1; + } } free(data); @@ -163,75 +162,75 @@ int invokeHttpRequestV2(const char *url, struct http_get_options *options, long // Test insecure registry, assume registry cann't support https. if (util_has_prefix(url, "https://")) { - return -1; + return -1; } std::string data_path = get_dir() + "/data/v2/"; if (!strcmp(url, "http://hub-mirror.c.163.com/v2/")) { - count++; - file = data_path + "ping_head"; + count++; + file = data_path + "ping_head"; } else if (!strcmp(url, "http://hub-mirror.c.163.com/v2/library/busybox/manifests/latest")) { - // test not found - if (count == COUNT_TEST_NOT_FOUND) { - file = data_path + "manifest_404"; - } else { - file = data_path + "manifest_list"; - } + // test not found + if (count == COUNT_TEST_NOT_FOUND) { + file = data_path + "manifest_404"; + } else { + file = data_path + "manifest_list"; + } } else if (util_has_prefix(url, "http://hub-mirror.c.163.com/v2/library/busybox/manifests/sha256:2131f09e")) { - file = data_path + "manifest_body"; + file = data_path + "manifest_body"; } else if (util_has_prefix(url, "http://hub-mirror.c.163.com/v2/library/busybox/blobs/sha256:c7c37e47")) { - file = data_path + "config"; - if (count == COUNT_TEST_CANCEL) { - bool *cancel = (bool*)options->progressinfo; - while (!(*cancel)) { - sleep(1); // schedule out to let cancel variable set to be true - } - if (options->progress_info_op(options->progressinfo, 0, 0, 0, 0) != 0) { + file = data_path + "config"; + if (count == COUNT_TEST_CANCEL) { + bool *cancel = (bool*)options->progressinfo; + while (!(*cancel)) { + sleep(1); // schedule out to let cancel variable set to be true + } + if (options->progress_info_op(options->progressinfo, 0, 0, 0, 0) != 0) { return -1; - } - } + } + } } else if (util_has_prefix(url, "http://hub-mirror.c.163.com/v2/library/busybox/blobs/sha256:91f30d77")) { - if (retry) { - retry = false; - options->errcode = CURLE_RANGE_ERROR; - return -1; - } - // test cancel - if (count == COUNT_TEST_CANCEL) { - return -1; - } - // test server error - if (count == COUNT_TEST_SERVER_ERROR) { - file = data_path + "0_server_error"; - } else { - file = data_path + "0"; - } + if (retry) { + retry = false; + options->errcode = CURLE_RANGE_ERROR; + return -1; + } + // test cancel + if (count == COUNT_TEST_CANCEL) { + return -1; + } + // test server error + if (count == COUNT_TEST_SERVER_ERROR) { + file = data_path + "0_server_error"; + } else { + file = data_path + "0"; + } } else { - ERROR("%s not match failed", url); - return -1; + ERROR("%s not match failed", url); + return -1; } size = util_file_size(file.c_str()); if (size < 0) { - ERROR("get file %s size failed", file.c_str()); - return -1; + ERROR("get file %s size failed", file.c_str()); + return -1; } data = util_read_text_file(file.c_str()); if (data == NULL) { - ERROR("read file %s failed", file.c_str()); - return -1; + ERROR("read file %s failed", file.c_str()); + return -1; } if (options->outputtype == HTTP_REQUEST_STRBUF) { - free(output_buffer->contents); - output_buffer->contents = util_strdup_s(data); + free(output_buffer->contents); + output_buffer->contents = util_strdup_s(data); } else { - if (util_write_file((const char *)options->output, data, size, 0600) != 0) { - free(data); - ERROR("write file %s failed", (char *)options->output); - return -1; - } + if (util_write_file((const char *)options->output, data, size, 0600) != 0) { + free(data); + ERROR("write file %s failed", (char *)options->output); + return -1; + } } free(data); @@ -247,41 +246,41 @@ int invokeHttpRequestOCI(const char *url, struct http_get_options *options, long std::string data_path = get_dir() + "/data/oci/"; if (!strcmp(url, "https://hub-mirror.c.163.com/v2/")) { - file = data_path + "ping_head"; + file = data_path + "ping_head"; } else if (!strcmp(url, "https://hub-mirror.c.163.com/v2/library/busybox/manifests/latest")) { - file = data_path + "index"; + file = data_path + "index"; } else if (util_has_prefix(url, "https://hub-mirror.c.163.com/v2/library/busybox/manifests/sha256:106429d7")) { - file = data_path + "manifest_body"; + file = data_path + "manifest_body"; } else if (util_has_prefix(url, "https://hub-mirror.c.163.com/v2/library/busybox/blobs/sha256:c7c37e47")) { - file = data_path + "config"; + file = data_path + "config"; } else if (util_has_prefix(url, "https://hub-mirror.c.163.com/v2/library/busybox/blobs/sha256:91f30d77")) { - file = data_path + "0"; + file = data_path + "0"; } else { - ERROR("%s not match failed", url); - return -1; + ERROR("%s not match failed", url); + return -1; } size = util_file_size(file.c_str()); if (size < 0) { - ERROR("get file %s size failed", file.c_str()); - return -1; + ERROR("get file %s size failed", file.c_str()); + return -1; } data = util_read_text_file(file.c_str()); if (data == NULL) { - ERROR("read file %s failed", file.c_str()); - return -1; + ERROR("read file %s failed", file.c_str()); + return -1; } if (options->outputtype == HTTP_REQUEST_STRBUF) { - free(output_buffer->contents); - output_buffer->contents = util_strdup_s(data); + free(output_buffer->contents); + output_buffer->contents = util_strdup_s(data); } else { - if (util_write_file((const char *)options->output, data, size, 0600) != 0) { - free(data); - ERROR("write file %s failed", (char *)options->output); - return -1; - } + if (util_write_file((const char *)options->output, data, size, 0600) != 0) { + free(data); + ERROR("write file %s failed", (char *)options->output); + return -1; + } } free(data); @@ -296,34 +295,35 @@ int invokeHttpRequestLogin(const char *url, struct http_get_options *options, lo std::string data_path = get_dir() + "/data/v2/"; if (!strcmp(url, "https://hub-mirror.c.163.com/v2/") || !strcmp(url, "https://test2.com/v2/")) { - file = data_path + "ping_head"; + file = data_path + "ping_head"; } else { - ERROR("%s not match failed", url); - return -1; + ERROR("%s not match failed", url); + return -1; } data = util_read_text_file(file.c_str()); if (data == NULL) { - ERROR("read file %s failed", file.c_str()); - return -1; + ERROR("read file %s failed", file.c_str()); + return -1; } if (options->outputtype == HTTP_REQUEST_STRBUF) { - free(output_buffer->contents); - output_buffer->contents = util_strdup_s(data); + free(output_buffer->contents); + output_buffer->contents = util_strdup_s(data); } free(data); return 0; } -int invokeStorageImgCreate(const char *id, const char *parent_id, const char *metadata, struct storage_img_create_options *opts) +int invokeStorageImgCreate(const char *id, const char *parent_id, const char *metadata, + struct storage_img_create_options *opts) { static int count = 0; count++; if (count == 1) { - return -1; + return -1; } return 0; @@ -386,33 +386,34 @@ struct layer_list *invokeStorageLayersGetByCompressDigest(const char *digest) list = (struct layer_list*)util_common_calloc_s(sizeof(struct layer_list)); if (list == NULL) { - ERROR("out of memory"); + ERROR("out of memory"); return NULL; } list->layers = (struct layer **)util_common_calloc_s(sizeof(struct layer*) * 1); if (list->layers == NULL) { - ERROR("out of memory"); - ret = -1; - goto out; + ERROR("out of memory"); + ret = -1; + goto out; } list->layers[0] = (struct layer *)util_common_calloc_s(sizeof(struct layer)); if (list->layers[0] == NULL) { - ERROR("out of memory"); - ret = -1; - goto out; + ERROR("out of memory"); + ret = -1; + goto out; } list->layers_len = 1; - list->layers[0]->uncompressed_digest = util_strdup_s("sha256:50761fe126b6e4d90fa0b7a6e195f6030fe250c016c2fc860ac40f2e8d2f2615"); + list->layers[0]->uncompressed_digest = + util_strdup_s("sha256:50761fe126b6e4d90fa0b7a6e195f6030fe250c016c2fc860ac40f2e8d2f2615"); list->layers[0]->id = util_strdup_s("sha256:50761fe126b6e4d90fa0b7a6e195f6030fe250c016c2fc860ac40f2e8d2f2615"); list->layers[0]->parent = NULL; out: if (ret != 0) { - free_layer_list(list); - list = NULL; + free_layer_list(list); + list = NULL; } return list; @@ -424,8 +425,8 @@ struct layer * invokeStorageLayerGet1(const char *layer_id) l = (struct layer *)util_common_calloc_s(sizeof(struct layer)); if (l == NULL) { - ERROR("out of memory"); - return NULL; + ERROR("out of memory"); + return NULL; } return l; @@ -493,29 +494,29 @@ static int init_log() void mockCommonAll(MockStorage *mock, MockOciImage *oci_image_mock) { - EXPECT_CALL(*mock, StorageImgCreate(::testing::_,::testing::_,::testing::_,::testing::_)) + EXPECT_CALL(*mock, StorageImgCreate(::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeStorageImgCreate)); EXPECT_CALL(*mock, StorageImgGet(::testing::_)) .WillRepeatedly(Invoke(invokeStorageImgGet)); - EXPECT_CALL(*mock, StorageImgSetBigData(::testing::_,::testing::_,::testing::_)) + EXPECT_CALL(*mock, StorageImgSetBigData(::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeStorageImgSetBigData)); - EXPECT_CALL(*mock, StorageImgAddName(::testing::_,::testing::_)) + EXPECT_CALL(*mock, StorageImgAddName(::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeStorageImgAddName)); - EXPECT_CALL(*mock, StorageImgDelete(::testing::_,::testing::_)) + EXPECT_CALL(*mock, StorageImgDelete(::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeStorageImgDelete)); - EXPECT_CALL(*mock, StorageImgSetLoadedTime(::testing::_,::testing::_)) + EXPECT_CALL(*mock, StorageImgSetLoadedTime(::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeStorageImgSetLoadedTime)); EXPECT_CALL(*mock, StorageImgSetImageSize(::testing::_)) .WillRepeatedly(Invoke(invokeStorageImgSetImageSize)); EXPECT_CALL(*mock, StorageGetImgTopLayer(::testing::_)) .WillRepeatedly(Invoke(invokeStorageGetImgTopLayer)); - EXPECT_CALL(*mock, StorageLayerCreate(::testing::_,::testing::_)) + EXPECT_CALL(*mock, StorageLayerCreate(::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeStorageLayerCreate)); - EXPECT_CALL(*mock, StorageSetHoldFlag(::testing::_,::testing::_)) + EXPECT_CALL(*mock, StorageSetHoldFlag(::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeStorageSetHoldFlag)); EXPECT_CALL(*mock, StorageLayerGet(::testing::_)) .WillRepeatedly(Invoke(invokeStorageLayerGet)); - EXPECT_CALL(*mock, StorageLayerTryRepairLowers(::testing::_,::testing::_)) + EXPECT_CALL(*mock, StorageLayerTryRepairLowers(::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeStorageLayerTryRepairLowers)); EXPECT_CALL(*mock, FreeLayerList(::testing::_)) .WillRepeatedly(Invoke(invokeFreeLayerList)); @@ -536,8 +537,8 @@ int create_certs(std::string &dir) if (util_write_file(ca.c_str(), "1", 1, 0600) != 0 || util_write_file(cert.c_str(), "1", 1, 0600) != 0 || util_write_file(key.c_str(), "1", 1, 0600) != 0) { - ERROR("write certs file failed"); - return -1; + ERROR("write certs file failed"); + return -1; } return 0; @@ -552,8 +553,8 @@ int remove_certs(std::string &dir) if (util_path_remove(ca.c_str()) != 0 || util_path_remove(cert.c_str()) != 0 || util_path_remove(key.c_str()) != 0) { - ERROR("remove certs file failed"); - return -1; + ERROR("remove certs file failed"); + return -1; } return 0; @@ -571,14 +572,14 @@ TEST_F(RegistryUnitTest, test_pull_v1_image) std::string auths_dir = get_dir() + "/auths"; std::string certs_dir = get_dir() + "/certs"; - std::string mirror_dir = certs_dir+"/hub-mirror.c.163.com"; + std::string mirror_dir = certs_dir + "/hub-mirror.c.163.com"; ASSERT_EQ(util_mkdir_p(auths_dir.c_str(), 0700), 0); ASSERT_EQ(util_mkdir_p(mirror_dir.c_str(), 0700), 0); ASSERT_EQ(create_certs(mirror_dir), 0); ASSERT_EQ(init_log(), 0); ASSERT_EQ(registry_init((char *)auths_dir.c_str(), (char *)certs_dir.c_str()), 0); - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_,::testing::_,::testing::_,::testing::_)) + EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeHttpRequestV1)); mockCommonAll(&m_storage_mock, &m_oci_image_mock); ASSERT_EQ(registry_pull(&options), 0); @@ -592,7 +593,7 @@ TEST_F(RegistryUnitTest, test_login) { registry_login_options options = {0}; - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_,::testing::_,::testing::_,::testing::_)) + EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeHttpRequestLogin)); options.host = (char*)"test2.com"; @@ -638,7 +639,7 @@ TEST_F(RegistryUnitTest, test_pull_v2_image) clock_gettime(CLOCK_MONOTONIC, &start_time); - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_,::testing::_,::testing::_,::testing::_)) + EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeHttpRequestV2)); mockCommonAll(&m_storage_mock, &m_oci_image_mock); @@ -656,7 +657,7 @@ TEST_F(RegistryUnitTest, test_pull_v2_image) clock_gettime(CLOCK_MONOTONIC, &end_time); - ASSERT_TRUE(end_time.tv_sec-start_time.tv_sec <= 10); + ASSERT_TRUE(end_time.tv_sec - start_time.tv_sec <= 10); } TEST_F(RegistryUnitTest, test_pull_oci_image) @@ -672,7 +673,7 @@ TEST_F(RegistryUnitTest, test_pull_oci_image) options->auth.password = NULL; options->skip_tls_verify = false; options->insecure_registry = false; - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_,::testing::_,::testing::_,::testing::_)) + EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeHttpRequestOCI)); mockCommonAll(&m_storage_mock, &m_oci_image_mock); ASSERT_EQ(registry_pull(options), 0); @@ -690,7 +691,7 @@ TEST_F(RegistryUnitTest, test_pull_already_exist) options.skip_tls_verify = true; options.insecure_registry = true; - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_,::testing::_,::testing::_,::testing::_)) + EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeHttpRequestV2)); mockCommonAll(&m_storage_mock, &m_oci_image_mock); EXPECT_CALL(m_storage_mock, StorageLayerGet(::testing::_)) @@ -699,7 +700,7 @@ TEST_F(RegistryUnitTest, test_pull_already_exist) options.image_name = (char*)"quay.io/coreos/etcd:v3.3.17-arm64"; options.dest_image_name = (char*)"quay.io/coreos/etcd:v3.3.17-arm64"; - EXPECT_CALL(m_http_mock, HttpRequest(::testing::_,::testing::_,::testing::_,::testing::_)) + EXPECT_CALL(m_http_mock, HttpRequest(::testing::_, ::testing::_, ::testing::_, ::testing::_)) .WillRepeatedly(Invoke(invokeHttpRequestV1)); EXPECT_CALL(m_storage_mock, StorageLayerGet(::testing::_)) .WillRepeatedly(Invoke(invokeStorageLayerGet)); @@ -714,7 +715,7 @@ TEST_F(RegistryUnitTest, test_aes) unsigned char *encoded = NULL; char *decoded = NULL; ASSERT_EQ(aes_encode((unsigned char *)text, strlen(text), &encoded), 0); - ASSERT_EQ(aes_decode(encoded, AES_256_CFB_IV_LEN+strlen(text), (unsigned char **)&decoded), 0); + ASSERT_EQ(aes_decode(encoded, AES_256_CFB_IV_LEN + strlen(text), (unsigned char **)&decoded), 0); ASSERT_STREQ(decoded, text); free(encoded); free(decoded); diff --git a/test/image/oci/storage/images/CMakeLists.txt b/test/image/oci/storage/images/CMakeLists.txt index bb3b2058df98597dc8b0c67d8cc6b033c379cb11..82ad4680d0d98985ff1b5513ce1f6d09be45b0f1 100644 --- a/test/image/oci/storage/images/CMakeLists.txt +++ b/test/image/oci/storage/images/CMakeLists.txt @@ -22,7 +22,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/registry_type.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/image_store/image_store.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/storage_mock.cc - storage_images_ut.cpp) + storage_images_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/image/oci/storage/images/storage_images_ut.cpp b/test/image/oci/storage/images/storage_images_ut.cc similarity index 100% rename from test/image/oci/storage/images/storage_images_ut.cpp rename to test/image/oci/storage/images/storage_images_ut.cc diff --git a/test/image/oci/storage/layers/CMakeLists.txt b/test/image/oci/storage/layers/CMakeLists.txt index 2a0539d0fd7bcf95a9a23f00d4fad5dd84ba6992..4cae382c6cd49c1b5ef2b3f86f805ed49d7dc324 100644 --- a/test/image/oci/storage/layers/CMakeLists.txt +++ b/test/image/oci/storage/layers/CMakeLists.txt @@ -30,7 +30,7 @@ add_executable(${DRIVER_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/quota/project_quota.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/driver_quota_mock.cc - storage_driver_ut.cpp) + storage_driver_ut.cc) target_include_directories(${DRIVER_EXE} PUBLIC ${GTEST_INCLUDE_DIR} @@ -101,7 +101,7 @@ add_executable(${LAYER_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/layer_store/graphdriver/quota/project_quota.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/driver_quota_mock.cc - storage_layers_ut.cpp) + storage_layers_ut.cc) target_include_directories(${LAYER_EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/image/oci/storage/layers/storage_driver_ut.cpp b/test/image/oci/storage/layers/storage_driver_ut.cc similarity index 93% rename from test/image/oci/storage/layers/storage_driver_ut.cpp rename to test/image/oci/storage/layers/storage_driver_ut.cc index 37a5a76923767acd7204bf63584533a7f04188f1..88e6f6819dd5004300649fb6663ab25bc0ae719e 100644 --- a/test/image/oci/storage/layers/storage_driver_ut.cpp +++ b/test/image/oci/storage/layers/storage_driver_ut.cc @@ -109,11 +109,12 @@ protected: std::string cp_command = "cp -r " + std::string(data_path) + " " + isulad_dir; ASSERT_EQ(system(cp_command.c_str()), 0); - std::string mkdir = "mkdir -p " + root_dir + "/overlay/1be74353c3d0fd55fb5638a52953e6f1bc441e5b1710921db9ec2aa202725569/merged " - + root_dir + "/overlay/1be74353c3d0fd55fb5638a52953e6f1bc441e5b1710921db9ec2aa202725569/work && " + std::string mkdir = "mkdir -p " + root_dir + + "/overlay/1be74353c3d0fd55fb5638a52953e6f1bc441e5b1710921db9ec2aa202725569/merged " + + root_dir + "/overlay/1be74353c3d0fd55fb5638a52953e6f1bc441e5b1710921db9ec2aa202725569/work && " "mkdir -p " + root_dir + "/overlay/9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63/empty " - + root_dir + "/overlay/9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63/merged " - + root_dir + "/overlay/9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63/work "; + + root_dir + "/overlay/9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63/merged " + + root_dir + "/overlay/9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63/work "; ASSERT_EQ(system(mkdir.c_str()), 0); opts = (struct storage_module_init_options *)util_common_calloc_s(sizeof(struct storage_module_init_options)); @@ -225,7 +226,7 @@ TEST_F(StorageDriverUnitTest, test_graphdriver_try_repair_lowers) TEST(StorageOverlay2QuotaOptionsTest, test_overlay2_is_quota_options) { std::vector options { "overlay2.size", "overlay2.basesize" }; - for(auto option : options) { + for (auto option : options) { ASSERT_TRUE(overlay2_is_quota_options(nullptr, option.c_str())); } } diff --git a/test/image/oci/storage/layers/storage_layers_ut.cpp b/test/image/oci/storage/layers/storage_layers_ut.cc similarity index 95% rename from test/image/oci/storage/layers/storage_layers_ut.cpp rename to test/image/oci/storage/layers/storage_layers_ut.cc index 3b038136477ffa6173733f96a1ca7d32facbd747..f99c6bc7e94e4cf6ae6a7a18535634d8e99cb6b1 100644 --- a/test/image/oci/storage/layers/storage_layers_ut.cpp +++ b/test/image/oci/storage/layers/storage_layers_ut.cc @@ -212,7 +212,8 @@ TEST_F(StorageLayersUnitTest, test_layers_load) } // check layer 7db8f44a0a8e12ea4283e3180e98880007efbd5de2e7c98b67de9cdd4dfffb0b - std::string mount_point = std::string(real_path) + "/overlay/7db8f44a0a8e12ea4283e3180e98880007efbd5de2e7c98b67de9cdd4dfffb0b/merged"; + std::string mount_point = std::string(real_path) + + "/overlay/7db8f44a0a8e12ea4283e3180e98880007efbd5de2e7c98b67de9cdd4dfffb0b/merged"; ASSERT_NE(layers[id_container], nullptr); ASSERT_STREQ(layers[id_container]->id, "7db8f44a0a8e12ea4283e3180e98880007efbd5de2e7c98b67de9cdd4dfffb0b"); ASSERT_STREQ(layers[id_container]->parent, "9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63"); @@ -222,8 +223,10 @@ TEST_F(StorageLayersUnitTest, test_layers_load) ASSERT_NE(layers[id_image], nullptr); ASSERT_STREQ(layers[id_image]->id, "9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63"); ASSERT_STREQ(layers[id_image]->parent, nullptr); - ASSERT_STREQ(layers[id_image]->compressed_digest, "sha256:0e03bdcc26d7a9a57ef3b6f1bf1a210cff6239bff7c8cac72435984032851689"); - ASSERT_STREQ(layers[id_image]->uncompressed_digest, "sha256:9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63"); + ASSERT_STREQ(layers[id_image]->compressed_digest, + "sha256:0e03bdcc26d7a9a57ef3b6f1bf1a210cff6239bff7c8cac72435984032851689"); + ASSERT_STREQ(layers[id_image]->uncompressed_digest, + "sha256:9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63"); ASSERT_EQ(layers[id_image]->uncompress_size, 1672256); free_layer_list(layer_list); diff --git a/test/image/oci/storage/rootfs/CMakeLists.txt b/test/image/oci/storage/rootfs/CMakeLists.txt index 72f510828bbc1911775c98566011a1766b7b5222..3ba56bb90f30ca08e95e1e31cdd434886cd0e05c 100644 --- a/test/image/oci/storage/rootfs/CMakeLists.txt +++ b/test/image/oci/storage/rootfs/CMakeLists.txt @@ -21,7 +21,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/rootfs_store/rootfs.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../src/daemon/modules/image/oci/storage/rootfs_store/rootfs_store.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/storage_mock.cc - storage_rootfs_ut.cpp) + storage_rootfs_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/image/oci/storage/rootfs/storage_rootfs_ut.cpp b/test/image/oci/storage/rootfs/storage_rootfs_ut.cc similarity index 97% rename from test/image/oci/storage/rootfs/storage_rootfs_ut.cpp rename to test/image/oci/storage/rootfs/storage_rootfs_ut.cc index da4831148f3078ef66ccb451d25ca7cb5a7e3e2a..b2adc1af317e85abc26372d2349c3e768cff7297 100644 --- a/test/image/oci/storage/rootfs/storage_rootfs_ut.cpp +++ b/test/image/oci/storage/rootfs/storage_rootfs_ut.cc @@ -103,7 +103,7 @@ protected: } std::vector ids { "0e025f44cdca20966a5e5f11e1d9d8eb726aef2d38ed20f89ea986987c2010a9", - "28a8e1311d71345b08788c16b8c4f45a57641854f0e7c16802eedd0eb334b832" }; + "28a8e1311d71345b08788c16b8c4f45a57641854f0e7c16802eedd0eb334b832" }; char store_real_path[PATH_MAX] = { 0x00 }; }; @@ -149,8 +149,8 @@ TEST_F(StorageRootfsUnitTest, test_rootfs_store_create) sizeof(names_with_id) / sizeof(names_with_id[0]), image.c_str(), layer_with_id.c_str(), metadata.c_str(), nullptr); char *container_without_id = - rootfs_store_create(nullptr, names_without_id, sizeof(names_without_id) / sizeof(names_without_id[0]), - image.c_str(), layer_without_id.c_str(), metadata.c_str(), nullptr); + rootfs_store_create(nullptr, names_without_id, sizeof(names_without_id) / sizeof(names_without_id[0]), + image.c_str(), layer_without_id.c_str(), metadata.c_str(), nullptr); ASSERT_STREQ(created_container, id.c_str()); ASSERT_NE(container_without_id, nullptr); diff --git a/test/path/CMakeLists.txt b/test/path/CMakeLists.txt index 7784f1fd697fab7a8c47bff092e7400d67619cb6..dcb69130a1fe52e362ddcdec097c70967738a3b2 100644 --- a/test/path/CMakeLists.txt +++ b/test/path/CMakeLists.txt @@ -14,7 +14,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils/cutils/utils_regex.c ${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils/cutils/utils_verify.c ${CMAKE_CURRENT_SOURCE_DIR}/../../src/utils/sha256/sha256.c - path_ut.cpp) + path_ut.cc) target_include_directories(${EXE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include diff --git a/test/path/path_ut.cpp b/test/path/path_ut.cc similarity index 100% rename from test/path/path_ut.cpp rename to test/path/path_ut.cc diff --git a/test/runtime/isula/CMakeLists.txt b/test/runtime/isula/CMakeLists.txt index fffe5832e2a8449554612dd6bd637e277d6c411c..9b4b35062309fa86d808e0765ebca953861bd91b 100644 --- a/test/runtime/isula/CMakeLists.txt +++ b/test/runtime/isula/CMakeLists.txt @@ -20,14 +20,14 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/common/sysinfo.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/command_parser.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/config/daemon_arguments.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../test/image/oci/oci_ut_common.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../../../test/image/oci/oci_ut_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/isulad_config_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/modules/runtime/isula/isula_rt_ops.c - isula_rt_ops_ut.cpp) + isula_rt_ops_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/runtime/isula/isula_rt_ops_ut.cpp b/test/runtime/isula/isula_rt_ops_ut.cc similarity index 100% rename from test/runtime/isula/isula_rt_ops_ut.cpp rename to test/runtime/isula/isula_rt_ops_ut.cc diff --git a/test/runtime/lcr/CMakeLists.txt b/test/runtime/lcr/CMakeLists.txt index 8528c51727ec5d254eddde5e39a8f832d0f3120e..829027e45181d6bc035f7cab1cee27c5504f2df3 100644 --- a/test/runtime/lcr/CMakeLists.txt +++ b/test/runtime/lcr/CMakeLists.txt @@ -19,14 +19,14 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/common/sysinfo.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/command_parser.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/config/daemon_arguments.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../test/image/oci/oci_ut_common.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../../../test/image/oci/oci_ut_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/isulad_config_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c - lcr_rt_ops_ut.cpp) + lcr_rt_ops_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/runtime/lcr/lcr_rt_ops_ut.cpp b/test/runtime/lcr/lcr_rt_ops_ut.cc similarity index 100% rename from test/runtime/lcr/lcr_rt_ops_ut.cpp rename to test/runtime/lcr/lcr_rt_ops_ut.cc diff --git a/test/services/execution/execute/execution_extend/CMakeLists.txt b/test/services/execution/execute/execution_extend/CMakeLists.txt index e28f76a505d8f234e28ecbb61f781209a4a9433e..aaff39efba9880ab086d659d19d271689202d24c 100644 --- a/test/services/execution/execute/execution_extend/CMakeLists.txt +++ b/test/services/execution/execute/execution_extend/CMakeLists.txt @@ -42,7 +42,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/engine_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/restartmanager_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../../mocks/specs_mock.cc - execution_extend_ut.cpp) + execution_extend_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/services/execution/execute/execution_extend/execution_extend_ut.cpp b/test/services/execution/execute/execution_extend/execution_extend_ut.cc similarity index 95% rename from test/services/execution/execute/execution_extend/execution_extend_ut.cpp rename to test/services/execution/execute/execution_extend/execution_extend_ut.cc index d12aca000e426a1ca2ecf7d1f7afbfbf83d0a57a..114721207315f3668a3a2c7a5e4ad54fc46e8379 100644 --- a/test/services/execution/execute/execution_extend/execution_extend_ut.cpp +++ b/test/services/execution/execute/execution_extend/execution_extend_ut.cc @@ -134,7 +134,7 @@ container_t *invokeContainersStoreGet(const char *id_or_name) } container_t *cont = (container_t *)util_common_calloc_s(sizeof(container_t)); cont->common_config = - (container_config_v2_common_config *)util_common_calloc_s(sizeof(container_config_v2_common_config)); + (container_config_v2_common_config *)util_common_calloc_s(sizeof(container_config_v2_common_config)); cont->refcnt = 1; return cont; } @@ -204,7 +204,7 @@ TEST_F(ExecutionExtendUnitTest, test_container_extend_callback_init_pause) service_container_callback_t cb; container_pause_request *request = (container_pause_request *)util_common_calloc_s(sizeof(container_pause_request)); container_pause_response *response = - (container_pause_response *)util_common_calloc_s(sizeof(container_pause_response)); + (container_pause_response *)util_common_calloc_s(sizeof(container_pause_response)); request->id = util_strdup_s("64ff21ebf4e4"); EXPECT_CALL(m_runtime, RuntimePause(_, _, _)).WillRepeatedly(Invoke(invokeRuntimePause)); @@ -230,9 +230,9 @@ TEST_F(ExecutionExtendUnitTest, test_container_extend_callback_init_resume) { service_container_callback_t cb; container_resume_request *request = - (container_resume_request *)util_common_calloc_s(sizeof(container_resume_request)); + (container_resume_request *)util_common_calloc_s(sizeof(container_resume_request)); container_resume_response *response = - (container_resume_response *)util_common_calloc_s(sizeof(container_resume_response)); + (container_resume_response *)util_common_calloc_s(sizeof(container_resume_response)); request->id = util_strdup_s("64ff21ebf4e4"); EXPECT_CALL(m_runtime, RuntimeResume(_, _, _)).WillRepeatedly(Invoke(invokeRuntimeResume)); diff --git a/test/services/execution/spec/CMakeLists.txt b/test/services/execution/spec/CMakeLists.txt index 9fabb6a1154d43e10f0a480ca0f71559aa1ba181..9ce30219cda3571426f13e05a5d156a451721676 100644 --- a/test/services/execution/spec/CMakeLists.txt +++ b/test/services/execution/spec/CMakeLists.txt @@ -18,7 +18,7 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/common/err_msg.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/namespace_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/common/selinux_label.c - selinux_label_ut.cpp) + selinux_label_ut.cc) add_executable(${MOCK_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/utils/cutils/utils.c @@ -37,7 +37,7 @@ add_executable(${MOCK_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/syscall_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../mocks/selinux_mock.cc ${CMAKE_CURRENT_SOURCE_DIR}/../../../../src/daemon/common/selinux_label.c - selinux_label_mock_ut.cpp) + selinux_label_mock_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/services/execution/spec/selinux_label_mock_ut.cpp b/test/services/execution/spec/selinux_label_mock_ut.cc similarity index 100% rename from test/services/execution/spec/selinux_label_mock_ut.cpp rename to test/services/execution/spec/selinux_label_mock_ut.cc diff --git a/test/services/execution/spec/selinux_label_ut.cpp b/test/services/execution/spec/selinux_label_ut.cc similarity index 100% rename from test/services/execution/spec/selinux_label_ut.cpp rename to test/services/execution/spec/selinux_label_ut.cc diff --git a/test/specs/specs/CMakeLists.txt b/test/specs/specs/CMakeLists.txt index 0f5acf7c06eaa6ce18359c31afef52401ea7891e..c9c29b2f53c7287d65f4ea30a4c59c3471c5ba13 100644 --- a/test/specs/specs/CMakeLists.txt +++ b/test/specs/specs/CMakeLists.txt @@ -23,14 +23,14 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/common/sysinfo.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/command_parser.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/config/daemon_arguments.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../test/image/oci/oci_ut_common.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../../../test/image/oci/oci_ut_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 - specs_ut.cpp) + specs_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/specs/specs/specs_ut.cpp b/test/specs/specs/specs_ut.cc similarity index 100% rename from test/specs/specs/specs_ut.cpp rename to test/specs/specs/specs_ut.cc diff --git a/test/specs/specs_extend/CMakeLists.txt b/test/specs/specs_extend/CMakeLists.txt index 95ac3dba64d2c1c51a87a2e43197b5060b655bf2..6193a89c22c25bcfea88bd33c474694d4104beef 100644 --- a/test/specs/specs_extend/CMakeLists.txt +++ b/test/specs/specs_extend/CMakeLists.txt @@ -23,14 +23,14 @@ add_executable(${EXE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/common/sysinfo.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/cmd/command_parser.c ${CMAKE_CURRENT_SOURCE_DIR}/../../../src/daemon/config/daemon_arguments.c - ${CMAKE_CURRENT_SOURCE_DIR}/../../../test/image/oci/oci_ut_common.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/../../../test/image/oci/oci_ut_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 - specs_extend_ut.cpp) + specs_extend_ut.cc) target_include_directories(${EXE} PUBLIC ${GTEST_INCLUDE_DIR} diff --git a/test/specs/specs_extend/specs_extend_ut.cpp b/test/specs/specs_extend/specs_extend_ut.cc similarity index 100% rename from test/specs/specs_extend/specs_extend_ut.cpp rename to test/specs/specs_extend/specs_extend_ut.cc diff --git a/tools/static_check.sh b/tools/static_check.sh index 7df0d03d531ccc67651ddfca52793f3669f5382f..c2ab7f1065cfa15992656ae3e287ea8528675d39 100755 --- a/tools/static_check.sh +++ b/tools/static_check.sh @@ -87,9 +87,9 @@ function codestyle_check() { local start_time=$(date +%s) local files if [[ ${1} == "all" ]]; then - files=$(find ./src ./test -regextype posix-extended -regex ".*\.(cc)") + files=$(find ./src ./test -regextype posix-extended -regex ".*\.(cc|cpp)") else - files=$(git diff --name-only HEAD | grep -E "*.cc$") + files=$(git diff --name-only HEAD | grep -E "*.cc$|*.cpp$") fi files=(${files// / }) local total=${#files[@]} @@ -128,7 +128,7 @@ function clang_format() { \____//_____//_/ |_|/_/ |_/ \____/ /_/ \____//_/ |_|/_/ /_//_/ |_|/_/ \033[0m] =================================================================================================" local start_time=$(date +%s) - local files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$") + local files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$|*.cpp$") files=(${files// / }) local total=${#files[@]} local failure_num=0 @@ -208,7 +208,7 @@ function astyle_format() { /_/ |_|/____/ /_/ /_//_____//_____/ /_/ \____//_/ |_|/_/ /_//_/ |_|/_/ \033[0m] =================================================================================================" local start_time=$(date +%s) - local files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h|c|cc)") + local files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h|c|cc|cpp)") files=(${files// / }) local total=${#files[@]} local failure_num=0 @@ -263,9 +263,9 @@ echo -e "\ local start_time=$(date +%s) local files if [[ ${1} == "all" ]]; then - files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h|c|cc)") + files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h|c|cc|cpp)") else - files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$") + files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$|*.cpp$") fi files=(${files// / }) local total=${#files[@]} @@ -360,13 +360,13 @@ function clang_tidy_check() { local files if [[ ${1} == "all" ]]; then - files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h|c|cc)") + files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h|c|cc|cpp)") elif [[ ${1} == "incremental" ]]; then - files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$") + files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$|*.cpp$") elif [[ -f "$1" ]]; then files="$1" elif [[ -d "$1" ]]; then - files=$(find "$1" -regextype posix-extended -regex ".*\.(h|c|cc)") + files=$(find "$1" -regextype posix-extended -regex ".*\.(h|c|cc|cpp)") fi files=(${files// / }) local total=${#files[@]} @@ -432,13 +432,13 @@ function clang_tidy_fix() { fi files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h)") elif [[ ${1} == "all" ]]; then - files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h|c|cc)") + files=$(find ./src ./test -regextype posix-extended -regex ".*\.(h|c|cc|cpp)") elif [[ ${1} == "incremental" ]]; then - files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$") + files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$|*.cpp$") elif [[ -f "$1" ]]; then files="$1" elif [[ -d "$1" ]]; then - files=$(find "$1" -regextype posix-extended -regex ".*\.(h|c|cc)") + files=$(find "$1" -regextype posix-extended -regex ".*\.(h|c|cc|cpp)") fi files=(${files// / }) local total=${#files[@]}