Version 0.15.0

- Add -formatspec and -attribute-format patches.
- Build with both cmake and autotools.
- Reenable s390x tests.
This commit is contained in:
Jerry James 2020-06-22 16:22:24 -06:00
parent c69cf8c51e
commit 5f9827a065
6 changed files with 247 additions and 23 deletions

6
.gitignore vendored
View File

@ -1,7 +1,3 @@
/check-0.9.14.tar.gz
/check-0.10.0.tar.gz
/0.10.0.tar.gz
/0.11.0.tar.gz
/check-0.12.0.tar.gz
/check-0.13.0.tar.gz
/check-0.14.0.tar.gz
/check-*.tar.gz

View File

@ -1,5 +1,5 @@
--- tests/check_check_master.c.orig 2018-01-29 20:33:55.033001412 -0700
+++ tests/check_check_master.c 2018-01-29 20:34:31.501879454 -0700
--- check-0.11.0/tests/check_check_master.c.orig 2018-01-29 20:33:55.033001412 -0700
+++ check-0.11.0/tests/check_check_master.c 2018-01-29 20:34:31.501879454 -0700
@@ -214,7 +214,7 @@ static master_test_t master_tests[] = {
{ "Simple Tests", "test_ck_assert_ldouble_ge", CK_FAILURE, CK_MSG_TEXT, "Assertion 'x >= y' failed: x == 2.5, y == 3" },
{ "Simple Tests", "test_ck_assert_ldouble_ge_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion '2%d >= 3%f' failed: 2%d == 0, 3%f == 1" },
@ -9,8 +9,8 @@
{ "Simple Tests", "test_ck_assert_ldouble_eq_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(2%f - 3%d) < 2%p' failed: 3%d == 1, 2%f == 0, 2%p == 0" },
{ "Simple Tests", "test_ck_assert_ldouble_ne_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) >= t' failed: x == 0.001, y == 0.002, t == 0.01" },
{ "Simple Tests", "test_ck_assert_ldouble_ne_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(3%f - 3%d) >= 3%p' failed: 3%d == 1, 3%f == 1, 3%p == 1" },
--- tests/check_check_sub.c.orig 2017-10-20 06:44:10.000000000 -0600
+++ tests/check_check_sub.c 2018-01-29 20:33:55.034001409 -0700
--- check-0.11.0/tests/check_check_sub.c.orig 2017-10-20 06:44:10.000000000 -0600
+++ check-0.11.0/tests/check_check_sub.c 2018-01-29 20:33:55.034001409 -0700
@@ -1812,7 +1812,7 @@ START_TEST(test_ck_assert_ldouble_eq_tol
y*=10.0l;
t*=10.0l;

View File

@ -0,0 +1,90 @@
diff --git a/src/check.c b/src/check.c
index f74b384..89df345 100644
--- a/src/check.c
+++ b/src/check.c
@@ -362,25 +362,24 @@ void _mark_point(const char *file, int line)
send_loc_info(file, line);
}
-void _ck_assert_failed(const char *file, int line, const char *expr, ...)
+void _ck_assert_failed(const char *file, int line, const char *expr,
+ const char *msg, ...)
{
- const char *msg;
- va_list ap;
char buf[BUFSIZ];
const char *to_send;
send_loc_info(file, line);
- va_start(ap, expr);
- msg = (const char *)va_arg(ap, char *);
-
/*
* If a message was passed, format it with vsnprintf.
* Otherwise, print the expression as is.
*/
if(msg != NULL)
{
+ va_list ap;
+ va_start(ap, msg);
vsnprintf(buf, BUFSIZ, msg, ap);
+ va_end(ap);
to_send = buf;
}
else
@@ -388,7 +387,6 @@ void _ck_assert_failed(const char *file, int line, const char *expr, ...)
to_send = expr;
}
- va_end(ap);
send_failure_info(to_send);
if(cur_fork_status() == CK_FORK)
{
diff --git a/src/check.h.in b/src/check.h.in
index fdbc8b0..9baddc9 100644
--- a/src/check.h.in
+++ b/src/check.h.in
@@ -480,7 +480,7 @@ static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED)
*/
#define fail_if(expr, ...)\
(expr) ? \
- _ck_assert_failed(__FILE__, __LINE__, "Failure '"#expr"' occurred" , ## __VA_ARGS__, NULL) \
+ _ck_assert_failed(__FILE__, __LINE__, "Failure '"#expr"' occurred" , ## __VA_ARGS__) \
: _mark_point(__FILE__, __LINE__)
/*
@@ -500,11 +500,12 @@ static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED)
*/
#if @HAVE_FORK@
CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
- const char *expr,
- ...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(gnu_printf, 3, 4);
+ const char *expr, const char *msg,
+ ...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(gnu_printf, 4, 5);
#else
CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
- const char *expr, ...) CK_ATTRIBUTE_FORMAT(gnu_printf, 3, 4);
+ const char *expr, const char *msg,
+ ...) CK_ATTRIBUTE_FORMAT(gnu_printf, 4, 5);
#endif
/**
@@ -534,7 +535,7 @@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
#define ck_assert_msg(expr, ...) \
(expr) ? \
_mark_point(__FILE__, __LINE__) : \
- _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
+ _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__)
/**
* Unconditionally fail the test
@@ -553,7 +554,7 @@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line,
*
* @since 0.9.6
*/
-#define ck_abort_msg(...) _ck_assert_failed(__FILE__, __LINE__, "Failed" , ## __VA_ARGS__, NULL)
+#define ck_abort_msg(...) _ck_assert_failed(__FILE__, __LINE__, "Failed" , ## __VA_ARGS__)
/* Signed and unsigned integer comparison macros with improved output compared to ck_assert(). */
/* OP may be any comparison operator. */

View File

@ -0,0 +1,94 @@
diff --git a/src/check.h.in b/src/check.h.in
index fdbc8b0..d1c494d 100644
--- a/src/check.h.in
+++ b/src/check.h.in
@@ -1724,7 +1724,7 @@ do { \
#define _ck_assert_ptr(X, OP, Y) do { \
const void* _ck_x = (X); \
const void* _ck_y = (Y); \
- ck_assert_msg(_ck_x OP _ck_y, "Assertion '%s' failed: %s == %#x, %s == %#x", #X" "#OP" "#Y, #X, _ck_x, #Y, _ck_y); \
+ ck_assert_msg(_ck_x OP _ck_y, "Assertion '%s' failed: %s == %#lx, %s == %#lx", #X" "#OP" "#Y, #X, (unsigned long)_ck_x, #Y, (unsigned long)_ck_y); \
} while (0)
/* Pointer against NULL comparison macros with improved output
@@ -1733,9 +1733,9 @@ do { \
#define _ck_assert_ptr_null(X, OP) do { \
const void* _ck_x = (X); \
ck_assert_msg(_ck_x OP NULL, \
- "Assertion '%s' failed: %s == %#x", \
+ "Assertion '%s' failed: %s == %#lx", \
#X" "#OP" NULL", \
- #X, _ck_x); \
+ #X, (unsigned long)_ck_x); \
} while (0)
/**
diff --git a/src/check_error.c b/src/check_error.c
index 865e7d5..02b40ae 100644
--- a/src/check_error.c
+++ b/src/check_error.c
@@ -61,7 +61,7 @@ void *emalloc(size_t n)
p = malloc(n);
if(p == NULL)
- eprintf("malloc of %u bytes failed:", __FILE__, __LINE__ - 2, n);
+ eprintf("malloc of %zu bytes failed:", __FILE__, __LINE__ - 2, n);
return p;
}
@@ -71,6 +71,6 @@ void *erealloc(void *ptr, size_t n)
p = realloc(ptr, n);
if(p == NULL)
- eprintf("realloc of %u bytes failed:", __FILE__, __LINE__ - 2, n);
+ eprintf("realloc of %zu bytes failed:", __FILE__, __LINE__ - 2, n);
return p;
}
diff --git a/src/check_pack.c b/src/check_pack.c
index f4f4c6a..1d4f959 100644
--- a/src/check_pack.c
+++ b/src/check_pack.c
@@ -136,7 +136,7 @@ int pack(enum ck_msg_type type, char **buf, CheckMsg * msg)
len = pftab[type] (buf, msg);
if(len > (size_t) INT_MAX)
- eprintf("Value of len (%d) too big, max allowed %u\n",
+ eprintf("Value of len (%zu) too big, max allowed %u\n",
__FILE__, __LINE__ - 3, len, INT_MAX);
return (int) len;
}
@@ -159,10 +159,10 @@ int upack(char *buf, CheckMsg * msg, enum ck_msg_type *type)
diff = buf - obuf;
if(diff > (ptrdiff_t) INT_MAX)
- eprintf("Value of diff (%t) too big, max allowed %u\n",
+ eprintf("Value of diff (%td) too big, max allowed %d\n",
__FILE__, __LINE__ - 3, diff, INT_MAX);
if(diff > (ptrdiff_t) INT_MAX || diff < (ptrdiff_t) INT_MIN)
- eprintf("Value of diff (%t) too small, min allowed %u\n",
+ eprintf("Value of diff (%td) too small, min allowed %d\n",
__FILE__, __LINE__ - 6, diff, INT_MIN);
return (int) diff;
}
diff --git a/tests/check_check_master.c b/tests/check_check_master.c
index aaf45f3..a157904 100644
--- a/tests/check_check_master.c
+++ b/tests/check_check_master.c
@@ -589,7 +589,7 @@ START_TEST(test_check_failure_lnos)
}
if (line_no > 0 && tr_lno(tr) != line_no) {
- ck_abort_msg("For test %d (failure %d): Expected lno %d, got %d for suite %s, msg %s",
+ ck_abort_msg("For test %d (failure %d): Expected lno %ld, got %d for suite %s, msg %s",
i, number_failed, line_no, tr_lno(tr), tr_tcname(tr), tr_msg(tr));
}
}
@@ -597,7 +597,7 @@ START_TEST(test_check_failure_lnos)
/* At this point, there should be no remaining failures */
line_no = get_next_failure_line_num(line_num_failures);
ck_assert_msg(line_no == -1,
- "No more failure line numbers expected, but found %d", line_no);
+ "No more failure line numbers expected, but found %ld", line_no);
}
END_TEST

View File

@ -1,6 +1,6 @@
Name: check
Version: 0.14.0
Release: 3%{?dist}
Version: 0.15.0
Release: 1%{?dist}
Summary: A unit test framework for C
Source0: https://github.com/libcheck/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
License: LGPLv2+
@ -9,7 +9,14 @@ URL: http://libcheck.github.io/check/
Patch0: %{name}-0.11.0-info-in-builddir.patch
# Fix test failures due to varying floating point behavior across platforms
Patch1: %{name}-0.11.0-fp.patch
# Fix format specifiers that do not match their arguments
# See https://github.com/libcheck/check/pull/271
Patch2: %{name}-0.15.0-formatspec.patch
# Make CK_ATTRIBUTE_FORMAT refer to the right arguments
# See https://github.com/libcheck/check/pull/272
Patch3: %{name}-0.15.0-attribute-format.patch
BuildRequires: cmake
BuildRequires: gcc
BuildRequires: libtool
BuildRequires: patchutils
@ -26,7 +33,6 @@ The output from unit tests can be used within source code editors and IDEs.
%package devel
Summary: Libraries and headers for developing programs with check
Requires: pkgconfig
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
@ -53,13 +59,16 @@ programs suitable for use with the Check unit test framework.
%if 0%{?fedora}
%patch0 -p1 -b .info-in-builddir
%endif
%patch1
%patch1 -p1
%patch2 -p1
%patch3 -p1
# Fix detection of various time-related function declarations
sed -e '/DECLS(\[a/s|)|,,,[AC_INCLUDES_DEFAULT\n[#include <time.h>\n #include <sys/time.h>]]&|' \
-i configure.ac
# Improve the info directory entry
# See https://github.com/libcheck/check/pull/273
sed -e 's/\(Check: (check)\)Introduction./\1. A unit testing framework for C./' \
-i doc/check.texi
@ -70,45 +79,74 @@ find . -name .cvsignore -delete
autoreconf -ivf
%build
# The autotools build does not create the cmake files.
# The cmake build does not create the info or aclocal files.
# Therefore we build with both and combine the results to get everything.
mkdir autotools_build
cd autotools_build
%global _configure ../configure
%configure --disable-timeout-tests
# Get rid of undesirable hardcoded rpaths
# Get rid of undesirable hardcoded rpaths; workaround libtool reordering
# -Wl,--as-needed after all the libraries.
sed -e 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' \
-e 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' \
-e 's|CC="\(.*g..\)"|CC="\1 -Wl,--as-needed"|' \
-i libtool
make %{?_smp_mflags}
# Do not try to apply -Werror=format-security to the test code. Many tests
# compute format strings on the fly, which causes that flag to trigger errors.
# It's just test code; the library itself builds with the error enabled.
sed -i 's/ -Werror=format-security//g' tests/Makefile
%make_build
cd -
mkdir cmake_build
cd cmake_build
%cmake -DCHECK_ENABLE_TIMEOUT_TESTS:BOOL=OFF ..
# See above
sed -i 's/ -Werror=format-security//g' \
$(grep -Frl -e ' -Werror=format-security' tests)
%make_build
cd -
%install
make DESTDIR=$RPM_BUILD_ROOT install
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -rf $RPM_BUILD_ROOT%{_infodir}/dir
rm -rf $RPM_BUILD_ROOT%{_docdir}/%{name}
cd autotools_build
%make_install
rm -rf %{buildroot}%{_libdir}
rm -rf %{buildroot}%{_infodir}/dir
rm -rf %{buildroot}%{_docdir}/%{name}
cd -
cd cmake_build
%make_install
cd -
%check
%ifnarch s390x
cd autotools_build
export LD_LIBRARY_PATH=$PWD/src/.libs
make check
%endif
# Don't need to package the sh, log or trs files
# when we scoop the other checkmk/test files for doc
rm -rf checkmk/test/check_checkmk*
# these files are empty
rm -rf checkmk/test/empty_input
cd -
%ldconfig_scriptlets
%files
%doc AUTHORS NEWS
%license COPYING.LESSER
%{_libdir}/libcheck.so.*
%{_libdir}/libcheck.so.0*
%{_infodir}/check*
%files devel
%doc doc/example
%{_includedir}/check.h
%{_includedir}/check_stdint.h
%{_libdir}/cmake/check/
%{_libdir}/libcheck.so
%{_libdir}/pkgconfig/check.pc
%{_datadir}/aclocal/check.m4
@ -125,6 +163,12 @@ rm -rf checkmk/test/empty_input
%{_mandir}/man1/checkmk.1*
%changelog
* Mon Jun 22 2020 Jerry James <loganjerry@gmail.com> - 0.15.0-1
- Version 0.15.0
- Add -formatspec and -attribute-format patches
- Build with both cmake and autotools
- Reenable s390x tests
* Fri Jan 31 2020 Tom Callaway <spot@fedoraproject.org> - 0.14.0-3
- disable tests on s390x

View File

@ -1 +1 @@
SHA512 (check-0.14.0.tar.gz) = 54ad175c00cf0c73b4386cf6b3d6a404a5da4f57897d099e772f148f410108c44767c3266a940113be73a6861b3f3ee1706c558cc71ec51df99687f19f3a3bb4
SHA512 (check-0.15.0.tar.gz) = efde93977a38520b3b83a9e2f678d07b916fc27e41cf839a663900c4153d645fe4274ec3b7e2dabf475457f909f61734632c97b7257c49f5853fd11d920b0c84