From 50b2cd8d60ac6e9d8a73536ffd2c7ea7db40f63a Mon Sep 17 00:00:00 2001 From: songbuhuang <544824346@qq.com> Date: Thu, 10 Nov 2022 16:27:08 +0800 Subject: [PATCH] libevthp add gcov compile options Signed-off-by: songbuhuang <544824346@qq.com> --- 0006-libevhtp-add-gcov-compile-options.patch | 143 +++++++++++++++++++ libevhtp.spec | 9 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 0006-libevhtp-add-gcov-compile-options.patch diff --git a/0006-libevhtp-add-gcov-compile-options.patch b/0006-libevhtp-add-gcov-compile-options.patch new file mode 100644 index 0000000..0140714 --- /dev/null +++ b/0006-libevhtp-add-gcov-compile-options.patch @@ -0,0 +1,143 @@ +From c5845d807bd88118bb5974ce08c469cfe6c6d258 Mon Sep 17 00:00:00 2001 +From: songbuhuang <544824346@qq.com> +Date: Thu, 10 Nov 2022 16:17:53 +0800 +Subject: [PATCH] libevhtp add gcov compile options + +Signed-off-by: songbuhuang <544824346@qq.com> +--- + CMakeLists.txt | 12 ++++++++++++ + examples/example_basic.c | 7 +++++-- + examples/example_chunked.c | 9 +++++---- + examples/example_pause.c | 4 ++++ + examples/example_request_fini.c | 4 ++++ + examples/example_vhost.c | 4 ++++ + examples/https/example_https_server.c | 7 +++++-- + 7 files changed, 39 insertions(+), 8 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5bc89d5..d4596f6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -64,6 +64,17 @@ set(evhtp_dir_headers + "include/evhtp/parser.h" + "include/evhtp/log.h") + ++if(ENABLE_GCOV) ++ MESSAGE(STATUS "Enable coverage compile option") ++ set(COVERAGE_C_OPTION "${COVERAGE_OPTION} -fprofile-arcs -ftest-coverage -fkeep-static-functions -fkeep-inline-functions") ++ set(COVERAGE_CXX_OPTION "${COVERAGE_OPTION} -fprofile-arcs -ftest-coverage") ++endif(ENABLE_GCOV) ++ ++if(CMAKE_BUILD_TYPE STREQUAL Debug) ++ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COVERAGE_C_OPTION}") ++ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_CXX_OPTION}") ++endif() ++ + if(NOT EVHTP_DISABLE_SSL) + find_package(OpenSSL) + if(OPENSSL_FOUND) +@@ -334,6 +345,7 @@ message(STATUS "${Blue}CMAKE_SYSTEM_VERSION${ColourReset} : " ${CMAKE_SYSTEM + message(STATUS "${Blue}CMAKE_C_COMPILER${ColourReset} : " ${CMAKE_C_COMPILER}) + message(STATUS "${Blue}CMAKE_AR${ColourReset} : " ${CMAKE_AR}) + message(STATUS "${Blue}CMAKE_RANLIB${ColourReset} : " ${CMAKE_RANLIB}) ++message(STATUS "${Blue}COVERAGE_C_OPTION${ColourReset} : " ${COVERAGE_C_OPTION}) + message(STATUS "${Blue}CFLAGS${ColourReset} : ${CMAKE_C_FLAGS}") + + if(CMAKE_BUILD_TYPE MATCHES Debug) +diff --git a/examples/example_basic.c b/examples/example_basic.c +index 9948152..a2f0c18 100644 +--- a/examples/example_basic.c ++++ b/examples/example_basic.c +@@ -43,6 +43,9 @@ main(int argc, char ** argv) + + log_info("Basic server, run: curl http://127.0.0.1:%d/", + bind__sock_port0_(htp)); +- event_base_loop(evbase, 0); +- return 0; ++ struct timeval ten_sec; ++ ten_sec.tv_sec = 10; ++ ten_sec.tv_usec = 0; ++ event_base_loopexit(evbase, &ten_sec); ++ return event_base_loop(evbase, 0); + } +diff --git a/examples/example_chunked.c b/examples/example_chunked.c +index cfab23d..6289286 100644 +--- a/examples/example_chunked.c ++++ b/examples/example_chunked.c +@@ -157,8 +157,9 @@ main(int argc, char ** argv) + + log_info("curl http://127.0.0.1:%d/", bind__sock_port0_(htp)); + +- event_base_loop(evbase, 0); +- +- +- return 0; ++ struct timeval ten_sec; ++ ten_sec.tv_sec = 10; ++ ten_sec.tv_usec = 0; ++ event_base_loopexit(evbase, &ten_sec); ++ return event_base_loop(evbase, 0); + } +diff --git a/examples/example_pause.c b/examples/example_pause.c +index 0cccac2..8293e0e 100644 +--- a/examples/example_pause.c ++++ b/examples/example_pause.c +@@ -106,5 +106,9 @@ main(int argc, char ** argv) { + log_info("response delayed for 10s: " + "curl http://127.0.0.1:%d/", bind__sock_port0_(htp)); + ++ struct timeval sec; ++ sec.tv_sec = 15; ++ sec.tv_usec = 0; ++ event_base_loopexit(evbase, &sec); + return event_base_loop(evbase, 0); + } +diff --git a/examples/example_request_fini.c b/examples/example_request_fini.c +index d4d6da6..46a1fce 100644 +--- a/examples/example_request_fini.c ++++ b/examples/example_request_fini.c +@@ -59,5 +59,9 @@ main(int argc, char ** argv) { + GENCHAR(), GENCHAR(), GENCHAR()); + + ++ struct timeval ten_sec; ++ ten_sec.tv_sec = 10; ++ ten_sec.tv_usec = 0; ++ event_base_loopexit(evbase, &ten_sec); + return event_base_loop(evbase, 0); + } +diff --git a/examples/example_vhost.c b/examples/example_vhost.c +index 3b6881c..76116e8 100644 +--- a/examples/example_vhost.c ++++ b/examples/example_vhost.c +@@ -112,5 +112,9 @@ main(int argc, char ** argv) { + log_info("curl -H'Host: gmail.google.com' http://127.0.0.1:%d/vhost", port); + } + ++ struct timeval ten_sec; ++ ten_sec.tv_sec = 10; ++ ten_sec.tv_usec = 0; ++ event_base_loopexit(evbase, &ten_sec); + return event_base_loop(evbase, 0); + } /* main */ +diff --git a/examples/https/example_https_server.c b/examples/https/example_https_server.c +index 3e020b2..0dc5afd 100644 +--- a/examples/https/example_https_server.c ++++ b/examples/https/example_https_server.c +@@ -252,8 +252,11 @@ main(int argc, char ** argv) { + + log_info("curl https://127.0.0.1:4443/"); + +- event_base_loop(evbase, 0); +- return 0; ++ struct timeval ten_sec; ++ ten_sec.tv_sec = 10; ++ ten_sec.tv_usec = 0; ++ event_base_loopexit(evbase, &ten_sec); ++ return event_base_loop(evbase, 0); + #else + log_error("Not compiled with SSL support, go away"); + return EXIT_FAILURE; +-- +2.25.1 + diff --git a/libevhtp.spec b/libevhtp.spec index f1c0aa7..76d7982 100644 --- a/libevhtp.spec +++ b/libevhtp.spec @@ -2,7 +2,7 @@ Name: libevhtp Version: 1.2.18 -Release: 4 +Release: 5 Summary: Libevent based HTTP API. License: BSD3 @@ -13,6 +13,7 @@ Patch9001: 0002-evhtp-enable-dynamic-thread-pool.patch Patch9002: 0003-close-open-ssl.-we-do-NOT-use-it-in-lcrd.patch Patch9003: 0004-Use-shared-library-instead-static-one.patch Patch9004: 0005-libevhtp-add-securce-compile-options.patch +Patch9005: 0006-libevhtp-add-gcov-compile-options.patch BuildRequires: git gcc-c++ cmake libevent-devel @@ -65,6 +66,12 @@ find %{buildroot} -name '*.so.*' -exec strip {} ';' /usr/lib/pkgconfig/evhtp.pc %changelog +* Thu Nov 08 2022 huangsong - 1.2.18-5 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC: add gcov compile options + * Thu May 05 2022 zhangxiaoyu - 1.2.18-4 - Type:enhancement - ID:NA -- Gitee