%description devel
This package contains the development files for %{name}.
+%if 0%{?gcov:1}
+%package gcov
+Summary: %{name} gcov data
+
+%description gcov
+gcov objects
+
+%package unittests
+Summary: %{name} unittests binary
+
+%description unittests
+unittests binary
+%endif
+
%prep
%setup -q
%build
%if 0%{?gcov:1}
-export LDFLAGS+=" -lgcov"
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
%endif
export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
make %{?jobs:-j%jobs}
-%if 0%{?gcov:1}
-mkdir -p gcov-obj
-find . -name '*.gcno' -exec cp '{}' gcov-obj ';'
-%endif
-
%install
rm -rf %{buildroot}
%make_install
+%if 0%{?gcov:1}
+builddir=$(basename $PWD)
+gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
+mkdir -p "$gcno_obj_dir"
+find . -name '*.gcno' -exec cp '{}' "$gcno_obj_dir" ';'
+
+cat << EOF > run-unittest.sh
+#!/bin/bash
+setup() {
+ echo "setup start"
+}
+
+test_main() {
+ echo "test_main start"
+ LD_PRELOAD=/usr/lib/libnfc-mock.so /usr/bin/tct-nfc-core
+}
+
+teardown() {
+ echo "teardown start"
+}
+
+main() {
+ setup
+ test_main
+ teardown
+}
+
+main "$@"
+EOF
+
+mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
+install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}
+%endif
+
%check
%if 0%{?gcov:1}
-pushd unittest
-./run_coverage.sh
-popd
+LD_LIBRARY_PATH=. LD_PRELOAD=unittest/libnfc-mock.so unittest/tct-nfc-core
+lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.total.info
+lcov --remove %{name}.total.info -o %{name}.info '*unittest/*'
+genhtml %{name}.info -o out --legend --show-details
%endif
%post -p /sbin/ldconfig
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-network-nfc.so
%{_bindir}/nfc_unit_test
+
+%if 0%{?gcov:1}
+%files gcov
+%{_datadir}/gcov/obj/*
+
+%files unittests
+%{_libdir}/libnfc-mock.so
+%{_bindir}/tct-nfc-core
+%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
+%endif
#define CHECK_INITIALIZED() \
do { \
- /* LCOV_EXCL_START */ \
if (llcp_proxy == NULL) { \
if (net_nfc_client_llcp_init() != NET_NFC_OK) { \
DEBUG_ERR_MSG("llcp_proxy fail"); \
\
if (net_nfc_client_manager_is_activated() == false) \
return NET_NFC_NOT_ACTIVATED; \
- /* LCOV_EXCL_STOP */ \
} while (0)
typedef struct _LlcpFuncData LlcpFuncData;
SET_TARGET_PROPERTIES(${NFC_MOCK} PROPERTIES
COMPILE_FLAGS ${NFC_MOCK_CFLAGS}
)
+INSTALL(TARGETS ${NFC_MOCK} DESTINATION ${LIB_INSTALL_LIB})
ADD_EXECUTABLE(${UNITTEST_NAME} ${UNITTEST_NAME}.cpp ${TC_SOURCES} )
TARGET_LINK_LIBRARIES(${UNITTEST_NAME}
capi-network-nfc
)
-# INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR})
+INSTALL(TARGETS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR})
+++ /dev/null
-#!/bin/bash
-
-export LD_LIBRARY_PATH=..:.:$LD_LIBRARY_PATH
-pushd ../
-RootDir=$PWD
-popd
-
-unitTestFile=tct-nfc-core
-if [ ! -x "./$unitTestFile" ]
-then
- echo "$unitTestFile file does not exist!"
- exit -1
-fi
-
-LD_PRELOAD=./libnfc-mock.so ./$unitTestFile
-
-CMakeDir=${RootDir}/CMakeFiles/capi-network-nfc.dir/src
-CoverageDir=${RootDir}/coverage
-
-pushd $CMakeDir
-
- for obj in `ls *.o`
- do
- gcov -b -c $obj
- done
-
- if [ -f /usr/bin/lcov ]
- then
- lcov -c -d . -o cov.info
- genhtml cov.info -o ${CoverageDir}
- echo "Coverage test result created! [${CoverageDir}]"
- else
- echo "lcov does not exist!"
- fi
-popd