diff --git a/0001-fix-wrong-license.patch b/0001-fix-wrong-license.patch index 05a8461831a95da688d2c1ead95b71ba5605f0c8..ab7a97c53a3f9fdfc36d68ae2ef9a918bc19bc23 100644 --- a/0001-fix-wrong-license.patch +++ b/0001-fix-wrong-license.patch @@ -1,7 +1,7 @@ From 74c5abe35a931aca850d5619faecbd62e75d9fb2 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Tue, 26 May 2020 20:04:13 +0800 -Subject: [PATCH 01/10] fix wrong license +Subject: [PATCH 01/11] fix wrong license Signed-off-by: haozi007 --- diff --git a/0002-support-import-rootfs-to-be-image.patch b/0002-support-import-rootfs-to-be-image.patch index 6ebdd8d23009c4147cf540c471da62ccf9f2e570..2271cde7613f3d7b5dddd9f639bd5fbfb00d91c4 100644 --- a/0002-support-import-rootfs-to-be-image.patch +++ b/0002-support-import-rootfs-to-be-image.patch @@ -1,7 +1,7 @@ From 15b7cc66a03f26c35dfc551a960edc24e5c52440 Mon Sep 17 00:00:00 2001 From: WangFengTu Date: Wed, 27 May 2020 11:25:56 +0800 -Subject: [PATCH 02/10] support import rootfs to be image +Subject: [PATCH 02/11] support import rootfs to be image Signed-off-by: WangFengTu --- diff --git a/0003-support-calico.patch b/0003-support-calico.patch index 60c08db983595b7d3a901f9fc2bd113fe6673c0a..32877e43a3f2733f43fefa5115a25e34c00b6148 100644 --- a/0003-support-calico.patch +++ b/0003-support-calico.patch @@ -1,7 +1,7 @@ From 855d567b2bd92aada6c7d61a75aae2d5441a1efe Mon Sep 17 00:00:00 2001 From: haozi007 Date: Tue, 2 Jun 2020 10:15:58 +0800 -Subject: [PATCH 03/10] support calico +Subject: [PATCH 03/11] support calico Signed-off-by: haozi007 --- diff --git a/0004-improve-check-driver-of-log.patch b/0004-improve-check-driver-of-log.patch index 8c3554be18b63bac5e5c58065086022e3c0211a4..aa8219eb9c238a224cba8b63fb693fa707fc9099 100644 --- a/0004-improve-check-driver-of-log.patch +++ b/0004-improve-check-driver-of-log.patch @@ -1,7 +1,7 @@ From 72c179403743bd9bd82f0e4d80c558d883b973ac Mon Sep 17 00:00:00 2001 From: haozi007 Date: Tue, 9 Jun 2020 14:44:51 +0800 -Subject: [PATCH 04/10] improve check driver of log +Subject: [PATCH 04/11] improve check driver of log 1. add llt for log 2. improve init driver of log diff --git a/0005-improve-llt-framework.patch b/0005-improve-llt-framework.patch index 95ab56f36f1b84e3a5eb97eab54a4960c9e24e2d..8b0edabb0d56895413db87850e56a86a8be0e9ca 100644 --- a/0005-improve-llt-framework.patch +++ b/0005-improve-llt-framework.patch @@ -1,7 +1,7 @@ From d97eb223fea08b12b63aa84f1c67a9a38fd1fee9 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Thu, 11 Jun 2020 14:41:55 +0800 -Subject: [PATCH 05/10] improve llt framework +Subject: [PATCH 05/11] improve llt framework 1. add hook to run genhtml for llt 2. improve llt diff --git a/0006-fix-log-test-error.patch b/0006-fix-log-test-error.patch index 51c20b4e53b16ef9b394a12cf81d7acff0607fcd..173772c9632c2981a97aff1c299f6e5b5148f833 100644 --- a/0006-fix-log-test-error.patch +++ b/0006-fix-log-test-error.patch @@ -1,7 +1,7 @@ From 02054466c71822e197499b0271cfed57c96598b2 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Thu, 11 Jun 2020 15:14:48 +0800 -Subject: [PATCH 06/10] fix log test error +Subject: [PATCH 06/11] fix log test error Signed-off-by: haozi007 --- diff --git a/0007-improve-html-show-result.patch b/0007-improve-html-show-result.patch index 2f96f64e9449c77d83c7ab1d8a3f0a9f358b9c4d..b37dd943272bdea41ae98eda967d4de70769a893 100644 --- a/0007-improve-html-show-result.patch +++ b/0007-improve-html-show-result.patch @@ -1,7 +1,7 @@ From abc0b5907d4b50729aa83a4c41d4a7e02d857aea Mon Sep 17 00:00:00 2001 From: haozi007 Date: Thu, 11 Jun 2020 15:48:32 +0800 -Subject: [PATCH 07/10] improve html show result +Subject: [PATCH 07/11] improve html show result Signed-off-by: haozi007 --- diff --git a/0008-change-tests-name.patch b/0008-change-tests-name.patch index a284c8fb97a82ac6e6394358d4165e35ef67413e..953eca458b204a19883f7d4962980251c4e4ec17 100644 --- a/0008-change-tests-name.patch +++ b/0008-change-tests-name.patch @@ -1,7 +1,7 @@ From cb27a1612fdba43b94e9af1232da4378205c4c8a Mon Sep 17 00:00:00 2001 From: haozi007 Date: Sat, 13 Jun 2020 10:32:28 +0800 -Subject: [PATCH 08/10] change tests name +Subject: [PATCH 08/11] change tests name 1. change name of tests 2. default to run tests after build diff --git a/0009-Pull-Request-49-change-name-of-testcases.patch b/0009-Pull-Request-49-change-name-of-testcases.patch index 19ed7f3c7cb6041a0dc3c0df274c1d9c249a0195..bfe918cea0a67ec968e7c8ad1927b16621f8efde 100644 --- a/0009-Pull-Request-49-change-name-of-testcases.patch +++ b/0009-Pull-Request-49-change-name-of-testcases.patch @@ -1,7 +1,7 @@ From c1cd034cf73b483c4c120c789c188ee64d19f7d3 Mon Sep 17 00:00:00 2001 From: lifeng_isula Date: Mon, 15 Jun 2020 10:39:15 +0800 -Subject: [PATCH 09/10] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!4?= +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 diff --git a/0010-change-tests-name.patch b/0010-change-tests-name.patch index b4ebef0b5e67441b2af68279258d5cc05ce4cea1..3c6d80b77064ea84741e05d407bc108b746d0b3d 100644 --- a/0010-change-tests-name.patch +++ b/0010-change-tests-name.patch @@ -1,7 +1,7 @@ From 71eb58f5a5002faf6ad4bc1a77cbf483d06f27c9 Mon Sep 17 00:00:00 2001 From: haozi007 Date: Tue, 16 Jun 2020 14:40:10 +0800 -Subject: [PATCH 10/10] change tests name +Subject: [PATCH 10/11] change tests name Signed-off-by: haozi007 --- diff --git a/0011-support-fuzz-test.patch b/0011-support-fuzz-test.patch new file mode 100644 index 0000000000000000000000000000000000000000..5b4b2201935eb36f6f474adab8bfb14eccaaffde --- /dev/null +++ b/0011-support-fuzz-test.patch @@ -0,0 +1,241 @@ +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.spec b/lcr.spec index 7b3f784c8baea064c4392543f985350aba1d38d8..cf397423f43511fa052999ebdaa2610c65238f5b 100644 --- a/lcr.spec +++ b/lcr.spec @@ -1,5 +1,5 @@ %global _version 2.0.2 -%global _release 20200616.163046.git9a34ea5f +%global _release 20200628.162917.gitafc142aa %global _inner_name isula_libutils Name: lcr @@ -22,6 +22,7 @@ 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