From cce8417bfc118f8ae7660692cd8e6524e8dec9a3 Mon Sep 17 00:00:00 2001 From: Egor Artemov Date: Dec 15 2020 01:15:08 +0000 Subject: Initial import (#1843300). --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64ebd93 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/cgreen-1.3.0.tar.gz diff --git a/0001-Bump-number-of-messages-in-test-for-message-blocking.patch b/0001-Bump-number-of-messages-in-test-for-message-blocking.patch new file mode 100644 index 0000000..e7d6d14 --- /dev/null +++ b/0001-Bump-number-of-messages-in-test-for-message-blocking.patch @@ -0,0 +1,26 @@ +From c6efe6b5eb5151a16deb377a33f67fb690df55d8 Mon Sep 17 00:00:00 2001 +From: Thomas Nilefalk +Date: Wed, 12 Aug 2020 08:14:40 +0200 +Subject: [PATCH 1/2] Bump number of messages in test for message blocking to + force some architectures to throw exception + +--- + tests/messaging_tests.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/messaging_tests.c b/tests/messaging_tests.c +index 52b3b15..2988bf3 100644 +--- a/tests/messaging_tests.c ++++ b/tests/messaging_tests.c +@@ -41,7 +41,7 @@ static void catch_signal(int s) { + } + + Ensure(failure_reported_and_exception_thrown_when_messaging_would_block) { +- const int LOOPS = 65536; ++ const int LOOPS = 65537; + int messaging = start_cgreen_messaging(33); + int loop; + char panic_message[1000]; +-- +2.28.0 + diff --git a/0002-fix-unittest-issue-on-arch-s390x.patch b/0002-fix-unittest-issue-on-arch-s390x.patch new file mode 100644 index 0000000..66106f0 --- /dev/null +++ b/0002-fix-unittest-issue-on-arch-s390x.patch @@ -0,0 +1,89 @@ +From 7a5c1c80ca6d2f6fd707254d4a9c70a639fdff65 Mon Sep 17 00:00:00 2001 +From: Alvin Chen +Date: Tue, 10 Nov 2020 23:03:23 -0500 +Subject: [PATCH 2/2] fix unittest issue on arch-s390x + +--- + tests/constraint_messages_tests.c | 6 +++--- + tests/constraint_messages_tests.expected | 4 ++-- + tests/custom_constraint_messages_tests.c | 8 ++++---- + 3 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/tests/constraint_messages_tests.c b/tests/constraint_messages_tests.c +index 6eb2412..728a19f 100644 +--- a/tests/constraint_messages_tests.c ++++ b/tests/constraint_messages_tests.c +@@ -39,7 +39,7 @@ Ensure(ConstraintMessage,for_is_equal_to) { + Ensure(ConstraintMessage, for_is_equal_to_hex) { + unsigned char bytes[4]; + memset(bytes, 0xaa, sizeof(bytes)); +- assert_that(bytes[0], is_equal_to_hex(0xbb)); ++ assert_that((unsigned char) bytes[0], is_equal_to_hex(0xbb)); + } + + Ensure(ConstraintMessage, for_is_not_equal_to) { +@@ -60,8 +60,8 @@ Ensure(ConstraintMessage, for_is_less_than) { + + // Contents of struct/memory + Ensure(ConstraintMessage, for_is_equal_to_contents_of) { +- int forty_five[45] = {45, 44, 43}, thirty_three[33] = {45, 44, 33}; +- assert_that(thirty_three, is_equal_to_contents_of(forty_five, 55)); ++ char forty_five[45] = {45, 44, 43}, thirty_three[33] = {45, 44, 33}; ++ assert_that(thirty_three, is_equal_to_contents_of(forty_five, 45)); + } + + Ensure(ConstraintMessage, for_is_not_equal_to_contents_of) { +diff --git a/tests/constraint_messages_tests.expected b/tests/constraint_messages_tests.expected +index 364e788..31901ac 100644 +--- a/tests/constraint_messages_tests.expected ++++ b/tests/constraint_messages_tests.expected +@@ -52,7 +52,7 @@ constraint_messages_tests.c: Failure: ConstraintMessage -> for_is_equal_to + + constraint_messages_tests.c: Failure: ConstraintMessage -> for_is_equal_to_contents_of + Expected [thirty_three] to [equal contents of] [forty_five] +- at offset: [8] ++ at offset: [2] + actual value: [0x21] + expected value: [0x2b] + +@@ -62,7 +62,7 @@ constraint_messages_tests.c: Failure: ConstraintMessage -> for_is_equal_to_doubl + expected value: [3.300000] + + constraint_messages_tests.c: Failure: ConstraintMessage -> for_is_equal_to_hex +- Expected [bytes[0]] to [equal] [0xbb] ++ Expected [(unsigned char) bytes[0]] to [equal] [0xbb] + actual value: [0xaa] + expected value: [0xbb] + +diff --git a/tests/custom_constraint_messages_tests.c b/tests/custom_constraint_messages_tests.c +index 5653841..b9e76c9 100644 +--- a/tests/custom_constraint_messages_tests.c ++++ b/tests/custom_constraint_messages_tests.c +@@ -82,12 +82,12 @@ Ensure(CustomConstraint, custom_constraint_using_a_function_with_arguments_funct + + */ + typedef struct Box { +- int id; ++ char id; + int size; + } Box; + + typedef struct Piece { +- int id; ++ char id; + int size; + } Piece; + +@@ -127,7 +127,7 @@ Constraint *create_piece_fit_in_box_constraint(intptr_t expected_value, const ch + #define can_fit_in_box(box) create_piece_fit_in_box_constraint((intptr_t)box, #box) + + Ensure(CustomConstraint, more_complex_custom_constraint_function) { +- Box box1 = {.id = 1, .size = 5}; +- Piece piece99 = {.id = 99, .size = 6}; ++ Box box1 = {.id = (char)1, .size = 5}; ++ Piece piece99 = {.id = (char)99, .size = 6}; + assert_that(&piece99, can_fit_in_box(&box1)); + } +-- +2.28.0 + diff --git a/cgreen.spec b/cgreen.spec new file mode 100644 index 0000000..df378c1 --- /dev/null +++ b/cgreen.spec @@ -0,0 +1,85 @@ +Name: cgreen +Version: 1.3.0 +Release: 1%{?dist} +Summary: Modern unit test and mocking framework for C and C++ +License: ISC +URL: https://github.com/cgreen-devs/%{name} +Source0: https://github.com/cgreen-devs/%{name}/archive/%{version}/%{name}-%{version}.tar.gz + +# https://github.com/cgreen-devs/cgreen/issues/239 +Patch0: 0001-Bump-number-of-messages-in-test-for-message-blocking.patch +# https://github.com/cgreen-devs/cgreen/issues/226 +# https://github.com/cgreen-devs/cgreen/issues/227 +Patch1: 0002-fix-unittest-issue-on-arch-s390x.patch + +BuildRequires: cmake +BuildRequires: gcc-c++ +BuildRequires: perl-interpreter +BuildRequires: asciidoctor + +%description +A modern, portable, cross-language unit testing and mocking framework for C +and C++. + + +%package devel +Summary: Libraries and headers for developing programs with Cgreen +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +Libraries and headers for developing programs with Cgreen. + + +%package runner +Summary: A runner for the Cgreen unit testing and mocking framework +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description runner +A runner for the Cgreen unit testing and mocking framework. + + +%prep +%autosetup -p1 + +%build +%cmake -DCGREEN_WITH_HTML_DOCS=ON . +%cmake_build + +%install +%cmake_install + +%check +%ctest + +%files +%license LICENSE +%doc README.md +%{_libdir}/libcgreen.so.1* + + +%files devel +%doc doc/cgreen-guide-en-docinfo.html +%{_libdir}/libcgreen.so +%{_includedir}/cgreen +%{_libdir}/cmake/cgreen + + +%files runner +%{_bindir}/cgreen-debug +%{_bindir}/cgreen-runner +%{_mandir}/man1/cgreen-runner.1* +%{_mandir}/man1/cgreen-debug.1* +%{_mandir}/man5/cgreen.5* + + +%changelog +* Sun Nov 15 2020 Egor Artemov egor.Artemov@gmail.com - 1.3.0-1 +- Upstream fixed bugs that do not allow to run tests on s390x and pple64 + architectures. Backporting patches from master and enabling tests on s390x + and pple64. + +* Fri Jul 17 2020 Egor Artemov - 1.3.0-1 +- Bump to 1.3.0 version + +* Thu May 7 2020 Egor Artemov - 1.2.0-1 +- Build of 1.2.0 release diff --git a/sources b/sources new file mode 100644 index 0000000..d935ddf --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (cgreen-1.3.0.tar.gz) = 3734be08722900b4c6aaa1cd8a7a31ffd876c12742cf81266014158dad0919db46a457fbc742f3d7e9b1fdf75530ee872045962469eeeb6d1fc45fddf2b6d332