summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHayato Nakamura <hayato.nakamura@mail.toyota-td.jp>2013-11-29 19:01:03 +0900
committerHayato Nakamura <hayato.nakamura@mail.toyota-td.jp>2013-12-02 13:27:06 +0900
commit274fac46220d1f7cde855a5297f6f156558c0c0b (patch)
treef7079f9a23309b2e6c6fbcf2c9d3ceac3064287b
parent91fd3a9a3b432e8780c2620ef405f42ecc3f1db5 (diff)
downloadico-uxf-utilities-274fac46220d1f7cde855a5297f6f156558c0c0b.tar.gz
ico-uxf-utilities-274fac46220d1f7cde855a5297f6f156558c0c0b.tar.bz2
ico-uxf-utilities-274fac46220d1f7cde855a5297f6f156558c0c0b.zip
Change-Id: I6091cf7e662b7b19b94a8527b15ff470c6847c01 Signed-off-by: Hayato Nakamura <hayato.nakamura@mail.toyota-td.jp>
-rw-r--r--configure.ac10
-rw-r--r--include/ico_dbus_amb_efl.h40
-rw-r--r--include/ico_log.h37
-rw-r--r--packaging/ico-uxf-utilities.changes8
-rw-r--r--packaging/ico-uxf-utilities.spec15
-rw-r--r--src/Makefile.am3
-rw-r--r--src/ico_dbus_amb_efl.c498
-rw-r--r--src/ico_log.c2
-rw-r--r--test/Makefile.am13
-rwxr-xr-xtest/run_test_ico_log.sh445
-rw-r--r--test/tst_ico_log.c82
11 files changed, 1124 insertions, 29 deletions
diff --git a/configure.ac b/configure.ac
index 398b36c..42d3710 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
AC_PREREQ([2.68])
AC_INIT([ico-uxf-utilities],
- [0.9.01],
+ [0.9.03],
[https://BUG-REPORT-ADDRESS])
AC_CONFIG_HEADERS([config.h])
@@ -20,8 +20,12 @@ PKG_PROG_PKG_CONFIG()
PKG_CHECK_MODULES([GLIB], [glib-2.0])
PKG_CHECK_MODULES([DLOG], [dlog])
-OPT_CFLAGS="$GLIB_CFLAGS $DLOG_CFLAGS"
-OPT_LIBS="$GLIB_LIBS $DLOG_LIBS"
+PKG_CHECK_MODULES([ECORE], [ecore])
+PKG_CHECK_MODULES([ELEMENTARY], [elementary])
+PKG_CHECK_MODULES([EDBUS], [edbus])
+PKG_CHECK_MODULES([APPCORE_EFL], [appcore-efl])
+OPT_CFLAGS="$GLIB_CFLAGS $DLOG_CFLAGS $ECORE_CFLAGS $ELEMENTARY_CFLAGS $EDBUS_CFLAGS $APPCORE_EFL_CFLAGS"
+OPT_LIBS="$GLIB_LIBS $DLOG_LIBS $ECORE_LIBS $ELEMENTARY_LIBS $EDBUS_LIBS $APPCORE_EFL_LIBS"
AC_SUBST(OPT_CFLAGS)
AC_SUBST(OPT_LIBS)
diff --git a/include/ico_dbus_amb_efl.h b/include/ico_dbus_amb_efl.h
new file mode 100644
index 0000000..89a3a8e
--- /dev/null
+++ b/include/ico_dbus_amb_efl.h
@@ -0,0 +1,40 @@
+#ifndef _ICO_DBUS_AMB_EFL_H_
+#define _ICO_DBUS_AMB_EFL_H_
+#include <dbus/dbus.h>
+#include <sys/time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int dbus_type;
+
+union dbus_value_variant {
+ unsigned char yval;
+ dbus_bool_t bval;
+ dbus_int16_t i16val;
+ dbus_uint16_t ui16val;
+ dbus_int32_t i32val;
+ dbus_uint32_t ui32val;
+ dbus_int64_t i64val;
+ dbus_uint64_t ui64val;
+ double dval;
+ char *sval;
+};
+
+typedef void (*ico_dbus_amb_getcb)(const char *objectname, const char *property, dbus_type type, union dbus_value_variant value, void *user_data);
+typedef void (*ico_dbus_amb_noticb)(const char *objectname, const char *property, dbus_type type, union dbus_value_variant value, int sequence, struct timeval tv, void *user_data);
+
+int ico_dbus_amb_start(void);
+int ico_dbus_amb_end(void);
+int ico_dbus_amb_get(const char *objectname, const char *property, int zone, dbus_type type, ico_dbus_amb_getcb cb, void *user_data);
+//int ico_dbus_amb_set(const char *objectname, const char *property, int zone, dbus_type type, union dbus_value_variant value);
+int ico_dbus_amb_subscribe(const char *objectname, const char *property, int zone, dbus_type type, ico_dbus_amb_noticb cb, void *user_data);
+int ico_dbus_amb_unsubscribe(const char *objectname, const char *property, int zone);
+//int ico_dbus_amb_gethistory(const char *objectname, const char *property, int zone);
+//int ico_dbus_amb_getlist(void);
+
+#ifdef __cplusplus
+}
+#endif
+#endif //_ICO_DBUS_AMB_EFL_H_
diff --git a/include/ico_log.h b/include/ico_log.h
index e059da4..5f3b86c 100644
--- a/include/ico_log.h
+++ b/include/ico_log.h
@@ -36,21 +36,34 @@ extern "C" {
/**!< Maximum number of the log file */
/* Log output level */
-#define ICO_LOG_DEBUG 0x0080 /**!< Debug write */
-#define ICO_LOG_INFO 0x0040 /**!< Information */
-#define ICO_LOG_WARNING 0x0010 /**!< Warning */
-#define ICO_LOG_CRITICAL 0x0008 /**!< Critical */
-#define ICO_LOG_ERROR 0x0004 /**!< Error */
+#define ICO_LOG_LVL_PRF 0x0200 /**!< Performance */
+#define ICO_LOG_LVL_TRA 0x0100 /**!< Trace */
+#define ICO_LOG_LVL_DBG 0x0080 /**!< Debug write */
+#define ICO_LOG_LVL_INF 0x0040 /**!< Information */
+#define ICO_LOG_LVL_WRN 0x0010 /**!< Warning */
+#define ICO_LOG_LVL_CRI 0x0008 /**!< Critical */
+#define ICO_LOG_LVL_ERR 0x0004 /**!< Error */
/* Log output flush */
#define ICO_LOG_FLUSH 0x4000 /**!< Log outout with log flush */
#define ICO_LOG_NOFLUSH 0x2000 /**!< Log output without log flush */
+#define ICO_PRF(fmt,...) \
+{ \
+ ico_log_print(ICO_LOG_LVL_PRF, \
+ "%s> " fmt " (%s,%s:%d)\n", \
+ ico_get_str_cur_time("PRF"), \
+ ##__VA_ARGS__, \
+ __func__, \
+ __FILE__, \
+ __LINE__); \
+}
+
#define ICO_TRA(fmt,...) \
{ \
- ico_log_print(ICO_LOG_DEBUG, \
+ ico_log_print(ICO_LOG_LVL_TRA, \
"%s> " fmt " (%s,%s:%d)\n", \
- ico_get_str_cur_time("DBG"), \
+ ico_get_str_cur_time("TRA"), \
##__VA_ARGS__, \
__func__, \
__FILE__, \
@@ -59,7 +72,7 @@ extern "C" {
#define ICO_DBG(fmt,...) \
{ \
- ico_log_print(ICO_LOG_DEBUG, \
+ ico_log_print(ICO_LOG_LVL_DBG, \
"%s> " fmt " (%s,%s:%d)\n", \
ico_get_str_cur_time("DBG"), \
##__VA_ARGS__, \
@@ -70,7 +83,7 @@ extern "C" {
#define ICO_INF(fmt,...) \
{ \
- ico_log_print(ICO_LOG_INFO, \
+ ico_log_print(ICO_LOG_LVL_INF, \
"%s> " fmt " (%s,%s:%d)\n", \
ico_get_str_cur_time("INF"), \
##__VA_ARGS__, \
@@ -81,7 +94,7 @@ extern "C" {
#define ICO_WRN(fmt,...) \
{ \
- ico_log_print(ICO_LOG_WARNING, \
+ ico_log_print(ICO_LOG_LVL_WRN, \
"%s> " fmt " (%s,%s:%d)\n", \
ico_get_str_cur_time("WRN"), \
##__VA_ARGS__, \
@@ -92,7 +105,7 @@ extern "C" {
#define ICO_CRI(fmt,...) \
{ \
- ico_log_print(ICO_LOG_CRITICAL, \
+ ico_log_print(ICO_LOG_LVL_CRI, \
"%s> " fmt " (%s,%s:%d)\n", \
ico_get_str_cur_time("CRI"), \
##__VA_ARGS__, \
@@ -103,7 +116,7 @@ extern "C" {
#define ICO_ERR(fmt,...) \
{ \
- ico_log_print(ICO_LOG_ERROR, \
+ ico_log_print(ICO_LOG_LVL_ERR, \
"%s> " fmt " (%s,%s:%d)\n", \
ico_get_str_cur_time("ERR"), \
##__VA_ARGS__, \
diff --git a/packaging/ico-uxf-utilities.changes b/packaging/ico-uxf-utilities.changes
index 7628d95..4b0ec69 100644
--- a/packaging/ico-uxf-utilities.changes
+++ b/packaging/ico-uxf-utilities.changes
@@ -1,8 +1,6 @@
-* Tue Oct 08 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/tizen/20130919.204322@558ccea
-- 0.9.01 release
--- change version number from 0.2.x to 0.9.x
--- Fix for TIVI-1940 - /var/log/ico directory doesn't create when creating snapshot image
--- fox for - The largest-capacity limit of the log file does not work.
+* Fri Nov 29 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> ivi_oct_m2@01a342a
+- 0.9.04 release
+-- Addition: DBus API for AMB.
* Thu Sep 19 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/tizen/20130911.005417@250001b
- 0.2.04 release.
diff --git a/packaging/ico-uxf-utilities.spec b/packaging/ico-uxf-utilities.spec
index 4cb3f45..f9bf2dc 100644
--- a/packaging/ico-uxf-utilities.spec
+++ b/packaging/ico-uxf-utilities.spec
@@ -1,7 +1,7 @@
Name: ico-uxf-utilities
Summary: Common utilities for ico uifw
-Version: 0.9.01
-Release: 1.1
+Version: 0.9.04
+Release: 2.1
Group: Automotive/Libraries
License: Apache-2.0
URL: ""
@@ -10,8 +10,13 @@ Source0: %{name}-%{version}.tar.bz2
BuildRequires: pkgconfig(libwebsockets) >= 1.2
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(glib-2.0)
-Requires: /usr/bin/mkdir
-Requires: /usr/bin/chmod
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(elementary)
+BuildRequires: pkgconfig(edbus)
+BuildRequires: pkgconfig(appcore-efl)
+Requires(post): /usr/bin/mkdir
+Requires(post): /usr/bin/chmod
+Requires: automotive-message-broker >= 0.10.803
%description
common utilities for ico uifw.
@@ -41,6 +46,7 @@ make %{?_smp_mflags}
mkdir -p %{buildroot}/%{_includedir}/ico-util/
cp -f include/ico_uws.h %{buildroot}/%{_includedir}/ico-util/
cp -f include/ico_log.h %{buildroot}/%{_includedir}/ico-util/
+cp -f include/ico_dbus_amb_efl.h %{buildroot}/%{_includedir}/ico-util/
%post
/sbin/ldconfig
@@ -57,4 +63,5 @@ chmod 0777 %{_localstatedir}/log/ico/
%defattr(-,root,root,-)
%{_includedir}/ico-util/ico_uws.h
%{_includedir}/ico-util/ico_log.h
+%{_includedir}/ico-util/ico_dbus_amb_efl.h
%{_libdir}/libico-util*
diff --git a/src/Makefile.am b/src/Makefile.am
index 91e097e..9dcf6b4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,7 +5,8 @@ libico_util_la_LIBADD = $(OPT_LIBS) -lwebsockets
libico_util_la_LDFLAGS = -version-info 0:9:0
libico_util_la_SOURCES = \
ico_uws.c \
- ico_log.c
+ ico_log.c \
+ ico_dbus_amb_efl.c
AM_CFLAGS = $(GCC_CFLAGS)
AM_CPPFLAGS = $(GCC_CFLAGS) \
diff --git a/src/ico_dbus_amb_efl.c b/src/ico_dbus_amb_efl.c
new file mode 100644
index 0000000..be7bb39
--- /dev/null
+++ b/src/ico_dbus_amb_efl.c
@@ -0,0 +1,498 @@
+#include <Elementary.h>
+#include <E_DBus.h>
+#include <stdio.h>
+
+#include "ico_dbus_amb_efl.h"
+
+#define LATER1024
+
+/*============================================================================*/
+/* global API */
+/*============================================================================*/
+#if defined(__GNUC__) && __GNUC__ >= 4
+#define ICO_API __attribute__ ((visibility("default")))
+#else
+#define ICO_API
+#endif
+
+E_DBus_Connection *conn = NULL;
+static const char gBUSNAME[] = "org.automotive.message.broker";
+static const char gAMBManagerPath[] = "org.automotive.Manager";
+static const char gAMBManagerIf[] = "org.automotive.Manager";
+static const char gAMBInterface[] = "org.automotive.";
+static const char gAMBPROPERTIES_IF[] = "org.freedesktop.DBus.Properties";
+
+enum MethodType {
+ METHOD_SET,
+ METHOD_GET,
+ METHOD_GETHISTORY,
+ METHOD_SUBSCRIBE,
+ METHOD_UNSUBSCRIBE,
+};
+
+struct _method_args {
+ char *objectname;
+ char *property;
+ int zone;
+ dbus_type dtype;
+ union dbus_value_variant value;
+ ico_dbus_amb_getcb getcb;
+ ico_dbus_amb_noticb noticb;
+ enum MethodType mtype;
+ void *user_data;
+};
+
+struct _signal_handler {
+ char *objectname;
+ char *property;
+ int zone;
+ E_DBus_Signal_Handler *handler;
+ struct _method_args *args;
+ struct _signal_handler *next;
+};
+
+static struct _signal_handler *signal_handler_list = NULL;
+
+static int getproperty(struct _method_args *args);
+static void getproperty_cb(void *data, DBusMessage *msg, DBusError *error);
+static void set_cb(void *data, DBusMessage *msg, DBusError *error);
+static void get_cb(void *data, DBusMessage *msg, DBusError *error);
+static void subscribe_cb(void *data, DBusMessage *msg);
+
+ICO_API int ico_dbus_amb_start(void) {
+ int ret;
+ ret = e_dbus_init();
+ if (ret == 0) {
+ return -1;
+ }
+ conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+ if (conn == NULL) {
+ return -1;
+ }
+ return 0;
+}
+
+ICO_API int ico_dbus_amb_end(void) {
+ if (conn != NULL) {
+ e_dbus_connection_close(conn);
+ }
+ return 0;
+}
+
+ICO_API int ico_dbus_amb_get(const char *objectname, const char *property, int zone, dbus_type type, ico_dbus_amb_getcb cb, void *user_data) {
+ struct _method_args *args;
+
+ if (objectname == NULL || strlen(objectname) == 0) {
+ return -1;
+ }
+ if (property == NULL || strlen(property) == 0) {
+ return -1;
+ }
+ args = (struct _method_args*)malloc(sizeof(struct _method_args));
+ if (args == NULL) {
+ return -1;
+ }
+ args->objectname = strdup(objectname);
+ args->property = strdup(property);
+ args->getcb = cb;
+ args->zone = zone;
+ args->dtype = type;
+ args->mtype = METHOD_GET;
+ args->user_data = user_data;
+
+ return getproperty(args);
+}
+
+#if 0
+ICO_API int ico_dbus_amb_set(const char *objectname, const char *property, int zone, dbus_type type, union dbus_value_variant value) {
+ struct _method_args *args;
+
+ if (objectname == NULL || strlen(objectname) == 0) {
+ return -1;
+ }
+ if (property == NULL || strlen(property) == 0) {
+ return -1;
+ }
+ if (type == DBUST_TYPE_STRING && value.sval == NULL) {
+ return -1;
+ }
+
+ args = (struct _method_args*)malloc(sizeof(struct _method_args));
+ if (args == NULL) {
+ return -1;
+ }
+ args->objectname = strdup(objectname);
+ args->property = strdup(property);
+ args->zone = zone;
+ args->dtype = type;
+ args->mtype = METHOD_SET;
+ args->value = value;
+
+ return getproperty(args);
+}
+#endif
+
+ICO_API int ico_dbus_amb_subscribe(const char *objectname, const char *property, int zone, dbus_type type, ico_dbus_amb_noticb cb, void *user_data) {
+ struct _method_args *args;
+ struct _signal_handler *head;
+
+ if (objectname == NULL || strlen(objectname) == 0) {
+ return -1;
+ }
+ if (property == NULL || strlen(property) == 0) {
+ return -1;
+ }
+
+ if (signal_handler_list != NULL) {
+ head = signal_handler_list;
+ while (head != NULL) {
+ if (strcmp(head->property, property) == 0 && head->zone == zone && strcmp(head->objectname, objectname) == 0) {
+ return -2;
+ }
+ head = head->next;
+ }
+ }
+
+ args = (struct _method_args*)malloc(sizeof(struct _method_args));
+ if (args == NULL) {
+ return -1;
+ }
+ args->objectname = strdup(objectname);
+ args->property = strdup(property);
+ args->noticb = cb;
+ args->zone = zone;
+ args->dtype = type;
+ args->mtype = METHOD_SUBSCRIBE;
+ args->user_data = user_data;
+
+ return getproperty(args);
+}
+
+ICO_API int ico_dbus_amb_unsubscribe(const char *objectname, const char *property, int zone) {
+ struct _signal_handler *head, *prev;
+
+ if (objectname == NULL || strlen(objectname) == 0) {
+ return -1;
+ }
+ if (property == NULL || strlen(property) == 0) {
+ return -1;
+ }
+
+ if (signal_handler_list != NULL) {
+ prev = NULL;
+ head = signal_handler_list;
+ while (head != NULL) {
+ if (strcmp(head->property, property) == 0 && head->zone == zone && strcmp(head->objectname, objectname) == 0) {
+ if (prev == NULL) {
+ signal_handler_list = head->next;
+ }
+ else {
+ prev->next = head->next;
+ }
+ e_dbus_signal_handler_del(conn, head->handler);
+ free(head->objectname);
+ free(head->property);
+ free(head->args->objectname);
+ free(head->args->property);
+ free(head->args);
+ free(head);
+ return 0;
+ }
+ prev = head;
+ head = head->next;
+ }
+ }
+ return -2;
+}
+
+#if 0
+ICO_API int ico_dbus_amb_gethistory(const char *objectname, const char *property, int zone) {
+ return 0;
+}
+#endif
+
+int getproperty(struct _method_args *args) {
+ DBusMessage *msg;
+#ifdef LATER1024
+ msg = dbus_message_new_method_call(gBUSNAME, "/", gAMBManagerIf, "FindObjectForZone");
+ if (msg == NULL) {
+ return -1;
+ }
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &(args->objectname), DBUS_TYPE_INT32, &(args->zone), DBUS_TYPE_INVALID);
+#else
+ msg = dbus_message_new_method_call(gBUSNAME, "/", gAMBManagerIf, "findProperty");
+ if (msg == NULL) {
+ return -1;
+ }
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &(args->objectname), DBUS_TYPE_INVALID);
+#endif
+ e_dbus_message_send(conn, msg, getproperty_cb, -1, (void*)args);
+ dbus_message_unref(msg);
+ return 0;
+}
+
+void getproperty_cb(void *data, DBusMessage *msg, DBusError *error) {
+ struct _method_args *args;
+ DBusError e;
+ char *path;
+ DBusMessage *methodmsg;
+ char interface[128];
+ char *interfacep;
+ E_DBus_Signal_Handler *sighandler;
+ struct _signal_handler *_sig_handler, *head;
+ struct timeval tv;
+
+ if (!msg) {
+ if (error) {
+ fprintf(stderr, "%s: %s\n", error->name, error->message);
+ }
+ return;
+ }
+ dbus_error_init(&e);
+ args = (struct _method_args*)data;
+
+ dbus_message_get_args(msg, &e, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID);
+ //printf("Object Path:%s\n", path);
+ memset(interface, 0, sizeof(interface));
+ sprintf(interface, "%s%s", gAMBInterface, args->objectname);
+ interfacep = interface;
+
+ gettimeofday(&tv, NULL);
+ printf("%d.%06d LIB FINDPROPERTY %s %s\n", (int)tv.tv_sec, (int)tv.tv_usec, args->property, path);
+
+ switch(args->mtype) {
+ case METHOD_SET :
+ methodmsg = dbus_message_new_method_call(gBUSNAME, path, gAMBPROPERTIES_IF, "Set");
+ switch (args->dtype) {
+ case DBUS_TYPE_BYTE :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_BYTE, &(args->value.yval), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_BOOLEAN :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_BOOLEAN, &(args->value.bval), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_INT16 :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_INT16, &(args->value.i16val), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_UINT16 :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_UINT16, &(args->value.ui16val), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_INT32 :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_INT32, &(args->value.i32val), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_UINT32 :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_UINT32, &(args->value.ui32val), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_INT64 :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_INT64, &(args->value.i64val), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_UINT64 :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_UINT64, &(args->value.ui64val), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_DOUBLE :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_DOUBLE, &(args->value.dval), DBUS_TYPE_INVALID);
+ break;
+ case DBUS_TYPE_STRING :
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_STRING, &(args->value.sval), DBUS_TYPE_INVALID);
+ break;
+ default :
+ break;
+ }
+ e_dbus_message_send(conn, methodmsg, set_cb, -1, NULL);
+ dbus_message_unref(methodmsg);
+ free(args->objectname);
+ free(args->property);
+ free(args);
+ break;
+ case METHOD_GET :
+ methodmsg = dbus_message_new_method_call(gBUSNAME, path, gAMBPROPERTIES_IF, "Get");
+ dbus_message_append_args(methodmsg, DBUS_TYPE_STRING, &interfacep, DBUS_TYPE_STRING, &(args->property), DBUS_TYPE_INVALID);
+ e_dbus_message_send(conn, methodmsg, get_cb, -1, (void*)args);
+ dbus_message_unref(methodmsg);
+ break;
+ case METHOD_GETHISTORY :
+ break;
+ case METHOD_SUBSCRIBE :
+ _sig_handler = (struct _signal_handler*)malloc(sizeof(struct _signal_handler));
+ if (_sig_handler == NULL) {
+ free(args->objectname);
+ free(args->property);
+ free(args);
+ return;
+ }
+ sighandler = e_dbus_signal_handler_add(conn, gBUSNAME, path, gAMBPROPERTIES_IF, "PropertiesChanged", subscribe_cb, (void*)args);
+ _sig_handler->property = strdup(args->property);
+ _sig_handler->objectname = strdup(args->objectname);
+ _sig_handler->zone = args->zone;
+ _sig_handler->handler = sighandler;
+ _sig_handler->args = args;
+ _sig_handler->next = NULL;
+ if (signal_handler_list == NULL) {
+ signal_handler_list = _sig_handler;
+ }
+ else {
+ head = signal_handler_list;
+ while (head->next != NULL) {
+ head = head->next;
+ }
+ head->next = _sig_handler;
+ }
+ break;
+ case METHOD_UNSUBSCRIBE :
+ break;
+ default:
+ break;
+ }
+}
+
+void set_cb(void *data, DBusMessage *msg, DBusError *error) {
+ if (!msg) {
+ if (error) {
+ fprintf(stderr, "set_cb::DBusError [%s: %s]\n", error->name, error->message);
+ }
+ return;
+ }
+}
+
+void get_cb(void *data, DBusMessage *msg, DBusError *error) {
+ struct _method_args *args;
+ DBusError e;
+ union dbus_value_variant value;
+ DBusMessageIter iter, variant;
+
+ if (!msg) {
+ if (error) {
+ fprintf(stderr, "get_cb::DBusError [%s: %s]\n", error->name, error->message);
+ }
+ return;
+ }
+ if (!msg || !dbus_message_iter_init(msg, &iter)) {
+ return;
+ }
+ dbus_error_init(&e);
+ args = (struct _method_args*)data;
+ dbus_message_iter_recurse(&iter, &variant);
+
+ switch (args->dtype) {
+ case DBUS_TYPE_BYTE :
+ dbus_message_iter_get_basic(&variant, &value.yval);
+ break;
+ case DBUS_TYPE_BOOLEAN :
+ dbus_message_iter_get_basic(&variant, &value.bval);
+ break;
+ case DBUS_TYPE_INT16 :
+ dbus_message_iter_get_basic(&variant, &value.i16val);
+ break;
+ case DBUS_TYPE_UINT16 :
+ dbus_message_iter_get_basic(&variant, &value.ui16val);
+ break;
+ case DBUS_TYPE_INT32 :
+ dbus_message_iter_get_basic(&variant, &value.i32val);
+ break;
+ case DBUS_TYPE_UINT32 :
+ dbus_message_iter_get_basic(&variant, &value.ui32val);
+ break;
+ case DBUS_TYPE_INT64 :
+ dbus_message_iter_get_basic(&variant, &value.i64val);
+ break;
+ case DBUS_TYPE_UINT64 :
+ dbus_message_iter_get_basic(&variant, &value.ui64val);
+ break;
+ case DBUS_TYPE_DOUBLE :
+ dbus_message_iter_get_basic(&variant, &value.dval);
+ break;
+ case DBUS_TYPE_STRING :
+ dbus_message_iter_get_basic(&variant, &value.sval);
+ break;
+ default :
+ break;
+ }
+ args->getcb(args->objectname, args->property, args->dtype, value, args->user_data);
+ free(args->objectname);
+ free(args->property);
+ free(args);
+}
+
+static void subscribe_cb(void *data, DBusMessage *msg) {
+ struct _method_args *args;
+ DBusError e;
+ union dbus_value_variant value;
+ char *propertyname;
+ char *sequencename;
+ char *timename;
+ int sequenceno;
+ double time;
+ struct timeval tv;
+ int time_s;
+ int time_ms;
+ DBusMessageIter iter, dict, entry, variant;
+
+ if (!msg || !dbus_message_iter_init(msg, &iter)) {
+ return;
+ }
+ dbus_error_init(&e);
+ args = (struct _method_args*)data;
+
+ dbus_message_iter_next(&iter);
+ dbus_message_iter_recurse(&iter, &dict);
+ dbus_message_iter_recurse(&dict, &entry);
+ dbus_message_iter_get_basic(&entry, &propertyname);
+ if (strcmp(args->property, propertyname) != 0) {
+ return;
+ }
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &variant);
+
+ switch (args->dtype) {
+ case DBUS_TYPE_BYTE :
+ dbus_message_iter_get_basic(&variant, &value.yval);
+ break;
+ case DBUS_TYPE_BOOLEAN :
+ dbus_message_iter_get_basic(&variant, &value.bval);
+ break;
+ case DBUS_TYPE_INT16 :
+ dbus_message_iter_get_basic(&variant, &value.i16val);
+ break;
+ case DBUS_TYPE_UINT16 :
+ dbus_message_iter_get_basic(&variant, &value.ui16val);
+ break;
+ case DBUS_TYPE_INT32 :
+ dbus_message_iter_get_basic(&variant, &value.i32val);
+ break;
+ case DBUS_TYPE_UINT32 :
+ dbus_message_iter_get_basic(&variant, &value.ui32val);
+ break;
+ case DBUS_TYPE_INT64 :
+ dbus_message_iter_get_basic(&variant, &value.i64val);
+ break;
+ case DBUS_TYPE_UINT64 :
+ dbus_message_iter_get_basic(&variant, &value.ui64val);
+ break;
+ case DBUS_TYPE_DOUBLE :
+ dbus_message_iter_get_basic(&variant, &value.dval);
+ break;
+ case DBUS_TYPE_STRING :
+ dbus_message_iter_get_basic(&variant, &value.sval);
+ break;
+ default :
+ break;
+ }
+ dbus_message_iter_next(&dict);
+ dbus_message_iter_recurse(&dict, &entry);
+ dbus_message_iter_get_basic(&entry, &sequencename);
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &variant);
+ dbus_message_iter_get_basic(&variant, &sequenceno);
+ dbus_message_iter_next(&dict);
+ dbus_message_iter_recurse(&dict, &entry);
+ dbus_message_iter_get_basic(&entry, &timename);
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &variant);
+ dbus_message_iter_get_basic(&variant, &time);
+ //printf("Subscribe %s, %s:%d, %s:%f\n", propertyname, sequencename, sequenceno, timename, time);
+ time_s = (int)time;
+ time -= time_s;
+ time_ms = time * 1000000;
+ tv.tv_sec = time_s;
+ tv.tv_usec = time_ms;
+ args->noticb(args->objectname, args->property, args->dtype, value, sequenceno, tv, args->user_data);
+}
diff --git a/src/ico_log.c b/src/ico_log.c
index 3b8bf2c..a9c31d2 100644
--- a/src/ico_log.c
+++ b/src/ico_log.c
@@ -63,7 +63,7 @@ static char log_prog[32] = {0,}; /*!< name of output source module */
ICO_API void
ico_log_print(int level, const char *fmt, ...)
{
- if (log_level < level) {
+ if (!(log_level & level)) {
return;
}
va_list list;
diff --git a/test/Makefile.am b/test/Makefile.am
index 9f99442..0258ed0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -9,10 +9,11 @@ noinst_PROGRAMS = \
tst_ico_uws_client \
tst_ico_uws_server \
tst_ico_uws_multi_client \
- tst_ico_uws_multi_server
+ tst_ico_uws_multi_server \
+ tst_ico_log
check_LTLIBRARIES = $(TESTS)
-check_PROGRAMS = tst_ico_uws_client tst_ico_uws_server tst_ico_uws_multi_client tst_ico_uws_multi_server
+check_PROGRAMS = tst_ico_uws_client tst_ico_uws_server tst_ico_uws_multi_client tst_ico_uws_multi_server tst_ico_log
test_common_lib = -lwebsockets
test_target_lib = ../src/.libs/libico-util.so
@@ -33,5 +34,11 @@ tst_ico_uws_multi_server_SOURCES = tst_ico_uws_multi_server.c
tst_ico_uws_multi_server_CFLAGS = -I../include $(OPT_CFLAGS)
tst_ico_uws_multi_server_LDADD = $(test_target_lib) $(OPT_LIBS) $(test_common_lib)
-EXTRA_DIST = run_test.sh
+# tst_ico_log
+test_ico_log_target_lib = ../src/.libs/libico-log.so
+tst_ico_log_SOURCES = tst_ico_log.c
+tst_ico_log_CFLAGS = -I../include $(OPT_CFLAGS)
+tst_ico_log_LDADD = $(test_target_lib) $(OPT_LIBS)
+
+EXTRA_DIST = run_test.sh run_test_ico_log.sh
diff --git a/test/run_test_ico_log.sh b/test/run_test_ico_log.sh
new file mode 100755
index 0000000..3512a90
--- /dev/null
+++ b/test/run_test_ico_log.sh
@@ -0,0 +1,445 @@
+#!/bin/bash
+
+rm -f /var/log/ico/test_result_ico_log_*.log*
+rm -fr test_result_ico_log
+
+export LD_LIBRARY_PATH=../src/.libs:$LD_LIBRARY_PATH
+# N P T D I W C E
+# o x x x x x x x
+# x o x x x x x x
+# x x o x x x x x
+# x x x o x x x x
+# x x x x o x x x
+# x x x x x o x x
+# x x x x x x o x
+# x x x x x x x o
+./tst_ico_log none
+./tst_ico_log performance
+./tst_ico_log trace
+./tst_ico_log debug
+./tst_ico_log info
+./tst_ico_log warning
+./tst_ico_log critical
+./tst_ico_log error
+
+# N P T D I W C E
+# o o o o o o o o
+# o x o o o o o o
+# o o x o o o o o
+# o o o x o o o o
+# o o o o x o o o
+# o o o o o x o o
+# o o o o o o x o
+# o o o o o o o x
+./tst_ico_log performance,trace,debug,info,warning,critical,error
+./tst_ico_log trace,debug,info,warning,critical,error
+./tst_ico_log performance,debug,info,warning,critical,error
+./tst_ico_log performance,trace,info,warning,critical,error
+./tst_ico_log performance,trace,debug,warning,critical,error
+./tst_ico_log performance,trace,debug,info,critical,error
+./tst_ico_log performance,trace,debug,info,warning,error
+./tst_ico_log performance,trace,debug,info,warning,critical
+
+LOG_N=/var/log/ico/test_result_ico_log_00000000.log
+LOG_P=/var/log/ico/test_result_ico_log_00000200.log
+LOG_T=/var/log/ico/test_result_ico_log_00000100.log
+LOG_D=/var/log/ico/test_result_ico_log_00000080.log
+LOG_I=/var/log/ico/test_result_ico_log_00000040.log
+LOG_W=/var/log/ico/test_result_ico_log_00000010.log
+LOG_C=/var/log/ico/test_result_ico_log_00000008.log
+LOG_E=/var/log/ico/test_result_ico_log_00000004.log
+LOG_PTDIWCE=/var/log/ico/test_result_ico_log_000003DC.log
+LOG_TDIWCE=/var/log/ico/test_result_ico_log_000001DC.log
+LOG_PDIWCE=/var/log/ico/test_result_ico_log_000002DC.log
+LOG_PTIWCE=/var/log/ico/test_result_ico_log_0000035C.log
+LOG_PTDWCE=/var/log/ico/test_result_ico_log_0000039C.log
+LOG_PTDICE=/var/log/ico/test_result_ico_log_000003CC.log
+LOG_PTDIWE=/var/log/ico/test_result_ico_log_000003D4.log
+LOG_PTDIWC=/var/log/ico/test_result_ico_log_000003D8.log
+
+######
+LOG=$LOG_N
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ ! $RET_P -eq 0 -a ! $RET_T -eq 0 -a ! $RET_D -eq 0 -a ! $RET_I -eq 0 -a ! $RET_W -eq 0 -a ! $RET_C -eq 0 -a ! $RET_E -eq 0 ]
+then
+ echo -e "test_case level=none : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=none : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_P
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ $RET_P -eq 0 -a ! $RET_T -eq 0 -a ! $RET_D -eq 0 -a ! $RET_I -eq 0 -a ! $RET_W -eq 0 -a ! $RET_C -eq 0 -a ! $RET_E -eq 0 ]
+then
+ echo -e "test_case level=performance only : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=performance only : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_T
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ ! $RET_P -eq 0 -a $RET_T -eq 0 -a ! $RET_D -eq 0 -a ! $RET_I -eq 0 -a ! $RET_W -eq 0 -a ! $RET_C -eq 0 -a ! $RET_E -eq 0 ]
+then
+ echo -e "test_case level=trace only : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=trace only : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_D
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ ! $RET_P -eq 0 -a ! $RET_T -eq 0 -a $RET_D -eq 0 -a ! $RET_I -eq 0 -a ! $RET_W -eq 0 -a ! $RET_C -eq 0 -a ! $RET_E -eq 0 ]
+then
+ echo -e "test_case level=debug only : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=debug only : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_I
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ ! $RET_P -eq 0 -a ! $RET_T -eq 0 -a ! $RET_D -eq 0 -a $RET_I -eq 0 -a ! $RET_W -eq 0 -a ! $RET_C -eq 0 -a ! $RET_E -eq 0 ]
+then
+ echo -e "test_case level=info only : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=info only : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_W
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ ! $RET_P -eq 0 -a ! $RET_T -eq 0 -a ! $RET_D -eq 0 -a ! $RET_I -eq 0 -a $RET_W -eq 0 -a ! $RET_C -eq 0 -a ! $RET_E -eq 0 ]
+then
+ echo -e "test_case level=warning only : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=warning only : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_C
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ ! $RET_P -eq 0 -a ! $RET_T -eq 0 -a ! $RET_D -eq 0 -a ! $RET_I -eq 0 -a ! $RET_W -eq 0 -a $RET_C -eq 0 -a ! $RET_E -eq 0 ]
+then
+ echo -e "test_case level=critical only : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=critical only : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_E
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ ! $RET_P -eq 0 -a ! $RET_T -eq 0 -a ! $RET_D -eq 0 -a ! $RET_I -eq 0 -a ! $RET_W -eq 0 -a ! $RET_C -eq 0 -a $RET_E -eq 0 ]
+then
+ echo -e "test_case level=error only : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=error only : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_PTDIWCE
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ $RET_P -eq 0 -a $RET_T -eq 0 -a $RET_D -eq 0 -a $RET_I -eq 0 -a $RET_W -eq 0 -a $RET_C -eq 0 -a $RET_E -eq 0 ]
+then
+ echo -e "test_case level=all : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level= : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_TDIWCE
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ ! $RET_P -eq 0 -a $RET_T -eq 0 -a $RET_D -eq 0 -a $RET_I -eq 0 -a $RET_W -eq 0 -a $RET_C -eq 0 -a $RET_E -eq 0 ]
+then
+ echo -e "test_case level=performance off : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=performance off : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_PDIWCE
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ $RET_P -eq 0 -a ! $RET_T -eq 0 -a $RET_D -eq 0 -a $RET_I -eq 0 -a $RET_W -eq 0 -a $RET_C -eq 0 -a $RET_E -eq 0 ]
+then
+ echo -e "test_case level=trace off : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=trace off : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_PTIWCE
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ $RET_P -eq 0 -a $RET_T -eq 0 -a ! $RET_D -eq 0 -a $RET_I -eq 0 -a $RET_W -eq 0 -a $RET_C -eq 0 -a $RET_E -eq 0 ]
+then
+ echo -e "test_case level=debug off : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=debug off : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_PTDWCE
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ $RET_P -eq 0 -a $RET_T -eq 0 -a $RET_D -eq 0 -a ! $RET_I -eq 0 -a $RET_W -eq 0 -a $RET_C -eq 0 -a $RET_E -eq 0 ]
+then
+ echo -e "test_case level=info off : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=info off : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_PTDICE
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ $RET_P -eq 0 -a $RET_T -eq 0 -a $RET_D -eq 0 -a $RET_I -eq 0 -a ! $RET_W -eq 0 -a $RET_C -eq 0 -a $RET_E -eq 0 ]
+then
+ echo -e "test_case level=warning off : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=warning off : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_PTDIWE
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ $RET_P -eq 0 -a $RET_T -eq 0 -a $RET_D -eq 0 -a $RET_I -eq 0 -a $RET_W -eq 0 -a ! $RET_C -eq 0 -a $RET_E -eq 0 ]
+then
+ echo -e "test_case level=critical off : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=critical off : [\e[31m NG \e[m]"
+fi
+
+######
+LOG=$LOG_PTDIWC
+
+grep PRF $LOG > /dev/null 2>&1
+RET_P=$?
+grep TRA $LOG > /dev/null 2>&1
+RET_T=$?
+grep DBG $LOG > /dev/null 2>&1
+RET_D=$?
+grep INF $LOG > /dev/null 2>&1
+RET_I=$?
+grep WRN $LOG > /dev/null 2>&1
+RET_W=$?
+grep CRI $LOG > /dev/null 2>&1
+RET_C=$?
+grep ERR $LOG > /dev/null 2>&1
+RET_E=$?
+if [ $RET_P -eq 0 -a $RET_T -eq 0 -a $RET_D -eq 0 -a $RET_I -eq 0 -a $RET_W -eq 0 -a $RET_C -eq 0 -a ! $RET_E -eq 0 ]
+then
+ echo -e "test_case level=error off : [\e[32m OK \e[m]"
+else
+ echo -e "test_case level=error off : [\e[31m NG \e[m]"
+fi
+
+mkdir test_result_ico_log
+mv /var/log/ico/test_result_ico_log_*.log* test_result_ico_log
diff --git a/test/tst_ico_log.c b/test/tst_ico_log.c
new file mode 100644
index 0000000..01f5e9a
--- /dev/null
+++ b/test/tst_ico_log.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+
+/*========================================================================*/
+/**
+ * @file tst_ico_log.c
+ *
+ * @brief ico_log packege test program
+ */
+/*========================================================================*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ico_log.h"
+
+int
+main(int argc, char **argv)
+{
+ int debug_level = 0;
+
+ if (2 > argc) {
+ printf("usage: tst_ico_log loglevel\n"
+ "\tloglevel=none\n"
+ "\tloglevel=[performance,][trace,][debug,][info],"
+ "[warning,][critical,][error]\n");
+ exit(-1);
+ }
+
+ if (NULL != strstr(argv[1], "performance")) {
+ debug_level |= ICO_LOG_LVL_PRF;
+ }
+
+ if (NULL != strstr(argv[1], "trace")) {
+ debug_level |= ICO_LOG_LVL_TRA;
+ }
+
+ if (NULL != strstr(argv[1], "debug")) {
+ debug_level |= ICO_LOG_LVL_DBG;
+ }
+
+ if (NULL != strstr(argv[1], "info")) {
+ debug_level |= ICO_LOG_LVL_INF;
+ }
+
+ if (NULL != strstr(argv[1], "warning")) {
+ debug_level |= ICO_LOG_LVL_WRN;
+ }
+
+ if (NULL != strstr(argv[1], "critical")) {
+ debug_level |= ICO_LOG_LVL_CRI;
+ }
+
+ if (NULL != strstr(argv[1], "error")) {
+ debug_level |= ICO_LOG_LVL_ERR;
+ }
+
+ ico_log_set_level(debug_level);
+ char filename[128];
+ sprintf(filename, "test_result_ico_log_%08X", debug_level);
+ ico_log_open(filename);
+
+ printf("debug_level=0x%08X\n", debug_level);
+
+ ICO_PRF("test performance log");
+ ICO_TRA("test trace log");
+ ICO_DBG("test debug log");
+ ICO_INF("test info log");
+ ICO_WRN("test warning log");
+ ICO_CRI("test critical log");
+ ICO_ERR("test error log");
+
+ ico_log_close();
+
+ exit(0);
+}