[FOR TEST] Added basic test codes for tpl_wayland_egl_thread. 65/134765/4
authorjoonbum.ko <joonbum.ko@samsung.com>
Thu, 20 Apr 2017 08:14:40 +0000 (17:14 +0900)
committerjoonbum.ko <joonbum.ko@samsung.com>
Wed, 21 Jun 2017 07:04:25 +0000 (16:04 +0900)
 - executable file name is 'glib_wl_test'
 - bindir = /usr/bin/
 - This is a temporary commit for test until integration.

Change-Id: Ie51a8ec1221cf890a4a6bafcd3edb5cb50f170bf
Signed-off-by: joonbum.ko <joonbum.ko@samsung.com>
Makefile
packaging/libtpl-egl.spec
src/tpl_wayland_egl_thread.c

index 1e105e4..e1ad5ad 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -73,7 +73,7 @@ ifneq ($(call is-feature-enabled,winsys_wl),)
 TPL_HEADERS += $(SRC_DIR)/tpl_worker_thread.h
 TPL_HEADERS += $(SRC_DIR)/tpl_wayland_egl_thread.h
 TPL_SRCS += $(SRC_DIR)/tpl_wayland_egl.c
-TPL_SRCS += $(SRC_DIR)/tpl_wayland_egl_thread.c
+#TPL_SRCS += $(SRC_DIR)/tpl_wayland_egl_thread.c
 TPL_SRCS += $(SRC_DIR)/tpl_wayland_vk_wsi.c
 TPL_SRCS += $(SRC_DIR)/tpl_gbm.c
 TPL_SRCS += $(SRC_DIR)/protocol/tizen-surface-protocol.c
@@ -102,7 +102,7 @@ endif
 OBJS = $(TPL_SRCS:%.c=%.o)
 
 ################################################################################
-all: $(BIN_NAME)
+all: $(BIN_NAME) glib_wl_test
 
 $(BIN_NAME) : $(OBJS) $(TPL_HEADERS)
        $(CC) -o $@ $(OBJS) -shared -Wl,-soname,$(SO_NAME) $(CFLAGS) $(LDFLAGS)
@@ -110,6 +110,10 @@ $(BIN_NAME) : $(OBJS) $(TPL_HEADERS)
 %.o: %.c
        $(CC) -c -o $@ $< $(CFLAGS)
 
+#Make for test file
+glib_wl_test : $(OBJS) $(TPL_HEADERS)
+       $(CC) -o glib_wl_test $(SRC_DIR)/tpl_wayland_egl_thread.c -O0 $(CFLAGS) -DWORKER_TEST_ONLY $(LDFLAGS)
+
 clean:
        find . -name "*.o" -exec rm -vf {} \;
        find . -name "*~" -exec rm -vf {} \;
@@ -117,6 +121,8 @@ clean:
 
 install: all
        cp -va $(BIN_NAME) $(INST_DIR)/
+       cp glib_wl_test $(bindir)/
 
 uninstall:
        rm -f $(INST_DIR)/$(BIN_NAME)
+       rm -f $(bindir)/glib_wl_test
index 2afd29a..0e87da9 100644 (file)
@@ -14,6 +14,7 @@
 %define ENABLE_DEFAULT_LOG     0
 %define ENABLE_DEFAULT_DUMP    0
 %define ENABLE_OBJECT_HASH_CHECK       1
+%define ENABLE_WORKER_TEST_ONLY 1
 
 #TPL INSTALL OPTION
 %define ENABLE_TPL_TEST        0
@@ -157,6 +158,10 @@ TPL_OPTIONS=${TPL_OPTIONS}-default_dump
 TPL_OPTIONS=${TPL_OPTIONS}-object_hash_check
 %endif
 
+%if "%{ENABLE_WORKER_TEST_ONLY}" == "1"
+TPL_OPTIONS=${TPL_OPTIONS}-worker_test
+%endif
+
 %ifarch %arm aarch64
 TPL_OPTIONS=${TPL_OPTIONS}-arm_atomic_operation
 %endif
@@ -203,12 +208,21 @@ mkdir -p %{buildroot}
 mkdir -p %{buildroot}%{_libdir}
 mkdir -p %{buildroot}%{_includedir}
 mkdir -p %{buildroot}%{_libdir}/pkgconfig
+%if "%{ENABLE_WORKER_TEST_ONLY}" == "1"
+mkdir -p %{buildroot}%{_bindir}
+%endif
 
 export TPL_VER_MAJOR=%{TPL_VER_MAJOR}
 export TPL_VER_MINOR=%{TPL_VER_MINOR}
 export TPL_RELEASE=%{TPL_RELEASE}
 
+%if "%{ENABLE_WORKER_TEST_ONLY}" == "1"
+make install libdir=%{buildroot}%{_libdir} bindir=%{buildroot}%{_bindir}
+%endif
+
+%if "%{ENABLE_WORKER_TEST_ONLY}" == "0"
 make install libdir=%{buildroot}%{_libdir}
