diff options
author | jiyong.min <jiyong.min@samsung.com> | 2018-11-21 15:15:45 +0900 |
---|---|---|
committer | jiyong.min <jiyong.min@samsung.com> | 2018-11-21 15:48:09 +0900 |
commit | 7dc0afe20564102675919cb127f876b6d01c1c25 (patch) | |
tree | f0d9830bb8f3ac4f7db20b3fb923b036366dc75d | |
parent | f3fa0cefb4a1a3bb8b9a796384647a358605a800 (diff) | |
download | libmm-imgp-gstcs-7dc0afe20564102675919cb127f876b6d01c1c25.tar.gz libmm-imgp-gstcs-7dc0afe20564102675919cb127f876b6d01c1c25.tar.bz2 libmm-imgp-gstcs-7dc0afe20564102675919cb127f876b6d01c1c25.zip |
Adding initial structure for unittestsubmit/tizen/20181126.011146accepted/tizen/unified/20181127.073309
- It has only 1 testcases for mm_imgp of unittest
- It would be enabled by gtest build with '--define "gtests 1"'
Change-Id: I99bed90548e6ac53aa63db9b215956c6bc2bf417
-rw-r--r--[-rwxr-xr-x] | Makefile.am | 8 | ||||
-rw-r--r--[-rwxr-xr-x] | configure.ac | 20 | ||||
-rw-r--r--[-rwxr-xr-x] | packaging/libmm-imgp-gstcs.spec | 11 | ||||
-rw-r--r-- | unittest/Makefile.am | 14 | ||||
-rw-r--r-- | unittest/libmm_imgp_gstcs_unittest.cpp | 49 | ||||
-rw-r--r-- | unittest/libmm_imgp_gstcs_unittest.h | 26 |
6 files changed, 124 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am index a7d1b3c..942268e 100755..100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,10 +4,12 @@ ACLOCAL_AMFLAGS = -I m4 #aclocaldir = $(datadir)/aclocal SUBDIRS = \ - gstcs - + gstcs +if IS_TESTS +SUBDIRS += unittest +endif DIST_SUBDIRS = \ - gstcs + gstcs EXTRA_DIST = \ configure.ac autogen.sh depcomp diff --git a/configure.ac b/configure.ac index b0dd5e9..53a4e13 100755..100644 --- a/configure.ac +++ b/configure.ac @@ -10,6 +10,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign]) # Checks for programs. m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AC_PROG_CC +AC_PROG_CXX AC_PROG_LIBTOOL # Checks for libraries. @@ -59,8 +60,27 @@ PKG_CHECK_MODULES(GSTPBUTILS, gstreamer-pbutils-1.0 >= 1.2.0) AC_SUBST(GSTPBUTILS_CFLAGS) AC_SUBST(GSTPBUTILS_LIBS) +# for gtests +AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [unittest build]), + [ + case "${enableval}" in + yes) IS_TESTS=yes ;; + no) IS_TESTS=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-tests) ;; + esac + ], +[IS_TESTS=no]) +AM_CONDITIONAL([IS_TESTS], [test "x$IS_TESTS" = "xyes"]) + +AS_IF([test "x$enable_tests" = "xyes"], [ + PKG_CHECK_MODULES(GTESTS, gmock) + AC_SUBST(GTESTS_CFLAGS) + AC_SUBST(GTESTS_LIBS) +]) + AC_CONFIG_FILES([Makefile gstcs/Makefile + unittest/Makefile gstcs/mmutil-gstcs.pc ]) AC_OUTPUT diff --git a/packaging/libmm-imgp-gstcs.spec b/packaging/libmm-imgp-gstcs.spec index 8f785d5..a6ddc6e 100755..100644 --- a/packaging/libmm-imgp-gstcs.spec +++ b/packaging/libmm-imgp-gstcs.spec @@ -16,7 +16,9 @@ BuildRequires: pkgconfig(gstreamer-app-1.0) BuildRequires: pkgconfig(gstreamer-video-1.0) BuildRequires: pkgconfig(gstreamer-plugins-base-1.0) BuildRequires: pkgconfig(gstreamer-pbutils-1.0) - +%if 0%{?gtests:1} +BuildRequires: pkgconfig(gmock) +%endif %description Multimedia Framework Utility Library. @@ -41,7 +43,11 @@ export CFLAGS+=" -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow" export CFLAGS+=" -Wwrite-strings -Wswitch-default" CFLAGS="$CFLAGS -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" -D_MM_PROJECT_FLOATER" \ LDFLAGS+="-Wl,--rpath=%{_libdir} -Wl,--hash-style=both -Wl,--as-needed" \ +%if 0%{?gtests:1} +%configure --enable-tests +%else %configure +%endif make %{?jobs:-j%jobs} %install @@ -59,3 +65,6 @@ rm -rf %{buildroot} %manifest %{name}.manifest %defattr(-,root,root,-) %{_libdir}/*.so* +%if 0%{?gtests:1} +%{_bindir}/gtest* +%endif
\ No newline at end of file diff --git a/unittest/Makefile.am b/unittest/Makefile.am new file mode 100644 index 0000000..e588098 --- /dev/null +++ b/unittest/Makefile.am @@ -0,0 +1,14 @@ +# Unit tests +bin_PROGRAMS = gtest-libmm-imgp-gstcs + +gtest_libmm_imgp_gstcs_SOURCES = libmm_imgp_gstcs_unittest.cpp + +gtest_libmm_imgp_gstcs_CXXFLAGS = -I$(top_srcdir)/gstcs/include \ + $(GTESTS_CFLAGS) \ + -Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-cpp + +gtest_libmm_imgp_gstcs_DEPENDENCIES = $(top_srcdir)/gstcs/.libs/libmmutil_imgp_gstcs.la + +gtest_libmm_imgp_gstcs_LDADD = \ + $(GTESTS_LIBS) \ + $(top_srcdir)/gstcs/.libs/libmmutil_imgp_gstcs.la diff --git a/unittest/libmm_imgp_gstcs_unittest.cpp b/unittest/libmm_imgp_gstcs_unittest.cpp new file mode 100644 index 0000000..291c79c --- /dev/null +++ b/unittest/libmm_imgp_gstcs_unittest.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018 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 "libmm_imgp_gstcs_unittest.h" +#include "mm_util_gstcs.h" + +using ::testing::InitGoogleTest; +using ::testing::Test; +using ::testing::TestCase; + +class libmm_imgp_gstcs_Test : public ::testing::Test { + protected: + void SetUp() { + std::cout << "SetUp()" << std::endl; + } + + void TearDown() { + std::cout << "TearDown()" << std::endl; + } +}; + +TEST(libmm_imgp_gstcs_Test, mm_imgp_n) +{ + int ret = GSTCS_ERROR_INVALID_PARAMETER; + + ret = mm_imgp(NULL, NULL, NULL, IMGP_CSC); + EXPECT_EQ(ret, GSTCS_ERROR_INVALID_PARAMETER); +} + +int main(int argc, char **argv) +{ + InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); +} diff --git a/unittest/libmm_imgp_gstcs_unittest.h b/unittest/libmm_imgp_gstcs_unittest.h new file mode 100644 index 0000000..5728848 --- /dev/null +++ b/unittest/libmm_imgp_gstcs_unittest.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018 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 __LIB_MM_IMGP_GSTCS_UNITTEST_H__ +#define __LIB_MM_IMGP_GSTCS_UNITTEST_H__ + +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +#undef LOG_TAG +#define LOG_TAG "GTEST_LIBMM_IMGP_GSTCS" + +#endif /*__LIB_MM_IMGP_GSTCS_UNITTEST_H__*/ |