diff --git a/0001-fix-wrong-license.patch b/0001-fix-wrong-license.patch deleted file mode 100644 index ab7a97c53a3f9fdfc36d68ae2ef9a918bc19bc23..0000000000000000000000000000000000000000 --- a/0001-fix-wrong-license.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 74c5abe35a931aca850d5619faecbd62e75d9fb2 Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Tue, 26 May 2020 20:04:13 +0800 -Subject: [PATCH 01/11] fix wrong license - -Signed-off-by: haozi007 ---- - README.md | 2 +- - lcr.spec | 2 +- - update-version.bash | 33 +++++++++++++++++++++------------ - 3 files changed, 23 insertions(+), 14 deletions(-) - -diff --git a/README.md b/README.md -index 1984855..a1289c5 100644 ---- a/README.md -+++ b/README.md -@@ -12,4 +12,4 @@ iSulad follows the kernel coding conventions. You can find a detailed introducti - - ## Licensing - --lcr is licensed under the Mulan PSL v2. -+lcr is licensed under the LGPLv2.1+. -diff --git a/lcr.spec b/lcr.spec -index a706537..5644fdf 100644 ---- a/lcr.spec -+++ b/lcr.spec -@@ -9,7 +9,7 @@ URL: lcr - Source: lcr-2.0.tar.gz - Summary: Lightweight Container Runtime - Group: Applications/System --License: Mulan PSL v2 -+License: LGPLv2.1+ - BuildRoot: %{_tmppath}/lcr-%{version} - - BuildRequires: cmake -diff --git a/update-version.bash b/update-version.bash -index 77a6434..76697b8 100755 ---- a/update-version.bash -+++ b/update-version.bash -@@ -1,16 +1,25 @@ - ####################################################################### --##- @Copyright (C) Huawei Technologies., Ltd. 2019. All rights reserved. --# - lcr licensed under the Mulan PSL v2. --# - You can use this software according to the terms and conditions of the Mulan PSL v2. --# - You may obtain a copy of Mulan PSL v2 at: --# - http://license.coscl.org.cn/MulanPSL2 --# - THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR --# - IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR --# - PURPOSE. --# - See the Mulan PSL v2 for more details. --##- @Description: generate cetification --##- @Author: wujing --##- @Create: 2019-04-25 -+# lcr: utils library for iSula -+# -+# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. -+# -+# Authors: -+# Haozi007 -+# -+# This library is free software; you can redistribute it and/or -+# modify it under the terms of the GNU Lesser General Public -+# License as published by the Free Software Foundation; either -+# version 2.1 of the License, or (at your option) any later version. -+# -+# This library is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# Lesser General Public License for more details. -+# -+# You should have received a copy of the GNU Lesser General Public -+# License along with this library; if not, write to the Free Software -+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+# - ####################################################################### - #!/bin/bash - # --- -2.25.1 - diff --git a/0002-support-import-rootfs-to-be-image.patch b/0002-support-import-rootfs-to-be-image.patch deleted file mode 100644 index 2271cde7613f3d7b5dddd9f639bd5fbfb00d91c4..0000000000000000000000000000000000000000 --- a/0002-support-import-rootfs-to-be-image.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 15b7cc66a03f26c35dfc551a960edc24e5c52440 Mon Sep 17 00:00:00 2001 -From: WangFengTu -Date: Wed, 27 May 2020 11:25:56 +0800 -Subject: [PATCH 02/11] support import rootfs to be image - -Signed-off-by: WangFengTu ---- - src/json/schema/image/import-request.json | 12 ++++++++++++ - src/json/schema/image/import-response.json | 15 +++++++++++++++ - 2 files changed, 27 insertions(+) - create mode 100644 src/json/schema/image/import-request.json - create mode 100644 src/json/schema/image/import-response.json - -diff --git a/src/json/schema/image/import-request.json b/src/json/schema/image/import-request.json -new file mode 100644 -index 0000000..e2fe7bc ---- /dev/null -+++ b/src/json/schema/image/import-request.json -@@ -0,0 +1,12 @@ -+{ -+ "$schema": "http://json-schema.org/draft-04/schema#", -+ "type": "object", -+ "properties": { -+ "file": { -+ "type": "string" -+ }, -+ "tag": { -+ "type": "string" -+ } -+ } -+} -diff --git a/src/json/schema/image/import-response.json b/src/json/schema/image/import-response.json -new file mode 100644 -index 0000000..048f43d ---- /dev/null -+++ b/src/json/schema/image/import-response.json -@@ -0,0 +1,15 @@ -+{ -+ "$schema": "http://json-schema.org/draft-04/schema#", -+ "type": "object", -+ "properties": { -+ "id": { -+ "type": "string" -+ }, -+ "cc": { -+ "type": "uint32" -+ }, -+ "errmsg": { -+ "type": "string" -+ } -+ } -+} --- -2.25.1 - diff --git a/0003-support-calico.patch b/0003-support-calico.patch deleted file mode 100644 index 32877e43a3f2733f43fefa5115a25e34c00b6148..0000000000000000000000000000000000000000 --- a/0003-support-calico.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 855d567b2bd92aada6c7d61a75aae2d5441a1efe Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Tue, 2 Jun 2020 10:15:58 +0800 -Subject: [PATCH 03/11] support calico - -Signed-off-by: haozi007 ---- - src/json/schema/cni/net_conf.json | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/src/json/schema/cni/net_conf.json b/src/json/schema/cni/net_conf.json -index 3b40017..89427ae 100644 ---- a/src/json/schema/cni/net_conf.json -+++ b/src/json/schema/cni/net_conf.json -@@ -100,6 +100,12 @@ - "type": "string" - }, - "mtu": { -+ "type": "int32" -+ }, -+ "datastore_type": { -+ "type": "string" -+ }, -+ "nodename": { - "type": "string" - }, - "policy": { --- -2.25.1 - diff --git a/0004-improve-check-driver-of-log.patch b/0004-improve-check-driver-of-log.patch deleted file mode 100644 index aa8219eb9c238a224cba8b63fb693fa707fc9099..0000000000000000000000000000000000000000 --- a/0004-improve-check-driver-of-log.patch +++ /dev/null @@ -1,373 +0,0 @@ -From 72c179403743bd9bd82f0e4d80c558d883b973ac Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Tue, 9 Jun 2020 14:44:51 +0800 -Subject: [PATCH 04/11] improve check driver of log - -1. add llt for log -2. improve init driver of log - -Signed-off-by: haozi007 ---- - lcr.spec | 2 +- - tests/json_llt.cpp | 17 ++++++++-- - tests/log_llt.cpp | 53 +++++++++++++++++++++++++++++-- - third_party/log.c | 78 +++++++++++++++++++++++++--------------------- - third_party/log.h | 1 + - tools/static_check | 10 +++--- - 6 files changed, 113 insertions(+), 48 deletions(-) - -diff --git a/lcr.spec b/lcr.spec -index 5644fdf..0963e53 100644 ---- a/lcr.spec -+++ b/lcr.spec -@@ -1,5 +1,5 @@ - %global _version 2.0.2 --%global _release 20200526.162423.gitf1095eab -+%global _release 20200609.145938.gita2be0373 - %global _inner_name isula_libutils - - Name: lcr -diff --git a/tests/json_llt.cpp b/tests/json_llt.cpp -index 4a66305..9622ed4 100644 ---- a/tests/json_llt.cpp -+++ b/tests/json_llt.cpp -@@ -33,11 +33,11 @@ - TEST(json_testcase, test_oci_runtime_spec_hooks) - { - const char *fname = "./ocihook.json"; -- oci_runtime_spec_hooks *hooks = NULL; -+ oci_runtime_spec_hooks *hooks = nullptr; - parser_error jerr = nullptr; - char *jstr = nullptr; - -- hooks = oci_runtime_spec_hooks_parse_file(fname, NULL, &jerr); -+ hooks = oci_runtime_spec_hooks_parse_file(fname, nullptr, &jerr); - ASSERT_EQ(jerr, nullptr) << "parse hook failed: " << jerr; - ASSERT_NE(hooks, nullptr); - -@@ -82,11 +82,22 @@ TEST(json_testcase, test_oci_runtime_spec_hooks) - TEST(json_testcase, test_json_readfile) - { - const char *fname = "./ocihook.json"; -- char *jstr = NULL; -+ const char *not_exist = "/tmp/not_exist.json"; -+ char *jstr = nullptr; - size_t len = 0; - - jstr = read_file(fname, &len); - ASSERT_NE(jstr, nullptr); - ASSERT_EQ(len, 527); -+ free(jstr); -+ len = 0; -+ -+ jstr = read_file(not_exist, &len); -+ ASSERT_EQ(jstr, nullptr); -+ ASSERT_EQ(len, 0); -+ len = 0; -+ -+ jstr = read_file(nullptr, nullptr); -+ ASSERT_EQ(jstr, nullptr); - } - -diff --git a/tests/log_llt.cpp b/tests/log_llt.cpp -index 7d4a3d4..dbdebad 100644 ---- a/tests/log_llt.cpp -+++ b/tests/log_llt.cpp -@@ -42,7 +42,7 @@ TEST(log_testcases, test_isula_libutils_default_log_config) - ASSERT_EQ(tconf.file, nullptr); - ASSERT_EQ(tconf.driver, nullptr); - EXPECT_STREQ(name, tconf.name); -- EXPECT_STREQ("FATAL", tconf.priority); -+ EXPECT_STREQ("NOTSET", tconf.priority); - - // not quiet configs check - tconf.quiet = false; -@@ -79,28 +79,65 @@ TEST(log_testcases, test_isula_libutils_log_enable) - struct isula_libutils_log_config tconf = {0}; - const char *prefix = "fake"; - const char *prio = "INFO"; -+ const char *invalid_prio = "INVALID"; - const char *fname = "/tmp/fake.fifo"; - int fd = -1; -+ int ret = 0; -+ -+ ret = isula_libutils_log_enable(nullptr); -+ ASSERT_NE(ret, 0); -+ fd = isula_libutils_get_log_fd(); -+ ASSERT_EQ(fd, -1); - - tconf.driver = ISULA_LOG_DRIVER_FIFO; - tconf.prefix = prefix; - tconf.priority = prio; -+ tconf.file = nullptr; -+ ret = isula_libutils_log_enable(&tconf); -+ ASSERT_NE(ret, 0); -+ fd = isula_libutils_get_log_fd(); -+ ASSERT_EQ(fd, -1); -+ -+ tconf.driver = nullptr; -+ tconf.prefix = prefix; -+ tconf.priority = prio; - tconf.file = fname; -- isula_libutils_log_enable(&tconf); -+ ret = isula_libutils_log_enable(&tconf); -+ ASSERT_EQ(ret, 0); -+ fd = isula_libutils_get_log_fd(); -+ ASSERT_EQ(fd, -1); - -+ tconf.driver = ISULA_LOG_DRIVER_FIFO; -+ tconf.prefix = prefix; -+ tconf.priority = invalid_prio; -+ tconf.file = fname; -+ ret = isula_libutils_log_enable(&tconf); -+ ASSERT_EQ(ret, 0); - fd = isula_libutils_get_log_fd(); - ASSERT_GE(fd, 0); -+ DEBUG("debug log"); -+ check_log(fd, false, false, "debug log"); -+ isula_libutils_log_disable(); - -+ tconf.driver = ISULA_LOG_DRIVER_FIFO; -+ tconf.prefix = prefix; -+ tconf.priority = prio; -+ tconf.file = fname; -+ ret = isula_libutils_log_enable(&tconf); -+ ASSERT_EQ(ret, 0); -+ fd = isula_libutils_get_log_fd(); -+ ASSERT_GE(fd, 0); - INFO("info log"); - check_log(fd, true, true, "info log"); -- - DEBUG("debug log"); - check_log(fd, false, false, "debug log"); -+ isula_libutils_log_disable(); - } - - TEST(log_testcases, test_isula_libutils_log_prefix) - { - struct isula_libutils_log_config tconf = {0}; -+ const char *default_prefix = "iSula"; - const char *prefix = "prefix"; - const char *prio = "INFO"; - const char *fname = "/tmp/fake.fifo"; -@@ -121,5 +158,15 @@ TEST(log_testcases, test_isula_libutils_log_prefix) - isula_libutils_free_log_prefix(); - INFO("fake log"); - check_log(fd, true, false, prefix); -+ INFO("fake log"); -+ check_log(fd, true, true, default_prefix); -+ -+ isula_libutils_set_log_prefix(nullptr); -+ INFO("fake log"); -+ check_log(fd, true, true, default_prefix); -+ -+ isula_libutils_set_log_prefix(""); -+ INFO("fake log"); -+ check_log(fd, true, true, default_prefix); - } - -diff --git a/third_party/log.c b/third_party/log.c -index d0fa541..e8ee9b5 100644 ---- a/third_party/log.c -+++ b/third_party/log.c -@@ -79,7 +79,8 @@ void isula_libutils_default_log_config(const char *name, struct isula_libutils_l - { - log->name = name; - log->file = NULL; -- log->priority = "FATAL"; -+ // use to disable log -+ log->priority = "NOTSET"; - if (!log->quiet) { - log->driver = ISULA_LOG_DRIVER_STDOUT; - } -@@ -87,7 +88,7 @@ void isula_libutils_default_log_config(const char *name, struct isula_libutils_l - - void isula_libutils_set_log_prefix(const char *prefix) - { -- if (prefix == NULL) { -+ if (prefix == NULL || strlen(prefix) == 0) { - return; - } - -@@ -336,12 +337,45 @@ static int open_fifo(const char *fifo_path) - return fifo_fd; - } - --static bool check_log_driver(const struct isula_libutils_log_config *log) -+static void clean_pre_init() -+{ -+ g_lxc_log_category_lxc.appender = &log_appender_stderr; -+ g_lxc_log_category_lxc.priority = LXC_LOG_LEVEL_ERROR; -+} -+ -+static bool init_log_file(const char *fname) -+{ -+ if (fname == NULL) { -+ return false; -+ } -+ if (strcmp(fname, "none") == 0) { -+ return true; -+ } -+ if (lcr_util_build_dir(fname) != 0) { -+ CMD_SYSERROR("build log path \"%s\" failed", fname); -+ goto clean_out; -+ } -+ g_lxc_log_fd = open_fifo(fname); -+ if (g_lxc_log_fd == -1) { -+ CMD_SYSERROR("Open log fifo \"%s\" failed", fname); -+ goto clean_out; -+ } -+ -+ free(log_fname); -+ log_fname = lcr_util_strdup_s(fname); -+ return true; -+clean_out: -+ clean_pre_init(); -+ return false; -+} -+ -+static bool choice_log_driver(const struct isula_libutils_log_config *log) - { - bool is_fifo = false; - - // if driver is null, mean disable log - if (log->driver == NULL) { -+ g_lxc_log_category_lxc.priority = LXC_LOG_LEVEL_NOTSET; - return true; - } - g_lxc_log_category_lxc.appender = &log_appender_logfile; -@@ -350,10 +384,11 @@ static bool check_log_driver(const struct isula_libutils_log_config *log) - - // if set file, only use log_append_logfile - // we only support fifo driver with file -- if (log->file != NULL) { -- return is_fifo; -- } - if (is_fifo) { -+ return init_log_file(log->file); -+ } -+ if (log->file != NULL) { -+ clean_pre_init(); - return false; - } - -@@ -363,16 +398,8 @@ static bool check_log_driver(const struct isula_libutils_log_config *log) - return true; - } - --static void clean_pre_init() --{ -- g_lxc_log_category_lxc.appender = &log_appender_stderr; -- -- g_lxc_log_category_lxc.priority = LXC_LOG_LEVEL_ERROR; --} -- - int isula_libutils_log_enable(const struct isula_libutils_log_config *log) - { -- int ret = 0; - int lxc_priority = LXC_LOG_LEVEL_ERROR; - - if (log == NULL) -@@ -383,7 +410,7 @@ int isula_libutils_log_enable(const struct isula_libutils_log_config *log) - return 0; - } - -- if (!check_log_driver(log)) { -+ if (!choice_log_driver(log)) { - COMMAND_ERROR("Invalid log config of driver"); - return -1; - } -@@ -395,29 +422,8 @@ int isula_libutils_log_enable(const struct isula_libutils_log_config *log) - - isula_libutils_set_log_prefix(log->prefix != NULL ? log->prefix : log->name); - -- if (log->file) { -- if (strcmp(log->file, "none") == 0) { -- ret = 0; -- goto clean_out; -- } -- if (lcr_util_build_dir(log->file) != 0) { -- CMD_SYSERROR("build log path \"%s\" failed", log->file); -- ret = -1; -- goto clean_out; -- } -- g_lxc_log_fd = open_fifo(log->file); -- if (g_lxc_log_fd == -1) { -- CMD_SYSERROR("Open log fifo \"%s\" failed", log->file); -- ret = -1; -- goto clean_out; -- } -- log_fname = lcr_util_strdup_s(log->file); -- } - - return 0; --clean_out: -- clean_pre_init(); -- return ret; - } - - static inline void lxc_log_close(void) -diff --git a/third_party/log.h b/third_party/log.h -index 7f14ce0..2db0d98 100644 ---- a/third_party/log.h -+++ b/third_party/log.h -@@ -448,6 +448,7 @@ void isula_libutils_default_log_config(const char *name, struct isula_libutils_l - int isula_libutils_log_enable(const struct isula_libutils_log_config *log); - void isula_libutils_set_log_prefix(const char *prefix); - void isula_libutils_free_log_prefix(void); -+void isula_libutils_log_disable(); - - int isula_libutils_get_log_fd(void); - -diff --git a/tools/static_check b/tools/static_check -index 3a21d65..fd5c8ed 100755 ---- a/tools/static_check -+++ b/tools/static_check -@@ -91,7 +91,7 @@ function pclint_check() { - local start_time=$(date +%s) - local files - if [[ ${1} == "all" ]]; then -- files=$(find ./src ./test -regextype posix-extended -regex ".*\.(c|cc)") -+ files=$(find ./src ./tests -regextype posix-extended -regex ".*\.(c|cc)") - else - files=$(git diff --name-only HEAD | grep -E "*.c$") - fi -@@ -157,7 +157,7 @@ function codestyle_check() { - 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 ./tests -regextype posix-extended -regex ".*\.(h|c|cc)") - else - files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$") - fi -@@ -313,7 +313,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 ./tests -regextype posix-extended -regex ".*\.(h|c|cc)") - files=(${files// / }) - local total=${#files[@]} - local failure_num=0 -@@ -368,7 +368,7 @@ 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 ./tests -regextype posix-extended -regex ".*\.(h|c|cc)") - else - files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$") - fi -@@ -428,7 +428,7 @@ function cmetrics_check() { - 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 ./tests -regextype posix-extended -regex ".*\.(h|c|cc)") - else - files=$(git diff --name-only HEAD | grep -E "*.h$|*.c$|*.cc$") - fi --- -2.25.1 - diff --git a/0005-improve-llt-framework.patch b/0005-improve-llt-framework.patch deleted file mode 100644 index 8b0edabb0d56895413db87850e56a86a8be0e9ca..0000000000000000000000000000000000000000 --- a/0005-improve-llt-framework.patch +++ /dev/null @@ -1,246 +0,0 @@ -From d97eb223fea08b12b63aa84f1c67a9a38fd1fee9 Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Thu, 11 Jun 2020 14:41:55 +0800 -Subject: [PATCH 05/11] improve llt framework - -1. add hook to run genhtml for llt -2. improve llt - -Signed-off-by: haozi007 ---- - CMakeLists.txt | 27 +++++---------------------- - cmake/checker.cmake | 31 +++++++++++++++++++++++++------ - cmake/set_build_flags.cmake | 10 ++++++---- - tests/CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ - tests/log_llt.cpp | 25 +++++++++++++++++++++++++ - third_party/log.c | 4 ++-- - 6 files changed, 93 insertions(+), 34 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index c4acf43..dcb4232 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -23,8 +23,6 @@ - cmake_minimum_required (VERSION 2.8) - project (lcr) - --include(cmake/set_build_flags.cmake) -- - option(VERSION "set lcr version" ON) - if (VERSION STREQUAL "ON") - set(LCR_VERSION "2.0.2") -@@ -35,10 +33,8 @@ if (DEBUG STREQUAL "ON") - add_definitions("-g -o2") - endif() - --option(GCOV "set lcr gcov option" OFF) --if (GCOV STREQUAL "ON") -- set(LCR_GCOV "ON") --endif() -+include(cmake/set_build_flags.cmake) -+ - - if (LIB_INSTALL_DIR) - set(LIB_INSTALL_DIR_DEFAULT ${LIB_INSTALL_DIR}) -@@ -61,9 +57,6 @@ execute_process( - ) - message("-- commit id: " ${GIT_COMMIT_HASH}) - --set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines -fPIE -pie -shared -pthread") --set(CMAKE_EXE_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wtrampolines -fPIE -pie") -- - add_definitions(-DLCRPATH="${CMAKE_INSTALL_PREFIX}/var/lib/lcr") - add_definitions(-DLOGPATH="${CMAKE_INSTALL_PREFIX}/var/log/lcr") - add_definitions(-DLCR_GIT_COMMIT="${GIT_COMMIT_HASH}") -@@ -88,24 +81,14 @@ else () - message("-- Build static library") - endif() - --# llt and coverage --SET(CMAKE_VERBOSE_MAKEFILE OFF) --OPTION(ENABLE_COVERAGE "coverage switch" OFF) --IF(ENABLE_COVERAGE) -- MESSAGE(STATUS "Enable coverage compile option") -- SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage") -- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage") -- SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage -lgcov") --ENDIF(ENABLE_COVERAGE) -- - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party) - - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) - --OPTION(ENABLE_LLT "llt switch" OFF) --IF(ENABLE_LLT) -+# llt and gcoverage -+if (LCR_GCOV) - add_subdirectory(tests) --ENDIF(ENABLE_LLT) -+endif() - - # install all files - install(FILES ${CMAKE_BINARY_DIR}/conf/lcr.pc -diff --git a/cmake/checker.cmake b/cmake/checker.cmake -index c527442..20ad917 100644 ---- a/cmake/checker.cmake -+++ b/cmake/checker.cmake -@@ -69,11 +69,30 @@ find_library(LIBYAJL_LIBRARY yajl - HINTS ${PC_LIBYAJL_LIBDIR} ${PC_LIBYAJL_LIBRARY_DIRS}) - _CHECK(LIBYAJL_LIBRARY "LIBYAJL_LIBRARY-NOTFOUND" "libyajl.so") - --if (ENABLE_TESTS STREQUAL "ON") -- pkg_check_modules(PC_CHECK REQUIRED "check>=0.9.12") -- if (NOT PC_CHECK_FOUND) -- message("error: can not find check>=0.9.12") -- set(CHECKER_RESULT 1) -- endif() -+if (LCR_GCOV) -+ pkg_check_modules(PC_GTEST "gtest") -+ find_path(GTEST_INCLUDE_DIR gtest/gtest.h -+ HINTS ${PC_GTEST_INCLUDEDIR} ${PC_GTEST_INCLUDE_DIRS}) -+ _CHECK(GTEST_INCLUDE_DIR "GTEST_INCLUDE_DIR-NOTFOUND" "gtest.h") -+ find_library(GTEST_LIBRARY gtest -+ HINTS ${PC_GTEST_LIBDIR} ${PC_GTEST_LIBRARY_DIRS}) -+ _CHECK(GTEST_LIBRARY "GTEST_LIBRARY-NOTFOUND" "libgtest.so") -+ -+ pkg_check_modules(PC_GMOCK "gmock") -+ find_path(GMOCK_INCLUDE_DIR gmock/gmock.h -+ HINTS ${PC_GMOCK_INCLUDEDIR} ${PC_GMOCK_INCLUDE_DIRS}) -+ _CHECK(GMOCK_INCLUDE_DIR "GMOCK_INCLUDE_DIR-NOTFOUND" "gmock.h") -+ find_library(GMOCK_LIBRARY z -+ HINTS ${PC_GMOCK_LIBDIR} ${PC_GMOCK_LIBRARY_DIRS}) -+ _CHECK(GMOCK_LIBRARY "GMOCK_LIBRARY-NOTFOUND" "libgmock.so") -+ -+ find_program(CMD_GCOV gcov) -+ _CHECK(CMD_GCOV "CMD_GCOV-NOTFOUND" "gcov") -+ -+ find_program(CMD_LCOV lcov) -+ _CHECK(CMD_LCOV "CMD_LCOV-NOTFOUND" "lcov") -+ -+ find_program(CMD_GENHTML genhtml) -+ _CHECK(CMD_GENHTML "CMD_GENHTML-NOTFOUND" "genhtml") - endif() - -diff --git a/cmake/set_build_flags.cmake b/cmake/set_build_flags.cmake -index 46ba3c9..9aab5e1 100644 ---- a/cmake/set_build_flags.cmake -+++ b/cmake/set_build_flags.cmake -@@ -29,11 +29,13 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -W - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - -+option(LCR_GCOV "set lcr gcov option" OFF) - if (LCR_GCOV) -- set(CMAKE_C_FLAGS_DEBUG "-Wall -fprofile-arcs -ftest-coverage") -- set(CMAKE_CXX_FLAGS_DEBUG "-Wall -fprofile-arcs -ftest-coverage") -- message("-----CXXFLAGS: " ${CMAKE_CXX_FLAGS_DEBUG}) -+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fprofile-arcs -ftest-coverage") -+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fprofile-arcs -ftest-coverage") -+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") -+ message("-----CXXFLAGS: " ${CMAKE_CXX_FLAGS}) - message("------compile with gcov-------------") -- message("-----CFLAGS: " ${CMAKE_C_FLAGS_DEBUG}) -+ message("-----CFLAGS: " ${CMAKE_C_FLAGS}) - message("------------------------------------") - endif() -diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt -index 2d414ca..15708dd 100644 ---- a/tests/CMakeLists.txt -+++ b/tests/CMakeLists.txt -@@ -64,5 +64,35 @@ endmacro() - _DEFINE_NEW_TEST(log_llt log_testcase) - _DEFINE_NEW_TEST(json_llt json_testcase) - -+# mock test for run lcov to generate html -+add_executable(mock_llt main.cpp) -+target_include_directories(mock_llt PUBLIC -+ ${GTEST_INCLUDE_DIR} -+ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} -+ ) -+target_link_libraries(mock_llt -+ gtest -+ pthread -+ ) -+add_dependencies(mock_llt log_llt json_llt) -+ -+set(result isula_libutils.info) -+set(result_dir lcr_gcovs) -+set(target_dir src/CMakeFiles/isula_libutils.dir) -+ -+# generate gcov -+ -+add_custom_command(TARGET mock_llt -+ POST_BUILD -+ COMMAND ${CMAKE_COMMAND} -E remove -f ${result} -+ COMMAND ${CMAKE_COMMAND} -E make_directory ${result_dir} -+ COMMAND "ctest" -+ COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} -+ COMMAND ${CMD_GENHTML} --ignore-errors source -o ${result_dir} ${result} -+ COMMAND ${CMAKE_COMMAND} -E echo LLT finish -+ VERBATIM -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -+ ) -+ - # --------------- testcase add finish ----------------- - -diff --git a/tests/log_llt.cpp b/tests/log_llt.cpp -index dbdebad..a047f57 100644 ---- a/tests/log_llt.cpp -+++ b/tests/log_llt.cpp -@@ -107,6 +107,31 @@ TEST(log_testcases, test_isula_libutils_log_enable) - fd = isula_libutils_get_log_fd(); - ASSERT_EQ(fd, -1); - -+ tconf.driver = ISULA_LOG_DRIVER_STDOUT; -+ tconf.prefix = prefix; -+ tconf.priority = prio; -+ tconf.file = fname; -+ ret = isula_libutils_log_enable(&tconf); -+ ASSERT_NE(ret, 0); -+ isula_libutils_log_disable(); -+ -+ tconf.driver = ISULA_LOG_DRIVER_STDOUT; -+ tconf.prefix = prefix; -+ tconf.priority = prio; -+ tconf.file = nullptr; -+ ret = isula_libutils_log_enable(&tconf); -+ ASSERT_EQ(ret, 0); -+ TRACE("trace log"); -+ DEBUG("debug log"); -+ INFO("info log"); -+ NOTICE("notice log"); -+ WARN("warn log"); -+ ERROR("error log"); -+ EVENT("event log"); -+ CRIT("crit log"); -+ FATAL("fatal log"); -+ isula_libutils_log_disable(); -+ - tconf.driver = ISULA_LOG_DRIVER_FIFO; - tconf.prefix = prefix; - tconf.priority = invalid_prio; -diff --git a/third_party/log.c b/third_party/log.c -index e8ee9b5..83de005 100644 ---- a/third_party/log.c -+++ b/third_party/log.c -@@ -80,7 +80,7 @@ void isula_libutils_default_log_config(const char *name, struct isula_libutils_l - log->name = name; - log->file = NULL; - // use to disable log -- log->priority = "NOTSET"; -+ log->priority = "FATAL"; - if (!log->quiet) { - log->driver = ISULA_LOG_DRIVER_STDOUT; - } -@@ -375,7 +375,7 @@ static bool choice_log_driver(const struct isula_libutils_log_config *log) - - // if driver is null, mean disable log - if (log->driver == NULL) { -- g_lxc_log_category_lxc.priority = LXC_LOG_LEVEL_NOTSET; -+ g_lxc_log_category_lxc.priority = LXC_LOG_LEVEL_FATAL; - return true; - } - g_lxc_log_category_lxc.appender = &log_appender_logfile; --- -2.25.1 - diff --git a/0006-fix-log-test-error.patch b/0006-fix-log-test-error.patch deleted file mode 100644 index 173772c9632c2981a97aff1c299f6e5b5148f833..0000000000000000000000000000000000000000 --- a/0006-fix-log-test-error.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 02054466c71822e197499b0271cfed57c96598b2 Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Thu, 11 Jun 2020 15:14:48 +0800 -Subject: [PATCH 06/11] fix log test error - -Signed-off-by: haozi007 ---- - tests/log_llt.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/log_llt.cpp b/tests/log_llt.cpp -index a047f57..8944b38 100644 ---- a/tests/log_llt.cpp -+++ b/tests/log_llt.cpp -@@ -42,7 +42,7 @@ TEST(log_testcases, test_isula_libutils_default_log_config) - ASSERT_EQ(tconf.file, nullptr); - ASSERT_EQ(tconf.driver, nullptr); - EXPECT_STREQ(name, tconf.name); -- EXPECT_STREQ("NOTSET", tconf.priority); -+ EXPECT_STREQ("FATAL", tconf.priority); - - // not quiet configs check - tconf.quiet = false; --- -2.25.1 - diff --git a/0007-improve-html-show-result.patch b/0007-improve-html-show-result.patch deleted file mode 100644 index b37dd943272bdea41ae98eda967d4de70769a893..0000000000000000000000000000000000000000 --- a/0007-improve-html-show-result.patch +++ /dev/null @@ -1,26 +0,0 @@ -From abc0b5907d4b50729aa83a4c41d4a7e02d857aea Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Thu, 11 Jun 2020 15:48:32 +0800 -Subject: [PATCH 07/11] improve html show result - -Signed-off-by: haozi007 ---- - tests/CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt -index 15708dd..ca6d164 100644 ---- a/tests/CMakeLists.txt -+++ b/tests/CMakeLists.txt -@@ -87,7 +87,7 @@ add_custom_command(TARGET mock_llt - COMMAND ${CMAKE_COMMAND} -E remove -f ${result} - COMMAND ${CMAKE_COMMAND} -E make_directory ${result_dir} - COMMAND "ctest" -- COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} -+ COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "/usr/*" --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} - COMMAND ${CMD_GENHTML} --ignore-errors source -o ${result_dir} ${result} - COMMAND ${CMAKE_COMMAND} -E echo LLT finish - VERBATIM --- -2.25.1 - diff --git a/0008-change-tests-name.patch b/0008-change-tests-name.patch deleted file mode 100644 index 953eca458b204a19883f7d4962980251c4e4ec17..0000000000000000000000000000000000000000 --- a/0008-change-tests-name.patch +++ /dev/null @@ -1,189 +0,0 @@ -From cb27a1612fdba43b94e9af1232da4378205c4c8a Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Sat, 13 Jun 2020 10:32:28 +0800 -Subject: [PATCH 08/11] change tests name - -1. change name of tests -2. default to run tests after build -3. use option to manage gcov - -Signed-off-by: haozi007 ---- - CMakeLists.txt | 6 +-- - cmake/checker.cmake | 2 +- - cmake/set_build_flags.cmake | 4 +- - src/CMakeLists.txt | 4 -- - tests/CMakeLists.txt | 54 ++++++++++++++--------- - tests/{json_llt.cpp => libocispec_ut.cpp} | 4 +- - tests/{log_llt.cpp => log_ut.cpp} | 0 - 7 files changed, 39 insertions(+), 35 deletions(-) - rename tests/{json_llt.cpp => libocispec_ut.cpp} (97%) - rename tests/{log_llt.cpp => log_ut.cpp} (100%) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index dcb4232..53e985f 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -85,10 +85,8 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party) - - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) - --# llt and gcoverage --if (LCR_GCOV) -- add_subdirectory(tests) --endif() -+# ut and gcoverage -+add_subdirectory(tests) - - # install all files - install(FILES ${CMAKE_BINARY_DIR}/conf/lcr.pc -diff --git a/cmake/checker.cmake b/cmake/checker.cmake -index 20ad917..7f8e9cc 100644 ---- a/cmake/checker.cmake -+++ b/cmake/checker.cmake -@@ -69,7 +69,7 @@ find_library(LIBYAJL_LIBRARY yajl - HINTS ${PC_LIBYAJL_LIBDIR} ${PC_LIBYAJL_LIBRARY_DIRS}) - _CHECK(LIBYAJL_LIBRARY "LIBYAJL_LIBRARY-NOTFOUND" "libyajl.so") - --if (LCR_GCOV) -+if (ENABLE_GCOV) - pkg_check_modules(PC_GTEST "gtest") - find_path(GTEST_INCLUDE_DIR gtest/gtest.h - HINTS ${PC_GTEST_INCLUDEDIR} ${PC_GTEST_INCLUDE_DIRS}) -diff --git a/cmake/set_build_flags.cmake b/cmake/set_build_flags.cmake -index 9aab5e1..87cab3e 100644 ---- a/cmake/set_build_flags.cmake -+++ b/cmake/set_build_flags.cmake -@@ -29,8 +29,8 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -W - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - --option(LCR_GCOV "set lcr gcov option" OFF) --if (LCR_GCOV) -+option(ENABLE_GCOV "set lcr gcov option" OFF) -+if (ENABLE_GCOV) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fprofile-arcs -ftest-coverage") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 5e09c93..6ed2d95 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -103,10 +103,6 @@ if (CMAKE_TOOLCHAIN_FILE) - target_link_libraries(liblcr ${EXTRAL_LINK_LIBS}) - endif() - --if (LCR_GCOV) -- target_link_libraries(liblcr -lgcov) --endif() -- - # install all files - install(TARGETS liblcr - LIBRARY DESTINATION ${LIB_INSTALL_DIR_DEFAULT} PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) -diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt -index ca6d164..58a6fad 100644 ---- a/tests/CMakeLists.txt -+++ b/tests/CMakeLists.txt -@@ -61,38 +61,48 @@ endmacro() - - # --------------- testcase add here ----------------- - # api testcase --_DEFINE_NEW_TEST(log_llt log_testcase) --_DEFINE_NEW_TEST(json_llt json_testcase) -+_DEFINE_NEW_TEST(log_ut log_testcase) -+_DEFINE_NEW_TEST(libocispec_ut json_testcase) -+ - - # mock test for run lcov to generate html --add_executable(mock_llt main.cpp) --target_include_directories(mock_llt PUBLIC -+add_executable(mock_ut main.cpp) -+target_include_directories(mock_ut PUBLIC - ${GTEST_INCLUDE_DIR} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - ) --target_link_libraries(mock_llt -+target_link_libraries(mock_ut - gtest - pthread - ) --add_dependencies(mock_llt log_llt json_llt) -- --set(result isula_libutils.info) --set(result_dir lcr_gcovs) --set(target_dir src/CMakeFiles/isula_libutils.dir) -+add_dependencies(mock_ut log_ut libocispec_ut) - --# generate gcov -+# run ut and gcov -+if (ENABLE_GCOV) -+ set(result isula_libutils.info) -+ set(result_dir lcr_gcovs) -+ set(target_dir src/CMakeFiles/isula_libutils.dir) - --add_custom_command(TARGET mock_llt -- POST_BUILD -- COMMAND ${CMAKE_COMMAND} -E remove -f ${result} -- COMMAND ${CMAKE_COMMAND} -E make_directory ${result_dir} -- COMMAND "ctest" -- COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "/usr/*" --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} -- COMMAND ${CMD_GENHTML} --ignore-errors source -o ${result_dir} ${result} -- COMMAND ${CMAKE_COMMAND} -E echo LLT finish -- VERBATIM -- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -- ) -+ add_custom_command(TARGET mock_ut -+ POST_BUILD -+ COMMAND ${CMAKE_COMMAND} -E remove -f ${result} -+ COMMAND ${CMAKE_COMMAND} -E make_directory ${result_dir} -+ COMMAND "ctest" -+ COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "/usr/*" --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} -+ COMMAND ${CMD_GENHTML} --ignore-errors source -o ${result_dir} ${result} -+ COMMAND ${CMAKE_COMMAND} -E echo run gcov finish -+ VERBATIM -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -+ ) -+else() -+ add_custom_command(TARGET mock_ut -+ PRE_BUILD -+ COMMAND "ctest" -+ COMMAND ${CMAKE_COMMAND} -E echo UT finish -+ VERBATIM -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -+ ) -+endif() - - # --------------- testcase add finish ----------------- - -diff --git a/tests/json_llt.cpp b/tests/libocispec_ut.cpp -similarity index 97% -rename from tests/json_llt.cpp -rename to tests/libocispec_ut.cpp -index 9622ed4..58a1f52 100644 ---- a/tests/json_llt.cpp -+++ b/tests/libocispec_ut.cpp -@@ -30,7 +30,7 @@ - #include "read_file.h" - #include "oci_runtime_hooks.h" - --TEST(json_testcase, test_oci_runtime_spec_hooks) -+TEST(libocispec_testcase, test_oci_runtime_spec_hooks) - { - const char *fname = "./ocihook.json"; - oci_runtime_spec_hooks *hooks = nullptr; -@@ -79,7 +79,7 @@ TEST(json_testcase, test_oci_runtime_spec_hooks) - free(jstr); - } - --TEST(json_testcase, test_json_readfile) -+TEST(libocispec_testcase, test_json_readfile) - { - const char *fname = "./ocihook.json"; - const char *not_exist = "/tmp/not_exist.json"; -diff --git a/tests/log_llt.cpp b/tests/log_ut.cpp -similarity index 100% -rename from tests/log_llt.cpp -rename to tests/log_ut.cpp --- -2.25.1 - diff --git a/0009-Pull-Request-49-change-name-of-testcases.patch b/0009-Pull-Request-49-change-name-of-testcases.patch deleted file mode 100644 index bfe918cea0a67ec968e7c8ad1927b16621f8efde..0000000000000000000000000000000000000000 --- a/0009-Pull-Request-49-change-name-of-testcases.patch +++ /dev/null @@ -1,188 +0,0 @@ -From c1cd034cf73b483c4c120c789c188ee64d19f7d3 Mon Sep 17 00:00:00 2001 -From: lifeng_isula -Date: Mon, 15 Jun 2020 10:39:15 +0800 -Subject: [PATCH 09/11] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!4?= - =?UTF-8?q?9=20:=20change=20name=20of=20testcases'?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - ---- - CMakeLists.txt | 6 ++- - cmake/checker.cmake | 2 +- - cmake/set_build_flags.cmake | 4 +- - src/CMakeLists.txt | 4 ++ - tests/CMakeLists.txt | 54 +++++++++-------------- - tests/{libocispec_ut.cpp => json_llt.cpp} | 4 +- - tests/{log_ut.cpp => log_llt.cpp} | 0 - 7 files changed, 35 insertions(+), 39 deletions(-) - rename tests/{libocispec_ut.cpp => json_llt.cpp} (97%) - rename tests/{log_ut.cpp => log_llt.cpp} (100%) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 53e985f..dcb4232 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -85,8 +85,10 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party) - - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) - --# ut and gcoverage --add_subdirectory(tests) -+# llt and gcoverage -+if (LCR_GCOV) -+ add_subdirectory(tests) -+endif() - - # install all files - install(FILES ${CMAKE_BINARY_DIR}/conf/lcr.pc -diff --git a/cmake/checker.cmake b/cmake/checker.cmake -index 7f8e9cc..20ad917 100644 ---- a/cmake/checker.cmake -+++ b/cmake/checker.cmake -@@ -69,7 +69,7 @@ find_library(LIBYAJL_LIBRARY yajl - HINTS ${PC_LIBYAJL_LIBDIR} ${PC_LIBYAJL_LIBRARY_DIRS}) - _CHECK(LIBYAJL_LIBRARY "LIBYAJL_LIBRARY-NOTFOUND" "libyajl.so") - --if (ENABLE_GCOV) -+if (LCR_GCOV) - pkg_check_modules(PC_GTEST "gtest") - find_path(GTEST_INCLUDE_DIR gtest/gtest.h - HINTS ${PC_GTEST_INCLUDEDIR} ${PC_GTEST_INCLUDE_DIRS}) -diff --git a/cmake/set_build_flags.cmake b/cmake/set_build_flags.cmake -index 87cab3e..9aab5e1 100644 ---- a/cmake/set_build_flags.cmake -+++ b/cmake/set_build_flags.cmake -@@ -29,8 +29,8 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -W - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - --option(ENABLE_GCOV "set lcr gcov option" OFF) --if (ENABLE_GCOV) -+option(LCR_GCOV "set lcr gcov option" OFF) -+if (LCR_GCOV) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fprofile-arcs -ftest-coverage") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 6ed2d95..5e09c93 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -103,6 +103,10 @@ if (CMAKE_TOOLCHAIN_FILE) - target_link_libraries(liblcr ${EXTRAL_LINK_LIBS}) - endif() - -+if (LCR_GCOV) -+ target_link_libraries(liblcr -lgcov) -+endif() -+ - # install all files - install(TARGETS liblcr - LIBRARY DESTINATION ${LIB_INSTALL_DIR_DEFAULT} PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) -diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt -index 58a6fad..ca6d164 100644 ---- a/tests/CMakeLists.txt -+++ b/tests/CMakeLists.txt -@@ -61,48 +61,38 @@ endmacro() - - # --------------- testcase add here ----------------- - # api testcase --_DEFINE_NEW_TEST(log_ut log_testcase) --_DEFINE_NEW_TEST(libocispec_ut json_testcase) -- -+_DEFINE_NEW_TEST(log_llt log_testcase) -+_DEFINE_NEW_TEST(json_llt json_testcase) - - # mock test for run lcov to generate html --add_executable(mock_ut main.cpp) --target_include_directories(mock_ut PUBLIC -+add_executable(mock_llt main.cpp) -+target_include_directories(mock_llt PUBLIC - ${GTEST_INCLUDE_DIR} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - ) --target_link_libraries(mock_ut -+target_link_libraries(mock_llt - gtest - pthread - ) --add_dependencies(mock_ut log_ut libocispec_ut) -+add_dependencies(mock_llt log_llt json_llt) - --# run ut and gcov --if (ENABLE_GCOV) -- set(result isula_libutils.info) -- set(result_dir lcr_gcovs) -- set(target_dir src/CMakeFiles/isula_libutils.dir) -+set(result isula_libutils.info) -+set(result_dir lcr_gcovs) -+set(target_dir src/CMakeFiles/isula_libutils.dir) - -- add_custom_command(TARGET mock_ut -- POST_BUILD -- COMMAND ${CMAKE_COMMAND} -E remove -f ${result} -- COMMAND ${CMAKE_COMMAND} -E make_directory ${result_dir} -- COMMAND "ctest" -- COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "/usr/*" --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} -- COMMAND ${CMD_GENHTML} --ignore-errors source -o ${result_dir} ${result} -- COMMAND ${CMAKE_COMMAND} -E echo run gcov finish -- VERBATIM -- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -- ) --else() -- add_custom_command(TARGET mock_ut -- PRE_BUILD -- COMMAND "ctest" -- COMMAND ${CMAKE_COMMAND} -E echo UT finish -- VERBATIM -- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -- ) --endif() -+# generate gcov -+ -+add_custom_command(TARGET mock_llt -+ POST_BUILD -+ COMMAND ${CMAKE_COMMAND} -E remove -f ${result} -+ COMMAND ${CMAKE_COMMAND} -E make_directory ${result_dir} -+ COMMAND "ctest" -+ COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "/usr/*" --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} -+ COMMAND ${CMD_GENHTML} --ignore-errors source -o ${result_dir} ${result} -+ COMMAND ${CMAKE_COMMAND} -E echo LLT finish -+ VERBATIM -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -+ ) - - # --------------- testcase add finish ----------------- - -diff --git a/tests/libocispec_ut.cpp b/tests/json_llt.cpp -similarity index 97% -rename from tests/libocispec_ut.cpp -rename to tests/json_llt.cpp -index 58a1f52..9622ed4 100644 ---- a/tests/libocispec_ut.cpp -+++ b/tests/json_llt.cpp -@@ -30,7 +30,7 @@ - #include "read_file.h" - #include "oci_runtime_hooks.h" - --TEST(libocispec_testcase, test_oci_runtime_spec_hooks) -+TEST(json_testcase, test_oci_runtime_spec_hooks) - { - const char *fname = "./ocihook.json"; - oci_runtime_spec_hooks *hooks = nullptr; -@@ -79,7 +79,7 @@ TEST(libocispec_testcase, test_oci_runtime_spec_hooks) - free(jstr); - } - --TEST(libocispec_testcase, test_json_readfile) -+TEST(json_testcase, test_json_readfile) - { - const char *fname = "./ocihook.json"; - const char *not_exist = "/tmp/not_exist.json"; -diff --git a/tests/log_ut.cpp b/tests/log_llt.cpp -similarity index 100% -rename from tests/log_ut.cpp -rename to tests/log_llt.cpp --- -2.25.1 - diff --git a/0010-change-tests-name.patch b/0010-change-tests-name.patch deleted file mode 100644 index 3c6d80b77064ea84741e05d407bc108b746d0b3d..0000000000000000000000000000000000000000 --- a/0010-change-tests-name.patch +++ /dev/null @@ -1,227 +0,0 @@ -From 71eb58f5a5002faf6ad4bc1a77cbf483d06f27c9 Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Tue, 16 Jun 2020 14:40:10 +0800 -Subject: [PATCH 10/11] change tests name - -Signed-off-by: haozi007 ---- - CMakeLists.txt | 6 +-- - cmake/checker.cmake | 30 ++++++------ - cmake/set_build_flags.cmake | 4 +- - src/CMakeLists.txt | 4 -- - tests/CMakeLists.txt | 60 +++++++++++++---------- - tests/{json_llt.cpp => libocispec_ut.cpp} | 4 +- - tests/{log_llt.cpp => log_ut.cpp} | 0 - 7 files changed, 56 insertions(+), 52 deletions(-) - rename tests/{json_llt.cpp => libocispec_ut.cpp} (97%) - rename tests/{log_llt.cpp => log_ut.cpp} (100%) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index dcb4232..53e985f 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -85,10 +85,8 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party) - - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src) - --# llt and gcoverage --if (LCR_GCOV) -- add_subdirectory(tests) --endif() -+# ut and gcoverage -+add_subdirectory(tests) - - # install all files - install(FILES ${CMAKE_BINARY_DIR}/conf/lcr.pc -diff --git a/cmake/checker.cmake b/cmake/checker.cmake -index 20ad917..dde41a6 100644 ---- a/cmake/checker.cmake -+++ b/cmake/checker.cmake -@@ -69,23 +69,23 @@ find_library(LIBYAJL_LIBRARY yajl - HINTS ${PC_LIBYAJL_LIBDIR} ${PC_LIBYAJL_LIBRARY_DIRS}) - _CHECK(LIBYAJL_LIBRARY "LIBYAJL_LIBRARY-NOTFOUND" "libyajl.so") - --if (LCR_GCOV) -- pkg_check_modules(PC_GTEST "gtest") -- find_path(GTEST_INCLUDE_DIR gtest/gtest.h -- HINTS ${PC_GTEST_INCLUDEDIR} ${PC_GTEST_INCLUDE_DIRS}) -- _CHECK(GTEST_INCLUDE_DIR "GTEST_INCLUDE_DIR-NOTFOUND" "gtest.h") -- find_library(GTEST_LIBRARY gtest -- HINTS ${PC_GTEST_LIBDIR} ${PC_GTEST_LIBRARY_DIRS}) -- _CHECK(GTEST_LIBRARY "GTEST_LIBRARY-NOTFOUND" "libgtest.so") -+pkg_check_modules(PC_GTEST "gtest") -+find_path(GTEST_INCLUDE_DIR gtest/gtest.h -+ HINTS ${PC_GTEST_INCLUDEDIR} ${PC_GTEST_INCLUDE_DIRS}) -+_CHECK(GTEST_INCLUDE_DIR "GTEST_INCLUDE_DIR-NOTFOUND" "gtest.h") -+find_library(GTEST_LIBRARY gtest -+ HINTS ${PC_GTEST_LIBDIR} ${PC_GTEST_LIBRARY_DIRS}) -+_CHECK(GTEST_LIBRARY "GTEST_LIBRARY-NOTFOUND" "libgtest.so") - -- pkg_check_modules(PC_GMOCK "gmock") -- find_path(GMOCK_INCLUDE_DIR gmock/gmock.h -- HINTS ${PC_GMOCK_INCLUDEDIR} ${PC_GMOCK_INCLUDE_DIRS}) -- _CHECK(GMOCK_INCLUDE_DIR "GMOCK_INCLUDE_DIR-NOTFOUND" "gmock.h") -- find_library(GMOCK_LIBRARY z -- HINTS ${PC_GMOCK_LIBDIR} ${PC_GMOCK_LIBRARY_DIRS}) -- _CHECK(GMOCK_LIBRARY "GMOCK_LIBRARY-NOTFOUND" "libgmock.so") -+pkg_check_modules(PC_GMOCK "gmock") -+find_path(GMOCK_INCLUDE_DIR gmock/gmock.h -+ HINTS ${PC_GMOCK_INCLUDEDIR} ${PC_GMOCK_INCLUDE_DIRS}) -+_CHECK(GMOCK_INCLUDE_DIR "GMOCK_INCLUDE_DIR-NOTFOUND" "gmock.h") -+find_library(GMOCK_LIBRARY z -+ HINTS ${PC_GMOCK_LIBDIR} ${PC_GMOCK_LIBRARY_DIRS}) -+_CHECK(GMOCK_LIBRARY "GMOCK_LIBRARY-NOTFOUND" "libgmock.so") - -+if (ENABLE_GCOV) - find_program(CMD_GCOV gcov) - _CHECK(CMD_GCOV "CMD_GCOV-NOTFOUND" "gcov") - -diff --git a/cmake/set_build_flags.cmake b/cmake/set_build_flags.cmake -index 9aab5e1..87cab3e 100644 ---- a/cmake/set_build_flags.cmake -+++ b/cmake/set_build_flags.cmake -@@ -29,8 +29,8 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -W - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<))\"'") - --option(LCR_GCOV "set lcr gcov option" OFF) --if (LCR_GCOV) -+option(ENABLE_GCOV "set lcr gcov option" OFF) -+if (ENABLE_GCOV) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fprofile-arcs -ftest-coverage") - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov") -diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt -index 5e09c93..6ed2d95 100644 ---- a/src/CMakeLists.txt -+++ b/src/CMakeLists.txt -@@ -103,10 +103,6 @@ if (CMAKE_TOOLCHAIN_FILE) - target_link_libraries(liblcr ${EXTRAL_LINK_LIBS}) - endif() - --if (LCR_GCOV) -- target_link_libraries(liblcr -lgcov) --endif() -- - # install all files - install(TARGETS liblcr - LIBRARY DESTINATION ${LIB_INSTALL_DIR_DEFAULT} PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) -diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt -index ca6d164..89eb6cf 100644 ---- a/tests/CMakeLists.txt -+++ b/tests/CMakeLists.txt -@@ -37,8 +37,8 @@ macro(_DEFINE_NEW_TEST) - - target_link_libraries(${ARGV0} - isula_libutils -- gtest -- -lyajl -+ ${GTEST_LIBRARY} -+ ${LIBYAJL_LIBRARY} - pthread - ) - -@@ -61,38 +61,48 @@ endmacro() - - # --------------- testcase add here ----------------- - # api testcase --_DEFINE_NEW_TEST(log_llt log_testcase) --_DEFINE_NEW_TEST(json_llt json_testcase) -+_DEFINE_NEW_TEST(log_ut log_testcase) -+_DEFINE_NEW_TEST(libocispec_ut libocispec_testcase) -+ - - # mock test for run lcov to generate html --add_executable(mock_llt main.cpp) --target_include_directories(mock_llt PUBLIC -+add_executable(mock_ut main.cpp) -+target_include_directories(mock_ut PUBLIC - ${GTEST_INCLUDE_DIR} - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} - ) --target_link_libraries(mock_llt -- gtest -+target_link_libraries(mock_ut -+ ${GTEST_LIBRARY} - pthread - ) --add_dependencies(mock_llt log_llt json_llt) -- --set(result isula_libutils.info) --set(result_dir lcr_gcovs) --set(target_dir src/CMakeFiles/isula_libutils.dir) -+add_dependencies(mock_ut log_ut libocispec_ut) - --# generate gcov -+# run ut and gcov -+if (ENABLE_GCOV) -+ set(result isula_libutils.info) -+ set(result_dir lcr_gcovs) -+ set(target_dir src/CMakeFiles/isula_libutils.dir) - --add_custom_command(TARGET mock_llt -- POST_BUILD -- COMMAND ${CMAKE_COMMAND} -E remove -f ${result} -- COMMAND ${CMAKE_COMMAND} -E make_directory ${result_dir} -- COMMAND "ctest" -- COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "/usr/*" --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} -- COMMAND ${CMD_GENHTML} --ignore-errors source -o ${result_dir} ${result} -- COMMAND ${CMAKE_COMMAND} -E echo LLT finish -- VERBATIM -- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -- ) -+ add_custom_command(TARGET mock_ut -+ POST_BUILD -+ COMMAND ${CMAKE_COMMAND} -E remove -f ${result} -+ COMMAND ${CMAKE_COMMAND} -E make_directory ${result_dir} -+ COMMAND ctest -VV -+ COMMAND ${CMD_LCOV} --gcov-tool ${CMD_GCOV} --exclude "/usr/*" --exclude "*/src/utils.c" --exclude "*/json/*" -d ${CMAKE_BINARY_DIR}/${target_dir} -c -o ${result} -+ COMMAND ${CMD_GENHTML} --ignore-errors source -o ${result_dir} ${result} -+ COMMAND ${CMAKE_COMMAND} -E echo run gcov finish -+ VERBATIM -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -+ ) -+else() -+ add_custom_command(TARGET mock_ut -+ PRE_BUILD -+ COMMAND ${CMAKE_CTEST_COMMAND} -VV -+ COMMAND ${CMAKE_COMMAND} -E echo UT finish -+ VERBATIM -+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests -+ ) -+endif() - - # --------------- testcase add finish ----------------- - -diff --git a/tests/json_llt.cpp b/tests/libocispec_ut.cpp -similarity index 97% -rename from tests/json_llt.cpp -rename to tests/libocispec_ut.cpp -index 9622ed4..58a1f52 100644 ---- a/tests/json_llt.cpp -+++ b/tests/libocispec_ut.cpp -@@ -30,7 +30,7 @@ - #include "read_file.h" - #include "oci_runtime_hooks.h" - --TEST(json_testcase, test_oci_runtime_spec_hooks) -+TEST(libocispec_testcase, test_oci_runtime_spec_hooks) - { - const char *fname = "./ocihook.json"; - oci_runtime_spec_hooks *hooks = nullptr; -@@ -79,7 +79,7 @@ TEST(json_testcase, test_oci_runtime_spec_hooks) - free(jstr); - } - --TEST(json_testcase, test_json_readfile) -+TEST(libocispec_testcase, test_json_readfile) - { - const char *fname = "./ocihook.json"; - const char *not_exist = "/tmp/not_exist.json"; -diff --git a/tests/log_llt.cpp b/tests/log_ut.cpp -similarity index 100% -rename from tests/log_llt.cpp -rename to tests/log_ut.cpp --- -2.25.1 - diff --git a/0011-support-fuzz-test.patch b/0011-support-fuzz-test.patch deleted file mode 100644 index 5b4b2201935eb36f6f474adab8bfb14eccaaffde..0000000000000000000000000000000000000000 --- a/0011-support-fuzz-test.patch +++ /dev/null @@ -1,241 +0,0 @@ -From 10ee1a5e5eca638f0cc5190ae49c34e9841d8c8b Mon Sep 17 00:00:00 2001 -From: haozi007 -Date: Sun, 28 Jun 2020 16:16:04 +0800 -Subject: [PATCH 11/11] support fuzz test - -Signed-off-by: haozi007 ---- - tests/CMakeLists.txt | 7 ++++ - tests/fuzz/CMakeLists.txt | 40 ++++++++++++++++++ - tests/fuzz/dict/log_fuzz.dict | 14 +++++++ - tests/fuzz/fuzz.sh | 48 ++++++++++++++++++++++ - tests/fuzz/log_fuzz.cc | 76 +++++++++++++++++++++++++++++++++++ - 5 files changed, 185 insertions(+) - create mode 100644 tests/fuzz/CMakeLists.txt - create mode 100644 tests/fuzz/dict/log_fuzz.dict - create mode 100755 tests/fuzz/fuzz.sh - create mode 100644 tests/fuzz/log_fuzz.cc - -diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt -index 89eb6cf..e2ad103 100644 ---- a/tests/CMakeLists.txt -+++ b/tests/CMakeLists.txt -@@ -60,6 +60,13 @@ macro(_DEFINE_NEW_TEST) - endmacro() - - # --------------- testcase add here ----------------- -+ -+# fuzz test -+option(ENABLE_FUZZ "set lcr fuzz option" OFF) -+if (ENABLE_FUZZ) -+ add_subdirectory(fuzz) -+endif() -+ - # api testcase - _DEFINE_NEW_TEST(log_ut log_testcase) - _DEFINE_NEW_TEST(libocispec_ut libocispec_testcase) -diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt -new file mode 100644 -index 0000000..660b8be ---- /dev/null -+++ b/tests/fuzz/CMakeLists.txt -@@ -0,0 +1,40 @@ -+# lcr: fuzz tests -+# -+# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. -+# -+# Authors: -+# Haozi007 -+# -+# This library is free software; you can redistribute it and/or -+# modify it under the terms of the GNU Lesser General Public -+# License as published by the Free Software Foundation; either -+# version 2.1 of the License, or (at your option) any later version. -+# -+# This library is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# Lesser General Public License for more details. -+# -+# You should have received a copy of the GNU Lesser General Public -+# License along with this library; if not, write to the Free Software -+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+# -+ -+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-coverage=trace-pc") -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize-coverage=trace-pc") -+set(EXE log_fuzz) -+ -+configure_file("dict/log_fuzz.dict" ${CMAKE_BINARY_DIR}/tests/fuzz/dict/log_fuzz.dict COPYONLY) -+configure_file("fuzz.sh" ${CMAKE_BINARY_DIR}/tests/fuzz/fuzz.sh COPYONLY) -+ -+add_executable(${EXE} log_fuzz.cc) -+ -+target_include_directories(${EXE} PUBLIC -+ ${GTEST_INCLUDE_DIR} -+ PUBLIC ${CMAKE_SOURCE_DIR}/third_party -+ PUBLIC ${CMAKE_SOURCE_DIR}/third_party/libocispec -+ ) -+ -+set_target_properties(${EXE} PROPERTIES LINKER_LANGUAGE CXX) -+set_target_properties(${EXE} PROPERTIES LINK_FLAGS "-fsanitize-coverage=trace-pc") -+target_link_libraries(${EXE} ${CMAKE_THREAD_LIBS_INIT} isula_libutils Fuzzer pthread) -diff --git a/tests/fuzz/dict/log_fuzz.dict b/tests/fuzz/dict/log_fuzz.dict -new file mode 100644 -index 0000000..d6a438d ---- /dev/null -+++ b/tests/fuzz/dict/log_fuzz.dict -@@ -0,0 +1,14 @@ -+"x,,debug,prefix,stdout" -+",/tmp/fake.fifo,info,prefix,stdout" -+"x,,ERROR,prefix,stdout" -+"x,/tmp/fake.fifo,,prefix,stdout" -+"x,/tmp/fake.fifo,info,,stdout" -+"x,/tmp/fake.fifo,crit,prefix," -+"x,/tmp/fake.fifo,fatal,prefix,fifo" -+",/tmp/fake.fifo,info,prefix,fifo" -+"x,,ERROR,prefix,fifo" -+"x,/tmp/fake.fifo,,prefix,fifo" -+"x,/tmp/fake.fifo,debug,,fifo" -+"x,,invalid,prefix,stdout" -+"x,/tmp/fake.fifo,invalid,prefix,fifo" -+"invalid" -diff --git a/tests/fuzz/fuzz.sh b/tests/fuzz/fuzz.sh -new file mode 100755 -index 0000000..6f80cab ---- /dev/null -+++ b/tests/fuzz/fuzz.sh -@@ -0,0 +1,48 @@ -+# lcr: fuzz tests -+# -+# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. -+# -+# Authors: -+# Haozi007 -+# -+# This library is free software; you can redistribute it and/or -+# modify it under the terms of the GNU Lesser General Public -+# License as published by the Free Software Foundation; either -+# version 2.1 of the License, or (at your option) any later version. -+# -+# This library is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+# Lesser General Public License for more details. -+# -+# You should have received a copy of the GNU Lesser General Public -+# License along with this library; if not, write to the Free Software -+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+# -+ -+#!/bin/bash -+ -+LIB_FUZZING_ENGINE="/lib64/libFuzzer.a" -+FUZZ_OPTION="corpus -dict=./dict/log_fuzz.dict -runs=100000 -max_total_time=3600" -+ -+if [ ! -f "$LIB_FUZZING_ENGINE" ];then -+ echo "$LIB_FUZZING_ENGINE not exist, pls check" -+ exit 1 -+fi -+ -+# compile fuzz testcase -+make -j -+ -+# run fuzz testcases -+./log_fuzz ${FUZZ_OPTION} -artifact_prefix=log_fuzz- -+ -+echo "########### Fuzz Result ##############" -+crash=`find -name "*-crash-*"` -+if [ x"${crash}" != x"" ];then -+ echo "find bugs while fuzzing, pls check <*-crash-*> file" -+ find -name "*-crash-*" -+ exit 1 -+else -+ echo "all fuzz success." -+fi -+ -diff --git a/tests/fuzz/log_fuzz.cc b/tests/fuzz/log_fuzz.cc -new file mode 100644 -index 0000000..9dc02bb ---- /dev/null -+++ b/tests/fuzz/log_fuzz.cc -@@ -0,0 +1,76 @@ -+/****************************************************************************** -+ * log_fuzz: testcase for log -+ * -+ * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. -+ * -+ * Authors: -+ * Haozi007 -+ * -+ * This library is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU Lesser General Public -+ * License as published by the Free Software Foundation; either -+ * version 2.1 of the License, or (at your option) any later version. -+ * -+ * This library is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * Lesser General Public License for more details. -+ * -+ * You should have received a copy of the GNU Lesser General Public -+ * License along with this library; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -+ ********************************************************************************/ -+ -+#include -+#include -+#include -+#include -+#include "log.h" -+ -+ -+extern "C" void testLog(struct isula_libutils_log_config *conf) -+{ -+ (void)isula_libutils_log_enable(conf); -+ INFO("info log"); -+ isula_libutils_set_log_prefix(conf->prefix); -+ INFO("test prefix info"); -+ isula_libutils_log_disable(); -+} -+ -+ -+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -+{ -+ const char *default_name = "iSula"; -+ struct isula_libutils_log_config tconf = {0}; -+ std::string testData(reinterpret_cast(data), size); -+ std::vector ret_vec; -+ std::string tmpstr; -+ std::istringstream istr(testData); -+ while(std::getline(istr, tmpstr, ',')) { -+ ret_vec.push_back(tmpstr); -+ } -+ -+ if (ret_vec.size() == 5) { -+ if (ret_vec[0] != "") { -+ tconf.name = ret_vec[0].c_str(); -+ } -+ if (ret_vec[1] != "") { -+ tconf.file = ret_vec[1].c_str(); -+ } -+ if (ret_vec[2] != "") { -+ tconf.priority = ret_vec[2].c_str(); -+ } -+ if (ret_vec[3] != "") { -+ tconf.prefix = ret_vec[3].c_str(); -+ } -+ if (ret_vec[4] != "") { -+ tconf.driver = ret_vec[4].c_str(); -+ } -+ } else { -+ isula_libutils_default_log_config(default_name, &tconf); -+ } -+ -+ testLog(&tconf); -+ return 0; -+} -+ --- -2.25.1 - diff --git a/lcr-2.0.2.tar.gz b/lcr-2.0.2.tar.gz deleted file mode 100644 index e82ea04f2844641aa63b304448248f06d1a073b4..0000000000000000000000000000000000000000 Binary files a/lcr-2.0.2.tar.gz and /dev/null differ diff --git a/lcr-2.0.3.tar.gz b/lcr-2.0.3.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..a35ed243fb05fcc1f6da05e68ff0e725487ec83e Binary files /dev/null and b/lcr-2.0.3.tar.gz differ diff --git a/lcr.spec b/lcr.spec index dcc3ff4eb1c3f174adab95f8605de5477ff92a05..3dd36ec76af10aff8afe023ef03b4cff3fdb4fe4 100644 --- a/lcr.spec +++ b/lcr.spec @@ -1,5 +1,5 @@ -%global _version 2.0.2 -%global _release 20200628.162917.gitafc142aa +%global _version 2.0.3 +%global _release 20200903.183604.git62664adf %global _inner_name isula_libutils Name: lcr @@ -12,18 +12,6 @@ Group: Applications/System License: LGPLv2.1+ BuildRoot: %{_tmppath}/lcr-%{version} -Patch9000: 0001-fix-wrong-license.patch -Patch9001: 0002-support-import-rootfs-to-be-image.patch -Patch9002: 0003-support-calico.patch -Patch9003: 0004-improve-check-driver-of-log.patch -Patch9004: 0005-improve-llt-framework.patch -Patch9005: 0006-fix-log-test-error.patch -Patch9006: 0007-improve-html-show-result.patch -Patch9007: 0008-change-tests-name.patch -Patch9008: 0009-Pull-Request-49-change-name-of-testcases.patch -Patch9009: 0010-change-tests-name.patch -Patch9010: 0011-support-fuzz-test.patch - BuildRequires: cmake BuildRequires: lxc BuildRequires: lxc-devel @@ -109,5 +97,11 @@ rm -rf %{buildroot} %changelog +* Thu Sep 03 2020 zhangxiaoyu - 2.0.3-20200903.183604.git62664adf +- Type:enhancement +- ID:NA +- SUG:NA +- DESC: upgrade from v2.0.2 to v2.0.3 + * Fri Apr 14 2017 Hui Wang - 0.0.1 - Initial RPM release