Add TEST UNIT 82/126282/1
authorjunkyu han <junkyu.han@samsung.com>
Fri, 21 Apr 2017 01:08:40 +0000 (10:08 +0900)
committerjunkyu han <junkyu.han@samsung.com>
Fri, 21 Apr 2017 01:08:40 +0000 (10:08 +0900)
Change-Id: I136feeafc3aa4ee7caccf44f9f3f2e87bec44b42

28 files changed:
.cproject
inc/app_log.h [new file with mode: 0644]
inc/test.h [new file with mode: 0644]
test/test_main.c [new file with mode: 0755]
test/unit/inc/unit.h [new file with mode: 0755]
test/unit/inc/unit_assert.h [new file with mode: 0755]
test/unit/inc/unit_group.h [new file with mode: 0755]
test/unit/inc/unit_log_buf.h [new file with mode: 0644]
test/unit/inc/unit_result.h [new file with mode: 0644]
test/unit/unit.c [new file with mode: 0755]
test/unit/unit_assert.c [new file with mode: 0644]
test/unit/unit_group.c [new file with mode: 0755]
test/unit/unit_log_buf.c [new file with mode: 0755]
test/unit/unit_result.c [new file with mode: 0644]
test/unit/unit_test/inc/unit_test_common.h [new file with mode: 0755]
test/unit/unit_test/unit_test_append_log/unit_test_append_log.c [new file with mode: 0755]
test/unit/unit_test/unit_test_append_log/unit_test_append_log.h [new file with mode: 0755]
test/unit/unit_test/unit_test_assert_test/unit_test_assert.c [new file with mode: 0755]
test/unit/unit_test/unit_test_assert_test/unit_test_assert.h [new file with mode: 0755]
test/unit/unit_test/unit_test_function_test/unit_test_function.c [new file with mode: 0755]
test/unit/unit_test/unit_test_function_test/unit_test_function.h [new file with mode: 0755]
test/unit/unit_test/unit_test_function_test/unit_test_group_function.c [new file with mode: 0755]
test/unit/unit_test/unit_test_function_test/unit_test_log_buf_function.c [new file with mode: 0755]
test/unit/unit_test/unit_test_function_test/unit_test_unit_function.c [new file with mode: 0755]
test/unit/unit_test/unit_test_group_test/unit_test_group.c [new file with mode: 0755]
test/unit/unit_test/unit_test_group_test/unit_test_group.h [new file with mode: 0755]
test/unit/unit_test/unit_test_group_test/unit_test_group_result.c [new file with mode: 0755]
test/unit/unit_test/unit_test_main.c [new file with mode: 0755]

index 54d3f61..54c337b 100644 (file)
--- a/.cproject
+++ b/.cproject
                                                        <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1861057934" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
                                                        <builder autoBuildTarget="all" buildPath="${workspace_loc:/volume_test}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1339551853" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.1725349702" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
-                                                       <tool command="arm-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1215488085" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
+                                                       <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1215488085" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
                                                                <option id="gnu.cpp.compiler.option.optimization.level.848884621" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
                                                                <option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1595035921" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.1246463915" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.compiler.option.2044840000" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="mobile-3.0-device.core.private.20170309_1_gcc49.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="mobile-3.0-emulator.core.private_llvm37.i386.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.767162556" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
@@ -72,7 +78,6 @@
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/geofence&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/harfbuzz&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/iotcon&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/maps&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/nsd/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/pkgmgr&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/rua/&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/service-adaptor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/shortcut&quot;"/>
                                                                        <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value=" -fPIE"/>
                                                                        <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.cpp.compiler.option.include.paths.813576415" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
                                                                </option>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.763014395" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
                                                        </tool>
-                                                       <tool command="arm-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.863750666" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
+                                                       <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.863750666" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
                                                                <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.134528377" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
                                                                <option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.1164092750" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.1170591259" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.c.compiler.option.1373925105" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="mobile-3.0-device.core.private.20170309_1_gcc49.armel.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="mobile-3.0-emulator.core.private_llvm37.i386.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1805063977" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efl-extension&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/efreet-1&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/EGL&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eina-1/eina&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/eio-1&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/freetype2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/geofence&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/gio-unix-2.0&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES2&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/GLES3&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/glib-2.0&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/harfbuzz&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/iotcon&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/json-glib-1.0&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/KHR&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/location&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/maps&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/media&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/nsd/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/pkgmgr&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/rua/&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/service-adaptor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/shortcut&quot;"/>
                                                                        <listOptionValue builtIn="false" value="${RS_COMPILER_MISC}"/>
                                                                        <listOptionValue builtIn="false" value=" -fPIE"/>
                                                                        <listOptionValue builtIn="false" value="--sysroot=&quot;${SBI_SYSROOT}&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="-mthumb"/>
                                                                </option>
                                                                <option id="gnu.c.compiler.option.include.paths.375531648" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1527905728" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
                                                        </tool>
                                                        <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1836033279" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
-                                                       <tool command="arm-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1759945560" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
+                                                       <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.1759945560" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.1982731969" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.766560304" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.887987567" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
                                                                        <additionalInput kind="additionalinput" paths="$(LIBS)"/>
                                                                </inputType>
                                                        </tool>
-                                                       <tool command="arm-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1106066415" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
+                                                       <tool command="i386-linux-gnueabi-as" id="org.tizen.nativeapp.tool.sbi.gnu.assembler.base.1106066415" name="Assembler" superClass="org.tizen.nativeapp.tool.sbi.gnu.assembler.base">
                                                                <inputType id="cdt.managedbuild.tool.gnu.assembler.input.725304663" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
                                                        </tool>
                                                        <tool id="org.tizen.nativecore.tool.fnmapgen.990542831" name="C FN-Map Generator" superClass="org.tizen.nativecore.tool.fnmapgen"/>
