#
# spec file for package check
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


%define libname libcheck0
Name:           check
Version:        0.12.0
Release:        1.8
Summary:        Unit Test Framework for C
License:        LGPL-2.1-or-later
Group:          Development/Libraries/C and C++
URL:            https://libcheck.github.io/check/
Source:         https://github.com/libcheck/check/releases/download/%{version}/%{name}-%{version}.tar.gz
Source99:       baselibs.conf
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  fdupes
BuildRequires:  libtool
BuildRequires:  makeinfo
BuildRequires:  pkgconfig
BuildRequires:  sed

%description
Check is a unit test framework for C. It features a simple interface for
defining unit tests, limitating the developer the less possible.

%package -n %{libname}
Summary:        Unit Test Framework for C
Group:          System/Libraries
Obsoletes:      check < %{version}-%{release}
Provides:       check = %{version}-%{release}

%description -n %{libname}
Check is a unit test framework for C. It features a simple interface for
defining unit tests, limitating the developer the less possible. Tests
are run in a separate address space, so Check cancatch both, assertion
failures and code errors that cause segmentationfaults or other
signals. The output of unit tests can be used within source code
editors and IDEs.

%package devel
Summary:        Development files for the CHECK unit test framework
Group:          Development/Libraries/C and C++
Requires:       %{libname} = %{version}
Requires:       glibc-devel

%description devel
Check is a unit test framework for C. It features a simple interface
for defining unit tests, putting little in the way of the developer.
Tests are run in a separate address space, so Check can catch both
assertion failures and code errors that cause segmentation faults or
other signals. The output from unit tests can be used within source
code editors and IDEs.

%prep
%setup -q

%build
autoreconf -fiv
export CFLAGS="%{optflags} -std=gnu99"
export CXXFLAGS="%{optflags} -std=gnu99"
export FFLAGS="%{optflags} -std=gnu99"
%configure \
    --disable-static
%make_build docdir=%{_docdir}/%{name}

%install
%make_install docdir=%{_docdir}/%{name}
find %{buildroot} -type f -name "*.la" -delete -print
%fdupes %{buildroot}/%{_datadir}

# We package these either with %%license or %%doc macros
rm %{buildroot}%{_docdir}/%{name}/{COPYING.LESSER,ChangeLog,NEWS,README}

%post -n %{libname} -p /sbin/ldconfig
%post devel
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz

%postun -n %{libname} -p /sbin/ldconfig
%preun devel
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz

