# Tests by default. No tests: rpm -ba --define 'dotests 0' *.spec %{!?dotests: %define dotests 1} %define _libdir64 %{_prefix}/lib64 Summary: An elegant unit testing framework for C with support for mock objects Name: cmocka Version: 1.1.5 Release: 1 License: Apache V2.0 License Group: Development/Languages URL: https://cmocka.org/ Source0: https://cmocka.org/files/1.1/%{name}-%{version}.tar.xz Source1: https://cmocka.org/files/1.1/%{name}-%{version}.tar.xz.asc BuildRequires: gcc BuildRequires: cmake >= 3.16.0 Patch1: cmocka-1.1.5-ppc64.patch Patch2: cmocka-1.1.5-ldflags.patch %description There are a variety of C unit testing frameworks available however many of them are fairly complex and require the latest compiler technology. Some development requires the use of old compilers which makes it difficult to use some unit testing frameworks. In addition many unit testing frameworks assume the code being tested is an application or module that is targeted to the same platform that will ultimately execute the test. Because of this assumption many frameworks require the inclusion of standard C library headers in the code module being tested which may collide with the custom or incomplete implementation of the C library utilized by the code under test. Cmocka only requires a test application is linked with the standard C library which minimizes conflicts with standard C library headers. Also, CMocka tries to avoid the use of some of the newer features of C compilers. This results in CMocka being a relatively small library that can be used to test a variety of exotic code. If a developer wishes to simply test an application with the latest compiler then other unit testing frameworks may be preferable. This is the successor of Google's Cmockery. %package -n libcmocka Summary: Lightweight library to simplify and generalize unit tests for C Group: Libcmocka Requires: libgcc >= 8.3.0-1 Conflicts: cmockery2 %description -n libcmocka There are a variety of C unit testing frameworks available however many of them are fairly complex and require the latest compiler technology. Some development requires the use of old compilers which makes it difficult to use some unit testing frameworks. In addition many unit testing frameworks assume the code being tested is an application or module that is targeted to the same platform that will ultimately execute the test. Because of this assumption many frameworks require the inclusion of standard C library headers in the code module being tested which may collide with the custom or incomplete implementation of the C library utilized by the code under test. CMocka only requires a test application is linked with the standard C library which minimizes conflicts with standard C library headers. Also, CMocka tries to avoid the use of some of the newer features of C compilers. This results in CMocka being a relatively small library that can be used to test a variety of exotic code. If a developer wishes to simply test an application with the latest compiler then other unit testing frameworks may be preferable. This is the successor of Google's Cmockery. %package -n libcmocka-static Summary: Lightweight library to simplify and generalize unit tests for C %description -n libcmocka-static Static version of the cmocka library. %package -n libcmocka-devel Summary: Development headers for the cmocka library Group: Devel Requires: libcmocka = %{version}-%{release} Conflicts: cmockery2-devel %description -n libcmocka-devel Development headers for the cmocka unit testing library. %prep %setup -q -n %{name}-%{version} %patch1 %patch2 %build export CC="/opt/freeware/bin/gcc" # First build 64 bit export OBJECT_MODE=64 export CFLAGS64="-O2 -maix64" export LDFLAGS="-L/opt/freeware/lib64 -L/opt/freeware/lib -lpthread -Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib" mkdir obj cd obj cmake \ -DWITH_STATIC_LIB=ON \ -DWITH_CMOCKERY_SUPPORT=ON \ -DUNIT_TESTING=ON \ -DOBJECT_MODE="64" \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DINCLUDE_INSTALL_DIR=%{_prefix}/include \ -DCMAKE_INSTALL_LIBDIR="%{_libdir64}" \ -DBUILD_SHARED_LIBS:BOOL=OFF \ -DSYSCONF_INSTALL_DIR:PATH="%{_sysconfdir}" \ -DSHARE_INSTALL_PREFIX=share \ -DCMAKE_C_COMPILER="${CC}" \ -DCMAKE_C_FLAGS="$CFLAGS64" \ %{_builddir}/%{name}-%{version} gmake %{?_smp_mflags} VERBOSE=1 gmake %{_builddir}/%{name}-%{version}/obj/doc if [ "%{dotests}" == 1 ] then (ctest --output-on-failure || true ) echo " Two test cases failed because linker flag "ld --wrap=uptime" which is used to link the uptime() function will not work in AIX OS.\n\ Refer the file for more details:\ " %{_builddir}/%{name}-%{version}/example/mock/uptime/README.md" " fi %install [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} # install on 64bit mode cd obj export OBJECT_MODE=64 make DESTDIR=${RPM_BUILD_ROOT} install cd .. %clean [ "${RPM_BUILD_ROOT}" != "/" ] && rm -rf ${RPM_BUILD_ROOT} %files -n libcmocka %defattr(-,root,system,-) %doc AUTHORS README.md ChangeLog %license COPYING %{_libdir64}/libcmocka.* %files -n libcmocka-static %defattr(-,root,system,-) %{_libdir64}/libcmocka-static.a %files -n libcmocka-devel %defattr(-,root,system,-) %doc obj/doc %{_includedir}/cmocka.h %{_includedir}/cmocka_pbc.h %{_includedir}/cmockery/cmockery.h %{_includedir}/cmockery/pbc.h %{_libdir64}/pkgconfig/cmocka.pc %{_libdir64}/cmake/cmocka/cmocka-config-version.cmake %{_libdir64}/cmake/cmocka/cmocka-config.cmake %changelog * Thu Apr 30 2020 Ashwini Chandrappa - 1.1.5-1 - Initial build