Implementation of the test suite for API testing 72/74772/7
authorIevgen Vagin <i.vagin@samsung.com>
Wed, 15 Jun 2016 11:53:54 +0000 (14:53 +0300)
committerSeungbae Shin <seungbae.shin@samsung.com>
Mon, 4 Jul 2016 08:49:24 +0000 (01:49 -0700)
Change-Id: Ia9681a2cc28ef65fee2e491a3624614a0e5daf0f
Signed-off-by: Ievgen Vagin <i.vagin@samsung.com>
CMakeLists.txt
packaging/sound-pool.spec
test/CMakeLists.txt [new file with mode: 0644]
test/logger/logger.h [new file with mode: 0644]
test/logger/src/logger.c [new file with mode: 0644]
test/proxy/proxy.h [new file with mode: 0644]
test/proxy/src/proxy.c [new file with mode: 0644]
test/sound_pool_test.c [new file with mode: 0644]

index d34c3c1..ef95ddd 100755 (executable)
@@ -68,7 +68,7 @@ CONFIGURE_FILE(
 )
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
-#ADD_SUBDIRECTORY(test)
+ADD_SUBDIRECTORY(test)
 
 IF(UNIX)
 
index 0f74e31..f4bece1 100644 (file)
@@ -1,5 +1,5 @@
 Name:       sound-pool
-Version:    0.0.1
+Version:    0.0.2
 Summary:    Tizen Sound Pool module
 Release:    0
 Group:      Multimedia/Framework
@@ -40,7 +40,6 @@ make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
-mkdir -p %{buildroot}%{_bindir}
 
 %make_install
 
@@ -51,6 +50,7 @@ mkdir -p %{buildroot}%{_bindir}
 %manifest %{name}.manifest
 %license LICENSE.APLv2
 %{_libdir}/lib%{name}.so.*
