From: desperadok Date: Tue, 24 May 2022 10:20:21 +0000 (+0900) Subject: Added skeleton of unittest X-Git-Tag: submit/tizen/20220526.072840^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f76a063f01b3d169c0076c1da667dc809b994d9b;p=platform%2Fcore%2Fapi%2Fmediatool.git Added skeleton of unittest Change-Id: Iede6f9444ce2b09e1f7d1a6af29bbf6e7f365349 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ce80c73..37f7c9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,10 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "-I./include -I./include/headers ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -w") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +IF(MEDIA_TOOL_GTESTS_BUILD) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage") +ENDIF(MEDIA_TOOL_GTESTS_BUILD) + IF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DTARGET") ENDIF("${ARCH}" STREQUAL "arm") @@ -66,6 +70,9 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTAL IF(TIZEN_FEATURE_TESTSUITE) ADD_SUBDIRECTORY(test) ENDIF(TIZEN_FEATURE_TESTSUITE) +IF(MEDIA_TOOL_GTESTS_BUILD) +ADD_SUBDIRECTORY(unittest) +ENDIF(MEDIA_TOOL_GTESTS_BUILD) IF(UNIX) @@ -97,4 +104,3 @@ ADD_CUSTOM_COMMAND( ) ENDIF(UNIX) - diff --git a/packaging/capi-media-tool.spec b/packaging/capi-media-tool.spec index 8ad7a64..ff60f70 100644 --- a/packaging/capi-media-tool.spec +++ b/packaging/capi-media-tool.spec @@ -1,7 +1,7 @@ Name: capi-media-tool Summary: A Core API media tool library in Tizen Native API -Version: 0.1.52 -Release: 1 +Version: 0.1.53 +Release: 0 Group: Multimedia/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz @@ -10,6 +10,10 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(libtbm) +%if "%{gtests}" == "1" +BuildRequires: pkgconfig(mm-common) +BuildRequires: pkgconfig(gmock) +%endif %description A Core API media tool library in Tizen Native API @@ -52,7 +56,10 @@ export LDFLAGS+=" -lgcov" export CFLAGS+=" -DPATH_LIBDIR=\\\"%{_libdir}\\\"" MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ +%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ +%if "%{gtests}" == "1" + -DMEDIA_TOOL_GTESTS_BUILD=On \ +%endif %if "%{tizen_profile_name}" != "tv" -DTIZEN_FEATURE_TESTSUITE=On %else @@ -101,4 +108,3 @@ find . -name '*.gcno' -exec cp --parents '{}' "$gcno_obj_dir" ';' %files gcov %{_datadir}/gcov/obj/* %endif - diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100644 index 0000000..dd479c7 --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1,19 @@ + +LINK_DIRECTORIES(${CMAKE_BINARY_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) + +SET(GTEST_MEDIA_TOOL "gtest-media-tool") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpie") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie") + +FILE(GLOB GTEST_MEDIA_TOOL_SRCS *.cpp) + +PKG_CHECK_MODULES(GTEST_PKGS REQUIRED glib-2.0 dlog mm-common gmock) +INCLUDE_DIRECTORIES(${GTEST_PKGS_INCLUDE_DIRS}) +LINK_DIRECTORIES(${GTEST_PKGS_LIBRARY_DIRS}) + +ADD_EXECUTABLE(${GTEST_MEDIA_TOOL} ${GTEST_MEDIA_TOOL_SRCS}) +TARGET_LINK_LIBRARIES(${GTEST_MEDIA_TOOL} ${fw_name} ${GTEST_PKGS_LDFLAGS} -lgcov) + +INSTALL(TARGETS ${GTEST_MEDIA_TOOL} DESTINATION ${BINDIR}) diff --git a/unittest/media_tool_gtest.cpp b/unittest/media_tool_gtest.cpp new file mode 100644 index 0000000..77783b0 --- /dev/null +++ b/unittest/media_tool_gtest.cpp @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "media_tool_gtest.h" diff --git a/unittest/media_tool_gtest.h b/unittest/media_tool_gtest.h new file mode 100644 index 0000000..51bf85b --- /dev/null +++ b/unittest/media_tool_gtest.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MEDIATOOL_GTEST_H__ +#define __MEDIATOOL_GTEST_H__ + +#include "unittest.h" + +#endif /*__MEDIATOOL_GTEST_H__*/ diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp new file mode 100644 index 0000000..3cdc49c --- /dev/null +++ b/unittest/unittest.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "media_tool_gtest.h" +#include "media_format.h" + +using ::testing::InitGoogleTest; +using ::testing::Test; +using ::testing::TestCase; + +class MediaToolTest : public ::testing::Test { + protected: + void SetUp() { + std::cout << "SetUp()" << std::endl; + } + + void TearDown() { + std::cout << "TearDown()" << std::endl; + } +}; + +TEST(MediaToolTest, media_tool_gtest_create) +{ + media_format_h fmt; + int ret = media_format_create(&fmt); + ASSERT_EQ(ret, MEDIA_FORMAT_ERROR_NONE); + + media_format_unref(fmt); +} + +int main(int argc, char **argv) +{ + InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/unittest/unittest.h b/unittest/unittest.h new file mode 100644 index 0000000..04105f1 --- /dev/null +++ b/unittest/unittest.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __UNITTEST_H__ +#define __UNITTEST_H__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#endif /*__UNITTEST_H__*/