From f406a269e8a92c2cb7f119732fa00d64bba1ffd8 Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Sun, 1 Feb 2015 13:34:47 +0900 Subject: [PATCH] tizen 2.3 release --- TC/_export_env.sh | 10 +++ TC/_export_target_env.sh | 9 ++ TC/build.sh | 8 +- TC/config | 3 + TC/execute.sh | 1 + TC/push.sh | 17 ++++ TC/run.sh | 15 ++++ TC/unit/Makefile | 1 + TC/unit/tslist | 1 + .../utc_ApplicationFW_db_util_create_collation.c | 95 ++++++++++++++++++++++ collation.c | 6 ++ include/collation.h | 55 ++++++------- include/db-util-common.h | 15 +++- include/util-func.h | 21 ++--- packaging/libslp-db-util.spec | 10 +-- util_func.c | 8 +- 16 files changed, 217 insertions(+), 58 deletions(-) create mode 100755 TC/_export_env.sh create mode 100755 TC/_export_target_env.sh create mode 100644 TC/config create mode 100755 TC/push.sh create mode 100755 TC/run.sh create mode 100755 TC/unit/utc_ApplicationFW_db_util_create_collation.c diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..7a317f8 --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +source ./config + +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +#export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-simulator # tetware target path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..3fd8e3f --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,9 @@ +#!/bin/sh +. ./config + +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +#export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-simulator +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/build.sh b/TC/build.sh index c488da0..72aad6c 100755 --- a/TC/build.sh +++ b/TC/build.sh @@ -1,10 +1,6 @@ #!/bin/sh -export TET_INSTALL_PATH=/home/deuk/repository/tetware/TETware # local tetware path -export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH -export TET_ROOT=$TET_TARGET_PATH +. ./_export_env.sh # setting environment variables export TET_SUITE_ROOT=`pwd` FILE_NAME_EXTENSION=`date +%s` @@ -17,4 +13,4 @@ mkdir -p $RESULT_DIR tcc -c -p ./ tcc -b -j $JOURNAL_RESULT -p ./ -grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/config b/TC/config new file mode 100644 index 0000000..8733045 --- /dev/null +++ b/TC/config @@ -0,0 +1,3 @@ +PKG_NAME=libslp-db-util +TET_INSTALL_HOST_PATH=/var/tmp/TETware +TET_INSTALL_TARGET_PATH=/opt/home/TETware diff --git a/TC/execute.sh b/TC/execute.sh index 21021c0..b9aa762 100755 --- a/TC/execute.sh +++ b/TC/execute.sh @@ -1,5 +1,6 @@ #!/bin/sh export TET_INSTALL_PATH=/mnt/nfs/tetware/TETware +#export TET_INSTALL_PATH=/scratchbox/tetware export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target export PATH=$TET_TARGET_PATH/bin:$PATH export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH diff --git a/TC/push.sh b/TC/push.sh new file mode 100755 index 0000000..03b495f --- /dev/null +++ b/TC/push.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +. ./config + +TC_PATH=/opt/home/$PKG_NAME + +echo $TC_PATH + +sudo rm -rf ./results/* + +sdb shell "mkdir -p $TC_PATH" + +sdb shell "rm -rf $TC_PATH/results/*" + +sdb push . $TC_PATH + + diff --git a/TC/run.sh b/TC/run.sh new file mode 100755 index 0000000..cec5778 --- /dev/null +++ b/TC/run.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +source ./_export_target_env.sh + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/unit/Makefile b/TC/unit/Makefile index e82feb8..a8d3432 100755 --- a/TC/unit/Makefile +++ b/TC/unit/Makefile @@ -3,6 +3,7 @@ CC ?= gcc TARGETS = utc_ApplicationFW_db_util_close \ utc_ApplicationFW_db_util_open \ utc_ApplicationFW_db_util_open_with_options \ + utc_ApplicationFW_db_util_create_collation \ PKGS = sqlite3 dlog db-util diff --git a/TC/unit/tslist b/TC/unit/tslist index c221828..9272615 100755 --- a/TC/unit/tslist +++ b/TC/unit/tslist @@ -1,3 +1,4 @@ /unit/utc_ApplicationFW_db_util_close /unit/utc_ApplicationFW_db_util_open /unit/utc_ApplicationFW_db_util_open_with_options +/unit/utc_ApplicationFW_db_util_create_collation diff --git a/TC/unit/utc_ApplicationFW_db_util_create_collation.c b/TC/unit/utc_ApplicationFW_db_util_create_collation.c new file mode 100755 index 0000000..72bc35c --- /dev/null +++ b/TC/unit/utc_ApplicationFW_db_util_create_collation.c @@ -0,0 +1,95 @@ +/* + * libslp-db-util + * + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Hakjoo Ko + * + * 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 +#include + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_ApplicationFW_db_util_create_collation_func_01(void); +static void utc_ApplicationFW_db_util_create_collation_func_02(void); + +static sqlite3* db_hd = NULL; +char* db_path = "test.db"; + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_ApplicationFW_db_util_create_collation_func_01, POSITIVE_TC_IDX }, + { utc_ApplicationFW_db_util_create_collation_func_02, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ +} + +static void cleanup(void) +{ + if (db_hd) + db_util_close(db_hd); + db_hd = NULL; +} + +/** + * @brief Positive test case of db_util_create_collation() + */ +static void utc_ApplicationFW_db_util_create_collation_func_01(void) +{ + int r = 0; + + r = db_util_open(db_path, &db_hd, 0); + if (r != SQLITE_OK) { + tet_result(TET_UNINITIATED); + return; + } + r = db_util_create_collation(db_hd, DB_UTIL_COL_UCA, DB_UTIL_COL_UTF8, "text"); + if (r != SQLITE_OK) { + tet_infoline("db_util_create_collation() failed in positive test case"); + tet_result(TET_FAIL); + return; + } + tet_result(TET_PASS); +} + +/** + * @brief Negative test case of db_util_create_collation() + */ +static void utc_ApplicationFW_db_util_create_collation_func_02(void) +{ + int r = 0; + + r = db_util_create_collation(NULL, DB_UTIL_COL_UCA, DB_UTIL_COL_UTF8, NULL); + if (r == SQLITE_OK) { + tet_infoline("db_util_create_collation() failed in negative test case"); + tet_result(TET_FAIL); + return; + } + + tet_result(TET_PASS); +} diff --git a/collation.c b/collation.c index b81c216..435a3c0 100755 --- a/collation.c +++ b/collation.c @@ -474,6 +474,11 @@ int db_util_create_collation( DB_UTIL_TRACE_DEBUG("db_util_create_collation start"); + if( (!db_handle) || (!col_name) ) { + DB_UTIL_TRACE_ERROR("wrong input param"); + return DB_UTIL_ERROR; + } + ret = __db_util_dl_load_icu(); DB_UTIL_RETV_IF(ret != DB_UTIL_OK, DB_UTIL_ERROR); @@ -519,6 +524,7 @@ int db_util_create_collation( #endif default : DB_UTIL_TRACE_WARNING("wrong collate input type"); + ret = DB_UTIL_ERROR; } if(ret != DB_UTIL_OK) diff --git a/include/collation.h b/include/collation.h index f56e7e1..9a22c38 100755 --- a/include/collation.h +++ b/include/collation.h @@ -28,8 +28,13 @@ extern "C" { #include +/** + * @addtogroup DB_UTIL + * @{ + */ + /* - * Collations Types + * @brief Collations Types * * These types are intended for use in the * 2nd parameter to the [db_util_create_collation()] interface. @@ -63,47 +68,35 @@ extern "C" { */ typedef enum { - DB_UTIL_COL_UCA, - DB_UTIL_COL_LS_AS_CI, - DB_UTIL_COL_LS_AI_CI, - DB_UTIL_COL_LS_AI_CI_LC, - DB_UTIL_COL_KO_IC, //deprecated - DB_UTIL_COL_KO_IC_LC //deprecated + DB_UTIL_COL_UCA, /**< */ + DB_UTIL_COL_LS_AS_CI, /**< */ + DB_UTIL_COL_LS_AI_CI, /**< */ + DB_UTIL_COL_LS_AI_CI_LC, /**< */ + DB_UTIL_COL_KO_IC, //deprecated + DB_UTIL_COL_KO_IC_LC //deprecated } db_util_collate_type; /* - * Text Encodings + * @brief Text Encodings * * These encodings are intended for use in the * 3rd parameter to the [db_util_create_collation()] interface. */ typedef enum { - DB_UTIL_COL_UTF8 = SQLITE_UTF8, - DB_UTIL_COL_UTF16 = SQLITE_UTF16 + DB_UTIL_COL_UTF8 = SQLITE_UTF8, /**< */ + DB_UTIL_COL_UTF16 = SQLITE_UTF16 /**< */ } db_util_collate_textrep; - /** - * @defgroup DB_UTIL - * @ingroup StorageFW - * @{ - */ - -/** - * @fn int db_util_create_collation(sqlite3 *db_handle, db_util_collate_type type, db_util_collate_textrep text_type, char* col_name); - * This function defines a new collating sequences with the database connection specified as the firtst argument. - * This function is needed to be invoked after [db_util_open()]. - * - * @param[in] Db connection handle to create collation with - * @param[in] Collation type. This value must be one of the [db_util_collate_type] - * @param[in] Encoding of text passed to the collating function callback - * @param[in] The name of collation(UTF-8 string) - * return This function returns DB_UTIL_OK or error code on failure - * @exception None - * @remarks None + * @brief This function defines a new collating sequences with the database connection specified as the firtst argument. + * @remarks This function is needed to be invoked after [db_util_open()]. + * @param [in] Db connection handle to create collation with + * @param [in] Collation type. This value must be one of the [db_util_collate_type] + * @param [in] Encoding of text passed to the collating function callback + * @param [in] The name of collation(UTF-8 string) + * @return This function returns #DB_UTIL_OK or error code on failure * @pre Database connected * @post None - * @code */ EXPORT_API int db_util_create_collation( PARAM_IN sqlite3 *db_handle, @@ -113,8 +106,8 @@ EXPORT_API int db_util_create_collation( ); /** -*@} -*/ + * @} + */ #ifdef __cplusplus } diff --git a/include/db-util-common.h b/include/db-util-common.h index 4229d5a..9c6f933 100755 --- a/include/db-util-common.h +++ b/include/db-util-common.h @@ -31,6 +31,11 @@ extern "C" { #include #include +/** + * @addtogroup DB_UTIL + * @{ + */ + #ifndef EXPORT_API #define EXPORT_API __attribute__ ((visibility("default"))) #endif @@ -43,11 +48,17 @@ extern "C" { #define PARAM_OUT #endif +/** + * @brief Enumeration of error code. + */ typedef enum { - DB_UTIL_ERROR = SQLITE_ERROR, - DB_UTIL_OK = SQLITE_OK, + DB_UTIL_ERROR = SQLITE_ERROR, /**< Error */ + DB_UTIL_OK = SQLITE_OK, /**< Successful */ } db_util_err; +/** + * @} + */ #ifdef __cplusplus } diff --git a/include/util-func.h b/include/util-func.h index 951584d..faa3999 100755 --- a/include/util-func.h +++ b/include/util-func.h @@ -28,21 +28,22 @@ extern "C" { #include -#define DB_UTIL_REGISTER_HOOK_METHOD 0x00000001 -#define DB_UTIL_LUCENE_INDEX 0x00000002 - /** -* @defgroup StorageFW Storage Framework -* In order to support applications using DB -*/ + * @defgroup DB_UTIL DB Util + * @brief This provides functions to handle DB. + * @ingroup StorageFW + * @section DB_UTIL_HEADER Required Header + * \#include + */ /** - * @defgroup DB_UTIL - * @ingroup StorageFW + * @addtogroup DB_UTIL * @{ */ +#define DB_UTIL_REGISTER_HOOK_METHOD 0x00000001 +#define DB_UTIL_LUCENE_INDEX 0x00000002 /** * @brief invoke sqlite3_open with platform common configuration @@ -85,8 +86,8 @@ EXPORT_API int db_util_open_with_options(const char *pszFilePath, EXPORT_API int db_util_close(sqlite3 *ppDB); /** -*@} -*/ + * @} + */ #ifdef __cplusplus } diff --git a/packaging/libslp-db-util.spec b/packaging/libslp-db-util.spec index 947e95d..66960ff 100755 --- a/packaging/libslp-db-util.spec +++ b/packaging/libslp-db-util.spec @@ -1,6 +1,6 @@ Name: libslp-db-util Summary: DB Utility -Version: 0.1.5 +Version: 0.1.8 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 @@ -26,10 +26,10 @@ Requires: %{name} = %{version}-%{release} %setup -q -n %{name}-%{version} %build -%if 0%{?tizen_build_binary_release_type_eng} -export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE" -export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE" -export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE" +%if 0%{?sec_build_binary_debug_enable} +export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" %endif cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} diff --git a/util_func.c b/util_func.c index 0beaf48..992ef9f 100755 --- a/util_func.c +++ b/util_func.c @@ -101,7 +101,7 @@ int db_util_open(const char *pszFilePath, sqlite3 **ppDB, int nOption) return DB_UTIL_ERROR; } - if(access(pszFilePath, R_OK)) { + if((geteuid() != 0) && (access(pszFilePath, R_OK))) { if(errno == EACCES) { DB_UTIL_TRACE_ERROR("file access permission error"); return SQLITE_PERM; @@ -111,7 +111,7 @@ int db_util_open(const char *pszFilePath, sqlite3 **ppDB, int nOption) /* Open DB */ int rc = sqlite3_open(pszFilePath, ppDB); if (SQLITE_OK != rc) { - DB_UTIL_TRACE_ERROR("sqlite3_open error(%d), "); + DB_UTIL_TRACE_ERROR("sqlite3_open error(%d)", rc); return rc; } @@ -139,7 +139,7 @@ int db_util_open_with_options(const char *pszFilePath, sqlite3 **ppDB, mode = R_OK; #endif - if(access(pszFilePath, mode)) { + if((geteuid() != 0) && (access(pszFilePath, mode))) { if(errno == EACCES) { DB_UTIL_TRACE_ERROR("file access permission error"); return SQLITE_PERM; @@ -149,7 +149,7 @@ int db_util_open_with_options(const char *pszFilePath, sqlite3 **ppDB, /* Open DB */ int rc = sqlite3_open_v2(pszFilePath, ppDB, flags, zVfs); if (SQLITE_OK != rc) { - DB_UTIL_TRACE_ERROR("sqlite3_open_v2 error(%d), "); + DB_UTIL_TRACE_ERROR("sqlite3_open_v2 error(%d)",rc); return rc; } -- 2.7.4