Add initial structure for unittest 66/191366/4
authorSeokHoon Lee <andy.shlee@samsung.com>
Tue, 16 Oct 2018 08:59:30 +0000 (17:59 +0900)
committerSeokHoon Lee <andy.shlee@samsung.com>
Wed, 17 Oct 2018 08:44:58 +0000 (17:44 +0900)
- add initial version of unittest.

Signed-off-by: SeokHoon Lee <andy.shlee@samsung.com>
Change-Id: Ib295df2a23c0dbac59adc3e6a72f48d9a0e2aa1e

Makefile.am
configure.ac
packaging/libmm-wfd.spec
unittest/Makefile.am [new file with mode: 0644]
unittest/libmm_wfd_unittest.cpp [new file with mode: 0644]
unittest/libmm_wfd_unittest.h [new file with mode: 0644]

index 295c304..96b25a5 100755 (executable)
@@ -1,5 +1,8 @@
 ACLOCAL_AMFLAGS='-I m4'
 SUBDIRS = src
+if IS_TESTS
+SUBDIRS += unittest
+endif
 
 pcfiles = mm-wfd.pc
 pkgconfigdir = $(libdir)/pkgconfig
index 530f5ca..3a6946a 100644 (file)
@@ -11,6 +11,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 m4_pattern_allow([AM_PROG_AR])
 AM_PROG_AR
 AC_PROG_CC
+AC_PROG_CXX
 AC_PROG_LIBTOOL
 
 AC_FUNC_MMAP
@@ -22,6 +23,7 @@ AC_HEADER_STDBOOL
 AC_HEADER_STDC
 AC_HEADER_TIME
 AC_PROG_GCC_TRADITIONAL
+AC_SUBST(GCC_CXXFLAGS)
 
 # Checks for libraries.
 
@@ -101,6 +103,23 @@ PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, capi-system-info)
 AC_SUBST(CAPI_SYSTEM_INFO_CFLAGS)
 AC_SUBST(CAPI_SYSTEM_INFO_LIBS)
 
+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)
+])
+
 # for testsuite
 
 AC_ARG_ENABLE(sdk, AC_HELP_STRING([--enable-sdk], [sdk build]),
@@ -116,6 +135,7 @@ AM_CONDITIONAL([IS_SDK], [test "x$IS_SDK" = "xyes"])
 
 AC_CONFIG_FILES([Makefile
                src/Makefile
+               unittest/Makefile
                mm-wfd.pc
 ])
 AC_OUTPUT
index 35e2845..4b629ca 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-wfd
 Summary:    Multimedia Framework Wifi-Display Library
-Version:    0.2.237
+Version:    0.2.238
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
@@ -21,6 +21,10 @@ BuildRequires: pkgconfig(ecore-wl2)
 BuildRequires: pkgconfig(libtbm)
 BuildRequires: pkgconfig(libtzplatform-config)
 BuildRequires: pkgconfig(capi-system-info)
+%if 0%{?gtests:1}
+BuildRequires:  pkgconfig(gmock)
+%endif
+
 BuildRoot:  %{_tmppath}/%{name}-%{version}-build
 
 %description
@@ -56,7 +60,11 @@ LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--hash-style=both -Wl,--as-needed"; exp
 
 # always enable sdk build. This option should go away
 #  --enable-wfd-sink-uibc
-%configure --disable-static
+%configure \
+%if 0%{?gtests:1}
+--enable-tests \
+%endif
+--disable-static
 
 # Call make instruction with smp support
 make %{?jobs:-j%jobs}
@@ -81,6 +89,9 @@ rm -rf %{buildroot}
 %{_libdir}/*.so.*
 %manifest libmm-wfd.manifest
 %license LICENSE.APLv2.0
+%if 0%{?gtests:1}
+%{_bindir}/gtest-libmm-wfd
+%endif
 
 %files devel
 %defattr(-,root,root,-)
diff --git a/unittest/Makefile.am b/unittest/Makefile.am
new file mode 100644 (file)
index 0000000..20fadda
--- /dev/null
@@ -0,0 +1,12 @@
+bin_PROGRAMS = gtest-libmm-wfd
+
+gtest_libmm_wfd_SOURCES = libmm_wfd_unittest.cpp
+
+gtest_libmm_wfd_CXXFLAGS = -I$(top_srcdir)/src/include \
+                       $(GTESTS_CFLAGS)
+
+gtest_libmm_wfd_DEPENDENCIES = $(top_srcdir)/src/libmmfwfdsink.la
+
+gtest_libmm_wfd_LDADD = \
+                       $(GTESTS_LIBS) \
+                       $(top_srcdir)/src/libmmfwfdsink.la
diff --git a/unittest/libmm_wfd_unittest.cpp b/unittest/libmm_wfd_unittest.cpp
new file mode 100644 (file)
index 0000000..53ef29c
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_wfd_unittest.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+class libmm_wfd_Test : public ::testing::Test {
+       protected:
+               void SetUp() {
+                       std::cout << "SetUp()" << std::endl;
+               }
+
+               void TearDown() {
+                       std::cout << "TearDown()" << std::endl;
+               }
+};
+
+TEST(libmm_wfdTest, __wfd_get_fourcc_p1)
+{
+       EXPECT_EQ(1, 1);
+}
+
+int main(int argc, char **argv)
+{
+       InitGoogleTest(&argc, argv);
+
+       return RUN_ALL_TESTS();
+}
diff --git a/unittest/libmm_wfd_unittest.h b/unittest/libmm_wfd_unittest.h
new file mode 100644 (file)
index 0000000..adef7f1
--- /dev/null
@@ -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_WFD_UNITTEST_H__
+#define __LIB_MM_WFD_UNITTEST_H__
+
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#undef LOG_TAG
+#define LOG_TAG                "GTEST_LIBMM_WFD"
+
+#endif /*__LIB_MM_WFD_UNITTEST_H__*/