+%{_bindir}/*
 
 %files devel
 %manifest %{name}.manifest
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..a27573a
--- /dev/null
@@ -0,0 +1,34 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_test "${fw_name}-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0)
+FOREACH(flag ${${fw_test}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(modules "")
+SET(srcs "")
+FILE(GLOB children *)
+FOREACH(child ${children})
+    IF(IS_DIRECTORY ${child})
+        aux_source_directory(${child}/src mod_srcs)
+        LIST(APPEND srcs ${mod_srcs})
+        GET_FILENAME_COMPONENT(child_name ${child} NAME_WE)
+        LIST(APPEND modules ${child_name})
+    ENDIF()
+ENDFOREACH()
+
+INCLUDE_DIRECTORIES(../include)
+INCLUDE_DIRECTORIES(${modules})
+
+aux_source_directory(. sources)
+
+FOREACH(src ${sources})
+    GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+    SET(srcs ${src} ${mod_srcs})
+    ADD_EXECUTABLE(${src_name} ${srcs})
+    TARGET_LINK_LIBRARIES(${src_name} ${${fw_test}_LDFLAGS} ${fw_name})
+    INSTALL(TARGETS ${src_name} DESTINATION bin)
+ENDFOREACH()
diff --git a/test/logger/logger.h b/test/logger/logger.h
new file mode 100644 (file)
index 0000000..572459b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define MAX_PATH_LEN 1024
+#define MAX_MSG_LEN 1024
+
+#define _STRINGIFY(x) #x
+#define STRINGIFY(x) _STRINGIFY(x)
+
+#define MAX_PATH_LEN_STR STRINGIFY(MAX_PATH_LEN)
+#define MAX_MSG_LEN_STR STRINGIFY(MAX_MSG_LEN)
+
+#define LOG_MODE_NONE 0
+#define LOG_MODE_FILE 1
+#ifdef LOG_MODE_FILE
+#    define LOG_MODE_STDERR (LOG_MODE_FILE << 1)
+#    define LOG_MODE_DLOG   (LOG_MODE_FILE << 2)
+#endif
+
+/* Enumeration for terminal colors. Used in internal _printf() function */
+typedef enum {
+       CMD_COLOR_RED,
+       CMD_COLOR_YELLOW,
+       CMD_COLOR_GREEN
+} _cmd_color_e;
+
+/* Sets globally the mode of logging. mode has to be specified as a single or
+   combination of the following defines:
+   LOG_MODE_NONE - no logging;
+   LOG_MODE_FILE - logging to the file;
+   LOG_MODE_STDERR - logging to the standart error stream;
+   LOG_MODE_DLOG - logging to the dlog.
+   For example, set_logging_mode(LOG_MODE_FILE | LOG_MODE_DLOG) call will
+   direct all following logging to both file and dlog daemon */
+void _logger_set_logging_mode(int mode);
+
+/* Sets globally the name of the file for LOG_MODE_FILE logging mode */
+int _logger_set_file(const char *fname);
+
+/* Sets globally the log tag will be used in logging journals like Tizen dlog */
+int _logger_set_log_tag(const char *tag);
+
+/* Functions for corresponding logging: */
+int _logger_log_info(const char *fmt, ...);
+int _logger_log_warn(const char *fmt, ...);
+int _logger_log_err(const char *fmt, ...);
+
+/* Function for using instead of standard printf() if coloring is needed */
+int _printf(_cmd_color_e color, const char *fmt, ...);
diff --git a/test/logger/src/logger.c b/test/logger/src/logger.c
new file mode 100644 (file)
index 0000000..d3932ab
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "logger.h"
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <pthread.h>
+#include <dlog.h>
+
+#define INFO_TAG "[ INFO ]"
+#define WARNING_TAG "[ WARN ]"
+#define ERROR_TAG "[ ERROR ]"
+
+#ifndef COLORED_LOG
+       #define COLORED_LOG
+#endif
+#ifdef COLORED_LOG
+#define FONT_COLOR_RESET    "\033[0m"
+#define FONT_COLOR_RED      "\033[31m"
+#define FONT_COLOR_GREEN    "\033[32m"
+#define FONT_COLOR_YELLOW   "\033[33m"
+#else
+#define FONT_COLOR_RESET
+#define FONT_COLOR_RED
+#define FONT_COLOR_GREEN
+#define FONT_COLOR_YELLOW
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define MAX_LOG_TAG_LEN 32
+#define LOG_TAG "TIZEN_SOUND_POOL_TEST_SUITE"
+
+static struct {
+       int inited;
+       int mode;
+       char fname[MAX_PATH_LEN];
+       pthread_mutex_t mutex;
+       time_t timer;
+} __logger = { 0, LOG_MODE_NONE, {'\0'}, PTHREAD_MUTEX_INITIALIZER, 0 };
+
+static char LOGGER_LOG_TAG[MAX_LOG_TAG_LEN] = LOG_TAG;
+
+#define MAX_DATETIME_STR_LEN 26
+static char str_time[MAX_DATETIME_STR_LEN];
+
+void _logger_set_logging_mode(int mode)
+{
+       pthread_mutex_lock(&__logger.mutex);
+       __logger.mode = mode;
+       pthread_mutex_unlock(&__logger.mutex);
+}
+
+int _logger_set_file(const char *fname)
+{
+       if (!fname)
+               return -1;
+
+       FILE *fd = fopen(fname, "w+");
+       if (!fd)
+               return -1;
+
+       fclose(fd);
+
+       pthread_mutex_lock(&__logger.mutex);
+       strncpy(__logger.fname, fname, MAX_PATH_LEN - 1);
+       __logger.fname[MAX_PATH_LEN - 1] = '\0';
+       pthread_mutex_unlock(&__logger.mutex);
+
+       return 0;
+}
+
+int _logger_set_log_tag(const char *tag)
+{
+       if (!tag)
+               return -1;
+
+       pthread_mutex_lock(&__logger.mutex);
+       strncpy(LOGGER_LOG_TAG, tag, MAX_LOG_TAG_LEN - 1);
+       LOGGER_LOG_TAG[MAX_LOG_TAG_LEN - 1] = '\0';
+       pthread_mutex_unlock(&__logger.mutex);
+       return 0;
+}
+
+#   define __LOGGER_PREPARE()                                                  \
+               do {                                                                   \
+                       pthread_mutex_lock(&__logger.mutex);                               \
+                       time(&__logger.timer);                                             \
+                       strftime(str_time, MAX_DATETIME_STR_LEN, "%Y:%m:%d %H:%M:%S",      \
+                                       localtime(&__logger.timer));                               \
+               } while (0)
+
+#   define __LOGGER_UNPREPARE()                                                \
+               do {                                                                   \
+                       pthread_mutex_unlock(&__logger.mutex);                             \
+               } while (0)
+
+int _logger_log_info(const char *fmt, ...)
+{
+       int res = 0;
+       va_list args;
+       __LOGGER_PREPARE();
+
+       if ((__logger.mode & LOG_MODE_FILE) == LOG_MODE_FILE) {
+               FILE *fd = fopen(__logger.fname, "a");
+               if (!fd) {
+                       __LOGGER_UNPREPARE();
+                       return -1;
+               }
+               fprintf(fd, "[%s]", str_time);
+               fprintf(fd, INFO_TAG);
+               va_start(args, fmt);
+               res = vfprintf(fd, fmt, args);
+               fprintf(fd, "\n");
+               fclose(fd);
+       }
+       if ((__logger.mode & LOG_MODE_STDERR) == LOG_MODE_STDERR) {
+               fprintf(stderr, "[%s]", str_time);
+               fprintf(stderr, FONT_COLOR_GREEN INFO_TAG);
+               va_start(args, fmt);
+               res = vfprintf(stderr, fmt, args);
+               fprintf(stderr, FONT_COLOR_RESET);
+               fprintf(stderr, "\n");
+       }
+       if ((__logger.mode & LOG_MODE_DLOG) == LOG_MODE_DLOG) {
+               char msg[MAX_MSG_LEN] = { '\0' };
+               snprintf(msg, MAX_MSG_LEN, "[%s]%s", str_time, fmt);
+               va_start(args, fmt);
+               dlog_vprint(DLOG_INFO, LOGGER_LOG_TAG, msg, args);
+       }
+
+       va_end(args);
+       __LOGGER_UNPREPARE();
+       return res;
+}
+
+int _logger_log_warn(const char *fmt, ...)
+{
+       int res = 0;
+       va_list args;
+       __LOGGER_PREPARE();
+
+       if ((__logger.mode & LOG_MODE_FILE) == LOG_MODE_FILE) {
+               FILE *fd = fopen(__logger.fname, "a");
+               if (!fd) {
+                       __LOGGER_UNPREPARE();
+                       return -1;
+               }
+               fprintf(fd, "[%s]", str_time);
+               fprintf(fd, WARNING_TAG);
+               va_start(args, fmt);
+               res = vfprintf(fd, fmt, args);
+               fprintf(fd, "\n");
+               fclose(fd);
+       }
+       if ((__logger.mode & LOG_MODE_STDERR) == LOG_MODE_STDERR) {
+               fprintf(stderr, "[%s]", str_time);
+               fprintf(stderr, FONT_COLOR_YELLOW WARNING_TAG);
+               va_start(args, fmt);
+               res = vfprintf(stderr, fmt, args);
+               fprintf(stderr, FONT_COLOR_RESET);
+               fprintf(stderr, "\n");
+       }
+       if ((__logger.mode & LOG_MODE_DLOG) == LOG_MODE_DLOG) {
+               char msg[MAX_MSG_LEN] = { '\0' };
+               snprintf(msg, MAX_MSG_LEN, "[%s]%s", str_time, fmt);
+               va_start(args, fmt);
+               dlog_vprint(DLOG_WARN, LOGGER_LOG_TAG, msg, args);
+       }
+
+       va_end(args);
+       __LOGGER_UNPREPARE();
+       return res;
+}
+
+int _logger_log_err(const char *fmt, ...)
+{
+       int res = 0;
+       va_list args;
+       __LOGGER_PREPARE();
+
+       if ((__logger.mode & LOG_MODE_FILE) == LOG_MODE_FILE) {
+               FILE *fd = fopen(__logger.fname, "a");
+               if (!fd) {
+                       __LOGGER_UNPREPARE();
+                       return -1;
+               }
+               fprintf(fd, "[%s]", str_time);
+               fprintf(fd, ERROR_TAG);
+               va_start(args, fmt);
+               res = vfprintf(fd, fmt, args);
+               fprintf(fd, "\n");
+               fclose(fd);
+       }
+       if ((__logger.mode & LOG_MODE_STDERR) == LOG_MODE_STDERR) {
+               fprintf(stderr, "[%s]", str_time);
+               fprintf(stderr, FONT_COLOR_RED ERROR_TAG);
+               va_start(args, fmt);
+               res = vfprintf(stderr, fmt, args);
+               fprintf(stderr, FONT_COLOR_RESET);
+               fprintf(stderr, "\n");
+       }
+       if ((__logger.mode & LOG_MODE_DLOG) == LOG_MODE_DLOG) {
+               char msg[MAX_MSG_LEN] = { '\0' };
+               snprintf(msg, MAX_MSG_LEN, "[%s]%s", str_time, fmt);
+               va_start(args, fmt);
+               dlog_vprint(DLOG_ERROR, LOGGER_LOG_TAG, msg, args);
+       }
+
+       va_end(args);
+       __LOGGER_UNPREPARE();
+       return res;
+}
+
+int _printf(_cmd_color_e color, const char *fmt, ...)
+{
+       va_list args;
+       va_start(args, fmt);
+
+       switch (color) {
+       case CMD_COLOR_RED:
+               vprintf(FONT_COLOR_RED, args);
+               break;
+       case CMD_COLOR_YELLOW:
+               vprintf(FONT_COLOR_YELLOW, args);
+               break;
+       case CMD_COLOR_GREEN:
+               vprintf(FONT_COLOR_GREEN, args);
+               break;
+       default:
+               break;
+       }
+
+       int res = vprintf(fmt, args);
+       printf(FONT_COLOR_RESET);
+
+       va_end(args);
+
+       return res;
+}
diff --git a/test/proxy/proxy.h b/test/proxy/proxy.h
new file mode 100644 (file)
index 0000000..3cdc86e
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sound_pool.h"
+
+#define MAX_COMMAND_LINE_LEN 1024
+
+/* Test suite command list */
+#define CMD_EXIT                 "exit"                        /*  0 */
+#define CMD_HELP                 "help"                        /*  1 */
+#define CMD_CREATE_POOL          "pool create"                 /*  2 */
+#define CMD_DESTROY_POOL         "pool destroy"                /*  3 */
+#define CMD_ACTIVATE_POOL        "pool activate"               /*  4 */
+#define CMD_DEACTIVATE_POOL      "pool deactivate"             /*  5 */
+#define CMD_GET_POOL_STATE       "pool get state"              /*  6 */
+#define CMD_SET_POOL_VOLUME      "pool set volume"             /*  7 */
+#define CMD_GET_POOL_VOLUME      "pool get volume"             /*  8 */
+#define CMD_SET_POOL_CB_MSG      "pool set callback message"   /*  9 */
+#define CMD_SET_POOL_CB_SCRIPT   "pool set callback script"    /* 10 */
+#define CMD_UNSET_POOL_CB        "pool unset callback"         /* 11 */
+#define CMD_LIST_POOL            "pool list"                   /* 12 */
+#define CMD_LOAD_SOURCE          "source load"                 /* 13 */
+#define CMD_LOAD_MEDIA_PACKAGE   "source load mic"             /* 14 */
+#define CMD_UNLOAD_SOURCE        "source unload"               /* 15 */
+#define CMD_PLAY_STREAM          "stream play"                 /* 16 */
+#define CMD_STOP_STREAM          "stream stop"                 /* 17 */
+#define CMD_PAUSE_STREAM         "stream pause"                /* 18 */
+#define CMD_RESUME_STREAM        "stream resume"               /* 19 */
+#define CMD_SET_STREAM_VOLUME    "stream set volume"           /* 20 */
+#define CMD_GET_STREAM_VOLUME    "stream get volume"           /* 21 */
+#define CMD_SET_STREAM_LOOP      "stream set loop"             /* 22 */
+#define CMD_GET_STREAM_LOOP      "stream get loop"             /* 23 */
+#define CMD_SET_STREAM_PRIORITY  "stream set priority"         /* 24 */
+#define CMD_GET_STREAM_PRIORITY  "stream get priority"         /* 25 */
+#define CMD_GET_STREAM_STATE     "stream get state"            /* 26 */
+#define CMD_SET_STREAM_CB_MSG    "stream set callback message" /* 27 */
+#define CMD_SET_STREAM_CB_SCRIPT "stream set callback script"  /* 28 */
+#define CMD_UNSET_STREAM_CB      "stream unset callback"       /* 29 */
+#define CMD_EXECUTE_SCRIPT       "script execute"              /* 30 */
+#define CMD_SLEEP                "sleep"                       /* 31 */
+
+#define CMD_COUNT                32
+
+/* Command execution results list */
+#define OK   +1
+#define FAIL -1
+#define UCMD -2
+#define EXIT  0
+
+static char *cmd_list[MAX_COMMAND_LINE_LEN] = { CMD_EXIT, CMD_HELP,
+               CMD_CREATE_POOL, CMD_DESTROY_POOL, CMD_ACTIVATE_POOL,
+               CMD_DEACTIVATE_POOL, CMD_GET_POOL_STATE, CMD_SET_POOL_VOLUME,
+               CMD_GET_POOL_VOLUME, CMD_SET_POOL_CB_MSG, CMD_SET_POOL_CB_SCRIPT,
+               CMD_UNSET_POOL_CB, CMD_LIST_POOL, CMD_LOAD_SOURCE,
+               CMD_LOAD_MEDIA_PACKAGE, CMD_UNLOAD_SOURCE, CMD_PLAY_STREAM,
+               CMD_STOP_STREAM, CMD_PAUSE_STREAM, CMD_RESUME_STREAM,
+               CMD_SET_STREAM_VOLUME, CMD_GET_STREAM_VOLUME, CMD_SET_STREAM_LOOP,
+               CMD_GET_STREAM_LOOP, CMD_SET_STREAM_PRIORITY, CMD_GET_STREAM_PRIORITY,
+               CMD_GET_STREAM_STATE, CMD_SET_STREAM_CB_MSG, CMD_SET_STREAM_CB_SCRIPT,
+               CMD_UNSET_STREAM_CB, CMD_EXECUTE_SCRIPT, CMD_SLEEP };
+
+void print_cmd_help_msg();
+
+void print_async_msg();
+
+int _exec_cmd(const char *cmd_line);
diff --git a/test/proxy/src/proxy.c b/test/proxy/src/proxy.c
new file mode 100644 (file)
index 0000000..deaa36b
--- /dev/null
@@ -0,0 +1,1584 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "proxy.h"
+#include "logger.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define DEFAULT_MAX_STREAMS_PER_POOL_CNT 25
+#define MICROSECS_PER_MILLISEC 1000
+
+#define MAX_POOL_CNT 100
+static sound_pool_h pools[MAX_POOL_CNT] = { NULL };
+
+/* Messages to be used for callbacks output (for pool state changing) */
+static char *messages[MAX_POOL_CNT] = { NULL };
+/* Scripts will be launched from callbacks (for stream state changing) */
+static char *scripts[MAX_POOL_CNT] = { NULL };
+
+#define MAX_STREAM_CNT 1000
+/* Messages to be used for callbacks output (for pool state changing) */
+static char *stream_messages[MAX_POOL_CNT][MAX_STREAM_CNT] = { NULL };
+/* Messages to be used for callbacks output (for stream state changing) */
+static char *stream_scripts[MAX_POOL_CNT][MAX_STREAM_CNT] = { NULL };
+
+static int __proxy_sound_pool_execute_script(const char *pars);
+
+const char *__stringify_sound_pool_error(sound_pool_error_e error)
+{
+       switch (error) {
+       case SOUND_POOL_ERROR_NONE:
+               return "SOUND_POOL_ERROR_NONE";
+               break;
+       case SOUND_POOL_ERROR_NOT_SUPPORTED:
+               return "SOUND_POOL_ERROR_NOT_SUPPORTED";
+               break;
+       case SOUND_POOL_ERROR_MSG_TOO_LONG:
+               return "SOUND_POOL_ERROR_MSG_TOO_LONG";
+               break;
+       case SOUND_POOL_ERROR_NO_DATA:
+               return "SOUND_POOL_ERROR_NO_DATA";
+               break;
+       case SOUND_POOL_ERROR_KEY_NOT_AVAILABLE:
+               return "SOUND_POOL_ERROR_KEY_NOT_AVAILABLE";
+               break;
+       case SOUND_POOL_ERROR_OUT_OF_MEMORY:
+               return "SOUND_POOL_ERROR_OUT_OF_MEMORY";
+               break;
+       case SOUND_POOL_ERROR_INVALID_PARAMETER:
+               return "SOUND_POOL_ERROR_INVALID_PARAMETER";
+               break;
+       case SOUND_POOL_ERROR_INVALID_OPERATION:
+               return "SOUND_POOL_ERROR_INVALID_OPERATION";
+               break;
+       case SOUND_POOL_ERROR_PERMISSION_DENIED:
+               return "SOUND_POOL_ERROR_PERMISSION_DENIED";
+               break;
+       default:
+               return "";
+               break;
+       }
+
+       return NULL;
+}
+
+const char *__stringify_stream_state(sound_pool_stream_state_e state)
+{
+       switch (state) {
+       case SOUND_POOL_STREAM_STATE_NONE:
+               return "SOUND_POOL_STREAM_STATE_NONE";
+               break;
+       case SOUND_POOL_STREAM_STATE_PLAYING:
+               return "SOUND_POOL_STREAM_STATE_PLAYING";
+               break;
+       case SOUND_POOL_STREAM_STATE_PAUSED:
+               return "SOUND_POOL_STREAM_STATE_PAUSED";
+               break;
+       case SOUND_POOL_STREAM_STATE_SUSPENDED:
+               return "SOUND_POOL_STREAM_STATE_SUSPENDED";
+               break;
+       case SOUND_POOL_STREAM_STATE_STOPPED:
+               return "SOUND_POOL_STREAM_STATE_STOPPED";
+               break;
+       case SOUND_POOL_STREAM_STATE_FINISHED:
+               return "SOUND_POOL_STREAM_STATE_FINISHED";
+               break;
+       default:
+               return "";
+               break;
+       }
+
+       return NULL;
+}
+
+static void __sp_cb_msg(sound_pool_h pool, sound_pool_state_e prev_state,
+               sound_pool_state_e cur_state, void *data)
+{
+       const char *msg = (const char *)data;
+       _logger_log_info("Sound pool state was changing from %s to %s: %s",
+                       prev_state == SOUND_POOL_STATE_ACTIVE ?
+                                       "SOUND_POOL_STATE_ACTIVE" : "SOUND_POOL_STATE_INACTIVE",
+                       cur_state == SOUND_POOL_STATE_ACTIVE ?
+                                       "SOUND_POOL_STATE_ACTIVE" : "SOUND_POOL_STATE_INACTIVE",
+                       msg ? msg : "No message");
+}
+
+static void __sp_cb_scr(sound_pool_h pool, sound_pool_state_e prev_state,
+               sound_pool_state_e cur_state, void *data)
+{
+       const char *scr = (const char *)data;
+       _logger_log_info("Sound pool state was changing from %s to %s; "
+                       "Executing: %s...",
+                       prev_state == SOUND_POOL_STATE_ACTIVE ? "SOUND_POOL_STATE_ACTIVE" :
+                                       "SOUND_POOL_STATE_INACTIVE",
+                       cur_state == SOUND_POOL_STATE_ACTIVE ? "SOUND_POOL_STATE_ACTIVE" :
+                                       "SOUND_POOL_STATE_INACTIVE",
+                       scr ? scr : "No script");
+       __proxy_sound_pool_execute_script(scr);
+}
+
+static void __s_cb_msg(sound_pool_h pool, const char *tag, unsigned id,
+               sound_pool_stream_state_e prev_state,
+               sound_pool_stream_state_e cur_state, void *data)
+{
+       const char *msg = (const char *)data;
+       _logger_log_info("Stream state was changing from %s to %s: %s",
+                       __stringify_stream_state(prev_state),
+                       __stringify_stream_state(cur_state),
+                       msg ? msg : "No message");
+}
+
+static void __s_cb_scr(sound_pool_h pool, const char *tag, unsigned id,
+               sound_pool_stream_state_e prev_state,
+               sound_pool_stream_state_e cur_state, void *data)
+{
+       const char *scr = (const char *)data;
+       _logger_log_info("Sound pool state was changing from %s to %s; "
+                       "Executing: %s...", __stringify_stream_state(prev_state),
+                       __stringify_stream_state(cur_state),
+                       scr ? scr : "No script");
+       __proxy_sound_pool_execute_script(scr);
+}
+
+/* CMD_EXIT */
+static int __exit()
+{
+       return EXIT;
+}
+
+/* CMD_HELP */
+static int __print_cmd_help_msg()
+{
+       printf("\nTest suite usage help:\n");
+
+       printf(CMD_HELP "\n");
+       printf("\t- Shows this help.\n");
+
+       printf(CMD_CREATE_POOL "\n");
+       printf("\t- creates pool with specific identifier.\n");
+
+       printf(CMD_DESTROY_POOL "\n");
+       printf("\t- destroys pool with specific identifier.\n");
+
+       printf(CMD_ACTIVATE_POOL "\n");
+       printf("\t- activates pool with specific identifier.\n");
+
+       printf(CMD_DEACTIVATE_POOL "\n");
+       printf("\t- deactivates pool with specific identifier.\n");
+
+       printf(CMD_GET_POOL_STATE "\n");
+       printf("\t- shows state of the pool with specific identifier.\n");
+
+       printf(CMD_SET_POOL_VOLUME "\n");
+       printf("\t- use this command to set volume for the specific sound pool.\n");
+
+       printf(CMD_GET_POOL_VOLUME "\n");
+       printf("\t- shows volume of the sound pool with specific identifier.\n");
+
+       printf(CMD_SET_POOL_CB_MSG "\n");
+       printf("\t- sets callback which will show the message when sound pool "
+                       "state is changed.\n");
+
+       printf(CMD_SET_POOL_CB_SCRIPT "\n");
+       printf("\t- sets callback which will execute the script when sound pool "
+                       "state is changed.\n");
+
+       printf(CMD_UNSET_POOL_CB "\n");
+       printf("\t- unsets the callback for the sound pool.\n");
+
+       printf(CMD_LIST_POOL "\n");
+       printf("\t- shows ids of all pools had been created and their states.\n");
+
+       printf(CMD_LOAD_SOURCE "\n");
+       printf("\t- loads the source with specific source tag.\n");
+
+       printf(CMD_UNLOAD_SOURCE "\n");
+       printf("\t- unloads the source with specific source tag.\n");
+
+       printf(CMD_PLAY_STREAM "\n");
+       printf("\t- creates the stream with unique identifier and starts playback.\n"
+                       "\t  Source tag to be used for stream creation should be specified.\n");
+
+       printf(CMD_STOP_STREAM "\n");
+       printf("\t- stops the stream playback. Stream unique identifier should be\n"
+                       "\t  specified after command. After stopping the stream became invalid.\n");
+
+       printf(CMD_PAUSE_STREAM "\n");
+       printf("\t- pauses the stream playback. Stream unique identifier should be\n"
+                       "\t  specified after command.\n");
+
+       printf(CMD_RESUME_STREAM "\n");
+       printf("\t- resumes the stream was paused before. Stream unique identifier\n"
+                       "\t  should be specified after command.\n");
+
+       printf(CMD_SET_STREAM_VOLUME "\n");
+       printf("\t- use this command to set volume parameter of the stream.\n");
+
+       printf(CMD_GET_STREAM_VOLUME "\n");
+       printf("\t- shows volume of the stream in the pool with specified "
+                       "identifiers.\n");
+
+       printf(CMD_SET_STREAM_LOOP "\n");
+       printf("\t- use this command to set loop parameter of the stream.\n");
+
+       printf(CMD_GET_STREAM_LOOP "\n");
+       printf("\t- shows loop count of the stream in the pool with specified "
+                       "identifiers.\n");
+
+       printf(CMD_SET_STREAM_PRIORITY "\n");
+       printf("\t- use this command to set priority parameter of the stream.\n");
+
+       printf(CMD_GET_STREAM_PRIORITY "\n");
+       printf("\t- shows priority rank of the stream in the pool with specified "
+                       "identifiers.\n");
+
+       printf(CMD_GET_STREAM_STATE "\n");
+       printf("\t- shows state of the stream in the pool with specified "
+                       "identifiers.\n");
+
+       printf(CMD_SET_STREAM_CB_MSG "\n");
+       printf("\t- sets callback which will show the message when sound stream "
+                       "state is changed.\n");
+
+       printf(CMD_SET_STREAM_CB_SCRIPT "\n");
+       printf("\t- sets callback which will execute the script (from file) when "
+                       "sound stream state is changed.\n");
+
+       printf(CMD_UNSET_STREAM_CB "\n");
+       printf("\t- unsets the callback for the sound stream.\n");
+
+       printf(CMD_EXECUTE_SCRIPT "\n");
+       printf("\t- executes the script from the file in filesystem. Script has to\n"
+                       "\t  be compiled with commands supported by testsuite, one command\n"
+                       "\t  per single line.\n");
+
+       printf(CMD_SLEEP "\n");
+       printf("\t- suspends execution of the main thread for the specific amount "
+                       "of milleseconds.\n");
+
+       printf(CMD_EXIT "\n");
+       printf("\t- exits from the test suite.\n");
+
+       printf("\n");
+
+       return OK;
+}
+
+/* CMD_CREATE_POOL */
+static int __proxy_sound_pool_create(const char *pars)
+{
+       _logger_log_info(CMD_CREATE_POOL " command was called");
+
+       unsigned int max_streams = DEFAULT_MAX_STREAMS_PER_POOL_CNT;
+       if (pars != NULL)
+               sscanf(pars, " %u", &max_streams);
+
+       _logger_log_info("Creating the pool...");
+
+       sound_pool_h pool = NULL;
+       int ret = sound_pool_create(max_streams, &pool);
+
+       if (ret == SOUND_POOL_ERROR_NONE) {
+               _logger_log_info("sound_pool_create(%u, pool) returned %s value",
+                               max_streams, __stringify_sound_pool_error(ret));
+
+               size_t idx = 0;
+               while (idx < MAX_POOL_CNT) {
+                       if (pools[idx++] == NULL) {
+                               pools[--idx] = pool;
+                               break;
+                       }
+               }
+
+               if (idx == MAX_POOL_CNT) {
+                       _printf(CMD_COLOR_RED, "Limit of possible pools is exceeded. Destroy "
+                                       "some pools before creating of new ones.\n");
+
+                       _logger_log_warn("Pool can't be created due to test suite "
+                                       "restrictions. Destroying the pool...");
+
+                       ret = sound_pool_destroy(pool);
+                       if (ret == SOUND_POOL_ERROR_NONE)
+                               _logger_log_info("sound_pool_destroy(pool) returned %s value",
+                                               __stringify_sound_pool_error(ret));
+                       else
+                               _logger_log_err("sound_pool_destroy(pool) returned %s value",
+                                               __stringify_sound_pool_error(ret));
+
+                       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+               }
+
+               if (!pool)
+                       _logger_log_warn("Created pool is NULL");
+               else
+                       _logger_log_info("Identifier of the pool has been created is %zu", idx);
+       } else {
+               _logger_log_err("sound_pool_create(%u, pool) returned %s value",
+                               max_streams, __stringify_sound_pool_error(ret));
+       }
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_DESTROY_POOL */
+static int __proxy_sound_pool_destroy(const char *pars)
+{
+       int ret = SOUND_POOL_ERROR_NONE;
+       size_t idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu", &idx) < 1)) {
+               _printf(CMD_COLOR_RED, "You have to specify identifier of the pool to be "
+                               "destroyed after command! Format: " CMD_DESTROY_POOL " <id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_DESTROY_POOL " command was called");
+       _logger_log_info("Destroying the pool by %zu identifier...", idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to be destroyed is NULL");
+
+       ret = sound_pool_destroy(pools[idx]);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_destroy(pool) returned %s value",
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_destroy(pool) returned %s value",
+                               __stringify_sound_pool_error(ret));
+
+       pools[idx] = NULL;
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_ACTIVATE_POOL */
+static int __proxy_sound_pool_activate(const char *pars)
+{
+       int ret = SOUND_POOL_ERROR_NONE;
+       size_t idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu", &idx) < 1)) {
+               _printf(CMD_COLOR_RED, "You have to specify identifier of the pool "
+                               "to be activated after command name! Format: "
+                               CMD_ACTIVATE_POOL " <id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_ACTIVATE_POOL " command was called");
+       _logger_log_info("Activating the pool by %zu identifier...", idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to be activated is NULL");
+
+       ret = sound_pool_activate(pools[idx]);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_set_state(pool, "
+                               "SOUND_POOL_STATE_ACTIVE) returned %s value",
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_set_state(pool, "
+                               "SOUND_POOL_STATE_ACTIVE) returned %s value",
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_DEACTIVATE_POOL */
+static int __proxy_sound_pool_deactivate(const char *pars)
+{
+       size_t idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu", &idx) < 1)) {
+               _printf(CMD_COLOR_RED, "You have to specify identifier of the pool "
+                               "to be deactivated after command name! Format: "
+                               CMD_DEACTIVATE_POOL " <id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_DEACTIVATE_POOL " command was called");
+       _logger_log_info("Deactivating the pool by %zu identifier...", idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to be deactivated is NULL");
+
+       int ret = sound_pool_deactivate(pools[idx]);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_set_state(pool, "
+                               "SOUND_POOL_STATE_INACTIVE) returned %s value",
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_set_state(pool, "
+                               "SOUND_POOL_STATE_INACTIVE) returned %s value",
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_GET_POOL_STATE */
+static int __proxy_sound_pool_get_state(const char *pars)
+{
+       size_t idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu", &idx) < 1)) {
+               _printf(CMD_COLOR_RED, "You have to specify identifier of the pool "
+                               "to get state for, after command name! Format: "
+                               CMD_GET_POOL_STATE " <id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_GET_POOL_STATE " command was called");
+       _logger_log_info("Getting the pool state by %zu identifier...", idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to get state for is NULL");
+
+       sound_pool_state_e state = SOUND_POOL_STATE_INACTIVE;
+       int ret = sound_pool_get_state(pools[idx], &state);
+
+       const char *str_state = (state == SOUND_POOL_STATE_ACTIVE ?
+                       "SOUND_POOL_STATE_ACTIVE" : "SOUND_POOL_STATE_INACTIVE");
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_get_state(pool, state) returned %s value,"
+                               " state is %s", __stringify_sound_pool_error(ret), str_state);
+       else
+               _logger_log_err("sound_pool_get_state(pool, state) returned %s value,"
+                               " state is %s", __stringify_sound_pool_error(ret), str_state);
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SET_POOL_VOLUME */
+static int __proxy_sound_pool_set_volume(const char *pars)
+{
+       size_t idx = 0;
+       float volume = .0f;
+       if ((pars == NULL) || (sscanf(pars, " %zu %f", &idx, &volume) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both identifier of the "
+                               "pool and new volume float value to set volume for whole pool! "
+                               "Format: " CMD_SET_POOL_VOLUME " <id> <volume>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_SET_POOL_VOLUME " command was called");
+       _logger_log_info("Set %f volume value for pool with %zu identifier...",
+                       volume, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to get state for is NULL");
+
+       if (volume < .0f || volume > 1.0f)
+               _logger_log_warn("Volume is set as %f, not in [0, 1.0] range", volume);
+
+       int ret = sound_pool_set_volume(pools[idx], volume);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_set_global_volume(pool, %f) "
+                               "returned %s value", volume, __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_set_global_volume(pool, %f) "
+                               "returned %s value", volume, __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_GET_POOL_VOLUME */
+static int __proxy_sound_pool_get_volume(const char *pars)
+{
+       size_t idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu", &idx) < 1)) {
+               _printf(CMD_COLOR_RED, "You have to specify identifier of the pool "
+                               "to get volume for, after command name! Format: "
+                               CMD_GET_POOL_VOLUME " <id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_GET_POOL_VOLUME " command was called");
+       _logger_log_info("Getting the pool global volume for pool with %zu "
+                       "identifier...", idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to get state for is NULL");
+
+       float volume = .0f;
+       int ret = sound_pool_get_volume(pools[idx], &volume);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_get_global_volume(pool, volume) returned "
+                               "%s value, volume is %f", __stringify_sound_pool_error(ret),
+                               volume);
+       else
+               _logger_log_err("sound_pool_get_global_volume(pool, volume) returned "
+                               "%s value, volume is %f", __stringify_sound_pool_error(ret),
+                               volume);
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SET_POOL_CB_MSG */
+static int __proxy_sound_pool_set_state_change_callback_message(const char *pars)
+{
+       size_t idx = 0;
+
+       char msg[MAX_MSG_LEN] = { '\0' };
+
+       if ((pars == NULL) || (sscanf(pars, " %zu %"MAX_MSG_LEN_STR"[^ ]", &idx, msg) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both identifier of the "
+                               "pool and message to be shown each time when state of the pool "
+                               " is changed! Message should be a single word. Format: "
+                               CMD_SET_POOL_CB_MSG " <id> <message>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_SET_POOL_CB_MSG " command was called");
+       _logger_log_info("Set state changing callback (%s message) for pool with "
+                       "%zu identifier...", msg, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to set callback for is NULL");
+
+       if (messages[idx])
+               free(messages[idx]);
+       messages[idx] = strndup(msg, MAX_MSG_LEN);
+
+       int ret = sound_pool_set_state_change_callback(pools[idx], __sp_cb_msg,
+                       messages[idx]);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_set_state_change_callback(pool, cb, "
+                               "\"%s\") returned %s value", msg, __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_set_state_change_callback(pool, cb, "
+                               "\"%s\") returned %s value", msg, __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SET_POOL_CB_SCRIPT */
+static int __proxy_sound_pool_set_state_change_callback_script(const char *pars)
+{
+       size_t idx = 0;
+
+       char scr[MAX_MSG_LEN] = { '\0' };
+
+       if ((pars == NULL) || (sscanf(pars, " %zu %"MAX_MSG_LEN_STR"[^ ]", &idx, scr) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both identifier of the "
+                               "pool and script file name to be executed each time when state "
+                               "of the pool will be changed! Format: "
+                               CMD_SET_POOL_CB_SCRIPT " <id> <script file>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_SET_POOL_CB_SCRIPT " command was called");
+       _logger_log_info("Set state changing callback (%s script) for pool with "
+                       "%zu identifier...", scr, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to set callback for is NULL");
+
+       if (scripts[idx])
+               free(scripts[idx]);
+       scripts[idx] = strndup(scr, MAX_MSG_LEN);
+
+       int ret = sound_pool_set_state_change_callback(pools[idx], __sp_cb_scr,
+                       scripts[idx]);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_set_state_change_callback(pool, cb, "
+                               "\"%s\") returned %s value", scr, __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_set_state_change_callback(pool, cb, "
+                               "\"%s\") returned %s value", scr, __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_UNSET_POOL_CB */
+static int __proxy_sound_pool_unset_state_change_callback(const char *pars)
+{
+       size_t idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu", &idx) < 1)) {
+               _printf(CMD_COLOR_RED, "You have to specify identifier of the pool! "
+                               "Format: " CMD_UNSET_POOL_CB " <id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_UNSET_POOL_CB " command was called");
+       _logger_log_info("Unset state changing callback for pool with "
+                       "%zu identifier...", idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to unset callback for is NULL");
+
+       int ret = sound_pool_unset_state_change_callback(pools[idx]);
+
+       if (messages[idx] != NULL)
+               free(messages[idx]);
+       messages[idx] = NULL;
+
+       if (scripts[idx] != NULL)
+               free(scripts[idx]);
+       scripts[idx] = NULL;
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_unset_state_change_callback(pool) "
+                               "returned %s value", __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_unset_state_change_callback(pool) "
+                               "returned %s value", __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_LIST_POOL */
+static int __proxy_sound_pool_list()
+{
+       _logger_log_info("Getting the pool identifiers...");
+
+       const size_t buffer_size = 1024;
+       char buffer[buffer_size];
+       buffer[0] = '\0';
+
+       size_t idx = 0;
+       size_t len = 0;
+       while (idx < MAX_POOL_CNT) {
+               len = strnlen(buffer, buffer_size);
+               if (pools[idx++] != NULL) {
+                       size_t add_len = 1;
+                       size_t id = idx - 1;
+                       do
+                               add_len++;
+                       while ((id = id / 10) > 0);
+                       id = idx - 1;
+                       if (len + add_len + 1 > buffer_size)
+                               break;
+                       snprintf(buffer + len, buffer_size, "%zu ", id);
+               }
+       }
+
+       _printf(CMD_COLOR_GREEN, "Pools identifiers: %s\n", buffer);
+       _logger_log_info("Pools identifiers: %s", buffer);
+
+       _logger_log_info("Pool identifiers were retrieved...");
+
+       return OK;
+}
+
+/* CMD_LOAD_SOURCE */
+static int __proxy_sound_pool_load_source_from_file(const char *pars)
+{
+       size_t idx = 0;
+
+       char fname[MAX_PATH_LEN] = {'\0'};
+       char tag[MAX_PATH_LEN] = {'\0'};
+
+       if ((pars == NULL) || sscanf(pars, " %zu %"MAX_PATH_LEN_STR"[^ ] "
+                       "%"MAX_PATH_LEN_STR"[^ ]", &idx, fname, tag) < 2) {
+               _printf(CMD_COLOR_RED, "You have to specify at least pool identifier and "
+                               "file name to be loaded! Format: " CMD_LOAD_SOURCE " <pool id> "
+                               "<file name> <source tag>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       /* If tag wasn't specified by the user, we will use file path as a tag */
+       if (tag[0] == '\0')
+               strncpy(tag, fname, MAX_PATH_LEN);
+
+       _logger_log_info(CMD_LOAD_SOURCE " command was called");
+       _logger_log_info("Loading source to the pool with %zu identifier from %s file. "
+                       "Tag '%s' will be assigned for the loaded source...", idx, fname, tag);
+
+       int ret = sound_pool_load_source_from_file(pools[idx], fname, tag);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_load_source_from_file(pool, \"%s\", "
+                               "\"%s\") returned %s value", fname, tag,
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_load_source_from_file(pool, \"%s\", "
+                               "\"%s\") returned %s value", fname, tag,
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_UNLOAD_SOURCE */
+static int __proxy_sound_pool_unload_source(const char *pars)
+{
+       size_t idx = 0;
+
+       char tag[MAX_PATH_LEN] = {'\0'};
+
+       if ((pars == NULL) || sscanf(pars, " %zu %"MAX_PATH_LEN_STR"[^ ]", &idx, tag) < 2) {
+               _printf(CMD_COLOR_RED, "You have to specify both pool identifier and "
+                               "source tag to be unloaded! Format: " CMD_UNLOAD_SOURCE
+                               " <pool id> <source tag>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       _logger_log_info(CMD_UNLOAD_SOURCE " command was called");
+       _logger_log_info("Unloading source by '%s' tag from the pool with %zu "
+                       "identifier...", tag, idx);
+
+       int ret = sound_pool_unload_source(pools[idx], tag);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_unload_source(pool, \"%s\") returned "
+                               "%s value", tag, __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_unload_source(pool, \"%s\") returned "
+                               "%s value", tag, __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_PLAY_STREAM */
+static int __proxy_sound_pool_play_stream(const char *pars)
+{
+       size_t idx = 0;
+       int loop = 0;
+       float volume = 1.0f;
+       int rank = 0;
+
+       char tag[MAX_PATH_LEN] = {'\0'};
+
+       if ((pars == NULL) || sscanf(pars, " %zu %"MAX_PATH_LEN_STR"[^ ] %i %f %i",
+                                            &idx, tag, &loop, &volume, &rank) < 2) {
+               _printf(CMD_COLOR_RED, "You have to specify at least pool identifier and "
+                               "source tag to be played in stream! Format: " CMD_PLAY_STREAM
+                               " <pool id> <source tag> <loop> <volume> <priority rank>... \n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       _logger_log_info(CMD_PLAY_STREAM " command was called");
+       _logger_log_info("Playing stream based on source with '%s' tag from the pool "
+                       "with %zu identifier...", tag, idx);
+
+       int stream_idx = 0;
+       int ret = sound_pool_stream_play(pools[idx], tag, loop, volume, rank, NULL,
+                       NULL, &stream_idx);
+
+       if (ret == SOUND_POOL_ERROR_NONE) {
+               _logger_log_info("sound_pool_play_stream(pool, \"%s\", %i, %f, %i,"
+                               " NULL, NULL, &stream_idx) returned %s value. "
+                               "Generated identifier is %i", tag, loop, volume, rank,
+                               __stringify_sound_pool_error(ret), stream_idx);
+               _printf(CMD_COLOR_GREEN, "Generated stream identifier is %i\n", stream_idx);
+       } else {
+               _logger_log_err("sound_pool_play_stream(pool, \"%s\", %i, %f, %i,"
+                               " NULL, NULL, &stream_idx) returned %s value",
+                               tag, loop, volume, rank, __stringify_sound_pool_error(ret));
+       }
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_PAUSE_STREAM */
+static int __proxy_sound_pool_pause_stream(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+
+       if ((pars == NULL) || (sscanf(pars, " %zu %i", &idx, &stream_idx) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both pool identifier and "
+                               "stream to be paused identifier! Format: " CMD_PAUSE_STREAM
+                               " <pool id> <stream id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       _logger_log_info(CMD_PAUSE_STREAM " command was called");
+
+       int ret = sound_pool_stream_pause(pools[idx], stream_idx);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_pause_stream(pool, %i) returned %s "
+                               "value", stream_idx, __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_pause_stream(pool, %i) returned %s "
+                               "value", stream_idx, __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_RESUME_STREAM */
+static int __proxy_sound_pool_resume_stream(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+
+       if ((pars == NULL) || (sscanf(pars, " %zu %i", &idx, &stream_idx) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both pool identifier and "
+                               "stream to be resumed identifier! Format: " CMD_RESUME_STREAM
+                               " <pool id> <stream id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       _logger_log_info(CMD_RESUME_STREAM " command was called");
+
+       int ret = sound_pool_stream_resume(pools[idx], stream_idx);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_resume_stream(pool, %i) returned %s "
+                               "value", stream_idx, __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_resume_stream(pool, %i) returned %s "
+                               "value", stream_idx, __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_STOP_STREAM */
+static int __proxy_sound_pool_stop_stream(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+
+       if ((pars == NULL) || (sscanf(pars, " %zu %zu", &idx, &stream_idx) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both pool identifier and "
+                               "stream to be stopped identifier! Format: " CMD_STOP_STREAM
+                               " <pool id> <stream id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       _logger_log_info(CMD_STOP_STREAM " command was called");
+
+       int ret = sound_pool_stream_stop(pools[idx], stream_idx);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_stop_stream(pool, %i) returned %s "
+                               "value", stream_idx, __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_stop_stream(pool, %i) returned %s "
+                               "value", stream_idx, __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SET_STREAM_VOLUME */
+static int __proxy_sound_pool_stream_set_volume(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+       float volume_val = 1.0f;
+
+       if ((pars == NULL)
+                       || (sscanf(pars, " %zu %zu %f", &idx, &stream_idx, &volume_val) < 3)) {
+               _printf(CMD_COLOR_RED, "You have to specify all following parameters: "
+                               "pool identifier, stream identifier! Format: "
+                               CMD_SET_STREAM_VOLUME " <pool id> <stream id> <volume>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       if (volume_val < .0f || volume_val > 1.0f)
+               _logger_log_warn("Volume has to be specified in 0.0~1.0 range");
+
+       _logger_log_info(CMD_SET_STREAM_VOLUME " command was called");
+
+       int ret = sound_pool_stream_set_volume(pools[idx], stream_idx, volume_val);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_stream_set_volume(pool, %i, %f) "
+                               "returned %s value", stream_idx, volume_val,
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_stream_set_volume(pool, %i, %f) "
+                               "returned %s value", stream_idx, volume_val,
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_GET_STREAM_VOLUME */
+static int __proxy_sound_pool_stream_get_volume(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu %zu", &idx, &stream_idx) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both pool and stream "
+                               "identifiers after command name! Format: "
+                               CMD_GET_STREAM_VOLUME " <pool id> <stream id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_GET_STREAM_VOLUME " command was called");
+       _logger_log_info("Getting the %zu stream from %zu pool volume value...",
+                       stream_idx, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to get state for is NULL");
+
+       float volume = .0f;
+       int ret = sound_pool_stream_get_volume(pools[idx], stream_idx, &volume);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_stream_get_volume(pool, %zu, volume) "
+                               "returned %s value, volume is %f", stream_idx,
+                               __stringify_sound_pool_error(ret), volume);
+       else
+               _logger_log_err("sound_pool_stream_get_volume(pool, %zu, volume) "
+                               "returned %s value, volume is %f", stream_idx,
+                               __stringify_sound_pool_error(ret), volume);
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SET_STREAM_LOOP */
+static int __proxy_sound_pool_stream_set_loop(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+       int loop_val = 1;
+
+       if ((pars == NULL)
+                       || (sscanf(pars, " %zu %zu %i", &idx, &stream_idx, &loop_val) < 3)) {
+               _printf(CMD_COLOR_RED, "You have to specify all following parameters: "
+                               "pool identifier, stream identifier, and loop number! Format: "
+                               CMD_SET_STREAM_LOOP " <pool id> <stream id> <loop num>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       if (loop_val < 0)
+               _logger_log_warn("Loop number should to be greater than 0, but it's"
+                               "value is %i", loop_val);
+
+       _logger_log_info(CMD_SET_STREAM_LOOP " command was called");
+
+       int ret = sound_pool_stream_set_loop(pools[idx], stream_idx, loop_val);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_stream_set_loop(pool, %zu, %i) "
+                               "returned %s value", stream_idx, loop_val,
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_stream_set_loop(pool, %zu, %i) "
+                               "returned %s value", stream_idx, loop_val,
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_GET_STREAM_LOOP */
+static int __proxy_sound_pool_stream_get_loop(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu %zu", &idx, &stream_idx) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both pool and stream "
+                               "identifiers after command name! Format: "
+                               CMD_GET_STREAM_LOOP " <pool id> <stream id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_GET_STREAM_LOOP " command was called");
+       _logger_log_info("Getting the stream state by %zu identifier in %zu "
+                       "pool...", stream_idx, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool where stream should be located is NULL");
+
+       unsigned loop = 0;
+       int ret = sound_pool_stream_get_loop(pools[idx], stream_idx, &loop);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_stream_get_loop(pool, %zu, loop) "
+                               "returned %s value, loop value is %i", stream_idx,
+                               __stringify_sound_pool_error(ret), loop);
+       else
+               _logger_log_err("sound_pool_stream_get_loop(pool, %zu, loop) "
+                               "returned %s value, loop value is %i", stream_idx,
+                               __stringify_sound_pool_error(ret), loop);
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SET_STREAM_PRIORITY */
+static int __proxy_sound_pool_stream_set_priority(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+       int rank_val = 0;
+
+       if ((pars == NULL)
+                       || (sscanf(pars, " %zu %zu %i", &idx, &stream_idx, &rank_val) < 3)) {
+               _printf(CMD_COLOR_RED, "You have to specify all following parameters: "
+                               "pool identifier, stream identifier, and priority rank! Format: "
+                               CMD_SET_STREAM_PRIORITY " <pool id> <stream id> <rank>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with specified identifier is NULL");
+
+       if (rank_val < 0)
+               _logger_log_warn("Priority rank should to be greater or equal 0, but "
+                               "it's value is %i", rank_val);
+
+       _logger_log_info(CMD_SET_STREAM_PRIORITY " command was called");
+
+       int ret = sound_pool_stream_set_priority(pools[idx], stream_idx, rank_val);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_stream_set_priority(pool, %zu, %i) "
+                               "returned %s value", stream_idx, rank_val,
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_stream_set_priority(pool, %zu, %i) "
+                               "returned %s value", stream_idx, rank_val,
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_GET_STREAM_PRIORITY */
+static int __proxy_sound_pool_stream_get_priority(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu %zu", &idx, &stream_idx) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both pool and stream "
+                               "identifiers after command name! Format: "
+                               CMD_GET_STREAM_PRIORITY " <pool id> <stream id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_GET_STREAM_PRIORITY " command was called");
+       _logger_log_info("Getting the stream priority rank by %zu identifier in "
+                       "%zu pool...", stream_idx, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool where stream should be located is NULL");
+
+       unsigned rank = 0;
+       int ret = sound_pool_stream_get_priority(pools[idx], stream_idx, &rank);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_stream_get_priority(pool, %zu, rank) "
+                               "returned %s value, rank value is %i", stream_idx,
+                               __stringify_sound_pool_error(ret), rank);
+       else
+               _logger_log_err("sound_pool_stream_get_priority(pool, %zu, rank) "
+                               "returned %s value, rank value is %i", stream_idx,
+                               __stringify_sound_pool_error(ret), rank);
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_GET_STREAM_STATE */
+static int __proxy_sound_pool_get_stream_state(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu %zu", &idx, &stream_idx) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both pool and stream "
+                               "identifiers after command name! Format: "
+                               CMD_GET_STREAM_STATE " <pool id> <stream id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_GET_STREAM_STATE " command was called");
+       _logger_log_info("Getting the stream state by %zu identifier in %zu "
+                       "pool...", stream_idx, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool where stream should be located is NULL");
+
+       sound_pool_stream_state_e state = SOUND_POOL_STREAM_STATE_NONE;
+       int ret = sound_pool_stream_get_state(pools[idx], stream_idx,  &state);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_get_stream_state(pool, %zu, state) "
+                               "returned %s value, state is %s", stream_idx,
+                               __stringify_sound_pool_error(ret),
+                               __stringify_stream_state(state));
+       else
+               _logger_log_err("sound_pool_get_stream_state(pool, %zu, state) "
+                               "returned %s value, state is %s", stream_idx,
+                               __stringify_sound_pool_error(ret),
+                               __stringify_stream_state(state));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SET_STREAM_CB_MSG */
+static int __proxy_sound_pool_set_stream_state_change_callback_message(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+
+       char msg[MAX_MSG_LEN] = { '\0' };
+
+       if ((pars == NULL) || sscanf(pars, " %zu %zu %"MAX_MSG_LEN_STR"[^ ]",
+                                            &idx, &stream_idx, msg) < 3) {
+               _printf(CMD_COLOR_RED, "You have to specify both identifier of the "
+                               "pool and stream, plus message to be shown each time when "
+                               "state of the stream is changed! Message should be a single "
+                               "word. Format: "
+                               CMD_SET_STREAM_CB_MSG " <pool id> <stream id> <message>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (stream_idx > (MAX_STREAM_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Stream identifier value can't be greater than %d\n",
+                               MAX_STREAM_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_SET_STREAM_CB_MSG " command was called");
+       _logger_log_info("Set state changing callback (%s message) for stream %zu "
+                       "in pool with %zu identifier...", msg, stream_idx, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with stream to set callback for is NULL");
+
+       if (stream_messages[idx][stream_idx])
+               free(stream_messages[idx][stream_idx]);
+       stream_messages[idx][stream_idx] = strndup(msg, MAX_MSG_LEN);
+
+       int ret = sound_pool_stream_set_state_change_callback(pools[idx], stream_idx,
+                       __s_cb_msg, stream_messages[idx][stream_idx]);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_set_stream_state_change_callback(pool, "
+                               "%zu, cb, \"%s\") returned %s value", stream_idx, msg,
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_set_stream_state_change_callback(pool, "
+                               "%zu, cb, \"%s\") returned %s value", stream_idx, msg,
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SET_STREAM_CB_SCRIPT */
+static int __proxy_sound_pool_set_stream_state_change_callback_script(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+
+       char scr[MAX_MSG_LEN] = { '\0' };
+
+       if ((pars == NULL) || sscanf(pars, " %zu %zu %"MAX_MSG_LEN_STR"[^ ]",
+                                                &idx, &stream_idx, scr) < 3) {
+               _printf(CMD_COLOR_RED, "You have to specify both identifier of the "
+                               "pool and stream, plus file with script to be executed each "
+                               "time when state of the stream is changed! Message should be a "
+                               "single word. Format: " CMD_SET_STREAM_CB_SCRIPT
+                               " <pool id> <stream id> <script file>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       if (stream_idx > (MAX_STREAM_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Stream identifier value can't be greater than %d\n",
+                               MAX_STREAM_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_SET_STREAM_CB_SCRIPT " command was called");
+       _logger_log_info("Set state changing callback (%s script) for stream %zu "
+                       "in pool with %zu identifier...", scr, stream_idx, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool with stream to set callback for is NULL");
+
+       if (stream_scripts[idx][stream_idx])
+               free(stream_scripts[idx][stream_idx]);
+       stream_scripts[idx][stream_idx] = strndup(scr, MAX_MSG_LEN);
+
+       int ret = sound_pool_stream_set_state_change_callback(pools[idx], stream_idx,
+                       __s_cb_scr, stream_scripts[idx][stream_idx]);
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_set_stream_state_change_callback(pool, "
+                               "%zu, cb, \"%s\") returned %s value", stream_idx, scr,
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_err("sound_pool_set_stream_state_change_callback(pool, "
+                               "%zu, cb, \"%s\") returned %s value", stream_idx, scr,
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_UNSET_STREAM_CB */
+static int __proxy_sound_pool_unset_stream_state_change_callback(const char *pars)
+{
+       size_t idx = 0;
+       size_t stream_idx = 0;
+       if ((pars == NULL) || (sscanf(pars, " %zu %zu", &idx, &stream_idx) < 2)) {
+               _printf(CMD_COLOR_RED, "You have to specify both identifier of the "
+                               " pool and stream! Format: " CMD_UNSET_STREAM_CB
+                               " <pool id> <stream id>\n");
+               return FAIL;
+       }
+
+       if (idx > (MAX_POOL_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Pool identifier value can't be greater than %d\n",
+                               MAX_POOL_CNT - 1);
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_UNSET_STREAM_CB " command was called");
+       _logger_log_info("Unset state changing callback for the stream %zu in pool "
+                       "with %zu identifier...", stream_idx, idx);
+
+       if (pools[idx] == NULL)
+               _logger_log_warn("Pool to unset callback for is NULL");
+
+       int ret = sound_pool_stream_unset_state_change_callback(pools[idx], stream_idx);
+
+       if (stream_idx > (MAX_STREAM_CNT - 1)) {
+               _printf(CMD_COLOR_RED, "Stream identifier value can't be greater than %d\n",
+                               MAX_STREAM_CNT - 1);
+               return FAIL;
+       }
+
+       if (stream_messages[idx][stream_idx] != NULL)
+               free(stream_messages[idx][stream_idx]);
+       stream_messages[idx][stream_idx] = NULL;
+
+       if (stream_scripts[idx][stream_idx] != NULL)
+               free(stream_scripts[idx][stream_idx]);
+       stream_scripts[idx][stream_idx] = NULL;
+
+       if (ret == SOUND_POOL_ERROR_NONE)
+               _logger_log_info("sound_pool_unset_stream_state_change_callback(pool, "
+                               "%zu) returned %s value", stream_idx,
+                               __stringify_sound_pool_error(ret));
+       else
+               _logger_log_info("sound_pool_unset_stream_state_change_callback(pool, "
+                               "%zu) returned %s value", stream_idx,
+                               __stringify_sound_pool_error(ret));
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_SLEEP */
+static int __proxy_sleep(const char *pars)
+{
+       int ret = SOUND_POOL_ERROR_NONE;
+
+       useconds_t stime = 0;
+
+       if ((pars == NULL) || (sscanf(pars, " %u", &stime) < 1)) {
+               _printf(CMD_COLOR_RED, "You have to specify number of milliseconds "
+                               "for the pause duration! Format: " CMD_SLEEP " <millisecs>\n");
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_SLEEP " command was called");
+       _logger_log_info("Start main thread sleep for %u milliseconds...", stime);
+       stime *= MICROSECS_PER_MILLISEC;
+       usleep(stime);
+       _logger_log_info("Main thread sleep has been finished...", stime);
+
+       return (ret == SOUND_POOL_ERROR_NONE ? OK : FAIL);
+}
+
+/* CMD_EXECUTE_SCRIPT */
+static int __proxy_sound_pool_execute_script(const char *pars)
+{
+       char script_file[MAX_PATH_LEN] = {'\0'};
+
+       if ((pars == NULL) || (sscanf(pars, " %"MAX_PATH_LEN_STR"[^ ]", script_file) < 1)) {
+               _printf(CMD_COLOR_RED, "You have to specify script file name to be "
+                               "executed after command name! Format: " CMD_EXECUTE_SCRIPT " "
+                               "<script file>\n");
+               return FAIL;
+       }
+
+       _logger_log_info(CMD_EXECUTE_SCRIPT " command was called");
+       _logger_log_info("Loading script from file...");
+       FILE *fd = fopen(script_file, "r");
+
+       if (fd) {
+               _logger_log_info("File has been loaded...");
+               _logger_log_info("Reading lines...");
+               size_t line_len = 0;
+               char *line = NULL;
+               while ((line_len = getline(&line, &line_len, fd)) != -1) {
+                       line[strnlen(line, MAX_COMMAND_LINE_LEN) - 1] = '\0';
+                       _logger_log_info("Executing line: %s", line);
+                       if (_exec_cmd(line) != OK)
+                               _logger_log_warn("Unknown or unsupported command! "
+                                               "Line was skipped.");
+               }
+               _logger_log_info("Lines were read...");
+       } else {
+               _logger_log_err("File wasn't loaded...");
+               return FAIL;
+       }
+
+       _logger_log_info("Close file...");
+
+       if (fd)
+               fclose(fd);
+
+       return OK;
+}
+
+/* Number of parameters supported by each command */
+static int cmd_pars[MAX_COMMAND_LINE_LEN] = { /* CMD_EXIT */ 0,
+               /* CMD_HELP */ 0, /* CMD_CREATE_POOL */ 1, /* CMD_DESTROY_POOL */ 1,
+               /* CMD_ACTIVATE_POOL */ 1, /* CMD_DEACTIVATE_POOL */ 1,
+               /* CMD_GET_POOL_STATE */ 1, /* CMD_SET_POOL_VOLUME */ 2,
+               /* CMD_GET_POOL_VOLUME */ 2, /* CMD_SET_POOL_CB_MSG */ 2,
+               /* CMD_SET_POOL_CB_SCRIPT */ 2, /* CMD_UNSET_POOL_CB */ 1,
+               /* CMD_LIST_POOL */ 0, /* CMD_LOAD_SOURCE */ 3,
+               /* CMD_LOAD_MEDIA_PACKAGE */ 3, /* CMD_UNLOAD_SOURCE */ 2,
+               /* CMD_PLAY_STREAM */ 5, /* CMD_STOP_STREAM */ 2,
+               /* CMD_PAUSE_STREAM */ 2, /* CMD_RESUME_STREAM */ 2,
+               /* CMD_SET_STREAM_VOLUME */ 3, /* CMD_GET_STREAM_VOLUME */ 2,
+               /* CMD_SET_STREAM_LOOP */ 3, /* CMD_GET_STREAM_LOOP */ 2,
+               /* CMD_SET_STREAM_PRIORITY */ 3, /* CMD_GET_STREAM_PRIORITY */ 2,
+               /* CMD_GET_STREAM_STATE */ 2, /* CMD_SET_STREAM_CB_MSG */ 3,
+               /* CMD_SET_STREAM_CB_SCRIPT */ 3, /* CMD_UNSET_STREAM_CB */ 2,
+               /* CMD_EXECUTE_SCRIPT */ 1, /* CMD_SLEEP */ 1 };
+
+/* Command -> Function mapping */
+static int (*cmd_fcns[MAX_COMMAND_LINE_LEN])() = {
+               /* CMD_EXIT */ __exit,
+               /* CMD_HELP */ __print_cmd_help_msg,
+               /* CMD_CREATE_POOL */ __proxy_sound_pool_create,
+               /* CMD_DESTROY_POOL */ __proxy_sound_pool_destroy,
+               /* CMD_ACTIVATE_POOL */ __proxy_sound_pool_activate,
+               /* CMD_DEACTIVATE_POOL */ __proxy_sound_pool_deactivate,
+               /* CMD_GET_POOL_STATE */ __proxy_sound_pool_get_state,
+               /* CMD_SET_POOL_VOLUME */ __proxy_sound_pool_set_volume,
+               /* CMD_GET_POOL_VOLUME */ __proxy_sound_pool_get_volume,
+               /* CMD_SET_POOL_CB_MSG */ __proxy_sound_pool_set_state_change_callback_message,
+               /* CMD_SET_POOL_CB_SCRIPT */ __proxy_sound_pool_set_state_change_callback_script,
+               /* CMD_UNSET_POOL_CB */ __proxy_sound_pool_unset_state_change_callback,
+               /* CMD_LIST_POOL */ __proxy_sound_pool_list,
+               /* CMD_LOAD_SOURCE */ __proxy_sound_pool_load_source_from_file,
+               /* CMD_LOAD_MEDIA_PACKAGE */ NULL,
+               /* CMD_UNLOAD_SOURCE */ __proxy_sound_pool_unload_source,
+               /* CMD_PLAY_STREAM */ __proxy_sound_pool_play_stream,
+               /* CMD_STOP_STREAM */ __proxy_sound_pool_stop_stream,
+               /* CMD_PAUSE_STREAM */ __proxy_sound_pool_pause_stream,
+               /* CMD_RESUME_STREAM */ __proxy_sound_pool_resume_stream,
+               /* CMD_SET_STREAM_VOLUME */ __proxy_sound_pool_stream_set_volume,
+               /* CMD_GET_STREAM_VOLUME */ __proxy_sound_pool_stream_get_volume,
+               /* CMD_SET_STREAM_LOOP */ __proxy_sound_pool_stream_set_loop,
+               /* CMD_GET_STREAM_LOOP */ __proxy_sound_pool_stream_get_loop,
+               /* CMD_SET_STREAM_PRIORITY */ __proxy_sound_pool_stream_set_priority,
+               /* CMD_GET_STREAM_PRIORITY */ __proxy_sound_pool_stream_get_priority,
+               /* CMD_GET_STREAM_STATE */ __proxy_sound_pool_get_stream_state,
+               /* CMD_SET_STREAM_CB_MSG */ __proxy_sound_pool_set_stream_state_change_callback_message,
+               /* CMD_SET_STREAM_CB_SCRIPT */ __proxy_sound_pool_set_stream_state_change_callback_script,
+               /* CMD_UNSET_STREAM_CB */ __proxy_sound_pool_unset_stream_state_change_callback,
+               /* CMD_EXECUTE_SCRIPT */ __proxy_sound_pool_execute_script,
+               /* CMD_SLEEP */ __proxy_sleep };
+
+int _exec_cmd(const char *cmd_line)
+{
+       /* User just pressed enter: */
+       if (strlen(cmd_line) == 0) return OK;
+
+       size_t trim_len = 0;
+       while((cmd_line + trim_len)[0] == ' ')
+               trim_len++;
+
+       char *cmd = cmd_line + trim_len;
+
+       /* Macro for checking command correctness */
+#   define CHECK_CMD(ccmd, line) \
+                       (strncmp(ccmd, line, strnlen(ccmd, MAX_COMMAND_LINE_LEN)) == 0)
+
+       int idx = 0;
+       for (; idx < CMD_COUNT; ++idx) {
+               if (CHECK_CMD(cmd_list[idx], cmd)) {
+                       if (cmd_pars[idx] > 0) {
+                               if (cmd_fcns[idx])
+                                       return cmd_fcns[idx](cmd + strlen(cmd_list[idx]));
+                       } else {
+                               return cmd_fcns[idx]();
+                       }
+               }
+       }
+
+       return UCMD;
+}
diff --git a/test/sound_pool_test.c b/test/sound_pool_test.c
new file mode 100644 (file)
index 0000000..c2cce8a
--- /dev/null
@@ -0,0 +1,344 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "logger.h"
+#include "proxy.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <termios.h>
+#include <unistd.h>
+#include <getopt.h>
+
+#define KEY_CODE_ESCAPE      27
+#define KEY_CODE_BACKSPACE   127
+#define KEY_CODE_TAB         9
+#define KEY_CODE_ARROW_UP    65
+#define KEY_CODE_ARROW_DOWN  66
+#define KEY_CODE_ARROW_RIGHT 67
+#define KEY_CODE_ARROW_LEFT  68
+
+/* The list data structure to keep history of the test suite commands */
+typedef struct __cmd_history_s {
+       struct __cmd_history_s *prev;
+       struct __cmd_history_s *next;
+       char cmd[MAX_COMMAND_LINE_LEN];
+} _cmd_history_t;
+
+static _cmd_history_t *_cmd_history_tail = NULL;
+static _cmd_history_t *_cmd_history_curp = NULL;
+static char OUTPUT_LOG_FILE[MAX_PATH_LEN] = "out.log";
+
+void print_usage() {
+       printf( "Usage: sound_pool_test [options]                              \n");
+       printf( "Test Suite for testing Tizen SoundPool module                 \n");
+       printf( "-h, --help             - shows this help;                     \n");
+       printf( "-s, --script=SCRIPT    - executes commands from the text file \n"
+                       "                         directly after start;                \n");
+       printf( "-t, --target=TARGET(S) - selects the target or targets to     \n"
+                       "                         output logs. Possible targets are:   \n"
+                       "                         stderr, dlog, file. You can also     \n"
+                       "                         select multiple targets using coma.  \n"
+                       "                         for example,                         \n"
+                       "                         > sound_pool_test -t stderr,file     \n"
+                       "                         will output both in standard         \n"
+                       "                         error and file;                      \n");
+       printf( "-f, --file=FILEPATH    - selects file for file output logging.\n"
+                       "                         Works only in -t argument value      \n"
+                       "                         includes 'file' target;              \n");
+}
+
+_cmd_history_t *add_cmd_to_history(const char *cmd)
+{
+       if (!cmd)
+               return NULL;
+
+       if (!_cmd_history_tail) {
+               _cmd_history_tail = malloc(sizeof(_cmd_history_t));
+               if (!_cmd_history_tail)
+                       return NULL;
+               _cmd_history_tail->prev = NULL;
+               _cmd_history_tail->next = NULL;
+       } else {
+               _cmd_history_tail->next = malloc(sizeof(_cmd_history_t));
+               if (!_cmd_history_tail->next)
+                       return NULL;
+               _cmd_history_tail->next->prev = _cmd_history_tail;
+               _cmd_history_tail->next->next = NULL;
+               _cmd_history_tail = _cmd_history_tail->next;
+       }
+
+       strncpy(_cmd_history_tail->cmd, cmd, MAX_COMMAND_LINE_LEN - 1);
+       _cmd_history_tail->cmd[MAX_COMMAND_LINE_LEN - 1] = '\0';
+       _cmd_history_curp = _cmd_history_tail;
+       return _cmd_history_tail;
+}
+
+const char *pop_up_curp_from_cmd_history()
+{
+       if (!_cmd_history_curp)
+               return NULL;
+
+       const char *curp_cmd = _cmd_history_curp->cmd;
+       if (_cmd_history_curp->prev)
+               _cmd_history_curp = _cmd_history_curp->prev;
+       return curp_cmd;
+}
+
+const char *pop_down_curp_from_cmd_history()
+{
+       if (!_cmd_history_curp)
+               return NULL;
+
+       const char *curp_cmd = _cmd_history_curp->cmd;
+       if (_cmd_history_curp->next)
+               _cmd_history_curp = _cmd_history_curp->next;
+       return curp_cmd;
+}
+
+/* Searches the same part of two strings from the start and returns the length
+   of this part. For example, for the strings "Big Troll" and "Big troll" value
+   4 will be returned (the same part is "Big "). */
+size_t get_identical_start_len(const char *str1, const char *str2)
+{
+       size_t len1 = strnlen(str1, MAX_COMMAND_LINE_LEN);
+       size_t len2 = strnlen(str2, MAX_COMMAND_LINE_LEN);
+       size_t idx = 0;
+       while(idx < len1 && idx < len2) {
+               if (str1[idx] != str2[idx])
+                       break;
+               ++idx;
+       }
+       return idx;
+}
+
+size_t auto_fill(const char *cmd_start, char fill_hint[MAX_COMMAND_LINE_LEN])
+{
+       size_t idx = 0;
+       size_t cmd_start_len = strnlen(cmd_start, MAX_COMMAND_LINE_LEN);
+
+       char auto_fill[MAX_COMMAND_LINE_LEN] = { '\0' };
+       size_t fill_found = 0;
+
+       for (; idx < CMD_COUNT; ++idx) {
+               if (strncmp(cmd_start, cmd_list[idx], cmd_start_len) == 0) {
+                       if (!fill_found) {
+                               strncpy(auto_fill, cmd_list[idx], MAX_COMMAND_LINE_LEN);
+                               fill_found = strnlen(auto_fill, MAX_COMMAND_LINE_LEN);
+                       } else {
+                               fill_found = get_identical_start_len(auto_fill, cmd_list[idx]);
+                               auto_fill[fill_found] = '\0';
+                       }
+               }
+       }
+
+       if (!fill_found)
+               strncpy(fill_hint, cmd_start, MAX_COMMAND_LINE_LEN);
+       else
+               strncpy(fill_hint, auto_fill, MAX_COMMAND_LINE_LEN);
+
+       return fill_found;
+}
+
+size_t print_cmd_prompt()
+{
+       const char *prompt = "sound-pool-ts-cmd > ";
+       printf("%s", prompt);
+       /* Return the length of comand prompt c-string */
+       return strnlen(prompt, MAX_COMMAND_LINE_LEN);
+}
+
+int getch(void)
+{
+    struct termios oldattr, newattr;
+    int ch;
+    tcgetattr(STDIN_FILENO, &oldattr);
+    newattr = oldattr;
+    newattr.c_lflag &= ~(ICANON | ECHO);
+    tcsetattr(STDIN_FILENO, TCSANOW, &newattr);
+    ch = getchar();
+    tcsetattr(STDIN_FILENO, TCSANOW, &oldattr);
+    return ch;
+}
+
+size_t ts_getline(char *cmd_line)
+{
+       if (!cmd_line)
+               return 0;
+
+       print_cmd_prompt();
+
+       /* Read whole line */
+       int ci = 0;
+       char cc = '\0';
+       int c = 0;
+       while ((c = getch()) != EOF && (cc = (char)c) != '\n' &&
+                       ci < MAX_COMMAND_LINE_LEN - 1) {
+               if (cc == KEY_CODE_ESCAPE) { /* Arrow keys */
+                       getch();
+                       c = getch();
+                       if (c == EOF)
+                               continue;
+                       cc = (char)c; /* Here is particular arrow code */
+                       const char *curp_cmd = NULL;
+                       if (cc == KEY_CODE_ARROW_UP) {
+                               if ((curp_cmd = pop_up_curp_from_cmd_history())) {
+                                       while (ci-- != 0)
+                                               printf("\b \b");
+                                       printf("%s", curp_cmd);
+                                       strncpy(cmd_line, curp_cmd, MAX_COMMAND_LINE_LEN);
+                                       ci = strnlen(curp_cmd, MAX_COMMAND_LINE_LEN);
+                               }
+                       } else if (cc == KEY_CODE_ARROW_DOWN) {
+                               if ((curp_cmd = pop_down_curp_from_cmd_history())) {
+                                       while (ci-- != 0)
+                                               printf("\b \b");
+                                       printf("%s", curp_cmd);
+                                       strncpy(cmd_line, curp_cmd, MAX_COMMAND_LINE_LEN);
+                                       ci = strnlen(curp_cmd, MAX_COMMAND_LINE_LEN);
+                               }
+                       }
+                       continue;
+               }
+               if (cc == KEY_CODE_BACKSPACE) { /* Backspace key */
+                       if (ci != 0) {
+                               printf("\b \b");
+                               cmd_line[ci--] = '\0';
+                       }
+                       continue;
+               }
+               if (cc == KEY_CODE_TAB) { /* Tab key */
+                       size_t hint_len = auto_fill(cmd_line, cmd_line);
+                       while (ci < hint_len)
+                               printf("%c", cmd_line[ci++]);
+                       cmd_line[ci] = '\0';
+                       continue;
+               }
+               cmd_line[ci++] = cc;
+               cmd_line[ci] = '\0';
+               printf("%c", cc);
+       }
+
+       printf("\n");
+
+       return ci + 1;
+}
+
+int main(int argc, char* argv[])
+{
+       _logger_set_log_tag("TIZEN_SOUND_POOL_TEST_SUITE");
+       _logger_set_logging_mode(LOG_MODE_STDERR | LOG_MODE_DLOG);
+
+#   define OPTIONS "s:f:t:h"
+       struct option options[] = {
+               { "script",  required_argument, NULL, 's' },
+               { "logfile", required_argument, NULL, 'f' },
+               { "target",  required_argument, NULL, 't' },
+               { "help",    no_argument,       NULL, 'h' },
+               { NULL, 0, NULL, 0 }
+       };
+
+       char commands[MAX_COMMAND_LINE_LEN] = { '\0' };
+       size_t last_cmd_end = 0;
+
+       int opt = 0;
+       int do_print_usage = 0;
+       int do_set_file = 0;
+       while ((opt = getopt_long(argc, argv, OPTIONS, options, NULL)) != -1) {
+               switch (opt) {
+               case 's': {
+                       snprintf(commands + last_cmd_end, MAX_COMMAND_LINE_LEN,
+                                       "%s %s\n", CMD_EXECUTE_SCRIPT, optarg);
+                       last_cmd_end +=
+                                       strnlen(commands + last_cmd_end, MAX_COMMAND_LINE_LEN) + 1;
+                       break;
+               }
+               case 'f': {
+                       _logger_set_file(optarg);
+                       do_set_file--;
+                       break;
+               }
+               case 't': {
+                       int log_mode = LOG_MODE_NONE;
+                       char *token = strtok(optarg, ",");
+
+                       while (token != NULL) {
+                               if (strncmp(token, "stderr", MAX_MSG_LEN) == 0) {
+                                       log_mode |= LOG_MODE_STDERR;
+                               } else if (strncmp(token, "file", MAX_MSG_LEN) == 0) {
+                                       log_mode |= LOG_MODE_FILE;
+                                       do_set_file++;
+                               } else if (strncmp(token, "dlog", MAX_MSG_LEN) == 0) {
+                                       log_mode |= LOG_MODE_DLOG;
+                               } else {
+                                       _printf(CMD_COLOR_RED, "%s target is not supported! "
+                                                       "Use one (or combination separated by coma) "
+                                                       "from the list: dlog, stderr, and dlog.\n", token);
+                               }
+                               token = strtok(NULL, ", ");
+                       }
+
+                       if (log_mode != LOG_MODE_NONE)
+                               _logger_set_logging_mode(log_mode);
+                       break;
+               }
+               case 'h':
+               case '?': {
+                       do_print_usage = 1;
+                       break;
+               }
+               default:
+                       break;
+               }
+       }
+
+       if (do_print_usage != 0)
+               print_usage();
+
+       if (do_set_file > 0)
+               _logger_set_file(OUTPUT_LOG_FILE);
+
+       char *ccmd = commands;
+
+       while (ccmd[0] != '\0') {
+               if (_exec_cmd(ccmd) == UCMD) {
+                       _printf(CMD_COLOR_RED,
+                                       "Unknown command! Type 'help' for command help!\n");
+               }
+               ccmd += strnlen(ccmd, MAX_COMMAND_LINE_LEN) + 1;
+       }
+
+       char cmd_line[MAX_COMMAND_LINE_LEN];
+       size_t cmd_line_len = 0;
+
+       while ((cmd_line_len = ts_getline(cmd_line))) {
+               if (cmd_line_len == 1)
+                       continue;
+
+               /* Try to execute commands parsed from the line: */
+               int res = _exec_cmd(cmd_line);
+               if (res == EXIT)
+                       break;
+
+               if (res == UCMD)
+                       _printf(CMD_COLOR_RED,
+                                       "Unknown command! Type 'help' for command help!\n");
+
+               add_cmd_to_history(cmd_line);
+       }
+
+       return 0;
+}