%files -n %{libname}
%license COPYING.LESSER
%{_libdir}/*.so.*

%files devel
%doc AUTHORS ChangeLog NEWS README THANKS TODO
%{_infodir}/%{name}.info*
%{_mandir}/man1/checkmk.1%{?ext_man}
%dir %{_docdir}/%{name}
%doc %{_docdir}/%{name}/example
%{_bindir}/checkmk
%dir %{_datadir}/aclocal
%{_datadir}/aclocal/*.m4
%{_includedir}/*.h
%{_libdir}/*.so
%{_libdir}/pkgconfig/*.pc

%changelog
* Wed Feb 28 2018 dimstar@opensuse.org
- Modernize spec-file by calling spec-cleaner
* Fri Feb 16 2018 luc14n0@linuxmail.org
- Update to version 0.12.0:
  + Fix out-of-tree builds with CMake (gh#libcheck/check#86).
  + Fix issue found with Clang regarding invalid suffix on a
    literal (gh#libcheck/check#110).
  + Check now responds to a few errors in a more clear way when
    it cannot run tests (gh#libcheck/check#122 and
    gh#libcheck/check#123).
  + The maximum message size of check assertions is now
    configurable (gh#libcheck/check#127).
  + Check support added for Visual Studios 2010, 2012, 2013, 2015,
    and 2017 both for x86/64 and ARM (gh#libcheck/check#129 and
    gh#libcheck/check#125).
- Adopt the use of %%make_build and %%make_install rather than raw
  make commands, following the best practices. And pass docdir
  to configure instead of passing directly to make.
- Add automake, autoconf and sed BuildRequires to avoid implicit
  dependencies.
* Wed Sep 20 2017 avvissu@yandex.by
- Update to version 0.11.0:
  + Avoid issue in unit test output checking where a shell's
    built-in printf command does not work properly, but the printf
    program itself is correct.
  + Emit only valid XML characters in XML logging.
  + Add LGPL header to files where it was missing.
  + Strip timestamps from examples using filterdiff if available.
  + Fix potential SIGSEGV in Check related to the disk filling up
    during a test.
  + Support added for applying tags to test cases and selectively
    running test cases based on tags.
  + Macros for comparing memory regions
    (ck_assert_mem_eq, ck_assert_mem_ne) have been added.
  + Macros for comparing floating point numbers have been added.
  + Macros for comparing string, but allowing for NULL
    (ck_assert_pstr_eq,ck_assert_pstr_ne) have been added.
  + Macros for checking if a pointer is NULL or not have been
    added.
- Update the homepage and source Url to current location.
- Add libtool and makeinfo BuildRequires and use autoreconf when
  building, needed as package is not bootstraped.
- Add NEWS file.
* Tue Aug 18 2015 zaitor@opensuse.org
- Update to version 0.10.0:
  + CMake on MinGW and MSVC was unable to find time related types
    because time.h was not included. This header is now included
    for the checks.
  + If the test runner process catches a SIGTERM or SIGINT signal
    the running tests are now also killed.
  + If Check is compiled without support for fork(), the behavior
    of functions which require fork() to be useful have been
    changed. Functions that attempt to set CK_FORK mode are no-ops,
    check_fork() returns in failure, and check_waitpid_and_exit()
    exits in failure.
  + Add space around operators in assert messages for readability.
  + Use mkstemp() if available instead of tmpfile() or tempnam().
  + Fix issue with string formatting in ck_assert(), where using
    the %% operator would be interpreted as a string formatter.
  + In nofork mode, the location of a failed assertion within a
    test case was lost if that test case has a checked teardown
    fixture (even if that fixture function is empty). This is now
    fixed.
* Wed Mar  4 2015 jengelh@inai.de
- Implement shared library naming guidelines: move the library to
  libcheck0. The new package obsoletes 'check', as there is no
  other content.
- Do not pass --enable-pic to configure: only static libs profit
  from this.
- Add fdupes BuildRequires to eliminate the couple duplicates.
- Move %%install_info_delete from postun to preun: access to the
  .info files is required for successful execution.
* Sat Aug 23 2014 dimstar@opensuse.org
- Update to version 0.9.14:
  + Changes to (unofficially for now) support Solaris and AIX
    platforms.
  + Fix issue with checked teardown functions in CK_NOFORK mode.
  + Allow checked fixtures when compiled without fork().
  + Various code cleanup, including changes for compiling Check on
    c++ compilers Clang and g++.
  + Re-enable internal unit tests.
* Tue Jul  1 2014 dimstar@opensuse.org
- Update to version 0.9.13:
  + When a test assertion fails, exit() was invoked. This results
    in any registered exit handlers being invoked. A test should
    not be relied upon to clean up if it fails. Instead, _exit()
    will be used to signal a test failure, to prevent exit handlers
    from being invoked.
  + Fix issue with string formatting in ck_assert_(u)int_* calls,
    where using the %% operator would be interpreted as a string
    formatter.
  + If the LOG/XML/TAP file name is set to "-" either through the
    srunner_set_log() srunner_set_xml() or srunner_set_tap() calls
    or through the related environment variables, the logged data
    will be printed to stdout instead of a file. This is mainly to
    support using TAP for fixtures which expect the results to be
    reported via stdout. However, it is available via all of
    Check's logging modalities.
  + For CMake builds, check_stdint.h was not being installed. This
    is now fixed.
  + Check's example under doc/example now also works for CMake
    projects using Visual Studios and MSVC. This includes an
    example CMake configuration.
- Drop check-missing-includes.patch: fixed upstream.
* Sun Feb  2 2014 dimstar@opensuse.org
- Update to version 0.9.12:
  + Additional unit tests created for internal and external Check
    APIs.
  + Check now compiled on Windows using MSVC when using CMake and
    NMake. All unit tests pass, though shell script based ones need
    to be run in the MSYS environment.
  + Check now compiles on Windows using Visual Studio 10 when using
    CMake. check_check passes when run from Visual Studios.
  + Always capture the start and end times of tests when using
    NO_FORK mode. Previously the end time was not captured,
    resulting in arbitrary durations being recorded when tests
    failed. Bug#87.
  + Added additional configure script checks for support of
    timer_create() on the target system. This allows for OpenBSD to
    compile and run all Check's unit tests successfully.
  + Added a unit test, check_mem_leaks, which can be used against
    valgrind to test for memory leaks. No memory leaks were found.
  + Added tcase_add_loop_test support in checkm.
  + Add support for logging in Test Anything Protocol (TAP) format.
  + Refactor Check's assertions to be more like the assert() call
    in assert.h, in that static source code analyzers can use gcc
    attributes in the header to make assumptions about the flow of
    the code. See feature request #29.
  + Fix ck_assert_ptr_* causing const compilation warnings.
- Add check-missing-includes.patch: Add missing include in order
  to fix the build.
* Wed Nov  6 2013 dimstar@opensuse.org
- Update to version 0.9.11:
  + Check's unit tests pass when compiled out of the source tree.
  + Check compiles for Windows using the MinGW/msys environment
    (without using fork), and all unit tests pass.
  + Check compiles for Windows using the Cygwin environment, and
    all unit tests pass.
  + Check compiles for Windows using MinGW in Linux (without using
    fork), and all unit tests pass using wine 1.4.
* Thu Apr 18 2013 dimstar@opensuse.org
- Update to version 0.9.10:
  + Support 64bit int for __ck_assert_int (sf#3599471).
  + Add equivalent uint variants for __ck_assert_int (sf #3600433).
  + Detect if the system has a C99 compliant version of the printf
    related functions for check to use, and if not use an
    implementation provided by check.
  + Updated HACKING and release procedure in Makefile.am.
  + Detect if the system has clock_gettime() available, and if not
    use an implementation provided by check. clock_gettime() is
    used to measure test durations. The implementation for OSX uses
    OSX specific system calls to get the time. For all other
    systems, clock_gettime() does nothing.
  + Updated documentation in check.h to reference new check API.
  + Remove usage of deprecated fail(), fail_if(), and fail_unless()
    calls from check's unit tests.
  + Fix implementation of putenv in check's libcompat for systems
    that do not provide it.
  + Fix implementation of unsettenv in check's libcompat for
    systems that do not provide it.
  + mprovements to the new Check API: new comparison functions for
    pointers: ck_assert_ptr_(eq|ne).
  + Test timeouts can now be in nanosecond precision.
  + Cleanup compile warnings (sf#3579199).
  + Renamed Check's internal list functions to start with check_
    (sf#3448601).
* Tue Oct 23 2012 dimstar@opensuse.org
- Update to version 0.9.9:
  + Measure test duration and print in XML output (sf#3521371)
  + Added contrib/XML_for_JUnit.xsl (sf#3521371)
  + Added support for setting log files via environment variables.
    (sf#3576713)
  + Added better pkg-config and subunit support (sf#3417041)
  + Make tests/test_vars.in bourne shell compatible (sf#3472578)
  + Added ck_ prefix to mutex_lock variable, to avoid name clash on
    Solaris (sf#3472574)
  + In autoconf, request system extensions to generate 64-bit safe
    code (sf#2803433)
  + Fix for mutex deadlock when killing threads (sf#3564640)
  + Make XML output well-formed (sf#3575642, sf#3485651)
  + Fix buggy duration calculation (sf#3575451)
  + A more complete CMake / MSVC patch for those interested in
    pursuing Windows development with Check and Visual Studio.
  + Added instructions for improving the speed and output of `make
    check' when using Automake.
  + Added a chapter in the documentation for selective running of
    tests.
  + Changed how the message pipe is read. Before, the whole file
    was copied to RAM with realloc, giving problems with huge
    allocations for repetetive tests, the problem was visible for a
    specific GStreamer test case.
  + Improvements to the new Check API: documentation, macros that
    allow multiple evaluation, unit tests, and new
    ck_assert_(str|int)_(lt|le|gt|ge) comparison functions.
  + Made the new Check API primary and use it to define macros from
    old Check API
  + Added checkmk, a tool for reducing "boilerplate coding" when
    writing unit tests with check.
  + Added xslt link to xml output, added display of iteration field
    into xslt stylesheet and moved it to directory accessible from
    web page root
  + Added longjmp to fail function to ensure that no code will be
    executed in test function after failed assertion
  + Fix dead assignments and several possible NULL pointer
    dereferences.
* Thu Dec 22 2011 dimstar@opensuse.org
- Own %%{_datadir}/aclocal to fix build without automake/autoconf.
* Sat Sep 17 2011 jengelh@medozas.de
- Remove redundant tags/sections from specfile
- Use %%_smp_mflags for parallel building
* Sat Apr 24 2010 coolo@novell.com
- buildrequire pkg-config to fix provides
* Tue Feb  2 2010 puzel@novell.com
- Add pkg-config Recommends to check-devel, as required by policy.
* Sun Jan 31 2010 jengelh@medozas.de
- Package baselibs.conf
* Fri Nov 27 2009 dimstar@opensuse.org
- Update to version 0.9.8:
  + Added CK_SUBUNIT support for outputting test information in
    the subunit wire protocol.
  + Added code and tests for timeout scaling via environment
    variable
  + Added documentation for testing exit values with
    tcase_add_exit_test()
  + Add make_macros perl script from somebody
  + add type to check_type error message
  + add contrib dir with xslt transform
  + function exist testing support
  + introduce HAVE_WORKING_SETENV to protect tc_timeout_env usage
  + support running tests with multiple pthreads
  + partial MSYS/MinGW support.
- spec file cleaned using spec-cleaner.
* Sat Apr 18 2009 crrodriguez@suse.de
- remove static libraries and "la" files
* Thu Jan  1 2009 msuman@suse.de
- Updated to version 0.9.6:
  * add call to AC_REPLACE_FUNCS([strsignal])
  * add CK_FORK_GETENV to enum fork_status and delete CK_FORK_UNSPECIFIED
  * add CK_CTX_INVALID to ck_result_ctx and don't use -1 anymore
  * rename signal to _signal in _tcase_add_test to avoid a
    symbol clash with /usr/include/sys/signal.h on OS X.
  * define rpl_malloc and rpl_realloc for platforms where
    !malloc(0) and !realloc(0,0), such as AIX, because configure
    goes and redefines malloc/realloc in this case...
  * Added new Check fail API. Implemented on top of fail_unless. Future
    versions will reverse this so fail_unless is implemented on top of the
    ck_assert API. This API is not documented yet, will probably not be fully
    released until 0.9.8, when it will be possible to choose API.
  * More fixes and changes.
* Thu Apr 10 2008 ro@suse.de
- added baselibs.conf file to build xxbit packages
  for multilib support
* Tue Mar 27 2007 sbrabec@suse.cz
- Updated to version 0.9.5:
  * Fixed code coverage support.
  * Updated manual and converted from DocBook to Texinfo.
  * Added pkg-config support.
  * Added Libtool support to build both static and shared
    libraries.
  * Updated GNU Build System to use modern Autotools.
  * Added a new kind of test, looping tests.
  * Added possibility to turn off timeout tests.
  * Added coverage analysis for check's own unit tests.
  * More fixes and changes.
* Fri Feb 24 2006 sbrabec@suse.cz
- Fixed format string error (David Binderman, #143293).
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Mon Dec 12 2005 sbrabec@suse.cz
- Updated to version 0.9.3.
- Build with -fPIC.
* Mon May 30 2005 sbrabec@suse.cz
- New SuSE package, version 0.9.2.