--- /dev/null
+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
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}")
--- /dev/null
+#!/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
--- /dev/null
+#!/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
--- /dev/null
+# 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"
--- /dev/null
+all
+ ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+ :include:/unit/tslist
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
+TET_PASS_TC_NAME=True
--- /dev/null
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
--- /dev/null
+TET_OUTPUT_CAPTURE=False
--- /dev/null
+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)
--- /dev/null
+#!/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"
--- /dev/null
+/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
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+#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);
+}
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
--- /dev/null
+<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>
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
BuildRequires: cmake
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(dlog)
%description
%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}
%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,-)
#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)
{
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;
}
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;
/*
* @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;
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;
}
{
int r;
char query[QUERY_MAXLEN];
+ sqlite3_stmt *stmt;
+
+ LOGD("rua_delete_history_with_pkgname start");
if (_db == NULL)
return -1;
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;
}
{
int r;
char query[QUERY_MAXLEN];
+ sqlite3_stmt *stmt;
+
+ LOGD("rua_delete_history_with_apppath start");
if (_db == NULL)
return -1;
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;
}
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)
"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;
}
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;
}
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;
}
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);
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;
}
int r;
r = __exec(db, CREATE_RUA_HISTORY_TABLE);
- if (r == -1)
+ if (r == -1) {
+ LOGE("create table error");
return -1;
+ }
return 0;
}
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;
}