+%endif
 ln -sf libtpl-egl.so.%{TPL_VER_FULL}   %{buildroot}%{_libdir}/libtpl-egl.so.%{TPL_VERSION}
 ln -sf libtpl-egl.so.%{TPL_VERSION}    %{buildroot}%{_libdir}/libtpl-egl.so.%{TPL_VER_MAJOR}
 ln -sf libtpl-egl.so.%{TPL_VER_MAJOR}  %{buildroot}%{_libdir}/libtpl-egl.so
@@ -257,6 +271,10 @@ cp -a %{_builddir}/%{buildsubdir}/tc/libs/gtest/googletest/LICENSE %{buildroot}/
 %{_libdir}/libtpl-egl.so.%{TPL_VERSION}
 %{_libdir}/libtpl-egl.so.%{TPL_VER_FULL}
 
+%if "%{ENABLE_WORKER_TEST_ONLY}" == "1"
+%{_bindir}/glib_wl_test
+%endif
+
 #tpl-test files
 %if "%{ENABLE_TPL_TEST}" == "1"
 %dir /opt/usr/tpl-test/
index a673373..ec2b434 100644 (file)
@@ -8,10 +8,36 @@
 #include <glib.h>
 #include <glib-unix.h>
 
+#ifdef WORKER_TEST_ONLY
+#include <glib.h>
+#include <sys/syscall.h>
+
+#define FONT_DEFAULT   "\033[0m"       /* for reset to default color */
+#define FONT_RED               "\033[31m"      /* for error logs */
+#define FONT_GREEN             "\033[32m"      /* for frontend API logs */
+#define FONT_MAGENTA   "\033[35m"      /* for debug logs */
+
+#define tpl_log_d(t, f, x...)                                                                                  \
+       fprintf(stderr, FONT_MAGENTA t FONT_DEFAULT "[(tid:%li)(%s)] " f "\n",\
+                       syscall(SYS_gettid), __func__, ##x)
+#define tpl_log_t(t, f, x...)                                                                                  \
+       fprintf(stderr, FONT_GREEN t FONT_DEFAULT "[(tid:%li)(%s)] " f "\n", \
+                       syscall(SYS_gettid), __func__, ##x)
+#define tpl_log_e(t, f, x...)                                                                                  \
+       fprintf(stderr, FONT_RED t "[(tid:%li)(%s)] " f FONT_DEFAULT "\n",      \
+                       syscall(SYS_gettid), __func__, ##x)
+
+#define TPL_ERR(f, x...)               tpl_log_e("[TPL_ERROR]", f, ##x)
+#define TPL_DEBUG_M(f, x...)   tpl_log_d("[MAIN]", f, ##x)
+#define TPL_DEBUG_T(f, x...)   tpl_log_t("[THREAD]", f, ##x)
+
+typedef struct _twe_thread                     twe_thread;
+typedef struct _twe_thread_context     twe_thread_context;
+#else
 #include "wayland-egl/wayland-egl-priv.h"
 #include "tpl_wayland_egl_thread.h"
 #include "tpl_utils.h"
-
+#endif
 
 typedef struct _twe_wl_disp_source     twe_wl_disp_source;
 typedef struct _twe_wl_surf_source     twe_wl_surf_source;
@@ -405,3 +431,69 @@ twe_thread_del_wl_surface(twe_thread* thread, struct wl_surface *surface)
        g_source_destroy(&source->gsource);
        g_source_unref(&source->gsource);
 }
+
+#ifdef WORKER_TEST_ONLY
+static void reg_global(void *data,
+                                          struct wl_registry *wl_registry,
+                                          uint32_t name,
+                                          const char *interface,
+                                          uint32_t version)
+{
+       TPL_DEBUG_M("reg_global: %s_v_%d\n", interface, version);
+}
+
+
+static void reg_global_remove(void *data,
+                                                         struct wl_registry *wl_registry,
+                                                         uint32_t name)
+{
+}
+
+
+static const struct wl_registry_listener registry_listener = {
+       reg_global,
+       reg_global_remove
+};
+
+void
+main(void)
+{
+       struct wl_display *display;
+       struct wl_registry *registry;
+       struct wl_event_queue *ev_queue;
+       int count = 0;
+
+       twe_thread *t_thread = NULL;
+
+       TPL_DEBUG_M("[[GLIB_WL_THREAD_TEST]]");
+
+       /*Create the twe_thread*/
+       t_thread = twe_thread_create();
+
+       /*Add the wl_display to twe_thread*/
+       display = wl_display_connect(NULL);
+       ev_queue = wl_display_create_queue(display);
+
+       wl_proxy_set_queue((struct wl_proxy *)display, ev_queue);
+
+       registry = wl_display_get_registry(display);
+       wl_registry_add_listener(registry, &registry_listener, NULL);
+
+       twe_thread_add_wl_display(t_thread, display);
+
+       while (1) {
+               sleep(1);
+               count++;
+
+               if (count == 3) {
+                       TPL_DEBUG_M("#### PRE_DEL");
+                       twe_thread_del_wl_display(t_thread, display);
+                       TPL_DEBUG_M("#### DEL");
+               }
+       }
+
+       twe_thread_destroy(t_thread);
+}
+
+#endif
+