From 3a05784b7e8d34555b631ec3ca2fc9d67d609fd2 Mon Sep 17 00:00:00 2001 From: DongHun Kwak Date: Thu, 9 Jun 2022 09:41:01 +0900 Subject: [PATCH] feat: Create unittests package - Create unittests package Change-Id: I8e6b90951393778f4630457210523d85e0ea089a --- CMakeLists.txt | 4 +--- packaging/libslp-db-util.spec | 42 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f12f9e1..20c79b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,4 @@ INSTALL(FILES ${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) FILE(GLOB HEADERS include/*.h) INSTALL(FILES ${HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME}) -IF(BUILD_GCOV) - ADD_SUBDIRECTORY(tests) -ENDIF() +ADD_SUBDIRECTORY(tests) diff --git a/packaging/libslp-db-util.spec b/packaging/libslp-db-util.spec index a5273ac..8953422 100644 --- a/packaging/libslp-db-util.spec +++ b/packaging/libslp-db-util.spec @@ -12,11 +12,10 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(icu-i18n) BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(vconf) +BuildRequires: gtest-devel %if 0%{?gcov:1} -BuildRequires: gtest-devel BuildRequires: lcov -BuildRequires: tar %endif %description @@ -31,11 +30,15 @@ Devel package for libslp-db-util (devel) %if 0%{?gcov:1} %package gcov Summary: DB Utility(gcov) -Group: Application Framework/Database %description gcov libslp-db-util gcov objects %endif +%package unittests +Summary: %{name} unittests binary +%description unittests +unittests binary + %prep %setup -q cp %{SOURCE1001} ./%{name}.manifest @@ -63,6 +66,35 @@ mkdir -p "$gcno_obj_dir" find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';' %endif +cat << EOF > run-unittest.sh +#!/bin/sh +setup() { + echo "setup start" +} + +test_main() { + echo "test_main start" + /usr/bin/db-util-gtest +} + +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}/ +install -m 0755 ./tests/db-util-gtest %{buildroot}%{_bindir} + + %check %if 0%{?gcov:1} pushd tests @@ -91,3 +123,7 @@ genhtml %{name}.info -o out --legend --show-details %files gcov %{_datadir}/gcov/* %endif + +%files unittests +%{_bindir}/db-util-gtest +%{_bindir}/tizen-unittests/%{name}/run-unittest.sh -- 2.7.4