summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJihoon Jung <jh8801.jung@samsung.com>2024-10-31 11:09:40 +0900
committerJihoon Jung <jh8801.jung@samsung.com>2024-10-31 11:09:40 +0900
commitf50ae63e5004171f31feeaa24b249e4db77f1ebd (patch)
treead4d60800dc330012e01b888796d17eea4c1cc69
parentac176304ae8d951a9f87736f0173d74c054c0258 (diff)
downloadsmartcard-accepted/tizen_unified.tar.gz
smartcard-accepted/tizen_unified.tar.bz2
smartcard-accepted/tizen_unified.zip
Change-Id: I65b1632f76fafcbb51d47c9888cd7a40d6f7d14a Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
-rw-r--r--packaging/capi-network-smartcard.spec74
-rw-r--r--unittest/CMakeLists.txt7
-rwxr-xr-xunittest/run_coverage.sh35
3 files changed, 46 insertions, 70 deletions
diff --git a/packaging/capi-network-smartcard.spec b/packaging/capi-network-smartcard.spec
index 8ba4e69..08af448 100644
--- a/packaging/capi-network-smartcard.spec
+++ b/packaging/capi-network-smartcard.spec
@@ -30,28 +30,12 @@ Requires: %{name} = %{version}-%{release}
%description devel
-%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 CFLAGS+=" -fprofile-arcs -ftest-coverage"
-export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
-export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
%endif
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
@@ -65,51 +49,21 @@ cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} \
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/libsmartcard-mock.so /usr/bin/tct-smartcard-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}
-LD_LIBRARY_PATH=. LD_PRELOAD=unittest/libsmartcard-mock.so unittest/tct-smartcard-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
+pushd unittest
+./run_coverage.sh
+popd
%endif
%post -p /sbin/ldconfig
@@ -127,13 +81,3 @@ genhtml %{name}.info -o out --legend --show-details
%{_libdir}/pkgconfig/*.pc
%{_libdir}/libcapi-network-smartcard.so
%{_bindir}/smartcard_unit_test
-
-%if 0%{?gcov:1}
-%files gcov
-%{_datadir}/gcov/obj/*
-
-%files unittests
-%{_libdir}/libsmartcard-mock.so
-%{_bindir}/tct-smartcard-core
-%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
-%endif
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
index daab756..f3409c2 100644
--- a/unittest/CMakeLists.txt
+++ b/unittest/CMakeLists.txt
@@ -29,15 +29,12 @@ ADD_DEFINITIONS( -DMOBILE )
SET(SMARTCARD_MOCK "smartcard-mock")
SET(SMARTCARD_MOCK_SRCS
- mock/smartcard-mock.c
-)
-
+ mock/smartcard-mock.c)
SET(SMARTCARD_MOCK_CFLAGS "${CMAKE_C_FLAGS}" )
ADD_LIBRARY(${SMARTCARD_MOCK} SHARED ${SMARTCARD_MOCK_SRCS})
SET_TARGET_PROPERTIES(${SMARTCARD_MOCK} PROPERTIES
COMPILE_FLAGS ${SMARTCARD_MOCK_CFLAGS}
)
-INSTALL(TARGETS ${SMARTCARD_MOCK} DESTINATION ${LIB_INSTALL_LIB})
ADD_EXECUTABLE(${UNITTEST_NAME} ${UNITTEST_NAME}.cpp ${TC_SOURCES} )
TARGET_LINK_LIBRARIES(${UNITTEST_NAME}
@@ -48,4 +45,4 @@ TARGET_LINK_LIBRARIES(${UNITTEST_NAME}
capi-network-smartcard
)
-INSTALL(TARGETS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR})
+# INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR})
diff --git a/unittest/run_coverage.sh b/unittest/run_coverage.sh
new file mode 100755
index 0000000..38d5cb3
--- /dev/null
+++ b/unittest/run_coverage.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=..:.:$LD_LIBRARY_PATH
+pushd ../
+RootDir=$PWD
+popd
+
+unitTestFile=tct-smartcard-core
+if [ ! -x "./$unitTestFile" ]
+then
+ echo "$unitTestFile file does not exist!"
+ exit -1
+fi
+
+LD_PRELOAD=./libsmartcard-mock.so ./$unitTestFile
+
+CMakeDir=${RootDir}/CMakeFiles/capi-network-smartcard.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 . --exclude "/usr/lib/gcc/armv7l-tizen-linux-gnueabi/9.2.0/include/c++/*" -o cov.info
+ genhtml cov.info -o ${CoverageDir}
+ echo "Coverage test result created! [${CoverageDir}]"
+ else
+ echo "lcov does not exist!"
+ fi
+popd