ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(pkgconfig)
ADD_SUBDIRECTORY(test)
+IF(BUILD_GCOV)
+IF(DEBUG_GCOV)
+ ADD_DEFINITIONS(-DDEBUG_GCOV)
+ENDIF(DEBUG_GCOV)
+ ADD_SUBDIRECTORY(unittest)
+ENDIF(BUILD_GCOV)
Group: Network & Connectivity/API
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
-
BuildRequires: cmake
BuildRequires: pkgconfig(gobject-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-system-info)
%if 0%{?gcov:1}
+BuildRequires: gtest-devel
BuildRequires: lcov
%endif
-DLOCAL_STATE_DIR:PATH=%{_localstatedir} \
-DDATA_ROOT_DIR:PATH=%{_datadir} \
-DFULLVER=%{version} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
+ -DDEBUG_GCOV=%{?debug_gcov:1}%{!?debug_gcov:0} \
-DMAJORVER=${MAJORVER}
make %{?jobs:-j%jobs}
install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
%endif
+%check
+%if 0%{?gcov:1}
+pushd unittest
+./run_coverage.sh
+popd
+%endif
+
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
g_error_free(err); //LCOV_EXCL_LINE
}
- return STC_ERROR_OPERATION_FAILED;
+ return STC_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
stc_handle->dbus_connection.cancellable = g_cancellable_new();
*dbus_error = STC_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
- return NULL;
+ return NULL; //LCOV_EXCL_LINE
}
return reply;
if (ret != STC_ERROR_NONE) {
STC_LOGE("Create handle failed [%s]", //LCOV_EXCL_LINE
_stc_convert_error_type_to_string(ret));
- STC_UNLOCK;
+ STC_UNLOCK; //LCOV_EXCL_LINE
return ret; //LCOV_EXCL_LINE
}
--- /dev/null
+#SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+SET(UNITTEST_NAME "tct-stc-core")
+
+SET(CAPI_LIB "capi-network-stc")
+SET(TC_SOURCES
+ utc-stc.c
+ utc-stc-common.c
+)
+
+PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
+ capi-base-common
+ dlog
+ capi-system-info
+ glib-2.0
+ gio-unix-2.0
+)
+
+INCLUDE_DIRECTORIES(
+ ${${CAPI_LIB}_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/src/include
+ ${CMAKE_SOURCE_DIR}/src/internal/include
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+)
+
+ADD_DEFINITIONS( -DMOBILE )
+
+SET(STC_MOCK "stc-mock")
+SET(STC_MOCK_SRCS mock/stc-mock.c)
+SET(STC_MOCK_CFLAGS "${CMAKE_C_FLAGS}" )
+ADD_LIBRARY(${STC_MOCK} SHARED ${STC_MOCK_SRCS})
+SET_TARGET_PROPERTIES(${STC_MOCK} PROPERTIES
+ COMPILE_FLAGS ${STC_MOCK_CFLAGS}
+)
+
+ADD_EXECUTABLE(${UNITTEST_NAME} ${UNITTEST_NAME}.cpp ${TC_SOURCES} )
+TARGET_LINK_LIBRARIES(${UNITTEST_NAME}
+ ${${CAPI_LIB}_LIBRARIES}
+ ${LIB_NAME}
+ gtest
+ capi-network-stc
+)
+
+# INSTALL(PROGRAMS ${UNITTEST_NAME} DESTINATION ${BIN_INSTALL_DIR})
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef _ASSERT_H_
+#define _ASSERT_H_
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define assert(exp) \
+ do { \
+ if (!(exp)) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert Fail; Following expression is not true: %s\n", \
+ __FILE__, __LINE__, #exp); \
+ return 1; \
+ } \
+ } while (0)
+
+#define assert_eq(var, ref) \
+ do { \
+ if (var != ref) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are not equal\n", \
+ __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \
+ return 1; \
+ } \
+ } while (0)
+
+#define assert_eq_no_return(var, ref) \
+ do { \
+ if (var != ref) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are not equal\n", \
+ __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \
+ return ; \
+ } \
+ } while (0)
+
+#define assert_neq_no_return(var, ref) \
+ do { \
+ if (var == ref) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are equal\n", \
+ __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \
+ return ; \
+ } \
+ } while (0)
+
+#define assert_neq(var, ref) \
+ do { \
+ if (var == ref) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) and (%s == 0x%x) are equal\n", \
+ __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \
+ return 1; \
+ } \
+ } while (0)
+
+#define assert_gt(var, ref) \
+ do { \
+ if (var <= ref) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not greater than (%s == 0x%x)\n", \
+ __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \
+ return 1; \
+ } \
+ } while (0)
+
+#define assert_geq(var, ref) \
+ do { \
+ if (var < ref) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not greater than or equal to (%s == 0x%x)\n", \
+ __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \
+ return 1; \
+ } \
+ } while (0)
+
+#define assert_lt(var, ref) \
+ do { \
+ if (var >= ref) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not lower than (%s == 0x%x)\n", \
+ __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \
+ return 1; \
+ } \
+ } while (0)
+
+#define assert_leq(var, ref) \
+ do { \
+ if (var > ref) { \
+ fprintf(stderr, \
+ "\n[TCT][%s][Line : %d] Assert fail; Values (%s == 0x%x) is not lower than or equal to (%s == 0x%x)\n", \
+ __FILE__, __LINE__, #var, (int)var, #ref, (int)ref); \
+ return 1; \
+ } \
+ } while (0)
+
+#ifdef __cplusplus
+}
+#endif
+#endif // _ASSERT_H_
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef _TCT_COMMON_H_
+#define _TCT_COMMON_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "assert_local.h"
+
+#include <malloc.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#ifdef DEBUG_GCOV
+#define COMMON_DEBUG 1
+#else
+#define COMMON_DEBUG 0
+#endif
+
+#define FREE_MEMORY_TC(buffer) { \
+ if ( buffer != NULL ) \
+ { \
+ free(buffer); \
+ buffer = NULL; \
+ } \
+}
+
+#define PRINT_LOG(type, tag, ...) do { \
+ fprintf(stdout, ##__VA_ARGS__ ); \
+ fprintf(stdout, "\n" ); \
+} while(0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _TCT_COMMON_H_
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef _TESTCASE_H_
+#define _TESTCASE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* pointer to startup/cleanup functions */
+typedef void (*void_fun_ptr)(void);
+
+/* pointer to testcase functions */
+typedef int (*tc_fun_ptr)(void);
+
+/* struct describing specific testcase */
+typedef struct testcase_s {
+ const char* name;
+ tc_fun_ptr function;
+ void_fun_ptr startup;
+ void_fun_ptr cleanup;
+} testcase;
+
+#ifdef __cplusplus
+}
+#endif
+#endif // _TESTCASE_H_
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <system_info.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "stc.h"
+#include "stc-dbus.h"
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef DEBUG_GCOV
+#define MOCK_DEBUG 1
+#else
+#define MOCK_DEBUG 0
+#endif
+
+#define DEBUG_MOCK_LOG(str) {\
+ if (MOCK_DEBUG) {\
+ fprintf(stdout, "[Line:%5d][%s] ***** DEBUG [%s] *****\n",\
+ __LINE__, __FUNCTION__, str);\
+ }\
+}
+
+API int system_info_get_platform_bool(const char *key, bool *value)
+{
+ *value = TRUE;
+ return SYSTEM_INFO_ERROR_NONE;
+}
+
+API GDBusConnection *g_bus_get_sync(GBusType bus_type,
+ GCancellable *cancellable, GError **error)
+{
+ GObject *connection = g_try_malloc0(sizeof(GObject));
+
+ return (GDBusConnection *)connection;
+}
+
+API GCancellable *g_cancellable_new(void)
+{
+ GObject *cancellable = g_try_malloc0(sizeof(GObject));
+
+ return (GCancellable *)cancellable;
+}
+
+API void g_cancellable_cancel(GCancellable *cancellable)
+{
+ return;
+}
+
+API void g_object_unref (gpointer _object)
+{
+ return;
+}
+
+API GVariant *g_dbus_connection_call_sync(GDBusConnection *connection,
+ const gchar *bus_name, const gchar *object_path, const gchar *interface_name,
+ const gchar *method_name, GVariant *parameters, const GVariantType *reply_type,
+ GDBusCallFlags flags, gint timeout_msec, GCancellable *cancellable, GError **error)
+{
+ if (g_strcmp0(method_name, STC_MANAGER_METHOD_STATS_INIT) == 0) {
+ return GUINT_TO_POINTER(1);
+ }
+
+ return NULL;
+}
+
+struct statistics_info_s {
+ char *app_id;
+ char *ifname;
+ char *subscriber_id;
+ stc_iface_type_e iftype;
+ int64_t incoming_bytes;
+ int64_t outgoing_bytes;
+ stc_roaming_type_e roaming;
+ stc_process_state_e ground;
+} statistics_info[] = {
+ {
+ "org.tizen.browser",
+ "wlan0",
+ "",
+ STC_IFACE_WIFI,
+ 1024,
+ 2048,
+ STC_ROAMING_DISABLED,
+ STC_PROCESS_STATE_FOREGROUND,
+ },
+ {
+ "org.tizen.browser",
+ "seth_w0",
+ "ab2b67b4e1179d52adbf3ef95054aa459c920bdd31e5834c2bd9018cc595d29d",
+ STC_IFACE_DATACALL,
+ 256,
+ 128,
+ STC_ROAMING_ENABLED,
+ STC_PROCESS_STATE_BACKGROUND,
+ },
+};
+
+struct dbus_return_data_s {
+ GVariant *return_parameters;
+ GAsyncReadyCallback callback;
+ gpointer user_data;
+};
+
+static gboolean __connection_call_cb(gpointer user_data)
+{
+ struct dbus_return_data_s *dbus_return_data = user_data;
+
+ DEBUG_MOCK_LOG("__connection_call_cb");
+
+ dbus_return_data->callback(NULL,
+ (GAsyncResult *)dbus_return_data->return_parameters,
+ dbus_return_data->user_data);
+
+ return FALSE;
+}
+
+API void g_dbus_connection_call(GDBusConnection *connection, const gchar *bus_name,
+ const gchar *object_path, const gchar *interface_name, const gchar *method_name,
+ GVariant *parameters, const GVariantType *reply_type, GDBusCallFlags flags,
+ gint timeout_msec, GCancellable *cancellable, GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GVariantBuilder *builder = NULL;
+ GVariant *return_parameters = NULL;
+ struct dbus_return_data_s *dbus_return_data = NULL;
+
+ DEBUG_MOCK_LOG(method_name);
+
+ if (g_strcmp0(method_name, STC_MANAGER_METHOD_STATS_GET_ALL) == 0) {
+ int i;
+ int cnt = sizeof(statistics_info) / sizeof(struct statistics_info_s);
+
+ dbus_return_data = g_try_malloc0(sizeof(struct dbus_return_data_s));
+ builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
+
+ for (i = 0; i < cnt; ++i) {
+ GVariantBuilder sub_builder;
+ g_variant_builder_init(&sub_builder, G_VARIANT_TYPE("a{sv}"));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "app_id",
+ g_variant_new_string(statistics_info[i].app_id));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "ifname",
+ g_variant_new_string(statistics_info[i].ifname));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "subscriber_id",
+ g_variant_new_string(statistics_info[i].subscriber_id));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "iftype",
+ g_variant_new_uint16(statistics_info[i].iftype));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "cnt_in_bytes",
+ g_variant_new_int64(statistics_info[i].incoming_bytes));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "cnt_out_bytes",
+ g_variant_new_int64(statistics_info[i].outgoing_bytes));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "roaming",
+ g_variant_new_uint16(statistics_info[i].roaming));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "ground",
+ g_variant_new_uint16(statistics_info[i].ground));
+
+ g_variant_builder_add_value(builder, g_variant_builder_end(&sub_builder));
+ }
+
+ return_parameters = g_variant_new("(iaa{sv})", STC_ERROR_NONE, builder);
+ g_variant_builder_unref(builder);
+
+ dbus_return_data->return_parameters = return_parameters;
+ dbus_return_data->callback = callback;
+ dbus_return_data->user_data = user_data;
+
+ g_timeout_add(500, __connection_call_cb, dbus_return_data);
+ } else if (g_strcmp0(method_name, STC_MANAGER_METHOD_STATS_GET_PER_APP_ID) == 0) {
+ GVariantBuilder sub_builder;
+ dbus_return_data = g_try_malloc0(sizeof(struct dbus_return_data_s));
+ builder = g_variant_builder_new(G_VARIANT_TYPE("aa{sv}"));
+
+ g_variant_builder_init(&sub_builder, G_VARIANT_TYPE("a{sv}"));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "app_id",
+ g_variant_new_string(statistics_info[0].app_id));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "ifname",
+ g_variant_new_string(statistics_info[0].ifname));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "subscriber_id",
+ g_variant_new_string(statistics_info[0].subscriber_id));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "iftype",
+ g_variant_new_uint16(statistics_info[0].iftype));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "cnt_in_bytes",
+ g_variant_new_int64(statistics_info[0].incoming_bytes));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "cnt_out_bytes",
+ g_variant_new_int64(statistics_info[0].outgoing_bytes));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "roaming",
+ g_variant_new_uint16(statistics_info[0].roaming));
+
+ g_variant_builder_add(&sub_builder, "{sv}", "ground",
+ g_variant_new_uint16(statistics_info[0].ground));
+
+ g_variant_builder_add_value(builder, g_variant_builder_end(&sub_builder));
+
+ return_parameters = g_variant_new("(iaa{sv})", STC_ERROR_NONE, builder);
+ g_variant_builder_unref(builder);
+
+ dbus_return_data->return_parameters = return_parameters;
+ dbus_return_data->callback = callback;
+ dbus_return_data->user_data = user_data;
+
+ g_timeout_add(500, __connection_call_cb, dbus_return_data);
+ }
+
+ return;
+}
+
+API GVariant *g_dbus_connection_call_finish(GDBusConnection *connection,
+ GAsyncResult *res, GError **error)
+{
+ *error = NULL;
+ return (GVariant *)res;
+}
+
+API guint g_dbus_connection_signal_subscribe(GDBusConnection *connection,
+ const gchar *sender, const gchar *interface_name, const gchar *member,
+ const gchar *object_path, const gchar *arg0, GDBusSignalFlags flags,
+ GDBusSignalCallback callback, gpointer user_data, GDestroyNotify user_data_free_func)
+{
+ return 1;
+}
+
+API void g_dbus_connection_signal_unsubscribe(GDBusConnection *connection,
+ guint subscription_id)
+{
+ return;
+}
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+export LD_LIBRARY_PATH=../src/
+pushd ../
+RootDir=$PWD
+popd
+
+unitTestFile=tct-stc-core
+if [ ! -x "./$unitTestFile" ]
+then
+ echo "$unitTestFile file does not exist!"
+ exit -1
+fi
+
+LD_PRELOAD=./libstc-mock.so ./$unitTestFile
+
+CMakeDir=${RootDir}/src/CMakeFiles/capi-network-stc.dir/
+CoverageDir=${RootDir}/coverage
+
+pushd $CMakeDir
+
+ for obj in `ls *.o`
+ do
+ gcov -b -c $obj
+ done
+
+ if [ -f /usr/bin/lcov ]
+ then
+ lcov -c -d . --exclude "/usr/lib/gcc/armv7l-tizen-linux-gnueabi/9.2.0/include/c++/*" -o cov.info
+ genhtml cov.info -o ${CoverageDir}
+ echo "Coverage test result created! [${CoverageDir}]"
+ else
+ echo "lcov does not exist!"
+ fi
+popd
--- /dev/null
+//
+// Copyright (c) 2020 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include <stdio.h>
+#include <string.h>
+#include "tct_common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "tct-stc-core.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+#include <gtest/gtest.h>
+
+#include <malloc.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <stdbool.h>
+
+TEST(stc, stc){
+ char *pszGetTCName = NULL;
+ pszGetTCName = (char*)malloc( 256 );
+ memset( pszGetTCName, 0x00, 256);
+ strcpy( pszGetTCName, "utc_stc");
+ int i=0, result=0;
+
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, pszGetTCName);
+
+ int successCnt = 0;
+ int errorCnt = 0;
+ for ( i = 0; tc_array[i].name; i++ )
+ {
+ if (COMMON_DEBUG)
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "===========================================");
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[%s]", tc_array[i].name);
+ if ( 0 == strncmp(pszGetTCName, tc_array[i].name, strlen(pszGetTCName)) )
+ {
+ if ( tc_array[i].startup )
+ {
+ tc_array[i].startup();
+ }
+
+ result = tc_array[i].function();
+
+ if( result == 0 ){
+ successCnt++;
+ }
+ else {
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[Error][%d] %s returns value = %d", i, tc_array[i].name, result);
+ errorCnt++;
+ }
+
+ EXPECT_EQ(result, 0);
+ // ASSERT_EQ(result, 0);
+
+ if ( tc_array[i].cleanup )
+ {
+ tc_array[i].cleanup();
+ }
+ }
+ else {
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "Name check error! [%s][%s]", pszGetTCName, tc_array[i].name);
+ ASSERT_EQ(0, 1);
+ }
+ if (COMMON_DEBUG)
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "===========================================");
+ }
+
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "==========================");
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "Success [%4d / %4d]", successCnt, successCnt + errorCnt);
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "Error [%4d / %4d]", errorCnt, successCnt + errorCnt);
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "==========================");
+
+ FREE_MEMORY_TC(pszGetTCName);
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#ifndef __TCT_STC_NATIVE_H__
+#define __TCT_STC_NATIVE_H__
+
+#include "testcase.h"
+#include "tct_common.h"
+
+extern void utc_stc_startup(void);
+extern void utc_stc_cleanup(void);
+
+extern int utc_stc_initialize_p(void);
+extern int utc_stc_initialize_n(void);
+extern int utc_stc_deinitialize_p(void);
+extern int utc_stc_deinitialize_n(void);
+extern int utc_stc_stats_rule_create_p(void);
+extern int utc_stc_stats_rule_create_n(void);
+extern int utc_stc_stats_rule_destroy_p(void);
+extern int utc_stc_stats_rule_destroy_n(void);
+extern int utc_stc_stats_rule_set_app_id_p(void);
+extern int utc_stc_stats_rule_set_app_id_n(void);
+extern int utc_stc_stats_rule_set_time_interval_p(void);
+extern int utc_stc_stats_rule_set_time_interval_n(void);
+extern int utc_stc_stats_rule_set_iface_type_p(void);
+extern int utc_stc_stats_rule_set_iface_type_n(void);
+extern int utc_stc_stats_rule_set_time_period_p(void);
+extern int utc_stc_stats_rule_set_time_period_n(void);
+extern int utc_stc_stats_rule_get_app_id_p(void);
+extern int utc_stc_stats_rule_get_app_id_n(void);
+extern int utc_stc_stats_rule_get_time_interval_p(void);
+extern int utc_stc_stats_rule_get_time_interval_n(void);
+extern int utc_stc_stats_rule_get_iface_type_p(void);
+extern int utc_stc_stats_rule_get_iface_type_n(void);
+extern int utc_stc_stats_rule_get_time_period_p(void);
+extern int utc_stc_stats_rule_get_time_period_n(void);
+extern int utc_stc_get_stats_p(void);
+extern int utc_stc_get_stats_n(void);
+extern int utc_stc_get_all_stats_p(void);
+extern int utc_stc_get_all_stats_n(void);
+extern int utc_stc_foreach_stats_p(void);
+extern int utc_stc_foreach_stats_n(void);
+extern int utc_stc_foreach_all_stats_p(void);
+extern int utc_stc_foreach_all_stats_n(void);
+extern int utc_stc_get_total_stats_p(void);
+extern int utc_stc_get_total_stats_n(void);
+extern int utc_stc_stats_info_clone_p(void);
+extern int utc_stc_stats_info_clone_n(void);
+extern int utc_stc_stats_info_destroy_p(void);
+extern int utc_stc_stats_info_destroy_n(void);
+extern int utc_stc_stats_info_get_app_id_p(void);
+extern int utc_stc_stats_info_get_app_id_n(void);
+extern int utc_stc_stats_info_get_iface_name_p(void);
+extern int utc_stc_stats_info_get_iface_name_n(void);
+extern int utc_stc_stats_info_get_time_interval_p(void);
+extern int utc_stc_stats_info_get_time_interval_n(void);
+extern int utc_stc_stats_info_get_iface_type_p(void);
+extern int utc_stc_stats_info_get_iface_type_n(void);
+extern int utc_stc_stats_info_get_counter_p(void);
+extern int utc_stc_stats_info_get_counter_n(void);
+extern int utc_stc_stats_info_get_roaming_type_p(void);
+extern int utc_stc_stats_info_get_roaming_type_n(void);
+extern int utc_stc_stats_info_get_protocol_type_p(void);
+extern int utc_stc_stats_info_get_protocol_type_n(void);
+extern int utc_stc_stats_info_get_process_state_p(void);
+extern int utc_stc_stats_info_get_process_state_n(void);
+
+testcase tc_array[] = {
+ {"utc_stc_initialize_p",utc_stc_initialize_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_initialize_n",utc_stc_initialize_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_deinitialize_p",utc_stc_deinitialize_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_deinitialize_n",utc_stc_deinitialize_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_create_p",utc_stc_stats_rule_create_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_create_n",utc_stc_stats_rule_create_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_destroy_p",utc_stc_stats_rule_destroy_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_destroy_n",utc_stc_stats_rule_destroy_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_set_app_id_p",utc_stc_stats_rule_set_app_id_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_set_app_id_n",utc_stc_stats_rule_set_app_id_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_set_time_interval_p",utc_stc_stats_rule_set_time_interval_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_set_time_interval_n",utc_stc_stats_rule_set_time_interval_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_set_iface_type_p",utc_stc_stats_rule_set_iface_type_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_set_iface_type_n",utc_stc_stats_rule_set_iface_type_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_set_time_period_p",utc_stc_stats_rule_set_time_period_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_set_time_period_n",utc_stc_stats_rule_set_time_period_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_get_app_id_p",utc_stc_stats_rule_get_app_id_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_get_app_id_n",utc_stc_stats_rule_get_app_id_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_get_time_interval_p",utc_stc_stats_rule_get_time_interval_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_get_time_interval_n",utc_stc_stats_rule_get_time_interval_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_get_iface_type_p",utc_stc_stats_rule_get_iface_type_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_get_iface_type_n",utc_stc_stats_rule_get_iface_type_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_get_time_period_p",utc_stc_stats_rule_get_time_period_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_rule_get_time_period_n",utc_stc_stats_rule_get_time_period_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_get_stats_p",utc_stc_get_stats_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_get_stats_n",utc_stc_get_stats_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_get_all_stats_p",utc_stc_get_all_stats_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_get_all_stats_n",utc_stc_get_all_stats_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_foreach_stats_p",utc_stc_foreach_stats_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_foreach_stats_n",utc_stc_foreach_stats_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_foreach_all_stats_p",utc_stc_foreach_all_stats_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_foreach_all_stats_n",utc_stc_foreach_all_stats_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_get_total_stats_p",utc_stc_get_total_stats_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_get_total_stats_n",utc_stc_get_total_stats_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_clone_p",utc_stc_stats_info_clone_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_clone_n",utc_stc_stats_info_clone_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_destroy_p",utc_stc_stats_info_destroy_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_destroy_n",utc_stc_stats_info_destroy_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_app_id_p",utc_stc_stats_info_get_app_id_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_app_id_n",utc_stc_stats_info_get_app_id_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_iface_name_p",utc_stc_stats_info_get_iface_name_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_iface_name_n",utc_stc_stats_info_get_iface_name_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_time_interval_p",utc_stc_stats_info_get_time_interval_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_time_interval_n",utc_stc_stats_info_get_time_interval_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_iface_type_p",utc_stc_stats_info_get_iface_type_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_iface_type_n",utc_stc_stats_info_get_iface_type_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_counter_p",utc_stc_stats_info_get_counter_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_counter_n",utc_stc_stats_info_get_counter_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_roaming_type_p",utc_stc_stats_info_get_roaming_type_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_roaming_type_n",utc_stc_stats_info_get_roaming_type_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_protocol_type_p",utc_stc_stats_info_get_protocol_type_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_protocol_type_n",utc_stc_stats_info_get_protocol_type_n,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_process_state_p",utc_stc_stats_info_get_process_state_p,utc_stc_startup,utc_stc_cleanup},
+ {"utc_stc_stats_info_get_process_state_n",utc_stc_stats_info_get_process_state_n,utc_stc_startup,utc_stc_cleanup},
+ {NULL, NULL}
+};
+
+#endif // __TCT_STC_NATIVE_H__
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <time.h>
+#include "utc-stc-common.h"
+
+gboolean stc_callback_timeout(gpointer data)
+{
+ g_nCallbackRet = STC_ERROR_INVALID_OPERATION;
+ PRINT_RETURN("stc_callback_timeout", g_nCallbackRet);
+ QUIT_GMAIN_LOOP;
+ return false;
+}
+
+const char *stc_get_error(int err)
+{
+ switch (err) {
+ case STC_ERROR_NONE:
+ return "None";
+ case STC_ERROR_NOT_PERMITTED:
+ return "Operation not permitted";
+ case STC_ERROR_OUT_OF_MEMORY:
+ return "Out of memory";
+ case STC_ERROR_PERMISSION_DENIED:
+ return "Permission denied";
+ case STC_ERROR_RESOURCE_BUSY:
+ return "Device or resource busy";
+ case STC_ERROR_INVALID_OPERATION:
+ return "Invalid operation";
+ case STC_ERROR_INVALID_PARAMETER:
+ return "Invalid parameter";
+ case STC_ERROR_NOT_SUPPORTED:
+ return "Not supported";
+ case STC_ERROR_OPERATION_FAILED:
+ return "Operation failed";
+ case STC_ERROR_NOT_INITIALIZED:
+ return "Cgroup doen't mounted or daemon not started";
+ case STC_ERROR_ALREADY_INITIALIZED:
+ return "Already initialized";
+ case STC_ERROR_IN_PROGRESS:
+ return "In progress";
+ default:
+ return "Unknown";
+ }
+}
+
+bool stc_check_feature_supported(char *key)
+{
+ bool value = false;
+ int ret = system_info_get_platform_bool(key, &value);
+
+ if (ret != SYSTEM_INFO_ERROR_NONE)
+ return false;
+
+ return value;
+}
+
+time_t stc_make_time(int year, int mon, int day, int hour, int min)
+{
+ struct tm curr = { 0, };
+ curr.tm_year = year - 1900;
+ curr.tm_mon = mon - 1;
+ curr.tm_mday = day;
+ curr.tm_hour = hour;
+ curr.tm_min = min;
+ return mktime(&curr);
+}
+
+stc_error_e stc_get_all_stats_info(stc_stats_info_e e)
+{
+ int ret = STC_ERROR_NONE;
+ time_t from, to;
+
+ ret = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP);
+ CHECK_RETURN("stc_stats_rule_set_app_id", ret, STC_ERROR_NONE);
+
+ from = stc_make_time(2000, 1, 1, 1, 1);
+ time(&to);
+ ret = stc_stats_rule_set_time_interval(g_hRule, from, to);
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_NONE);
+
+ g_nCallbackRet = STC_ERROR_OPERATION_FAILED;
+ g_eStatsInfo = e;
+ ret = stc_get_all_stats(g_hSTC, g_hRule, stc_get_stats_finished_cb, NULL);
+ CHECK_RETURN("stc_get_all_stats", ret, STC_ERROR_NONE);
+ RUN_GMAIN_LOOP;
+ CHECK_RETURN(CALLBACK_RETURN, g_nCallbackRet, STC_ERROR_NONE);
+
+ return STC_ERROR_NONE;
+}
+
+void stc_get_stats_finished_cb(stc_error_e result,
+ stc_all_stats_info_h info, void *user_data)
+{
+ g_nCallbackRet = STC_ERROR_NONE;
+
+ int ret = STC_ERROR_NONE;
+
+ switch (g_eStatsInfo) {
+ case STATS_INFO_GET_ALL:
+ {
+ PRINT_RETURN("stc_get_all_stats", result);
+ }
+ break;
+ case STATS_INFO_FOREACH_ALL:
+ {
+ ret = stc_foreach_all_stats(info, stc_stats_info_callback, user_data);
+ PRINT_RETURN("stc_foreach_all_stats", ret);
+ }
+ break;
+ default:
+ PRINT_RETURN("stc_get_stats_finished_cb", ret);
+ break;
+ }
+
+ QUIT_GMAIN_LOOP;
+}
+
+stc_error_e stc_get_stats_info(stc_stats_info_e e)
+{
+ int ret = STC_ERROR_NONE;
+ time_t from, to;
+
+ ret = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP);
+ CHECK_RETURN("stc_stats_rule_set_app_id", ret, STC_ERROR_NONE);
+
+ from = stc_make_time(2000, 1, 1, 1, 1);
+ time(&to);
+ ret = stc_stats_rule_set_time_interval(g_hRule, from, to);
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_NONE);
+
+ g_nCallbackRet = STC_ERROR_NONE;
+ g_eStatsInfo = e;
+ ret = stc_get_stats(g_hSTC, g_hRule, stc_stats_info_callback, NULL);
+ CHECK_RETURN("stc_get_stats", ret, STC_ERROR_NONE);
+ RUN_GMAIN_LOOP;
+ CHECK_RETURN(CALLBACK_RETURN, g_nCallbackRet, STC_ERROR_NONE);
+
+ return STC_ERROR_NONE;
+}
+
+stc_error_e stc_foreach_stats_info(stc_stats_info_e e)
+{
+ int ret = STC_ERROR_NONE;
+ time_t from, to;
+
+ ret = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP);
+ CHECK_RETURN("stc_stats_rule_set_app_id", ret, STC_ERROR_NONE);
+
+ from = stc_make_time(2000, 1, 1, 1, 1);
+ time(&to);
+ ret = stc_stats_rule_set_time_interval(g_hRule, from, to);
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_NONE);
+
+ g_nCallbackRet = STC_ERROR_NONE;
+ g_eStatsInfo = e;
+ ret = stc_foreach_stats(g_hSTC, g_hRule, stc_stats_info_callback, NULL);
+ CHECK_RETURN("stc_foreach_stats", ret, STC_ERROR_NONE);
+ RUN_GMAIN_LOOP;
+ CHECK_RETURN(CALLBACK_RETURN, g_nCallbackRet, STC_ERROR_NONE);
+
+ return STC_ERROR_NONE;
+}
+
+stc_callback_ret_e stc_stats_info_callback(stc_error_e result,
+ stc_stats_info_h info, void *user_data)
+{
+ g_nCallbackRet = STC_ERROR_NONE;
+
+ int ret = STC_ERROR_NONE;
+
+ switch(g_eStatsInfo) {
+ case STATS_INFO_APPID:
+ {
+ char *app_id;
+ ret = stc_stats_info_get_app_id(info, &app_id);
+ PRINT_RETURN("stc_stats_info_get_app_id", ret);
+ }
+ break;
+ case STATS_INFO_IFACE_NAME:
+ {
+ char *iface_name;
+ ret = stc_stats_info_get_iface_name(info, &iface_name);
+ PRINT_RETURN("stc_stats_info_get_iface_name", ret);
+ }
+ break;
+ case STATS_INFO_TIME_INTERVAL:
+ {
+ time_t from;
+ time_t to;
+ ret = stc_stats_info_get_time_interval(info, &from, &to);
+ PRINT_RETURN("stc_stats_info_get_time_interval", ret);
+ }
+ break;
+ case STATS_INFO_IFACE_TYPE:
+ {
+ stc_iface_type_e iface_type;
+ ret = stc_stats_info_get_iface_type(info, &iface_type);
+ PRINT_RETURN("stc_stats_info_get_iface_type", ret);
+ }
+ break;
+ case STATS_INFO_COUNTER:
+ {
+ int64_t incoming;
+ int64_t outgoing;
+ ret = stc_stats_info_get_counter(info, &incoming, &outgoing);
+ PRINT_RETURN("stc_stats_info_get_counter", ret);
+ }
+ break;
+ case STATS_INFO_ROAMING_TYPE:
+ {
+ stc_roaming_type_e roaming;
+ ret = stc_stats_info_get_roaming_type(info, &roaming);
+ PRINT_RETURN("stc_stats_info_get_roaming_type", ret);
+ }
+ break;
+ case STATS_INFO_PROTOCOL_TYPE:
+ {
+ stc_protocol_type_e prototype;
+ ret = stc_stats_info_get_protocol_type(info, &prototype);
+ PRINT_RETURN("stc_stats_info_get_protocol_type", ret);
+ }
+ break;
+ case STATS_INFO_PROCESS_STATE:
+ {
+ stc_process_state_e procstate;
+ ret = stc_stats_info_get_process_state(info, &procstate);
+ PRINT_RETURN("stc_stats_info_get_process_state", ret);
+ }
+ break;
+ case STATS_INFO_CLONE:
+ case STATS_INFO_DESTROY:
+ {
+ stc_stats_info_h cloned = NULL;
+ ret = stc_stats_info_clone(info, &cloned);
+ PRINT_RETURN("stc_stats_info_clone", ret);
+ if (ret == STC_ERROR_NONE) {
+ ret = stc_stats_info_destroy(cloned);
+ PRINT_RETURN("stc_stats_info_destroy", ret);
+ }
+ }
+ break;
+ case STATS_INFO_FOREACH_ALL:
+ {
+ PRINT_RETURN("stc_foreach_all_stats", ret);
+ }
+ break;
+ default:
+ PRINT_RETURN("stc_stats_info_callback", ret);
+ break;
+ }
+
+ QUIT_GMAIN_LOOP;
+
+ return STC_CALLBACK_CANCEL;
+}
+
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef _STC_COMMON_H_
+#define _STC_COMMON_H_
+
+#include <tct_common.h>
+#include <stc.h>
+#include <system_info.h>
+#include <glib.h>
+
+#ifdef DEBUG_GCOV
+#define COMMON_DEBUG 1
+#else
+#define COMMON_DEBUG 0
+#endif
+
+#define CONFIG_VALUE_LEN_MAX 1024
+#define GMAINTIMEOUT 10000
+
+#define STC_FEATURE "http://tizen.org/feature/network.traffic_control"
+#define STC_ALL_APP "TOTAL_DATACALL"
+#define CALLBACK_RETURN "callback return"
+
+typedef enum {
+ STATS_INFO_UNKNOWN,
+ STATS_INFO_APPID,
+ STATS_INFO_IFACE_NAME,
+ STATS_INFO_TIME_INTERVAL,
+ STATS_INFO_IFACE_TYPE,
+ STATS_INFO_COUNTER,
+ STATS_INFO_ROAMING_TYPE,
+ STATS_INFO_PROTOCOL_TYPE,
+ STATS_INFO_PROCESS_STATE,
+ STATS_INFO_CLONE,
+ STATS_INFO_DESTROY,
+ STATS_INFO_GET_ALL,
+ STATS_INFO_FOREACH_ALL
+} stc_stats_info_e;
+
+GMainLoop *g_pMainLoop;
+guint g_nTimeoutId;
+int g_nCallbackRet;
+
+bool g_bFeatureSTC;
+
+stc_h g_hSTC;
+stc_stats_rule_h g_hRule;
+stc_error_e g_nCallbackRet;
+stc_stats_info_e g_eStatsInfo;
+
+#define RUN_GMAIN_LOOP {\
+ g_pMainLoop = g_main_loop_new(NULL, false);\
+ g_nTimeoutId = g_timeout_add(GMAINTIMEOUT, stc_callback_timeout, g_pMainLoop);\
+ if (COMMON_DEBUG) {\
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] Run mainloop [%p]",\
+ __LINE__, __FUNCTION__, g_pMainLoop);\
+ }\
+ g_main_loop_run(g_pMainLoop);\
+ g_source_remove(g_nTimeoutId);\
+ g_pMainLoop = NULL;\
+}
+
+#define QUIT_GMAIN_LOOP {\
+ if (COMMON_DEBUG) {\
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] Quit mainloop [%p]",\
+ __LINE__, __FUNCTION__, g_pMainLoop);\
+ }\
+ g_main_loop_quit(g_pMainLoop);\
+}
+
+#define FREE_MEMORY(var) {\
+ if(var != NULL) {\
+ g_free(var);\
+ var = NULL;\
+ }\
+}
+
+#define PRINT_RETURN(api, ret) {\
+ if (COMMON_DEBUG) {\
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s returned = %s",\
+ __LINE__, __FUNCTION__, api, stc_get_error(ret));\
+ }\
+}
+
+#define CHECK_RETURN(api, ret, val) {\
+ if (ret != val) {\
+ if (COMMON_DEBUG) {\
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s failed, error returned = %s",\
+ __LINE__, __FUNCTION__, api, stc_get_error(ret));\
+ }\
+ return 1;\
+ } else {\
+ if (COMMON_DEBUG) {\
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] %s",\
+ __LINE__, __FUNCTION__, api);\
+ }\
+ }\
+}
+
+#define DEBUG_LOG(str) {\
+ if (COMMON_DEBUG) {\
+ PRINT_LOG(DLOG_INFO, "NativeTCT", "[Line:%5d][%s] ***** DEBUG [%s] *****",\
+ __LINE__, __FUNCTION__, str);\
+ }\
+}
+
+gboolean stc_callback_timeout(gpointer data);
+const char *stc_get_error(int err);
+bool stc_check_feature_supported(char *key);
+time_t stc_make_time(int year, int mon, int day, int hour, int min);
+stc_error_e stc_get_all_stats_info(stc_stats_info_e e);
+void stc_get_stats_finished_cb(stc_error_e result,
+ stc_all_stats_info_h info, void *user_data);
+stc_error_e stc_get_stats_info(stc_stats_info_e e);
+stc_error_e stc_foreach_stats_info(stc_stats_info_e e);
+stc_callback_ret_e stc_stats_info_callback(stc_error_e result,
+ stc_stats_info_h info, void *user_data);
+
+
+#endif /* _STC_COMMON_H_ */
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#include "assert_local.h"
+#include "utc-stc-common.h"
+
+//& set: Stc
+
+void utc_stc_startup(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ g_bFeatureSTC = stc_check_feature_supported(STC_FEATURE);
+
+ ret = stc_initialize(&g_hSTC);
+ PRINT_RETURN("stc_initialize", ret);
+
+ ret = stc_stats_rule_create(g_hSTC, &g_hRule);
+ PRINT_RETURN("stc_stats_rule_create", ret);
+}
+
+void utc_stc_cleanup(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_destroy(g_hRule);
+ PRINT_RETURN("stc_stats_rule_destroy", ret);
+
+ ret = stc_deinitialize(g_hSTC);
+ PRINT_RETURN("stc_deinitialize", ret);
+}
+
+
+int utc_stc_initialize_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_initialize(&g_hSTC);
+ CHECK_RETURN("stc_initialize", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_deinitialize(g_hSTC);
+ CHECK_RETURN("stc_deinitialize", ret, STC_ERROR_NONE);
+
+ ret = stc_initialize(&g_hSTC);
+ CHECK_RETURN("stc_initialize", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_initialize_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_initialize(NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_initialize", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_initialize", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_deinitialize_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_deinitialize(&g_hSTC);
+ CHECK_RETURN("stc_deinitialize", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_deinitialize(g_hSTC);
+ CHECK_RETURN("stc_deinitialize", ret, STC_ERROR_NONE);
+
+ ret = stc_initialize(&g_hSTC);
+ CHECK_RETURN("stc_initialize", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_deinitialize_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_deinitialize(NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_deinitialize", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_deinitialize", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_create_p(void)
+{
+ stc_stats_rule_h hRule;
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_rule_create(g_hSTC, &hRule);
+ CHECK_RETURN("stc_stats_rule_create", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_stats_rule_create(g_hSTC, &hRule);
+ CHECK_RETURN("stc_stats_rule_create", ret, STC_ERROR_NONE);
+
+ ret = stc_stats_rule_destroy(hRule);
+ CHECK_RETURN("stc_stats_rule_destroy", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_rule_create_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_create(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_create", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_create", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_destroy_p(void)
+{
+ stc_stats_rule_h hRule = NULL;
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_rule_destroy(hRule);
+ CHECK_RETURN("stc_stats_rule_destroy", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_stats_rule_create(g_hSTC, &hRule);
+ CHECK_RETURN("stc_stats_rule_create", ret, STC_ERROR_NONE);
+
+ ret = stc_stats_rule_destroy(hRule);
+ CHECK_RETURN("stc_stats_rule_destroy", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_rule_destroy_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_destroy(NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_destroy", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_destroy", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_set_app_id_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_set_app_id", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_set_app_id", ret, STC_ERROR_NONE);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_set_app_id_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_set_app_id(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_set_app_id", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_set_app_id", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_set_time_interval_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_set_time_interval(g_hRule, 0, 0);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_NONE);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_set_time_interval_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_set_time_interval(NULL, 0, 0);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_set_iface_type_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_set_iface_type(g_hRule, STC_IFACE_DATACALL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_set_iface_type", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_set_iface_type", ret, STC_ERROR_NONE);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_set_iface_type_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_set_iface_type(NULL, STC_IFACE_UNKNOWN);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_set_iface_type", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_set_iface_type", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_set_time_period_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_set_time_period(g_hRule, STC_TIME_PERIOD_MONTH);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_set_time_period", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_set_time_period", ret, STC_ERROR_NONE);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_set_time_period_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_set_time_period(NULL, STC_TIME_PERIOD_UNKNOWN);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_set_time_period", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_set_time_period", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_get_app_id_p(void)
+{
+ int ret = STC_ERROR_NONE;
+ char *app_id = NULL;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_rule_get_app_id(g_hRule, &app_id);
+ CHECK_RETURN("stc_stats_rule_get_app_id", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_stats_rule_set_app_id(g_hRule, STC_ALL_APP);
+ CHECK_RETURN("stc_stats_rule_set_app_id", ret, STC_ERROR_NONE);
+
+ ret = stc_stats_rule_get_app_id(g_hRule, &app_id);
+ FREE_MEMORY(app_id);
+ CHECK_RETURN("stc_stats_rule_get_app_id", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_rule_get_app_id_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_get_app_id(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_get_app_id", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_get_app_id", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_get_time_interval_p(void)
+{
+ int ret = STC_ERROR_NONE;
+ time_t from, to;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_rule_get_time_interval(g_hRule, &from, &to);
+ CHECK_RETURN("stc_stats_rule_get_app_id", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_stats_rule_set_time_interval(g_hRule, 0, 0);
+ CHECK_RETURN("stc_stats_rule_get_time_interval", ret, STC_ERROR_NONE);
+
+ ret = stc_stats_rule_get_time_interval(g_hRule, &from, &to);
+ CHECK_RETURN("stc_stats_rule_get_time_interval", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_rule_get_time_interval_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_get_time_interval(NULL, NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_get_time_interval", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_get_time_interval", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_get_iface_type_p(void)
+{
+ int ret = STC_ERROR_NONE;
+ stc_iface_type_e iface_type;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_rule_get_iface_type(g_hRule, &iface_type);
+ CHECK_RETURN("stc_stats_rule_get_iface_type", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_stats_rule_set_iface_type(g_hRule, STC_IFACE_DATACALL);
+ CHECK_RETURN("stc_stats_rule_set_iface_type", ret, STC_ERROR_NONE);
+
+ ret = stc_stats_rule_get_iface_type(g_hRule, &iface_type);
+ CHECK_RETURN("stc_stats_rule_get_iface_type", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_rule_get_iface_type_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_get_iface_type(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_get_iface_type", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_get_iface_type", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_rule_get_time_period_p(void)
+{
+ int ret = STC_ERROR_NONE;
+ stc_time_period_e time_period;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_rule_get_time_period(g_hRule, &time_period);
+ CHECK_RETURN("stc_stats_rule_get_time_period", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_stats_rule_set_time_period(g_hRule, STC_TIME_PERIOD_MONTH);
+ CHECK_RETURN("stc_stats_rule_set_time_period", ret, STC_ERROR_NONE);
+
+ ret = stc_stats_rule_get_time_period(g_hRule, &time_period);
+ CHECK_RETURN("stc_stats_rule_get_time_period", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_rule_get_time_period_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_rule_get_time_period(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_rule_get_time_period", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_rule_get_time_period", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_get_stats_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_get_stats(g_hSTC, g_hRule, stc_stats_info_callback, NULL);
+ CHECK_RETURN("stc_get_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_get_stats_info(STATS_INFO_UNKNOWN);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_get_stats_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_get_stats(NULL, NULL, NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_get_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_get_stats", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_get_all_stats_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_get_all_stats(g_hSTC, g_hRule, stc_get_stats_finished_cb, NULL);
+ CHECK_RETURN("stc_get_all_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_get_all_stats_info(STATS_INFO_GET_ALL);
+ CHECK_RETURN("stc_get_all_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_get_all_stats_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_get_all_stats(NULL, NULL, NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_get_all_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_get_all_stats", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_foreach_stats_p(void)
+{
+ int ret = STC_ERROR_NONE;
+ time_t from, to;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_get_stats(g_hSTC, g_hRule, stc_stats_info_callback, NULL);
+ CHECK_RETURN("stc_get_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ from = stc_make_time(2000, 1, 1, 1, 1);
+ time(&to);
+ ret = stc_stats_rule_set_time_interval(g_hRule, from, to);
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_NONE);
+
+ g_nCallbackRet = STC_ERROR_NONE;
+ ret = stc_foreach_stats(g_hSTC, g_hRule, stc_stats_info_callback, NULL);
+ CHECK_RETURN("stc_foreach_stats", ret, STC_ERROR_NONE);
+ RUN_GMAIN_LOOP;
+ CHECK_RETURN(CALLBACK_RETURN, g_nCallbackRet, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_foreach_stats_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_foreach_stats(NULL, NULL, NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_foreach_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_foreach_stats", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_foreach_all_stats_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_foreach_all_stats(NULL, NULL, NULL);
+ CHECK_RETURN("stc_foreach_all_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_get_all_stats_info(STATS_INFO_FOREACH_ALL);
+ CHECK_RETURN("stc_get_all_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_foreach_all_stats_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_foreach_all_stats(NULL, NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_foreach_all_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_foreach_all_stats", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_get_total_stats_p(void)
+{
+ int ret = STC_ERROR_NONE;
+ time_t from, to;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_get_stats(g_hSTC, g_hRule, stc_stats_info_callback, NULL);
+ CHECK_RETURN("stc_get_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ from = stc_make_time(2000, 1, 1, 1, 1);
+ time(&to);
+ ret = stc_stats_rule_set_time_interval(g_hRule, from, to);
+ CHECK_RETURN("stc_stats_rule_set_time_interval", ret, STC_ERROR_NONE);
+
+ g_nCallbackRet = STC_ERROR_NONE;
+ ret = stc_get_total_stats(g_hSTC, g_hRule, stc_stats_info_callback, NULL);
+ CHECK_RETURN("stc_get_total_stats", ret, STC_ERROR_NONE);
+ RUN_GMAIN_LOOP;
+ CHECK_RETURN(CALLBACK_RETURN, g_nCallbackRet, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_get_total_stats_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_get_total_stats(NULL, NULL, NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_get_total_stats", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_get_total_stats", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_clone_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_clone(NULL, NULL);
+ CHECK_RETURN("stc_stats_info_clone", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_CLONE);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_clone_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_clone(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_clone", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_clone", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_destroy_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_destroy(NULL);
+ CHECK_RETURN("stc_stats_info_destroy", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_DESTROY);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_destroy_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_destroy(NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_destroy", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_destroy", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_app_id_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_get_app_id(g_hRule, NULL);
+ CHECK_RETURN("stc_stats_info_get_app_id", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_APPID);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_app_id_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_get_app_id(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_get_app_id", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_get_app_id", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_iface_name_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_get_iface_name(g_hRule, NULL);
+ CHECK_RETURN("stc_stats_info_get_iface_name", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_IFACE_NAME);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_iface_name_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_get_iface_name(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_get_iface_name", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_get_iface_name", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_time_interval_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_get_time_interval(g_hRule, 0, 0);
+ CHECK_RETURN("stc_stats_info_get_time_interval", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_TIME_INTERVAL);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_time_interval_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_get_time_interval(NULL, 0, 0);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_get_time_interval", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_get_time_interval", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_iface_type_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_get_iface_type(g_hRule, NULL);
+ CHECK_RETURN("stc_stats_info_get_iface_type", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_IFACE_TYPE);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_iface_type_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_get_iface_type(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_get_iface_type", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_get_iface_type", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_counter_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_get_counter(g_hRule, NULL, NULL);
+ CHECK_RETURN("stc_stats_info_get_counter", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_COUNTER);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_counter_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_get_counter(NULL, NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_get_counter", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_get_counter", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_roaming_type_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_get_roaming_type(g_hRule, NULL);
+ CHECK_RETURN("stc_stats_info_get_roaming_type", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_ROAMING_TYPE);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_roaming_type_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_get_roaming_type(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_get_roaming_type", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_get_roaming_type", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_protocol_type_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_get_protocol_type(g_hRule, NULL);
+ CHECK_RETURN("stc_stats_info_get_protocol_type", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_PROTOCOL_TYPE);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_protocol_type_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_get_protocol_type(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_get_protocol_type", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_get_protocol_type", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_process_state_p(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ if (!g_bFeatureSTC) {
+ ret = stc_stats_info_get_process_state(g_hRule, NULL);
+ CHECK_RETURN("stc_stats_info_get_process_state", ret, STC_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ ret = stc_foreach_stats_info(STATS_INFO_PROCESS_STATE);
+ CHECK_RETURN("stc_foreach_stats_info", ret, STC_ERROR_NONE);
+
+ return 0;
+}
+
+int utc_stc_stats_info_get_process_state_n(void)
+{
+ int ret = STC_ERROR_NONE;
+
+ ret = stc_stats_info_get_process_state(NULL, NULL);
+ if (!g_bFeatureSTC) {
+ CHECK_RETURN("stc_stats_info_get_process_state", ret, STC_ERROR_NOT_SUPPORTED);
+ } else {
+ CHECK_RETURN("stc_stats_info_get_process_state", ret, STC_ERROR_INVALID_PARAMETER);
+ }
+
+ return 0;
+}