test : add test module 68/135368/5
authorKichan Kwon <k_c.kwon@samsung.com>
Thu, 22 Jun 2017 05:41:36 +0000 (14:41 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Fri, 23 Jun 2017 08:07:51 +0000 (17:07 +0900)
- In current, it just writes a log

Change-Id: I33d856af450fb87517dd610d5f8dda89dd79ec69
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
CMakeLists.txt
packaging/resourced-headless.spec
src/test/resourced-headless-test.manifest [new file with mode: 0644]
src/test/test.c [new file with mode: 0644]

index 92b6a6c54211cf5b7fbe4272121fa28582d7796b..e535ea4790f87426d8f37064591ac284f072ab45 100644 (file)
@@ -56,3 +56,6 @@ BUILD_MODULE(${COMMON_LIBRARY} "common" "library")
 INCLUDE_DIRECTORIES(${${COMMON_LIBRARY}_DIR})
 
 BUILD_MODULE(${PKGNAME} "daemon" "binary")
+IF("${TEST_MODULE}" STREQUAL "ON")
+       BUILD_MODULE("${PKGNAME}-test" "test" "library")
+ENDIF()
index 391c4742ac32917aaa732f2239eac07cf0aa7f95..13ef131cf5f1b42798588c38075fac03ee9e83e0 100644 (file)
@@ -7,6 +7,8 @@ License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source101:  %{name}.service
 
+%define test_module    ON
+
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(glib-2.0)
@@ -23,6 +25,15 @@ Summary:     Common library
 %description common
 Common library for resourced-headless modules.
 
+%if %{test_module} == ON
+%package test
+Summary:       Test module
+Requires:   %{name} = %{version}-%{release}
+Requires:   %{name}-common = %{version}-%{release}
+%description test
+Test module for resourced-headless. It just writes log.
+%endif
+
 %prep
 %setup -q
 
@@ -40,7 +51,8 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %cmake . \
        -DFULLVER=%{version}    \
        -DMAJORVER=${MAJORVER}  \
-       -DLIB_DIR=%{_libdir}
+       -DLIB_DIR=%{_libdir}    \
+       -DTEST_MODULE=%{test_module}    \
 
 make %{?jobs:-j%jobs}
 
@@ -65,3 +77,10 @@ ln -s ../resourced-headless.service %{buildroot}%{_unitdir}/multi-user.target.wa
 %license LICENSE
 %manifest %{name}-common.manifest
 %{_libdir}/libresourced-headless-common.so*
+
+%if %{test_module} == ON
+%files test
+%license LICENSE
+%manifest %{name}-test.manifest
+%{_libdir}/libresourced-headless-test.so*
+%endif
diff --git a/src/test/resourced-headless-test.manifest b/src/test/resourced-headless-test.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/src/test/test.c b/src/test/test.c
new file mode 100644 (file)
index 0000000..43c3333
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * resourced-headless
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ *
+ * 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 <glib.h>
+#include <stdio.h>
+
+#include <log.h>
+#include <macro.h>
+#include <module.h>
+
+int __INIT__ test_init(void)
+{
+       _I("Test module is initialized!");
+
+       return 0;
+}
+
+int __EXIT__ test_exit(void)
+{
+       _I("Test module is finalized!");
+
+       return 0;
+}
+
+static struct module test_module = {
+       .name = "test",
+       .priority = MODULE_PRIORITY_NORMAL,
+       .init = test_init,
+       .exit = test_exit,
+};
+
+MODULE_REGISTER(&test_module)