diff --git a/inc/app_log.h b/inc/app_log.h
new file mode 100644 (file)
index 0000000..2579a04
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef __APP_LOG_H__
+#define __APP_LOG_H__
+
+#include <dlog.h>
+
+#include "test.h"
+
+#ifndef  LOG_TAG
+#define LOG_TAG "VOLUME"
+#endif
+
+#ifndef __MODULE__
+#define __MODULE__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
+#endif
+
+#define LOG_(prio, tag, fmt, arg...) ({ dlog_print(prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); })
+
+#if (TEST_MODE == TEST_UNIT)
+#define TEST_APP_LOG_TAG "TEST_APP"
+#define TEST_UNIT_LOG_TAG "TEST_UNIT"
+#define __D(format, arg...) LOG_(DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define __I(format, arg...) LOG_(DLOG_INFO, LOG_TAG, format, ##arg)
+#define __E(format, arg...) LOG_(DLOG_ERROR, LOG_TAG, format, ##arg)
+#define __T(format, arg...) ({ dlog_print(DLOG_DEBUG, TEST_APP_LOG_TAG, format, ##arg); unit_write_log(format, ##arg); })
+#define __TU(format, arg...) LOG_(DLOG_DEBUG, TEST_UNIT_LOG_TAG, format, ##arg)
+#elif (TEST_MODE == TEST_APP)
+#define TEST_APP_LOG_TAG "TEST_APP"
+#define __D(format, arg...) ({ dlog_print(DLOG_DEBUG, LOG_TAG, format, ##arg); unit_write_log(format, ##arg); })
+#define __I(format, arg...) LOG_(DLOG_INFO, LOG_TAG, format, ##arg)
+#define __E(format, arg...) LOG_(DLOG_ERROR, LOG_TAG, format, ##arg)
+#define __T(format, arg...) LOG_(DLOG_DEBUG, TEST_APP_LOG_TAG, format, ##arg)
+#else
+#define __D(format, arg...) LOG_(DLOG_DEBUG, LOG_TAG, format, ##arg)
+#define __I(format, arg...) LOG_(DLOG_INFO, LOG_TAG, format, ##arg)
+#define __E(format, arg...) LOG_(DLOG_ERROR, LOG_TAG, format, ##arg)
+#endif
+#endif
diff --git a/inc/test.h b/inc/test.h
new file mode 100644 (file)
index 0000000..726d895
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __TEST_H__
+#define __TEST_H__
+
+#define TEST_OFF 0
+#define TEST_APP 1
+#define TEST_UNIT 2
+
+#define TEST_MODE TEST_OFF
+
+#endif
diff --git a/test/test_main.c b/test/test_main.c
new file mode 100755 (executable)
index 0000000..ccfef16
--- /dev/null
@@ -0,0 +1,79 @@
+#include "../inc/test.h"
+#if (TEST_MODE == TEST_APP)
+
+#include "control/app_control.h"
+
+#include "unit/inc/unit.h"
+#include "function_test/function_test.h"
+#include "feature_test/feature_test.h"
+
+#include <Elementary.h>
+
+static struct {
+       Ecore_Timer * feature_test_run_timer;
+} s_info = {
+       .feature_test_run_timer = NULL,
+};
+
+static Eina_Bool __run_timer_callback(void * data);
+
+static bool __create(void * data)
+{
+}
+
+static void __app_control(app_control_h app_control_handle, void * data)
+{
+       app_control(app_control_handle, data);
+}
+
+static void __resume(void * data)
+{
+       app_resume(data);
+
+       if (s_info.feature_test_run_timer) {
+               ecore_timer_del(s_info.feature_test_run_timer);
+               s_info.feature_test_run_timer = NULL;
+       }
+
+       s_info.feature_test_run_timer = ecore_timer_add(1, __run_timer_callback, NULL);
+}
+
+static void __pause(void * data)
+{
+       app_pause(data);
+}
+
+static void __terminate(void * data)
+{
+       app_terminate(data);
+}
+
+static Eina_Bool __run_timer_callback(void * data)
+{
+       s_info.feature_test_run_timer = NULL;
+       return ECORE_CALLBACK_CANCEL;
+}
+
+int main(int argc, char *argv[])
+{
+       unit_init();
+
+       ui_app_lifecycle_callback_s lifecycle_callback = {NULL, };
+
+       lifecycle_callback.create = __create;
+       lifecycle_callback.app_control = __app_control;
+       lifecycle_callback.resume = __resume;
+       lifecycle_callback.pause = __pause;
+       lifecycle_callback.terminate = __terminate;
+
+       int ret = ui_app_main(argc, argv, &lifecycle_callback, NULL);
+       if (ret != APP_ERROR_NONE) {
+               __T("app_main() is failed. err = %d", ret);
+       }
+
+       unit_fini();
+
+       return 0;
+}
+
+#endif
diff --git a/test/unit/inc/unit.h b/test/unit/inc/unit.h
new file mode 100755 (executable)
index 0000000..b79a9a9
--- /dev/null
@@ -0,0 +1,34 @@
+#ifndef __TEST_UNIT_H__
+#define __TEST_UNIT_H__
+
+#include "../../../inc/test.h"
+#if TEST_MODE
+
+#include "../../../inc/app_log.h"
+#include "unit_assert.h"
+#include "unit_result.h"
+#include "unit_log_buf.h"
+#include "unit_group.h"
+
+#include <app.h>
+
+#define GROUP_COUNT_MAX 100
+#define CASE_COUNT_MAX 100
+
+#define TEST_GROUP(group_name, group_starter, group_complete_cb) unit_add_group(group_name, group_starter, group_complete_cb)
+#define TEST_CASE(group, case_starter) { \
+                       bool is_passed = false; \
+                       __set_up(); \
+                       case_starter(&is_passed); \
+                       __tear_down(); \
+                       if (is_passed) unit_result_pass((group)->result); \
+                       else unit_result_fail((group)->result); \
+               }
+
+void unit_init(void);
+void unit_fini(void);
+void unit_add_group(const char * group_name, void(*group_starter)(unit_group_t * group), void(*group_complete_cb)(void));
+
+#endif
+
+#endif
diff --git a/test/unit/inc/unit_assert.h b/test/unit/inc/unit_assert.h
new file mode 100755 (executable)
index 0000000..e841210
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef __TEST_UNIT_ASSERT_H__
+#define __TEST_UNIT_ASSERT_H__
+
+#include "../../../inc/test.h"
+#if TEST_MODE
+
+#include <app.h>
+
+#define TEST_ASSERT_TRUE(value) { \
+               bool __ret = unit_assert_true((value), (__FUNCTION__), (__LINE__)); \
+               if (!__ret) { \
+                       return; \
+               } \
+       }
+#define TEST_ASSERT_EQUAL_INT(expected_value, input_value) { \
+               bool __ret = unit_assert_equal_int((expected_value), (input_value), (__FUNCTION__), (__LINE__)); \
+               if (!__ret) { \
+                       return; \
+               } \
+       }
+#define TEST_ASSERT_EQUAL_DOUBLE(expected_value, input_value) { \
+               bool __ret = unit_assert_equal_double((expected_value), (input_value), (__FUNCTION__), (__LINE__)); \
+               if (!__ret) { \
+                       return; \
+               } \
+       }
+#define TEST_ASSERT_EQUAL_STRING(expected_value, input_value) { \
+               bool __ret = unit_assert_equal_string((expected_value), (input_value), (__FUNCTION__), (__LINE__)); \
+               if (!__ret) { \
+                       return; \
+               } \
+       }
+#define TEST_ASSERT_EQUAL_OBJECT(expected_value, input_value, compare_func) { \
+               bool __ret = unit_assert_equal_object((expected_value), (input_value), (compare_func), (__FUNCTION__), (__LINE__)); \
+               if (!__ret) { \
+                       return; \
+               } \
+       }
+#define TEST_ASSERT_EQUAL_LOG(input_value) { \
+               bool __ret = unit_equal_log((input_value), (__FUNCTION__), (__LINE__)); \
+               if (!__ret) { \
+                       return; \
+               } \
+       }
+
+bool unit_assert_true(const int value, const char * func, const int line);
+bool unit_assert_equal_int(const int expected_value, const int input_value, const char * func, const int line);
+bool unit_assert_equal_double(const double expected_value, const double input_value, const char * func, const int line);
+bool unit_assert_equal_string(const char * expected_value, const char * input_value, const char * func, const int line);
+bool unit_assert_equal_object(const void * expected_value, const void * input_value,
+               bool(*compare_func)(const void * object1, const void * object2),
+               const char * func, const int line);
+
+#endif
+
+#endif
diff --git a/test/unit/inc/unit_group.h b/test/unit/inc/unit_group.h
new file mode 100755 (executable)
index 0000000..5703fbf
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef __TEST_UNIT_GROUP_H__
+#define __TEST_UNIT_GROUP_H__
+
+#include "../../../inc/test.h"
+#if TEST_MODE
+
+#include "unit_result.h"
+
+#include <app.h>
+
+typedef struct __unit_group_t {
+       char * name;
+       unit_result_t * result;
+       void(*finish)(struct __unit_group_t * group);
+       void(*group_complete_cb)(void);
+} unit_group_t;
+
+unit_group_t * unit_group_new(const char * name, void(*finish)(unit_group_t * group));
+void unit_group_del(unit_group_t * group);
+
+#endif
+
+#endif
diff --git a/test/unit/inc/unit_log_buf.h b/test/unit/inc/unit_log_buf.h
new file mode 100644 (file)
index 0000000..f37a473
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef __TEST_UNIT_LOG_BUF_H__
+#define __TEST_UNIT_LOG_BUF_H__
+
+#include "../../../inc/test.h"
+#if TEST_MODE
+
+#include <app.h>
+
+void unit_write_log(char *fmt, ...);
+void unit_clear_log(void);
+bool unit_equal_log(const char * input_value, const char * func, const int line);
+
+#endif
+
+#endif
diff --git a/test/unit/inc/unit_result.h b/test/unit/inc/unit_result.h
new file mode 100644 (file)
index 0000000..da42750
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef __TEST_RESULT_H__
+#define __TEST_RESULT_H__
+
+#include "../../../inc/test.h"
+#if TEST_MODE
+
+typedef struct __unit_result_t {
+       int ran_case;
+       int passed;
+       int failed;
+} unit_result_t;
+
+unit_result_t * unit_result_new(void);
+void unit_result_init(unit_result_t * result);
+void unit_result_del(unit_result_t * result);
+void unit_result_add(unit_result_t * dest, unit_result_t * src);
+void unit_result_fail(unit_result_t * result);
+void unit_result_pass(unit_result_t * result);
+
+#endif
+
+#endif
diff --git a/test/unit/unit.c b/test/unit/unit.c
new file mode 100755 (executable)
index 0000000..83a238c
--- /dev/null
@@ -0,0 +1,72 @@
+#include "../../inc/test.h"
+#if TEST_MODE
+
+#include "inc/unit.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+static struct {
+       unit_result_t * result;
+} s_info = {
+       .result = NULL,
+};
+
+static void __group_finish(unit_group_t * group);
+
+void unit_init(void)
+{
+       unit_clear_log();
+
+       __T("----------------------------------------------------------------------------");
+       __T("                    TEST START");
+       __T("----------------------------------------------------------------------------");
+
+       if (s_info.result == NULL)
+               s_info.result = unit_result_new();
+
+       unit_result_init(s_info.result);
+}
+
+void unit_fini(void)
+{
+       __T("----------------------------------------------------------------------------");
+       __T("%d case ran, %d passed, %d failed",
+                               s_info.result->ran_case, s_info.result->passed, s_info.result->failed);
+       __T("%s", s_info.result->failed ? "FAIL" : "OK");
+       __T("----------------------------------------------------------------------------");
+
+       unit_result_del(s_info.result);
+       s_info.result = NULL;
+}
+
+void unit_add_group(const char * group_name, void(*group_starter)(unit_group_t * group), void(*group_complete_cb)(void))
+{
+       unit_group_t * group = unit_group_new(group_name, __group_finish);
+       group->group_complete_cb = group_complete_cb;
+       group_starter(group);
+}
+
+static void __group_finish(unit_group_t * group)
+{
+       __T("##### [!!!%s!!!] Group[%s]: %d case ran, %d passed, %d failed",
+                       group->result->failed ? "FAIL" : "OK", group->name,
+                       group->result->ran_case, group->result->passed, group->result->failed);
+
+       unit_result_add(s_info.result, group->result);
+       group->group_complete_cb();
+}
+
+#if (TEST_MODE == TEST_UNIT)
+unit_result_t * __t__get_unit_result(void)
+{
+       if (s_info.result == NULL)
+               s_info.result = unit_result_new();
+
+       return s_info.result;
+}
+#endif
+
+#endif
diff --git a/test/unit/unit_assert.c b/test/unit/unit_assert.c
new file mode 100644 (file)
index 0000000..d515a4c
--- /dev/null
@@ -0,0 +1,61 @@
+#include "../../inc/test.h"
+#if TEST_MODE
+
+#include "inc/unit.h"
+
+#include <stdlib.h>
+#include <math.h>
+
+bool unit_assert_true(const int value, const char * func, const int line)
+{
+       if (value == 0) {
+               __T("%s (%d) FAIL", func, line);
+               return false;
+       }
+
+       return true;
+}
+
+bool unit_assert_equal_int(const int expected_value, const int input_value, const char * func, const int line)
+{
+       if (expected_value != input_value) {
+               __T("%s (%d) FAIL, Expected %d was %d", func, line, expected_value, input_value);
+               return false;
+       }
+
+       return true;
+}
+
+bool unit_assert_equal_double(const double expected_value, const double input_value, const char * func, const int line)
+{
+       if (fabs(expected_value - input_value) >= 1e-10) {
+               __T("%s (%d) FAIL, Expected %.10lf was %.10lf", func, line, expected_value, input_value);
+               return false;
+       }
+
+       return true;
+}
+
+bool unit_assert_equal_string(const char * expected_value, const char * input_value, const char * func, const int line)
+{
+       if (strcmp(expected_value, input_value)) {
+               __T("%s (%d) FAIL, Expected %s was %s", func, line, expected_value, input_value);
+               return false;
+       }
+
+       return true;
+}
+
+bool unit_assert_equal_object(const void * expected_value, const void * input_value,
+               bool(*compare_func)(const void * object1, const void * object2),
+               const char * func, const int line)
+{
+       if (!compare_func(expected_value, input_value)) {
+               __T("%s (%d) FAIL, Objects are not equal", func, line);
+               return false;
+       }
+
+       return true;
+}
+
+#endif
diff --git a/test/unit/unit_group.c b/test/unit/unit_group.c
new file mode 100755 (executable)
index 0000000..6f6ef5f
--- /dev/null
@@ -0,0 +1,29 @@
+#include "../../inc/test.h"
+#if TEST_MODE
+
+#include "inc/unit_group.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+unit_group_t * unit_group_new(const char * name, void(*finish)(unit_group_t * group))
+{
+       unit_group_t * group = (unit_group_t *)malloc(sizeof(unit_group_t));
+       group->name = strdup(name);
+       group->result = unit_result_new();
+       group->finish = finish;
+       group->group_complete_cb = NULL;
+
+       return group;
+}
+
+void unit_group_del(unit_group_t * group)
+{
+       if (group == NULL) return ;
+
+       unit_result_del(group->result);
+       free(group->name);
+       free(group);
+}
+
+#endif
diff --git a/test/unit/unit_log_buf.c b/test/unit/unit_log_buf.c
new file mode 100755 (executable)
index 0000000..8138f88
--- /dev/null
@@ -0,0 +1,55 @@
+#include "../../inc/test.h"
+#if TEST_MODE
+
+#include "inc/unit.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#define LOG_MAX_SIZE 4096
+
+static struct __unit_log_buf_s {
+       char log_buf[LOG_MAX_SIZE];
+} s_info = {
+       .log_buf = { 0, },
+};
+
+#define __fmt_to_string(buf, fmt) { \
+               va_list ap; \
+               va_start(ap, fmt); \
+               vsnprintf(buf, LOG_MAX_SIZE, fmt, ap); \
+               va_end(ap); \
+       }
+
+void unit_write_log(char *fmt, ...)
+{
+       char * buf = (char *)malloc(sizeof(char) * LOG_MAX_SIZE);
+       __fmt_to_string(buf, fmt);
+
+       strcat(s_info.log_buf, buf);
+       strcat(s_info.log_buf, "\n");
+
+       free(buf);
+}
+
+void unit_clear_log(void)
+{
+       memset(s_info.log_buf, 0, sizeof(s_info.log_buf));
+}
+
+bool unit_equal_log(const char * input_value, const char * func, const int line)
+{
+       if (strcmp(s_info.log_buf, input_value)) {
+               __T("%s (%d) FAIL, Expected %s was %s", func, line, input_value, s_info.log_buf);
+               return false;
+       }
+
+       return true;
+}
+
+#if (TEST_MODE == TEST_UNIT)
+char * __t__get_unit_log_buf(void) { return s_info.log_buf; }
+#endif
+
+#endif
diff --git a/test/unit/unit_result.c b/test/unit/unit_result.c
new file mode 100644 (file)
index 0000000..8bb7460
--- /dev/null
@@ -0,0 +1,49 @@
+#include "../../inc/test.h"
+#if TEST_MODE
+
+#include "inc/unit_result.h"
+
+#include <stdlib.h>
+
+unit_result_t * unit_result_new(void)
+{
+       unit_result_t * result = (unit_result_t *)malloc(sizeof(unit_result_t));
+       result->ran_case = 0;
+       result->passed = 0;
+       result->failed = 0;
+
+       return result;
+}
+
+void unit_result_init(unit_result_t * result)
+{
+       result->ran_case = 0;
+       result->passed = 0;
+       result->failed = 0;
+}
+
+void unit_result_del(unit_result_t * result)
+{
+       free(result);
+}
+
+void unit_result_add(unit_result_t * dest, unit_result_t * src)
+{
+       dest->ran_case += src->ran_case;
+       dest->passed += src->passed;
+       dest->failed += src->failed;
+}
+
+void unit_result_fail(unit_result_t * result)
+{
+       result->ran_case += 1;
+       result->failed += 1;
+}
+
+void unit_result_pass(unit_result_t * result)
+{
+       result->ran_case += 1;
+       result->passed += 1;
+}
+
+#endif
diff --git a/test/unit/unit_test/inc/unit_test_common.h b/test/unit/unit_test/inc/unit_test_common.h
new file mode 100755 (executable)
index 0000000..9bd86ea
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef __TEST_TEST_RUN_H__
+#define __TEST_TEST_RUN_H__
+
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+#include "../../../../inc/app_log.h"
+#include "../../inc/unit.h"
+
+#include <app.h>
+#include <string.h>
+
+#define __unit_test_run(before, after, func, fail_log) { \
+               s_info.log = (before); \
+               (func)(); \
+               if (s_info.log != (after)) { \
+                       __TU(fail_log); \
+                       return ; \
+               } \
+       }
+
+#endif
+
+#endif
diff --git a/test/unit/unit_test/unit_test_append_log/unit_test_append_log.c b/test/unit/unit_test/unit_test_append_log/unit_test_append_log.c
new file mode 100755 (executable)
index 0000000..081810c
--- /dev/null
@@ -0,0 +1,27 @@
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "unit_test_append_log.h"
+
+#include <stdio.h>
+#include <string.h>
+
+void unit_test_log_append_unit_init(char * buf)
+{
+       strcat(buf, "----------------------------------------------------------------------------\n");
+       strcat(buf, "                    TEST START\n");
+       strcat(buf, "----------------------------------------------------------------------------\n");
+}
+
+void unit_test_log_append_unit_fini(char * buf, unit_result_t * result)
+{
+       char str[1024] = { 0, };
+       strcat(buf, "----------------------------------------------------------------------------\n");
+       sprintf(str, "%d case ran, %d passed, %d failed\n",
+                               result->ran_case, result->passed, result->failed);
+       strcat(buf, str);
+       result->failed ? strcat(buf, "FAIL\n") : strcat(buf, "OK\n");
+       strcat(buf, "----------------------------------------------------------------------------\n");
+}
+
+#endif
diff --git a/test/unit/unit_test/unit_test_append_log/unit_test_append_log.h b/test/unit/unit_test/unit_test_append_log/unit_test_append_log.h
new file mode 100755 (executable)
index 0000000..aefcad4
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef __TEST_TEST_LOG_H__
+#define __TEST_TEST_LOG_H__
+
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+#include "../inc/unit_test_common.h"
+
+void unit_test_log_append_unit_init(char * buf);
+void unit_test_log_append_unit_fini(char * buf, unit_result_t * result);
+
+#endif
+
+#endif
diff --git a/test/unit/unit_test/unit_test_assert_test/unit_test_assert.c b/test/unit/unit_test/unit_test_assert_test/unit_test_assert.c
new file mode 100755 (executable)
index 0000000..2d8b0c7
--- /dev/null
@@ -0,0 +1,224 @@
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "unit_test_assert.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <memory.h>
+
+static struct __assert_s {
+       int log;
+} s_info = {
+       .log = 0,
+};
+
+typedef struct __object_t {
+       int a;
+       double b;
+       bool c;
+       void(*func_a)(void);
+       void(*func_b)(void);
+} object_t;
+
+extern char * __t__get_unit_log_buf(void);
+
+static void __unit_test_assert_bool_ok(void);
+static void __unit_test_assert_bool_fail(void);
+static void __unit_test_assert_int_ok(void);
+static void __unit_test_assert_int_fail(void);
+static void __unit_test_assert_double_ok(void);
+static void __unit_test_assert_double_fail(void);
+static void __unit_test_assert_string_ok(void);
+static void __unit_test_assert_string_fail(void);
+static void __unit_test_assert_object_ok(void);
+static void __unit_test_assert_object_fail(void);
+static void __unit_test_assert_log_ok(void);
+static void __unit_test_assert_log_fail(void);
+
+static bool __object_equal(const void * object1, const void * object2);
+
+void unit_test_assert(void)
+{
+       __unit_test_run_assert(0, 1, __unit_test_assert_int_ok);
+       __unit_test_run_assert(987654321, 987654321, __unit_test_assert_int_fail);
+       __unit_test_run_assert(0, 1, __unit_test_assert_bool_ok);
+       __unit_test_run_assert(987654321, 987654321, __unit_test_assert_bool_fail);
+       __unit_test_run_assert(0, 1, __unit_test_assert_double_ok);
+       __unit_test_run_assert(987654321, 987654321, __unit_test_assert_double_fail);
+       __unit_test_run_assert(0, 1, __unit_test_assert_string_ok);
+       __unit_test_run_assert(987654321, 987654321, __unit_test_assert_string_fail);
+       __unit_test_run_assert(0, 1, __unit_test_assert_object_ok);
+       __unit_test_run_assert(987654321, 987654321, __unit_test_assert_object_fail);
+       __unit_test_run_assert(0, 1, __unit_test_assert_log_ok);
+       __unit_test_run_assert(987654321, 987654321, __unit_test_assert_log_fail);
+}
+
+static void __unit_test_assert_bool_ok(void)
+{
+       TEST_ASSERT_TRUE(1);
+       TEST_ASSERT_TRUE(-1);
+       TEST_ASSERT_TRUE(987654321);
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_bool_fail(void)
+{
+       TEST_ASSERT_TRUE(0);
+       s_info.log = 0;
+}
+
+static void __unit_test_assert_int_ok(void)
+{
+       TEST_ASSERT_EQUAL_INT(1, 1);
+       TEST_ASSERT_EQUAL_INT(-1, -1);
+       TEST_ASSERT_EQUAL_INT(987654321, 987654321);
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_int_fail(void)
+{
+       TEST_ASSERT_EQUAL_INT(100, 100);
+       TEST_ASSERT_EQUAL_INT(1, 2);
+       s_info.log = 0;
+       TEST_ASSERT_EQUAL_INT(-1, -1);
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_double_ok(void)
+{
+       TEST_ASSERT_EQUAL_DOUBLE(1.0, 1.0);
+       TEST_ASSERT_EQUAL_DOUBLE(0.1, 0.1);
+       TEST_ASSERT_EQUAL_DOUBLE(0.000001, 0.000001);
+       TEST_ASSERT_EQUAL_DOUBLE(0.00000000001, 0.00000000002);
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_double_fail(void)
+{
+       TEST_ASSERT_EQUAL_DOUBLE(0.00000000001, 0.00000000002);
+       TEST_ASSERT_EQUAL_DOUBLE(0.0000000001, 0.0000000002);
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_string_ok(void)
+{
+       TEST_ASSERT_EQUAL_STRING("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+       TEST_ASSERT_EQUAL_STRING("abcdefg", "abcdefg");
+       char str1[] = "abcdefghijklmnopqrstuvwxyz";
+       char str2[] = "abcdefghijklmnopqrstuvwxyz";
+       TEST_ASSERT_EQUAL_STRING(str1, str2);
+       TEST_ASSERT_EQUAL_STRING(str1 + 5, str2 + 5);
+       char str3[] = "abcdefghijklmnopqrstuvwxyz";
+       char str4[] = "aabcdefghijklmnopqrstuvwxyz";
+       TEST_ASSERT_EQUAL_STRING(str3, str4+1);
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_string_fail(void)
+{
+       TEST_ASSERT_EQUAL_STRING("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
+
+       char str1[] = "abcdefghijklmnopqrstuvwxyz";
+       char str2[] = "abcdefghijklmnopqrstuvwxyz";
+       TEST_ASSERT_EQUAL_STRING(str1, str2 + 1);
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_object_ok(void)
+{
+       object_t a = { 0, 0, 0, 0, 0 };
+       object_t b = { 0, 0, 0, 0, 0 };
+       TEST_ASSERT_EQUAL_OBJECT(&a, &b, __object_equal);
+       a.a = 1;
+       b.a = 1;
+       TEST_ASSERT_EQUAL_OBJECT(&a, &b, __object_equal);
+       a.b = 0.00000000001;
+       b.b = 0.00000000002;
+       TEST_ASSERT_EQUAL_OBJECT(&a, &b, __object_equal);
+       a.func_a = __unit_test_assert_object_ok;
+       b.func_a = __unit_test_assert_object_ok;
+       TEST_ASSERT_EQUAL_OBJECT(&a, &b, __object_equal);
+
+       object_t * p_a = (object_t *)malloc(sizeof(object_t));
+       object_t * p_b = (object_t *)malloc(sizeof(object_t));
+       memset(p_a, 0, sizeof(object_t));
+       memset(p_b, 0, sizeof(object_t));
+       TEST_ASSERT_EQUAL_OBJECT(p_a, p_b, __object_equal);
+       p_a->a = 1;
+       p_b->a = 1;
+       p_a->b = 0.00000000001;
+       p_b->b = 0.00000000002;
+       p_a->func_a = __unit_test_assert_object_ok;
+       p_b->func_a = __unit_test_assert_object_ok;
+       p_a->c = 1;
+       p_b->c = 1;
+       TEST_ASSERT_EQUAL_OBJECT(p_a, p_b, __object_equal);
+
+       free(p_a);
+       free(p_b);
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_object_fail(void)
+{
+       object_t a = { 0, 0, 0, 0, 0 };
+       object_t b = { 0, 0, 0, 0, 0 };
+       TEST_ASSERT_EQUAL_OBJECT(&a, &b, __object_equal);
+       a.a = 1;
+       b.a = 1;
+       TEST_ASSERT_EQUAL_OBJECT(&a, &b, __object_equal);
+       a.b = 0.0000000001;
+       b.b = 0.0000000002;
+       TEST_ASSERT_EQUAL_OBJECT(&a, &b, __object_equal);
+       a.func_a = __unit_test_assert_object_ok;
+       b.func_a = __unit_test_assert_object_ok;
+       TEST_ASSERT_EQUAL_OBJECT(&a, &b, __object_equal);
+
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_log_ok(void)
+{
+       char * buf = __t__get_unit_log_buf();
+       strcpy(buf, "");
+       TEST_ASSERT_EQUAL_LOG("");
+
+       __T("assert");
+       TEST_ASSERT_EQUAL_LOG("assert\n");
+       __T("%s", "log");
+       TEST_ASSERT_EQUAL_LOG("assert\nlog\n");
+       __T("%d %.2lf ok", 99, 0.01);
+       TEST_ASSERT_EQUAL_LOG("assert\nlog\n99 0.01 ok\n");
+
+       s_info.log = 1;
+}
+
+static void __unit_test_assert_log_fail(void)
+{
+       char * buf = __t__get_unit_log_buf();
+       strcpy(buf, "");
+       TEST_ASSERT_EQUAL_LOG("");
+
+       __T("assert");
+       __T("%s", "log");
+       __T("%d %.2lf ok", 99, 0.01);
+       TEST_ASSERT_EQUAL_LOG("assert\nlog\n99 0.01 ok");
+
+       s_info.log = 1;
+}
+
+static bool __object_equal(const void * object1, const void * object2)
+{
+       object_t * a = (object_t *)object1;
+       object_t * b = (object_t *)object2;
+       if (a->a != b->a) return false;
+       if (fabs(a->b - b->b) >= 1e-10) return false;
+       if (a->c != b->c) return false;
+       if (a->func_a != b->func_a) return false;
+       if (a->func_b != b->func_b) return false;
+
+       return true;
+}
+
+#endif
diff --git a/test/unit/unit_test/unit_test_assert_test/unit_test_assert.h b/test/unit/unit_test/unit_test_assert_test/unit_test_assert.h
new file mode 100755 (executable)
index 0000000..1031a34
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef __TEST_TEST_UNIT_ASSERT_H__
+#define __TEST_TEST_UNIT_ASSERT_H__
+
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+#include "../inc/unit_test_common.h"
+
+#define __unit_test_run_assert(before, after, func) __unit_test_run(before, after, func, "!!!!!ASSERT MACRO TEST FAIL!!!!!")
+
+void unit_test_assert(void);
+
+#endif
+
+#endif
diff --git a/test/unit/unit_test/unit_test_function_test/unit_test_function.c b/test/unit/unit_test/unit_test_function_test/unit_test_function.c
new file mode 100755 (executable)
index 0000000..f06f089
--- /dev/null
@@ -0,0 +1,13 @@
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "unit_test_function.h"
+
+void unit_test_function(void)
+{
+       unit_test_unit_function();
+       unit_test_log_buf_function();
+       unit_test_group_function();
+}
+
+#endif
diff --git a/test/unit/unit_test/unit_test_function_test/unit_test_function.h b/test/unit/unit_test/unit_test_function_test/unit_test_function.h
new file mode 100755 (executable)
index 0000000..889cf67
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef __TEST_TEST_UNIT_FUNCTION_H__
+#define __TEST_TEST_UNIT_FUNCTION_H__
+
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "../inc/unit_test_common.h"
+#define __unit_test_run_function(before, after, func) __unit_test_run(before, after, func, "##########FUNCTION TEST FAIL##########")
+
+void unit_test_function(void);
+void unit_test_unit_function(void);
+void unit_test_log_buf_function(void);
+void unit_test_group_function(void);
+
+#endif
+
+#endif
diff --git a/test/unit/unit_test/unit_test_function_test/unit_test_group_function.c b/test/unit/unit_test/unit_test_function_test/unit_test_group_function.c
new file mode 100755 (executable)
index 0000000..3601753
--- /dev/null
@@ -0,0 +1,37 @@
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "unit_test_function.h"
+
+static struct {
+       int log;
+} s_info = {
+       .log = 0,
+};
+
+static void __unit_test_group_new(void);
+
+void unit_test_group_function(void)
+{
+       __unit_test_run_function(0, 1, __unit_test_group_new);
+}
+
+static void __group_finish(unit_group_t * group) {}
+
+static void __unit_test_group_new(void)
+{
+       unit_group_t * group = unit_group_new("group_1", __group_finish);
+       TEST_ASSERT_TRUE(group != NULL);
+       TEST_ASSERT_EQUAL_STRING("group_1", group->name);
+       TEST_ASSERT_EQUAL_INT(0, group->result->ran_case);
+       TEST_ASSERT_EQUAL_INT(0, group->result->passed);
+       TEST_ASSERT_EQUAL_INT(0, group->result->failed);
+       TEST_ASSERT_TRUE(group->finish != NULL)
+       TEST_ASSERT_TRUE(group->group_complete_cb == NULL)
+
+       unit_group_del(group);
+
+       s_info.log = 1;
+}
+
+#endif
diff --git a/test/unit/unit_test/unit_test_function_test/unit_test_log_buf_function.c b/test/unit/unit_test/unit_test_function_test/unit_test_log_buf_function.c
new file mode 100755 (executable)
index 0000000..5c43231
--- /dev/null
@@ -0,0 +1,50 @@
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "unit_test_function.h"
+
+extern char * __t__get_unit_log_buf(void);
+
+static struct {
+       int log;
+} s_info = {
+       .log = 0,
+};
+
+static void __unit_test_write_log(void);
+static void __unit_test_clear_log(void);
+
+void unit_test_log_buf_function(void)
+{
+       __unit_test_run_function(0, 1, __unit_test_write_log);
+       __unit_test_run_function(0, 1, __unit_test_clear_log);
+}
+
+static void __unit_test_write_log(void)
+{
+       char * buf = __t__get_unit_log_buf();
+       strcpy(buf, "");
+       TEST_ASSERT_EQUAL_STRING(buf, "");
+
+       unit_write_log("write");
+       unit_write_log("log");
+
+       TEST_ASSERT_EQUAL_STRING(buf, "write\nlog\n");
+
+       s_info.log = 1;
+}
+
+static void __unit_test_clear_log(void)
+{
+       char * buf = __t__get_unit_log_buf();
+       strcpy(buf, "clear");
+       TEST_ASSERT_EQUAL_STRING(buf, "clear");
+
+       unit_clear_log();
+
+       TEST_ASSERT_EQUAL_STRING(buf, "");
+
+       s_info.log = 1;
+}
+
+#endif
diff --git a/test/unit/unit_test/unit_test_function_test/unit_test_unit_function.c b/test/unit/unit_test/unit_test_function_test/unit_test_unit_function.c
new file mode 100755 (executable)
index 0000000..3c635fd
--- /dev/null
@@ -0,0 +1,134 @@
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "unit_test_function.h"
+#include "../unit_test_append_log/unit_test_append_log.h"
+
+extern unit_result_t * __t__get_unit_result(void);
+
+static struct {
+       int log;
+} s_info = {
+       .log = 0,
+};
+
+static void __unit_test_uint_result(void);
+static void __unit_test_unit_init(void);
+static void __unit_test_unit_fini(void);
+
+void unit_test_unit_function(void)
+{
+       __unit_test_run_function(0, 1, __unit_test_uint_result);
+       __unit_test_run_function(0, 1, __unit_test_unit_init);
+       __unit_test_run_function(0, 1, __unit_test_unit_fini);
+}
+
+static void __unit_test_uint_result(void)
+{
+       unit_result_t * result = unit_result_new();
+
+       TEST_ASSERT_EQUAL_INT(0, result->ran_case);
+       TEST_ASSERT_EQUAL_INT(0, result->passed);
+       TEST_ASSERT_EQUAL_INT(0, result->failed);
+
+       int i = 0;
+       for (i = 0; i < 3; i++) unit_result_pass(result);
+       for (i = 0; i < 2; i++) unit_result_fail(result);
+       for (i = 0; i < 3; i++) unit_result_pass(result);
+       for (i = 0; i < 2; i++) unit_result_fail(result);
+       for (i = 0; i < 3; i++) unit_result_pass(result);
+       for (i = 0; i < 2; i++) unit_result_fail(result);
+
+       TEST_ASSERT_EQUAL_INT(15, result->ran_case);
+       TEST_ASSERT_EQUAL_INT(9, result->passed);
+       TEST_ASSERT_EQUAL_INT(6, result->failed);
+
+       unit_result_t * result2 = unit_result_new();
+       for (i = 0; i < 9; i++) unit_result_pass(result2);
+       for (i = 0; i < 8; i++) unit_result_fail(result2);
+
+       TEST_ASSERT_EQUAL_INT(17, result2->ran_case);
+       TEST_ASSERT_EQUAL_INT(9, result2->passed);
+       TEST_ASSERT_EQUAL_INT(8, result2->failed);
+
+       unit_result_add(result, result2);
+
+       TEST_ASSERT_EQUAL_INT(32, result->ran_case);
+       TEST_ASSERT_EQUAL_INT(18, result->passed);
+       TEST_ASSERT_EQUAL_INT(14, result->failed);
+
+       unit_result_init(result);
+
+       TEST_ASSERT_EQUAL_INT(0, result->ran_case);
+       TEST_ASSERT_EQUAL_INT(0, result->passed);
+       TEST_ASSERT_EQUAL_INT(0, result->failed);
+
+       unit_result_del(result2);
+       unit_result_del(result);
+
+       s_info.log = 1;
+}
+
+static void __unit_test_unit_init(void)
+{
+       unit_clear_log();
+
+       int i = 0;
+       unit_result_t * result = __t__get_unit_result();
+       unit_result_init(result);
+
+       for (i = 0; i < 9; i++) unit_result_pass(result);
+       for (i = 0; i < 8; i++) unit_result_fail(result);
+       TEST_ASSERT_EQUAL_INT(8, result->failed);
+       TEST_ASSERT_EQUAL_INT(9, result->passed);
+       TEST_ASSERT_EQUAL_INT(17, result->ran_case);
+
+       unit_init();
+
+       TEST_ASSERT_EQUAL_INT(0, result->failed);
+       TEST_ASSERT_EQUAL_INT(0, result->passed);
+       TEST_ASSERT_EQUAL_INT(0, result->ran_case);
+
+       char buf[1024] = { 0, };
+       unit_test_log_append_unit_init(buf);
+       TEST_ASSERT_EQUAL_LOG(buf);
+
+       s_info.log = 1;
+}
+
+static void __unit_test_unit_fini(void)
+{
+       unit_init();
+       unit_clear_log();
+
+       int i = 0;
+       unit_result_t * result = __t__get_unit_result();
+       for (i = 0; i < 9; i++) unit_result_pass(result);
+       for (i = 0; i < 8; i++) unit_result_fail(result);
+       TEST_ASSERT_EQUAL_INT(8, result->failed);
+       TEST_ASSERT_EQUAL_INT(9, result->passed);
+       TEST_ASSERT_EQUAL_INT(17, result->ran_case);
+
+       char buf[1024] = { 0, };
+       unit_test_log_append_unit_fini(buf, result);
+
+       unit_fini();
+       TEST_ASSERT_EQUAL_LOG(buf);
+
+       unit_clear_log();
+
+       result = __t__get_unit_result();
+       for (i = 0; i < 99; i++) unit_result_pass(result);
+       for (i = 0; i < 88; i++) unit_result_fail(result);
+
+       buf[0] = 0;
+       unit_test_log_append_unit_fini(buf, result);
+
+       unit_fini();
+
+       TEST_ASSERT_EQUAL_LOG(buf);
+
+       s_info.log = 1;
+}
+
+#endif
diff --git a/test/unit/unit_test/unit_test_group_test/unit_test_group.c b/test/unit/unit_test/unit_test_group_test/unit_test_group.c
new file mode 100755 (executable)
index 0000000..186a7d5
--- /dev/null
@@ -0,0 +1,84 @@
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "unit_test_group.h"
+
+#include <efl_extension.h>
+
+static struct {
+       int log;
+       int current_group;
+       char group_name[3][128];
+       void(*group_starter_pool[3])(unit_group_t * group);
+} s_info = {
+       .log = 0,
+       .current_group = 0,
+       .group_name = {
+                       "unit_test_group_pass",
+                       "unit_test_group_fail",
+                       "",
+               },
+       .group_starter_pool = {
+                               unit_test_group_pass,
+                               unit_test_group_fail,
+                               NULL,
+               },
+};
+
+extern unit_result_t * __t__get_unit_result(void);
+
+static void __unit_test_pass_group(void);
+static void __unit_test_fail_group(void);
+static void __run_next_group(void);
+static void __complete_group_cb(void);
+
+void unit_test_group(void)
+{
+       s_info.current_group = 0;
+       __run_next_group();
+}
+
+static void __run_next_group(void)
+{
+       if (s_info.current_group >= 2) {
+               return ;
+       }
+
+       unit_init();
+       TEST_GROUP(s_info.group_name[s_info.current_group], s_info.group_starter_pool[s_info.current_group], __complete_group_cb);
+}
+
+static void __complete_group_cb(void)
+{
+       if (s_info.current_group == 0) {
+               __unit_test_run_group(0, 1, __unit_test_pass_group);
+       } else if (s_info.current_group == 1) {
+               __unit_test_run_group(0, 1, __unit_test_fail_group);
+       }
+
+       s_info.current_group += 1;
+
+       __run_next_group();
+}
+
+static void __unit_test_pass_group(void)
+{
+       unit_result_t * result = __t__get_unit_result();
+       TEST_ASSERT_EQUAL_INT(3, result->passed);
+       TEST_ASSERT_EQUAL_INT(0, result->failed);
+       TEST_ASSERT_EQUAL_INT(3, result->ran_case);
+
+       s_info.log = 1;
+}
+
+static void __unit_test_fail_group(void)
+{
+       unit_result_t * result = __t__get_unit_result();
+       TEST_ASSERT_EQUAL_INT(2, result->passed);
+       TEST_ASSERT_EQUAL_INT(1, result->failed);
+       TEST_ASSERT_EQUAL_INT(3, result->ran_case);
+
+       s_info.log = 1;
+}
+
+#endif
diff --git a/test/unit/unit_test/unit_test_group_test/unit_test_group.h b/test/unit/unit_test/unit_test_group_test/unit_test_group.h
new file mode 100755 (executable)
index 0000000..7c23c3f
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __TEST_TEST_UNIT_GROUP_H__
+#define __TEST_TEST_UNIT_GROUP_H__
+
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "../inc/unit_test_common.h"
+#define __unit_test_run_group(before, after, func) __unit_test_run(before, after, func, "!!!!!GROUP TEST FAIL!!!!!")
+
+void unit_test_group(void);
+void unit_test_group_pass(unit_group_t * group);
+void unit_test_group_fail(unit_group_t * group);
+
+#endif
+
+#endif
diff --git a/test/unit/unit_test/unit_test_group_test/unit_test_group_result.c b/test/unit/unit_test/unit_test_group_test/unit_test_group_result.c
new file mode 100755 (executable)
index 0000000..8c0bffc
--- /dev/null
@@ -0,0 +1,80 @@
+#include "../../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "unit_test_group.h"
+
+static struct {
+       int log;
+} s_info = {
+       .log = 0,
+};
+
+static void __set_up(void)
+{
+       s_info.log = 99;
+}
+
+static void __tear_down(void)
+{
+       TEST_ASSERT_EQUAL_INT(88, s_info.log);
+
+       s_info.log = 66;
+}
+
+static void __pass_case(bool * is_passed)
+{
+       TEST_ASSERT_EQUAL_INT(99, s_info.log);
+       s_info.log = 88;
+
+       TEST_ASSERT_TRUE(true);
+
+       *is_passed = true;
+}
+
+static void __fail_case(bool * is_passed)
+{
+       TEST_ASSERT_EQUAL_INT(99, s_info.log);
+       s_info.log = 88;
+
+       TEST_ASSERT_TRUE(false);
+
+       *is_passed = true;
+}
+
+void unit_test_group_pass(unit_group_t * group)
+{
+       s_info.log = 0;
+       TEST_ASSERT_TRUE(group != NULL);
+       TEST_ASSERT_EQUAL_INT(0, group->result->ran_case);
+       TEST_ASSERT_EQUAL_INT(0, group->result->passed);
+       TEST_ASSERT_EQUAL_INT(0, group->result->failed);
+
+       TEST_CASE(group, __pass_case);
+       TEST_ASSERT_EQUAL_INT(66, s_info.log);
+       TEST_CASE(group, __pass_case);
+       TEST_ASSERT_EQUAL_INT(66, s_info.log);
+       TEST_CASE(group, __pass_case);
+       TEST_ASSERT_EQUAL_INT(66, s_info.log);
+
+       group->finish(group);
+}
+
+void unit_test_group_fail(unit_group_t * group)
+{
+       s_info.log = 0;
+       TEST_ASSERT_TRUE(group != NULL);
+       TEST_ASSERT_EQUAL_INT(0, group->result->ran_case);
+       TEST_ASSERT_EQUAL_INT(0, group->result->passed);
+       TEST_ASSERT_EQUAL_INT(0, group->result->failed);
+
+       TEST_CASE(group, __pass_case);
+       TEST_ASSERT_EQUAL_INT(66, s_info.log);
+       TEST_CASE(group, __pass_case);
+       TEST_ASSERT_EQUAL_INT(66, s_info.log);
+       TEST_CASE(group, __fail_case);
+       TEST_ASSERT_EQUAL_INT(66, s_info.log);
+
+       group->finish(group);
+}
+
+#endif
diff --git a/test/unit/unit_test/unit_test_main.c b/test/unit/unit_test/unit_test_main.c
new file mode 100755 (executable)
index 0000000..fb51f03
--- /dev/null
@@ -0,0 +1,56 @@
+#include "../../../inc/test.h"
+#if (TEST_MODE == TEST_UNIT)
+
+#include "../inc/unit.h"
+#include "unit_test_assert_test/unit_test_assert.h"
+#include "unit_test_function_test/unit_test_function.h"
+#include "unit_test_group_test/unit_test_group.h"
+
+#include <app.h>
+#include <Elementary.h>
+
+static bool __create(void * data)
+{
+       unit_test_assert();
+       unit_test_function();
+       unit_test_group();
+
+       return false;
+}
+
+static void __app_control(app_control_h app_control_handle, void * data)
+{
+}
+
+static void __resume(void * data)
+{
+}
+
+static void __pause(void * data)
+{
+}
+
+static void __terminate(void * data)
+{
+       __TU("If there's no log, test is successful.");
+}
+
+int main(int argc, char *argv[])
+{
+       ui_app_lifecycle_callback_s lifecycle_callback = {NULL, };
+
+       lifecycle_callback.create = __create;
+       lifecycle_callback.app_control = __app_control;
+       lifecycle_callback.resume = __resume;
+       lifecycle_callback.pause = __pause;
+       lifecycle_callback.terminate = __terminate;
+
+       int ret = ui_app_main(argc, argv, &lifecycle_callback, NULL);
+       if (ret != APP_ERROR_NONE) {
+               __T("app_main() is failed. err = %d", ret);
+       }
+
+       return 0;
+}
+
+#endif