From 37c2afb962234c8d2bacd66225f0160dbf1c720b Mon Sep 17 00:00:00 2001 From: chengzrz Date: Wed, 16 Nov 2022 22:57:19 +0800 Subject: [PATCH] add compile option for coverage Signed-off-by: chengzrz (cherry picked from commit b81a308b0e20fc18b47f4ffdbb87926f1f23ad95) --- 0007-add-coverage-compile-option.patch | 49 ++++++++++++++++++++++++++ protobuf.spec | 9 ++++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 0007-add-coverage-compile-option.patch diff --git a/0007-add-coverage-compile-option.patch b/0007-add-coverage-compile-option.patch new file mode 100644 index 0000000..3e423f9 --- /dev/null +++ b/0007-add-coverage-compile-option.patch @@ -0,0 +1,49 @@ +From c87fadf8be81e48697eca3308981ec3a684ecfcc Mon Sep 17 00:00:00 2001 +From: chengzrz +Date: Wed, 16 Nov 2022 17:47:10 +0800 +Subject: [PATCH] protobuf: add coverage compile option + +Type:testcode +reason:add coverage compile option + +Signed-off-by: chengzrz +--- + configure.ac | 7 +++++++ + src/Makefile.am | 4 ++++ + 2 files changed, 11 insertions(+) + +diff --git a/configure.ac b/configure.ac +index eb70a76..2ef1668 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -72,6 +72,13 @@ AC_ARG_WITH([protoc], + [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])], + [],[with_protoc=no]) + ++AC_ARG_ENABLE([coverage], ++ [AS_HELP_STRING([--enable-coverage], ++ [generate coverage report])], ++ [coverage=yes],[coverage=no]) ++ ++AM_CONDITIONAL([HAVE_COVERAGE], [test "x$coverage" == "xyes"]) ++ + # Checks for programs. + AC_PROG_CC + AC_PROG_CXX +diff --git a/src/Makefile.am b/src/Makefile.am +index 9af3db1..81d1418 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -21,6 +21,10 @@ endif + PROTOBUF_VERSION = 25:0:0 + PROTOBUF_OPT_FLAG += -Wl,-z,now -fstack-check + ++if HAVE_COVERAGE ++PROTOBUF_OPT_FLAG += -fprofile-arcs -ftest-coverage ++endif ++ + if GCC + # Turn on all warnings except for sign comparison (we ignore sign comparison + # in Google so our code base have tons of such warnings). +-- +2.26.3 diff --git a/protobuf.spec b/protobuf.spec index fa25507..26dac29 100644 --- a/protobuf.spec +++ b/protobuf.spec @@ -8,7 +8,7 @@ Summary: Protocol Buffers - Google's data interchange format Name: protobuf Version: 3.14.0 -Release: 6 +Release: 7 License: BSD URL: https://github.com/protocolbuffers/protobuf Source: https://github.com/protocolbuffers/protobuf/releases/download/v%{version}%{?rcver}/%{name}-all-%{version}%{?rcver}.tar.gz @@ -20,6 +20,7 @@ Patch9002: 0003-fix-CVE-2021-22570.patch Patch9003: 0004-Improve-performance-of-parsing-unknown-fields-in-Jav.patch Patch9004: 0005-fix-CVE-2022-1941.patch Patch9005: 0006-fix-CVE-2022-3171.patch +Patch9006: 0007-add-coverage-compile-option.patch BuildRequires: make autoconf automake emacs gcc-c++ libtool pkgconfig zlib-devel @@ -325,6 +326,12 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_emacs_sitestartdir} %endif %changelog +* Mon Nov 21 2022 chengzeruizhi - 3.14.0-7 +- Type:enhancement +- ID:NA +- SUG:NA +- DESC: add compile option for coverage + * Tue Oct 18 2022 chengzeruizhi - 3.14.0-6 - Type:bugfix - ID:NA -- Gitee