tizen 2.3.1 release tizen_2.3.1 submit/tizen_2.3.1/20150915.080258 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:15:23 +0000 (22:15 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:15:23 +0000 (22:15 +0900)
28 files changed:
.gitignore [new file with mode: 0755]
CMakeLists.txt
TC/build.sh [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/tet_code [new file with mode: 0755]
TC/tet_scen [new file with mode: 0755]
TC/tetbuild.cfg [new file with mode: 0755]
TC/tetclean.cfg [new file with mode: 0755]
TC/tetexec.cfg [new file with mode: 0755]
TC/unit/Makefile [new file with mode: 0755]
TC/unit/tc_gen.sh [new file with mode: 0755]
TC/unit/tslist [new file with mode: 0755]
TC/unit/utc_ApplicationFW_rua_add_history_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_rua_clear_history_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_rua_delete_history_with_apppath_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_rua_delete_history_with_pkgname_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_rua_fini_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_rua_history_get_rec_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_rua_history_load_db_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_rua_history_unload_db_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_rua_init_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_rua_is_latest_app_func.c [new file with mode: 0755]
TC/unit/utc_MODULE_API_func.c.in [new file with mode: 0644]
data/rua_db.sql
librua.manifest [new file with mode: 0644]
packaging/librua.spec
src/perf-measure.c
src/rua.c [changed mode: 0644->0755]

diff --git a/.gitignore b/.gitignore
new file mode 100755 (executable)
index 0000000..1af2e9f
--- /dev/null
@@ -0,0 +1,34 @@
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+packages
+binaries
+*~
+CMakeCache.txt
+CMakeFiles
+Makefile
+build-stamp
+cmake_install.cmake
+configure-stamp
+cscope.*
+debian/files
+debian/librua-0.install
+debian/librua-0.postinst
+debian/librua-0.postinst.debhelper
+debian/librua-0.postrm.debhelper
+debian/librua-0.substvars
+debian/librua-0/*
+debian/librua-dbg.substvars
+debian/librua-dbg/*
+debian/librua-dev.install
+debian/librua-dev.substvars
+debian/librua-dev/*
+install_manifest.txt
+librua.so*
+rua.pc
+tags
index 01055ed..8a63ffa 100644 (file)
@@ -15,7 +15,7 @@ SET(SRCS
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED sqlite3 db-util)
+pkg_check_modules(pkgs REQUIRED sqlite3 db-util dlog)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..eb74d6c
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export TET_INSTALL_PATH=$HOME/workspace/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 TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..e2c742e
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+export TET_INSTALL_PATH=/mnt/nfs/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
+
+export TET_ROOT=$TET_TARGET_PATH
+
+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 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/tet_code b/TC/tet_code
new file mode 100755 (executable)
index 0000000..a2cf6c1
--- /dev/null
@@ -0,0 +1,12 @@
+# TET reserved codes
+0 "PASS"
+1 "FAIL"
+2 "UNRESOLVED"
+3 "NOTINUSE"
+4 "UNSUPPORTED"
+5 "UNTESTED"
+6 "UNINITIATED"
+7 "NORESULT"
+
+# Test suite additional codes
+33 "INSPECT"
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755 (executable)
index 0000000..43cbc9b
--- /dev/null
@@ -0,0 +1,7 @@
+all
+       ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+       :include:/unit/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100755 (executable)
index 0000000..6192c78
--- /dev/null
@@ -0,0 +1,3 @@
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
+TET_PASS_TC_NAME=True
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100755 (executable)
index 0000000..c66eda4
--- /dev/null
@@ -0,0 +1,2 @@
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100755 (executable)
index 0000000..0d9d39a
--- /dev/null
@@ -0,0 +1 @@
+TET_OUTPUT_CAPTURE=False
diff --git a/TC/unit/Makefile b/TC/unit/Makefile
new file mode 100755 (executable)
index 0000000..eb5f6a4
--- /dev/null
@@ -0,0 +1,31 @@
+CC ?= gcc
+
+TARGETS =      utc_ApplicationFW_rua_clear_history_func \
+               utc_ApplicationFW_rua_init_func \
+               utc_ApplicationFW_rua_fini_func \
+               utc_ApplicationFW_rua_delete_history_with_pkgname_func \
+               utc_ApplicationFW_rua_add_history_func \
+               utc_ApplicationFW_rua_delete_history_with_apppath_func \
+               utc_ApplicationFW_rua_is_latest_app_func \
+               utc_ApplicationFW_rua_history_load_db_func \
+               utc_ApplicationFW_rua_history_unload_db_func \
+               utc_ApplicationFW_rua_history_get_rec_func
+
+PKGS = bundle rua
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TARGETS)
diff --git a/TC/unit/tc_gen.sh b/TC/unit/tc_gen.sh
new file mode 100755 (executable)
index 0000000..54f482d
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+TMPSTR=$0
+SCRIPT=${TMPSTR##*/}
+
+if [ $# -lt 2 ]; then
+       echo "Usage) $SCRIPT module_name api_name"
+       exit 1
+fi
+
+MODULE=$1
+API=$2
+TEMPLATE=utc_MODULE_API_func.c.in
+TESTCASE=utc_${MODULE}_${API}_func
+
+sed -e '
+       s^@API@^'"$API"'^g
+       s^@MODULE@^'"$MODULE"'^g
+       ' $TEMPLATE > $TESTCASE.c
+
+if [ ! -e "$TESTCASE.c" ]; then
+       echo "Failed"
+       exit 1
+fi
+echo "Testcase file is $TESTCASE.c"
+echo "Done"
+echo "please put \"$TESTCASE\" as Target in Makefile"
+echo "please put \"/unit/$TESTCASE\" in tslist"
diff --git a/TC/unit/tslist b/TC/unit/tslist
new file mode 100755 (executable)
index 0000000..7d1e3ca
--- /dev/null
@@ -0,0 +1,10 @@
+/unit/utc_ApplicationFW_rua_clear_history_func
+/unit/utc_ApplicationFW_rua_init_func
+/unit/utc_ApplicationFW_rua_fini_func
+/unit/utc_ApplicationFW_rua_delete_history_with_pkgname_func
+/unit/utc_ApplicationFW_rua_add_history_func
+/unit/utc_ApplicationFW_rua_delete_history_with_apppath_func
+/unit/utc_ApplicationFW_rua_is_latest_app_func
+/unit/utc_ApplicationFW_rua_history_load_db_func
+/unit/utc_ApplicationFW_rua_history_unload_db_func
+/unit/utc_ApplicationFW_rua_history_get_rec_func
diff --git a/TC/unit/utc_ApplicationFW_rua_add_history_func.c b/TC/unit/utc_ApplicationFW_rua_add_history_func.c
new file mode 100755 (executable)
index 0000000..975b37e
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_add_history_func_01(void);
+static void utc_rua_add_history_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_add_history_func_01, POSITIVE_TC_IDX},
+       {utc_rua_add_history_func_02, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_add_history start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_add_history ends ");
+       rua_clear_history();
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_add_history()
+ */
+static void utc_rua_add_history_func_01(void)
+{
+       int ret = 0;
+       struct rua_rec rec;
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret = rua_add_history(&rec);
+       if (ret == 0) {
+               tet_infoline("rua_add_history test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_add_history test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
+
+/**
+ * @brief Negative test case of rua_add_history()
+ */
+static void utc_rua_add_history_func_02(void)
+{
+       int ret = 0;
+
+       ret = rua_add_history(NULL);
+       if (ret == -1) {
+               tet_infoline("rua_add_history test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_add_history test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_clear_history_func.c b/TC/unit/utc_ApplicationFW_rua_clear_history_func.c
new file mode 100644 (file)
index 0000000..18d6098
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_clear_history_func_01(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_clear_history_func_01, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_clear_history start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_clear_history ends ");
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_clear_history()
+ */
+static void utc_rua_clear_history_func_01(void)
+{
+       int ret = 0;
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_clear_history();
+       if (ret == 0) {
+               tet_infoline("rua_clear_history test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_clear_history test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_delete_history_with_apppath_func.c b/TC/unit/utc_ApplicationFW_rua_delete_history_with_apppath_func.c
new file mode 100755 (executable)
index 0000000..6014986
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_delete_history_with_apppath_func_01(void);
+static void utc_rua_delete_history_with_apppath_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_delete_history_with_apppath_func_01, POSITIVE_TC_IDX},
+       {utc_rua_delete_history_with_apppath_func_02, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_delete_history_with_apppath start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_delete_history_with_apppath ends ");
+       rua_clear_history();
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_delete_history_with_apppath()
+ */
+static void utc_rua_delete_history_with_apppath_func_01(void)
+{
+       int ret = 0;
+       struct rua_rec rec;
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_add_history(&rec);
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret =
+           rua_delete_history_with_apppath
+           ("/opt/apps/org.tizen.testapp/bin/testapp");
+       if (ret == 0) {
+               tet_infoline("rua_delete_history_with_apppath test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_delete_history_with_apppath test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
+
+/**
+ * @brief Negative test case of rua_delete_history_with_apppath()
+ */
+static void utc_rua_delete_history_with_apppath_func_02(void)
+{
+       int ret = 0;
+       ret = rua_delete_history_with_apppath(NULL);
+       if (ret == -1) {
+               tet_infoline("rua_delete_history_with_apppath test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_delete_history_with_apppath test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_delete_history_with_pkgname_func.c b/TC/unit/utc_ApplicationFW_rua_delete_history_with_pkgname_func.c
new file mode 100755 (executable)
index 0000000..ee3b1bb
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_delete_history_with_pkgname_func_01(void);
+static void utc_rua_delete_history_with_pkgname_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_delete_history_with_pkgname_func_01, POSITIVE_TC_IDX},
+       {utc_rua_delete_history_with_pkgname_func_02, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_delete_history_with_pkgname start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_delete_history_with_pkgname ends ");
+       rua_clear_history();
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_delete_history_with_pkgname()
+ */
+static void utc_rua_delete_history_with_pkgname_func_01(void)
+{
+       int ret = 0;
+       struct rua_rec rec;
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_add_history(&rec);
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret = rua_delete_history_with_pkgname("org.tizen.testapp");
+       if (ret == 0) {
+               tet_infoline("rua_delete_history_with_pkgname test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_delete_history_with_pkgname test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
+
+/**
+ * @brief Negative test case of rua_delete_history_with_pkgname()
+ */
+static void utc_rua_delete_history_with_pkgname_func_02(void)
+{
+       int ret = 0;
+       ret = rua_delete_history_with_pkgname(NULL);
+       if (ret == -1) {
+               tet_infoline("rua_delete_history_with_pkgname test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_delete_history_with_pkgname test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_fini_func.c b/TC/unit/utc_ApplicationFW_rua_fini_func.c
new file mode 100644 (file)
index 0000000..bfe8a48
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_fini_func_01(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_fini_func_01, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_fini start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_fini ends ");
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_fini()
+ */
+static void utc_rua_fini_func_01(void)
+{
+       int ret = 0;
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_fini();
+       if (ret == 0) {
+               tet_infoline("rua_fini test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_fini test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_history_get_rec_func.c b/TC/unit/utc_ApplicationFW_rua_history_get_rec_func.c
new file mode 100755 (executable)
index 0000000..0489976
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_history_get_rec_func_01(void);
+static void utc_rua_history_get_rec_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_history_get_rec_func_01, POSITIVE_TC_IDX},
+       {utc_rua_history_get_rec_func_02, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_history_get_rec start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_history_get_rec ends ");
+       rua_clear_history();
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_history_get_rec()
+ */
+static void utc_rua_history_get_rec_func_01(void)
+{
+       struct rua_rec rec_result = { 0, };
+       int ret = 0;
+       char **table = NULL;
+       int nrows = 0;
+       int ncols = 0;
+       int row = 0;
+
+       struct rua_rec rec = { 0, };
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_add_history(&rec);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret = rua_history_load_db(&table, &nrows, &ncols);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_history_get_rec(&rec_result, table, nrows, ncols, row);
+       if (ret == 0) {
+               tet_infoline("rua_history_get_rec test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_history_get_rec test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       rua_history_unload_db(&table);
+       return;
+}
+
+/**
+ * @brief Negative test case of rua_history_get_rec()
+ */
+static void utc_rua_history_get_rec_func_02(void)
+{
+       int ret = 0;
+       struct rua_rec rec_result = { 0, };
+       char **table = NULL;
+       int nrows = 0;
+       int ncols = 0;
+       int row = 0;
+
+       struct rua_rec rec = { 0, };
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test program initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_add_history(&rec);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret = rua_history_load_db(&table, &nrows, &ncols);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_history_get_rec(&rec_result, table, nrows, ncols, row + 10);
+       if (ret == -1) {
+               tet_infoline("rua_history_get_rec test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_history_get_rec test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       rua_history_unload_db(&table);
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_history_load_db_func.c b/TC/unit/utc_ApplicationFW_rua_history_load_db_func.c
new file mode 100755 (executable)
index 0000000..ffc98f2
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_history_load_db_func_01(void);
+static void utc_rua_history_load_db_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_history_load_db_func_01, POSITIVE_TC_IDX},
+       {utc_rua_history_load_db_func_02, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_history_load_db start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_history_load_db ends ");
+       rua_clear_history();
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_history_load_db()
+ */
+static void utc_rua_history_load_db_func_01(void)
+{
+       int ret = 0;
+       char **table = NULL;
+       int nrows = 0;
+       int ncols = 0;
+
+       struct rua_rec rec;
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+       ret = rua_add_history(&rec);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret = rua_history_load_db(&table, &nrows, &ncols);
+       if (ret == 0) {
+               tet_infoline("rua_history_load_db test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_history_load_db test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
+
+/**
+ * @brief Negative test case of rua_history_load_db()
+ */
+static void utc_rua_history_load_db_func_02(void)
+{
+       int ret = 0;
+       int nrows = 0;
+       int ncols = 0;
+       ret = rua_history_load_db(NULL, &nrows, &ncols);
+       if (ret == -1) {
+               tet_infoline("rua_history_load_db test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_history_load_db test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_history_unload_db_func.c b/TC/unit/utc_ApplicationFW_rua_history_unload_db_func.c
new file mode 100755 (executable)
index 0000000..bef7bb7
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_history_unload_db_func_01(void);
+static void utc_rua_history_unload_db_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_history_unload_db_func_01, POSITIVE_TC_IDX},
+       {utc_rua_history_unload_db_func_02, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_history_unload_db start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_history_unload_db ends ");
+       rua_clear_history();
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_history_unload_db()
+ */
+static void utc_rua_history_unload_db_func_01(void)
+{
+       int ret = 0;
+       char **table = NULL;
+       int nrows = 0;
+       int ncols = 0;
+       struct rua_rec rec;
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+       rua_add_history(&rec);
+       ret = rua_history_load_db(&table, &nrows, &ncols);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret = rua_history_unload_db(&table);
+       if (ret == 0) {
+               tet_infoline("rua_history_unload_db test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_history_unload_db test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
+
+/**
+ * @brief Negative test case of rua_history_unload_db()
+ */
+static void utc_rua_history_unload_db_func_02(void)
+{
+       int ret = 0;
+       char **table = NULL;
+       int nrows = 0;
+       int ncols = 0;
+       struct rua_rec rec;
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+       rua_add_history(&rec);
+       ret = rua_history_load_db(&table, &nrows, &ncols);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret = rua_history_unload_db(&table);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       ret = rua_history_unload_db(&table);
+       if (ret == -1) {
+               tet_infoline("rua_history_unload_db test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_history_unload_db test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_init_func.c b/TC/unit/utc_ApplicationFW_rua_init_func.c
new file mode 100644 (file)
index 0000000..d933d8e
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_init_func_01(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_init_func_01, POSITIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_init start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_init ends ");
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_init()
+ */
+static void utc_rua_init_func_01(void)
+{
+       int ret = 0;
+       ret = rua_init();
+       if (ret == 0) {
+               tet_infoline("rua_init test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_init test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_ApplicationFW_rua_is_latest_app_func.c b/TC/unit/utc_ApplicationFW_rua_is_latest_app_func.c
new file mode 100755 (executable)
index 0000000..5ac174f
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ *  RUA
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>
+ *
+ * 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 <tet_api.h>
+#include <rua.h>
+#include <unistd.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_rua_is_latest_app_func_01(void);
+static void utc_rua_is_latest_app_func_02(void);
+static void utc_rua_is_latest_app_func_03(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_rua_is_latest_app_func_01, POSITIVE_TC_IDX},
+       {utc_rua_is_latest_app_func_02, NEGATIVE_TC_IDX},
+       {utc_rua_is_latest_app_func_03, NEGATIVE_TC_IDX},
+       {NULL, 0}
+};
+
+static void startup(void)
+{
+       tet_infoline("Testing API rua_is_latest_app start");
+       return;
+}
+
+static void cleanup(void)
+{
+       tet_infoline("Testing API rua_is_latest_app ends ");
+       rua_clear_history();
+       rua_fini();
+       return;
+}
+
+/**
+ * @brief Positive test case of rua_is_latest_app()
+ */
+static void utc_rua_is_latest_app_func_01(void)
+{
+       int ret = 0;
+       struct rua_rec rec;
+       char *pkgname = "org.tizen.testapp";
+       char *apppath = "/opt/apps/org.tizen.testapp/bin/testapp";
+
+       ret = rua_init();
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       memset(&rec, 0, sizeof(rec));
+       rec.pkg_name = pkgname;
+       rec.app_path = apppath;
+
+       ret = rua_add_history(&rec);
+       if (ret != 0) {
+               tet_infoline("Test initialization failed!!!");
+               tet_result(TET_UNINITIATED);
+               return;
+       }
+       ret = rua_is_latest_app("org.tizen.testapp");
+       if (ret == 0) {
+               tet_infoline("rua_is_latest_app test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_is_latest_app test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
+
+/**
+ * @brief Negative test case of rua_is_latest_app()
+ */
+static void utc_rua_is_latest_app_func_02(void)
+{
+       int ret = 0;
+       ret = rua_is_latest_app(NULL);
+       if (ret == -1) {
+               tet_infoline("rua_is_latest_app test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_is_latest_app test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
+
+/**
+ * @brief Negative test case of rua_is_latest_app()
+ */
+static void utc_rua_is_latest_app_func_03(void)
+{
+       int ret = 0;
+       ret = rua_is_latest_app("org.tizen.abcd");
+       if (ret == -1) {
+               tet_infoline("rua_is_latest_app test PASS!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_PASS);
+       } else {
+               tet_infoline("rua_is_latest_app test FAIL!");
+               tet_printf("ret = %d", ret);
+               tet_result(TET_FAIL);
+       }
+       return;
+}
diff --git a/TC/unit/utc_MODULE_API_func.c.in b/TC/unit/utc_MODULE_API_func.c.in
new file mode 100644 (file)
index 0000000..9630027
--- /dev/null
@@ -0,0 +1,65 @@
+#include <tet_api.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_@MODULE@_@API@_func_01(void);
+static void utc_@MODULE@_@API@_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX },
+       { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of @API@()
+ */
+static void utc_@MODULE@_@API@_func_01(void)
+{
+       int r = 0;
+
+/*
+       r = @API@(...);
+*/
+       if (r) {
+               tet_infoline("@API@() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init @API@()
+ */
+static void utc_@MODULE@_@API@_func_02(void)
+{
+       int r = 0;
+
+/*
+       r = @API@(...);
+*/
+       if (r) {
+               tet_infoline("@API@() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
index 4ae26ca..cead231 100644 (file)
@@ -1,8 +1,8 @@
 PRAGMA journal_mode = PERSIST;
 
 CREATE TABLE IF NOT EXISTS rua_history (
-       id INTEGER PRIMARY KEY,
-       pkg_name TEXT,
+       id INTEGER,
+       pkg_name TEXT PRIMARY KEY,
        app_path TEXT,
        arg TEXT,
        launch_time INTEGER
diff --git a/librua.manifest b/librua.manifest
new file mode 100644 (file)
index 0000000..092b284
--- /dev/null
@@ -0,0 +1,17 @@
+<manifest>
+       <define>
+               <domain name="rua"/>
+               <provide>
+                       <label name="rua::db"/>
+               </provide>
+       </define>
+       <request>
+               <domain name="rua"/>
+       </request>
+       <assign>
+               <filesystem path="/usr/lib/librua.so.0" label="_"/>
+               <filesystem path="/usr/lib/librua.so.0.1.0" label="_"/>
+               <filesystem path="/opt/dbspace/.rua.db" label="rua::db"/>
+               <filesystem path="/opt/dbspace/.rua.db-journal" label="rua::db"/>
+       </assign>
+</manifest>
index 261d068..5d28580 100644 (file)
@@ -1,10 +1,10 @@
 
 Name:       librua
 Summary:    Recently used application
-Version:    0.1.0
-Release:    33
+Version:    0.1.8
+Release:    1
 Group:      System/Libraries
-License:    Apache License, Version 2.0
+License:    Apache-2.0
 Source0:    librua-%{version}.tar.gz
 Requires(post): /sbin/ldconfig
 Requires(post): /usr/bin/sqlite3
@@ -12,6 +12,7 @@ Requires(postun): /sbin/ldconfig
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(sqlite3)
 BuildRequires:  pkgconfig(db-util)
+BuildRequires:  pkgconfig(dlog)
 
 
 %description
@@ -33,6 +34,11 @@ Recently used application library (devel)
 
 
 %build
+%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}
 
 
@@ -41,27 +47,26 @@ make %{?jobs:-j%jobs}
 %install
 rm -rf %{buildroot}
 %make_install
+mkdir -p %{buildroot}/usr/share/license
+install LICENSE %{buildroot}/usr/share/license/%{name}
+
+mkdir -p %{buildroot}/opt/dbspace
+sqlite3 %{buildroot}/opt/dbspace/.rua.db < %{buildroot}/opt/share/rua_db.sql
+rm -rf %{buildroot}/opt/share/rua_db.sql
 
 %post
 /sbin/ldconfig
-mkdir -p /opt/dbspace/
-sqlite3 /opt/dbspace/.rua.db < /opt/share/rua_db.sql
-rm -rf /opt/share/rua_db.sql
-chown 0:5000 /opt/dbspace/.rua.db
-chown 0:5000 /opt/dbspace/.rua.db-journal
-chmod 660 /opt/dbspace/.rua.db
-chmod 660 /opt/dbspace/.rua.db-journal
 
 %postun -p /sbin/ldconfig
 
 
-
 %files
+%manifest librua.manifest
 %defattr(-,root,root,-)
-%config(missingok) /opt/share/rua_db.sql
 /usr/lib/librua.so.*
-
-
+/usr/share/license/%{name}
+%attr(660,root,app) /opt/dbspace/.rua.db
+%attr(660,root,app) /opt/dbspace/.rua.db-journal
 
 %files devel
 %defattr(-,root,root,-)
index 5168852..bba3dc9 100644 (file)
 
 #include <stdio.h>
 #include <sys/time.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "RUA_PERF"
 
 unsigned int _perf_measure_start(const char *tag, char *func_name, int line)
 {
@@ -34,7 +41,7 @@ unsigned int _perf_measure_start(const char *tag, char *func_name, int line)
        gettimeofday(&t, NULL);
        ts_start = t.tv_sec * 1000000UL + t.tv_usec;
 
-       printf("### START [%s:%d] timestamp(%u)\n", func_name, line, ts_start);
+       SECURE_LOGD("### START [%s:%d] timestamp(%u)\n", func_name, line, ts_start);
 
        return ts_start;
 }
@@ -52,10 +59,10 @@ unsigned int _perf_measure_end(const char *tag, unsigned int ts_start,
        if (ts_start)
                elapsed_time = ts_end - ts_start;
 
-       printf("### END [%s:%d] timestamp(%u)\n", func_name, line, ts_end);
+       SECURE_LOGD("### END [%s:%d] timestamp(%u)\n", func_name, line, ts_end);
 
        if (elapsed_time)
-               printf("### ELAPSED [%s:%d] timestamp(%u)\n", func_name, line,
+               SECURE_LOGD("### ELAPSED [%s:%d] timestamp(%u)\n", func_name, line,
                        elapsed_time);
 
        return ts_end;
old mode 100644 (file)
new mode 100755 (executable)
index 9b5ef8b..4b38f99
--- a/src/rua.c
+++ b/src/rua.c
@@ -21,6 +21,7 @@
 
 /*
  * @file    rua.c
+ * @author  Noha Park (noha.park@samsung.com)
  * @version 0.1
  */
 
 #include "db-schema.h"
 #include "perf-measure.h"
 
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "RUA"
+
 #define RUA_DB_PATH    "/opt/dbspace"
 #define RUA_DB_NAME    ".rua.db"
 #define RUA_HISTORY    "rua_history"
        "order by launch_time desc limit 1 "
 
 static sqlite3 *_db = NULL;
-
 static int __exec(sqlite3 *db, char *query);
-static int __create_table(sqlite3 *db);
 static sqlite3 *__db_init(char *root);
 
+#define _F(fmt, arg...) do { \
+       FILE *fp; \
+       fp = fopen("/opt/usr/media/.rua.log", "a+"); \
+       if (NULL == fp) break; \
+       fprintf(fp, "[%d]"fmt"\n", getpid(),##arg); \
+       fclose(fp); \
+} while (0)
+
 int rua_clear_history(void)
 {
        int r;
@@ -59,6 +74,10 @@ int rua_clear_history(void)
        snprintf(query, QUERY_MAXLEN, "delete from %s;", RUA_HISTORY);
 
        r = __exec(_db, query);
+       if (r == -1) {
+               LOGE("rua_clear_history error");
+               return -1;
+       }
 
        return r;
 }
@@ -67,6 +86,9 @@ int rua_delete_history_with_pkgname(char *pkg_name)
 {
        int r;
        char query[QUERY_MAXLEN];
+       sqlite3_stmt *stmt;
+
+       LOGD("rua_delete_history_with_pkgname start");
 
        if (_db == NULL)
                return -1;
@@ -74,10 +96,32 @@ int rua_delete_history_with_pkgname(char *pkg_name)
        if (pkg_name == NULL)
                return -1;
 
-       snprintf(query, QUERY_MAXLEN, "delete from %s where pkg_name = '%s';",
-               RUA_HISTORY, pkg_name);
+       sqlite3_snprintf(QUERY_MAXLEN, query, "delete from %s where pkg_name = ?",
+               RUA_HISTORY);
 
-       r = __exec(_db, query);
+       r = sqlite3_prepare(_db, query, sizeof(query), &stmt, NULL);
+       if (r != SQLITE_OK) {
+               LOGE("sqlite3_prepare error(%d)", r);
+               return -1;
+       }
+
+       r = sqlite3_bind_text(stmt, 1, pkg_name, strlen(pkg_name), SQLITE_STATIC);
+       if(r != SQLITE_OK) {
+               LOGE("pkg name bind error(%d) \n", r);
+               sqlite3_finalize(stmt);
+               return -1;
+       }
+
+       r = sqlite3_step(stmt);
+       if (r != SQLITE_DONE) {
+               LOGE("delete history error(%d/%d)", r, sqlite3_extended_errcode(_db));
+               sqlite3_finalize(stmt);
+               return -1;
+       }
+
+       sqlite3_finalize(stmt);
+
+       LOGD("rua_delete_history_with_pkgname ok");
 
        return r;
 }
@@ -86,6 +130,9 @@ int rua_delete_history_with_apppath(char *app_path)
 {
        int r;
        char query[QUERY_MAXLEN];
+       sqlite3_stmt *stmt;
+
+       LOGD("rua_delete_history_with_apppath start");
 
        if (_db == NULL)
                return -1;
@@ -93,10 +140,32 @@ int rua_delete_history_with_apppath(char *app_path)
        if (app_path == NULL)
                return -1;
 
-       snprintf(query, QUERY_MAXLEN, "delete from %s where app_path = '%s';",
-               RUA_HISTORY, app_path);
+       sqlite3_snprintf(QUERY_MAXLEN, query,"delete from %s where app_path = ?",
+               RUA_HISTORY);
 
-       r = __exec(_db, query);
+       r = sqlite3_prepare(_db, query, sizeof(query), &stmt, NULL);
+       if (r != SQLITE_OK) {
+               LOGE("sqlite3_prepare error(%d)", r);
+               return -1;
+       }
+
+       r = sqlite3_bind_text(stmt, 1, app_path, strlen(app_path), SQLITE_STATIC);
+       if(r != SQLITE_OK) {
+               LOGE("pkg name bind error(%d) \n", r);
+               sqlite3_finalize(stmt);
+               return -1;
+       }
+
+       r = sqlite3_step(stmt);
+       if (r != SQLITE_DONE) {
+               LOGE("delete history error(%d/%d)", r, sqlite3_extended_errcode(_db));
+               sqlite3_finalize(stmt);
+               return -1;
+       }
+
+       sqlite3_finalize(stmt);
+
+       LOGD("rua_delete_history_with_apppath ok");
 
        return r;
 }
@@ -104,59 +173,86 @@ int rua_delete_history_with_apppath(char *app_path)
 int rua_add_history(struct rua_rec *rec)
 {
        int r;
-       int cnt = 0;
        char query[QUERY_MAXLEN];
-       sqlite3_stmt *stmt;
+       sqlite3_stmt *stmt = NULL;
+
+       LOGD("rua_add_history start");
 
        unsigned int timestamp;
        timestamp = PERF_MEASURE_START("RUA");
 
-       if (_db == NULL)
+       if (_db == NULL) {
+               LOGE("rua is not initialized");
                return -1;
+       }       
 
-       if (rec == NULL)
+       if (rec == NULL) {
+               LOGE("input param is null");
                return -1;
+       }
 
-       snprintf(query, QUERY_MAXLEN,
-               "select count(*) from %s where pkg_name = '%s';", RUA_HISTORY,
-               rec->pkg_name);
+       if(rec->pkg_name == NULL) {
+               LOGE("pkg name is null");
+               return -1;
+       }
+
+       if(rec->app_path == NULL) {
+               LOGE("app path is null");
+               return -1;
+       }
+
+       sqlite3_snprintf(QUERY_MAXLEN, query,
+               "REPLACE INTO %s(pkg_name,app_path,arg,launch_time) VALUES (?,?,?,?)",
+               RUA_HISTORY);
 
        r = sqlite3_prepare(_db, query, sizeof(query), &stmt, NULL);
        if (r != SQLITE_OK) {
-               return -1;
+               LOGE("sqlite3_prepare error(%d , %d, %s)", r, sqlite3_extended_errcode(_db), sqlite3_errmsg(_db));
+               goto func_err;
        }
 
-       r = sqlite3_step(stmt);
-       if (r == SQLITE_ROW) {
-               cnt = sqlite3_column_int(stmt, 0);
+       r = sqlite3_bind_text(stmt, 1, rec->pkg_name, strlen(rec->pkg_name), SQLITE_STATIC);
+       if(r != SQLITE_OK) {
+               LOGE("pkg name bind error(%d) \n", r);
+               goto func_err;
        }
-       sqlite3_finalize(stmt);
 
-       if (cnt == 0)
-               /* insert */
-               snprintf(query, QUERY_MAXLEN,
-                       "insert into %s ( pkg_name, app_path, arg, launch_time ) "
-                       " values ( \"%s\", \"%s\", \"%s\", %d ) ",
-                       RUA_HISTORY,
-                       rec->pkg_name ? rec->pkg_name : "",
-                       rec->app_path ? rec->app_path : "",
-                       rec->arg ? rec->arg : "", time(NULL));
-       else
-               /* update */
-               snprintf(query, QUERY_MAXLEN,
-                       "update %s set arg='%s', launch_time='%d' where pkg_name = '%s';",
-                       RUA_HISTORY,
-                       rec->arg ? rec->arg : "", time(NULL), rec->pkg_name);
+       r = sqlite3_bind_text(stmt, 2, rec->app_path, strlen(rec->app_path), SQLITE_STATIC);
+       if(r != SQLITE_OK) {
+               LOGE("pkg name bind error(%d) \n", r);
+               goto func_err;
+       }
 
-       r = __exec(_db, query);
-       if (r == -1) {
-               printf("[RUA ADD HISTORY ERROR] %s\n", query);
-               return -1;
+       r = sqlite3_bind_text(stmt, 3, rec->arg ? rec->arg : "", -1, SQLITE_STATIC);
+       if(r != SQLITE_OK) {
+               LOGE("arg bind error(%d) \n", r);
+               goto func_err;
        }
 
+       r = sqlite3_bind_int(stmt, 4, (int)time(NULL));
+       if(r != SQLITE_OK) {
+               LOGE("arg bind error(%d) \n", r);
+               goto func_err;
+       }
+
+       r = sqlite3_step(stmt);
+       if (r != SQLITE_DONE) {
+               LOGE("step error(%d) \n", r);
+               goto func_err;
+       }
+       sqlite3_finalize(stmt);
+
        PERF_MEASURE_END("RUA", timestamp);
 
+       LOGD("rua_add_history ok");
+
        return r;
+
+func_err :
+       if(stmt)
+               sqlite3_finalize(stmt);
+
+       return -1;
 }
 
 int rua_history_load_db(char ***table, int *nrows, int *ncols)
@@ -177,11 +273,13 @@ int rua_history_load_db(char ***table, int *nrows, int *ncols)
                 "select * from %s order by launch_time desc;", RUA_HISTORY);
 
        r = sqlite3_get_table(_db, query, &db_result, nrows, ncols, &db_err);
-
-       if (r == SQLITE_OK)
+       if (r == SQLITE_OK) {
                *table = db_result;
-       else
+               LOGE("rua_history_load_db ok. nrows : %d, ncols : %d", *nrows, *ncols);
+       } else {
+               SECURE_LOGE("rua_history_load_db error(%d / %s)", r, db_err);
                sqlite3_free_table(db_result);
+       }
 
        return r;
 }
@@ -250,6 +348,7 @@ int rua_is_latest_app(const char *pkg_name)
 
        r = sqlite3_prepare(_db, Q_LATEST, sizeof(Q_LATEST), &stmt, NULL);
        if (r != SQLITE_OK) {
+               LOGE("rua_is_latest_app prepare error(%d)", r);
                return -1;
        }
 
@@ -257,11 +356,13 @@ int rua_is_latest_app(const char *pkg_name)
        if (r == SQLITE_ROW) {
                ct = sqlite3_column_text(stmt, 0);
                if (ct == NULL || ct[0] == '\0') {
+                       LOGW("sqlite3_column_text null");
                        sqlite3_finalize(stmt);
                        return -1;
                }
 
-               if (strncmp(pkg_name, ct, strlen(pkg_name)) == 0) {
+               if (strncmp(pkg_name, (const char*)ct, strlen(pkg_name)) == 0) {
+                       SECURE_LOGW("pkg_name(%s) / ct(%s)", pkg_name, ct);
                        sqlite3_finalize(stmt);
                        return 0;
                }
@@ -284,8 +385,10 @@ int rua_init(void)
        snprintf(defname, sizeof(defname), "%s/%s", RUA_DB_PATH, RUA_DB_NAME);
        _db = __db_init(defname);
 
-       if (_db == NULL)
+       if (_db == NULL) {
+               LOGW("rua_init error");
                return -1;
+       }
 
        PERF_MEASURE_END("RUA", timestamp);
 
@@ -315,8 +418,8 @@ static int __exec(sqlite3 *db, char *query)
                return -1;
 
        r = sqlite3_exec(db, query, NULL, NULL, &errmsg);
-
        if (r != SQLITE_OK) {
+               SECURE_LOGE("query(%s) exec error(%s)", query, errmsg);
                sqlite3_free(errmsg);
                return -1;
        }
@@ -329,8 +432,10 @@ static int __create_table(sqlite3 *db)
        int r;
 
        r = __exec(db, CREATE_RUA_HISTORY_TABLE);
-       if (r == -1)
+       if (r == -1) {
+               LOGE("create table error");
                return -1;
+       }
 
        return 0;
 }
@@ -342,13 +447,10 @@ static sqlite3 *__db_init(char *root)
 
        r = db_util_open(root, &db, 0);
        if (r) {
-               db_util_close(db);
-               return NULL;
-       }
-
-       r = __create_table(db);
-       if (r) {
-               db_util_close(db);
+               _F("db util open error(%d/%d/%d/%s)", r,
+                       sqlite3_errcode(db),
+                       sqlite3_extended_errcode(db),
+                       sqlite3_errmsg(db));
                return NULL;
        }