tizen 2.3.1 release tizen_2.3.1 submit/tizen_2.3.1/20150915.080112 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:13:20 +0000 (22:13 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:13:20 +0000 (22:13 +0900)
22 files changed:
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_ac_check_launch_privilege_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_ac_register_launch_privilege_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func.c [new file with mode: 0755]
TC/unit/utc_MODULE_API_func.c.in [new file with mode: 0755]
app-checker.manifest [new file with mode: 0644]
include/app-checker-server.h
include/app-checker.h
include/internal.h
packaging/app-checker.spec
src/ac_lib.c
src/ac_server.c
src/ac_sock.c

diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..e7a9432
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export TET_INSTALL_PATH=$HOME/git/tetware/TETware  # local tetware path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
+
+export 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..a119011
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+export TET_INSTALL_PATH=/mnt/nfs/git/tetware/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..a584acd
--- /dev/null
@@ -0,0 +1,2 @@
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
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..8993f7d
--- /dev/null
@@ -0,0 +1,25 @@
+CC ?= gcc
+
+TARGETS = utc_ApplicationFW_ac_register_launch_privilege_func \
+       utc_ApplicationFW_ac_unregister_launch_privilege_func \
+       utc_ApplicationFW_ac_check_launch_privilege_func
+
+PKGS = glib-2.0 dlog app-checker
+
+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
+LDFLAGS += -L/usr/lib -lpthread
+
+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..2478015
--- /dev/null
@@ -0,0 +1,3 @@
+/unit/utc_ApplicationFW_ac_register_launch_privilege_func
+/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func
+/unit/utc_ApplicationFW_ac_check_launch_privilege_func
diff --git a/TC/unit/utc_ApplicationFW_ac_check_launch_privilege_func.c b/TC/unit/utc_ApplicationFW_ac_check_launch_privilege_func.c
new file mode 100755 (executable)
index 0000000..df57741
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ *  app-checker
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@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 <app-checker.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_ac_check_launch_privilege_func_01(void);
+static void utc_ApplicationFW_ac_check_launch_privilege_func_02(void);
+static void utc_ApplicationFW_ac_check_launch_privilege_func_03(void);
+static void utc_ApplicationFW_ac_check_launch_privilege_func_04(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_ApplicationFW_ac_check_launch_privilege_func_01, POSITIVE_TC_IDX},
+       {utc_ApplicationFW_ac_check_launch_privilege_func_02, NEGATIVE_TC_IDX},
+       {utc_ApplicationFW_ac_check_launch_privilege_func_03, NEGATIVE_TC_IDX},
+       {utc_ApplicationFW_ac_check_launch_privilege_func_04, NEGATIVE_TC_IDX},
+       {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/** API Prototype
+*int ac_check_launch_privilege(const char *pkg_name,
+*                      const char *pkg_type, int pid);
+*/
+
+
+/**
+ * @brief Positive test case of ac_check_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_check_launch_privilege_func_01(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_check_launch_privilege("org.tizen.calculator", "deb",
+                                     getpid());
+       if (r < 0) {
+               tet_infoline
+                   ("ac_check_launch_privilege()"
+                    " failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of ac_check_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_check_launch_privilege_func_02(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_check_launch_privilege(NULL, "deb", getpid());
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_check_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of ac_check_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_check_launch_privilege_func_03(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_check_launch_privilege("org.tizen.calculator", NULL, getpid());
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_check_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 03 of ac_check_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_check_launch_privilege_func_04(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_check_launch_privilege(NULL, NULL, getpid());
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_check_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_ac_register_launch_privilege_func.c b/TC/unit/utc_ApplicationFW_ac_register_launch_privilege_func.c
new file mode 100755 (executable)
index 0000000..34cfe03
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ *  app-checker
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@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 <app-checker.h>
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_ac_register_launch_privilege_func_01(void);
+static void utc_ApplicationFW_ac_register_launch_privilege_func_02(void);
+static void utc_ApplicationFW_ac_register_launch_privilege_func_03(void);
+static void utc_ApplicationFW_ac_register_launch_privilege_func_04(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_ApplicationFW_ac_register_launch_privilege_func_01,
+        POSITIVE_TC_IDX},
+       {utc_ApplicationFW_ac_register_launch_privilege_func_02,
+        NEGATIVE_TC_IDX},
+       {utc_ApplicationFW_ac_register_launch_privilege_func_03,
+        NEGATIVE_TC_IDX},
+       {utc_ApplicationFW_ac_register_launch_privilege_func_04,
+        NEGATIVE_TC_IDX},
+       {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+/** API Prototype
+*int ac_register_launch_privilege(const char *pkg_name,
+*                               const char *pkg_type);
+*/
+
+/**
+ * @brief Positive test case of ac_register_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_register_launch_privilege_func_01(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_register_launch_privilege("org.tizen.calculator", "deb");
+       if (r < 0 && r != AC_R_ENOPULUGINS) {
+               tet_infoline
+                   ("ac_register_launch_privilege()"
+                    " failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of ac_register_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_register_launch_privilege_func_02(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_register_launch_privilege(NULL, "deb");
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_register_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of ac_register_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_register_launch_privilege_func_03(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_register_launch_privilege("org.tizen.calculator", NULL);
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_register_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 03 of ac_register_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_register_launch_privilege_func_04(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_register_launch_privilege(NULL, NULL);
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_register_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func.c b/TC/unit/utc_ApplicationFW_ac_unregister_launch_privilege_func.c
new file mode 100755 (executable)
index 0000000..73f8fd8
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ *  app-checker
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@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 <app-checker.h>
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup) (void) = startup;
+void (*tet_cleanup) (void) = cleanup;
+
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_01(void);
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_02(void);
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_03(void);
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_04(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       {utc_ApplicationFW_ac_unregister_launch_privilege_func_01,
+        POSITIVE_TC_IDX},
+       {utc_ApplicationFW_ac_unregister_launch_privilege_func_02,
+        NEGATIVE_TC_IDX},
+       {utc_ApplicationFW_ac_unregister_launch_privilege_func_03,
+        NEGATIVE_TC_IDX},
+       {utc_ApplicationFW_ac_unregister_launch_privilege_func_04,
+        NEGATIVE_TC_IDX},
+       {NULL, 0},
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/** API Prototype
+*int ac_unregister_launch_privilege(const char *pkg_name,
+*                              const char *pkg_type);
+*/
+
+
+/**
+ * @brief Positive test case of ac_unregister_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_01(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_unregister_launch_privilege("org.tizen.calculator", "deb");
+       if (r < 0 && r != AC_R_ENOPULUGINS) {
+               tet_infoline
+                   ("ac_unregister_launch_privilege()"
+                    " failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 01 of ac_unregister_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_02(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_unregister_launch_privilege(NULL, "deb");
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_unregister_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 02 of ac_unregister_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_03(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_unregister_launch_privilege("org.tizen.calculator", NULL);
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_unregister_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case 03 of ac_unregister_launch_privilege()
+ */
+static void utc_ApplicationFW_ac_unregister_launch_privilege_func_04(void)
+{
+       int r = AC_R_ERROR;
+       r = ac_unregister_launch_privilege(NULL, NULL);
+       if (r != AC_R_EINVAL) {
+               tet_infoline
+                   ("ac_unregister_launch_privilege()"
+                    " failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_MODULE_API_func.c.in b/TC/unit/utc_MODULE_API_func.c.in
new file mode 100755 (executable)
index 0000000..2899c28
--- /dev/null
@@ -0,0 +1,76 @@
+#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 },
+};
+
+static void startup(void)
+{
+       int r;
+/*
+       char *err;
+       r = initailze...;
+       if (r) {
+               err = "Error message.......";
+               tet_infoline(err);
+               tet_delete(POSITIVE_TC_IDX, err);
+               tet_delete(NEGATIVE_TC_IDX, err);
+       }
+*/
+
+}
+
+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);
+}
diff --git a/app-checker.manifest b/app-checker.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
index 4667fab..a1f4614 100755 (executable)
@@ -32,7 +32,8 @@ typedef enum _ac_return_val {
        AC_R_OK = 0                     /**< General success */
 }ac_return_val;
 
-int ac_server_initailize();
+int ac_server_initialize();
+int ac_server_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid);
 
 #ifdef __cpulusplus
        }
index b3c4fe0..9ae03be 100755 (executable)
@@ -36,7 +36,7 @@ typedef enum _ac_return_val {
        AC_R_OK = 0                     /**< General success */
 }ac_return_val;
 
-int ac_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid);
+int ac_check_launch_privilege(const char *appid, const char *pkg_type, int pid);
 
 int ac_register_launch_privilege(const char *pkg_name, const char *pkg_type);
 
index 54ce035..d8a2138 100755 (executable)
  * limitations under the License.
  *
  */
-\r
-\r
-#ifndef __INTERNAL_H__\r
-#define __INTERNAL_H__\r
-\r
-#include <unistd.h>\r
-#include <ctype.h>\r
-#include <dlog.h>\r
-\r
-#undef LOG_TAG\r
-#define LOG_TAG "APP-CHECKER"\r
-\r
-#define MAX_PACKAGE_STR_SIZE 512\r
-#define MAX_PACKAGE_TYPE_SIZE 128\r
-\r
-struct ac_data {\r
-       char pkg_name[MAX_PACKAGE_STR_SIZE];\r
-       char pkg_type[MAX_PACKAGE_TYPE_SIZE];\r
-       int pid;\r
-};\r
-\r
-#define _E(fmt, arg...) LOGE("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)\r
-#define _D(fmt, arg...) LOGD("[%s,%d] "fmt,__FUNCTION__,__LINE__,##arg)\r
-\r
-#define retvm_if(expr, val, fmt, arg...) do { \\r
-       if(expr) { \\r
-               _E(fmt, ##arg); \\r
-               _E("(%s) -> %s() return", #expr, __FUNCTION__); \\r
-               return (val); \\r
-       } \\r
-} while (0)\r
-\r
-#define retv_if(expr, val) do { \\r
-       if(expr) { \\r
-               _E("(%s) -> %s() return", #expr, __FUNCTION__); \\r
-               return (val); \\r
-       } \\r
-} while (0)\r
-\r
-#endif /* __INTERNAL_H__ */\r
-\r
+
+
+#ifndef __INTERNAL_H__
+#define __INTERNAL_H__
+
+#include <unistd.h>
+#include <ctype.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "APP_CHECKER"
+
+#define MAX_PACKAGE_STR_SIZE 512
+#define MAX_PACKAGE_TYPE_SIZE 128
+
+struct ac_data {
+       char pkg_name[MAX_PACKAGE_STR_SIZE];
+       char pkg_type[MAX_PACKAGE_TYPE_SIZE];
+       int pid;
+};
+
+#define _E(fmt, arg...) LOGE(fmt,##arg)
+#define _D(fmt, arg...) LOGD(fmt,##arg)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if(expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if(expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#endif /* __INTERNAL_H__ */
+
index 9b2a378..e1bc108 100644 (file)
@@ -1,9 +1,9 @@
 Name:      app-checker
 Summary:    App Checker
-Version:    0.0.8
-Release:    2
+Version:    0.0.20
+Release:    1
 Group:      System/Libraries
-License:    Apache License, Version 2.0
+License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 
 Requires(post): /sbin/ldconfig
@@ -50,7 +50,12 @@ libapp-checker server (developement files)
 
 
 %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
+export CFLAGS="$CFLAGS -Wall -Werror -Wno-unused-function"
 CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=/usr
 
 make %{?jobs:-j%jobs}
@@ -69,6 +74,7 @@ mkdir -p /usr/lib/ac-plugins
 
 
 %files
+%manifest app-checker.manifest
 %defattr(-,root,root,-)
 /usr/lib/libapp-checker.so.0
 /usr/lib/libapp-checker.so.0.1.0
@@ -80,6 +86,7 @@ mkdir -p /usr/lib/ac-plugins
 /usr/include/app-checker/app-checker.h
 
 %files server
+%manifest app-checker.manifest
 %defattr(-,root,root,-)
 /usr/lib/libapp-checker-server.so.0
 /usr/lib/libapp-checker-server.so.0.1.0
index ccea484..cfb92b3 100755 (executable)
@@ -39,8 +39,10 @@ static int app_send_cmd(const char *pkg_name, const char *pkg_type, int pid, int
        unsigned char *data;
        struct ac_data ad;
 
-       strncpy(ad.pkg_name, pkg_name, MAX_PACKAGE_STR_SIZE);
-       strncpy(ad.pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE);
+       memset(&ad, 0, sizeof(ad));
+
+       strncpy(ad.pkg_name, pkg_name, MAX_PACKAGE_STR_SIZE-1);
+       strncpy(ad.pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE-1);
        ad.pid = pid;
 
        data = (unsigned char *)g_base64_encode((const guchar *)&ad, sizeof(ad));
@@ -68,14 +70,14 @@ static int app_send_cmd(const char *pkg_name, const char *pkg_type, int pid, int
        return ret;
 }
 
-SLPAPI int ac_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid)
+SLPAPI int ac_check_launch_privilege(const char *appid, const char *pkg_type, int pid)
 {
        int ret = -1;
 
-       if(pkg_name == NULL || pkg_type == NULL)
+       if(appid == NULL || pkg_type == NULL)
                return AC_R_EINVAL;
 
-       ret = app_send_cmd(pkg_name, pkg_type, pid, AC_CHECK);
+       ret = app_send_cmd(appid, pkg_type, pid, AC_CHECK);
 
        return ret;
 }
index 5373524..c88820f 100755 (executable)
@@ -36,7 +36,7 @@
 #include "internal.h"
 
 #define PLUGINS_PREFIX "/usr/lib/ac-plugins"
-#define MAX_LOCAL_BUFSZ        512
+#define MAX_LOCAL_BUFSZ        512
 
 #ifndef SLPAPI
 #define SLPAPI __attribute__ ((visibility("default")))
@@ -76,21 +76,21 @@ static int __check_launch_privilege(const char *pkg_name, const char *pkg_type,
        GSList *iter2 = NULL;
        ac_type_list_t *type_t;
        ac_so_list_t *so_t;
-       
+
        for (iter = pkg_type_list; iter != NULL; iter = g_slist_next(iter)) {
                type_t = iter->data;
                if (strncmp(type_t->pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE) == 0) {
                        for (iter2 = type_t->so_list; iter2 != NULL; iter2 = g_slist_next(iter2)) {
                                so_t = iter2->data;
-                               _D("type : %s / so name : %s / func : %x", type_t->pkg_type, so_t->so_name, so_t->ac_check);
+                               SECURE_LOGD("type : %s / so name : %s / func : %x", type_t->pkg_type, so_t->so_name, so_t->ac_check);
                                if (so_t->ac_check && so_t->ac_check(pkg_name) < 0) {
                                        if(pid > 0)
-                                               __send_to_sigkill(pid);                                 
+                                               __send_to_sigkill(pid);
                                        return AC_R_ERROR;
                                }
                        }
                        return AC_R_OK;
-               }                                               
+               }
        }
 
        return AC_R_ENOPULUGINS;
@@ -103,7 +103,7 @@ static int __register_launch_privilege(const char *pkg_name, const char *pkg_typ
        ac_type_list_t *type_t;
        ac_so_list_t *so_t;
        int ret = AC_R_OK;
-       
+
        for (iter = pkg_type_list; iter != NULL; iter = g_slist_next(iter)) {
                type_t = iter->data;
                if (strncmp(type_t->pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE) == 0) {
@@ -114,7 +114,7 @@ static int __register_launch_privilege(const char *pkg_name, const char *pkg_typ
                                }
                        }
                        return ret;
-               }                                               
+               }
        }
 
        return AC_R_ENOPULUGINS;
@@ -128,7 +128,7 @@ static int __unregister_launch_privilege(const char *pkg_name, const char *pkg_t
        ac_type_list_t *type_t;
        ac_so_list_t *so_t;
        int ret = AC_R_OK;
-       
+
        for (iter = pkg_type_list; iter != NULL; iter = g_slist_next(iter)) {
                type_t = iter->data;
                if (strncmp(type_t->pkg_type, pkg_type, MAX_PACKAGE_TYPE_SIZE) == 0) {
@@ -139,7 +139,7 @@ static int __unregister_launch_privilege(const char *pkg_name, const char *pkg_t
                                }
                        }
                        return ret;
-               }                                               
+               }
        }
 
        return AC_R_ENOPULUGINS;;
@@ -163,29 +163,35 @@ static gboolean __ac_handler(gpointer data)
        }
 
        ad = (struct ac_data *)g_base64_decode((const gchar*)pkt->data, (gsize *)&size);
+       if (ad == NULL) {
+               _E("out of memory");
+               free(pkt);
+               close(clifd);
+               return FALSE;
+       }
 
-       _D("cmd : %d, pkgname : %s, pkgtype : %s", pkt->cmd, ad->pkg_name, ad->pkg_type);
+       SECURE_LOGD("cmd : %d, pkgname : %s, pkgtype : %s", pkt->cmd, ad->pkg_name, ad->pkg_type);
 
        switch (pkt->cmd) {
        case AC_CHECK:
                _send_result_to_server(clifd, AC_R_OK);
                ret = __check_launch_privilege(ad->pkg_name, ad->pkg_type, ad->pid);
-               g_free(ad); 
+               g_free(ad);
                free(pkt);
                return TRUE;
                break;
        case AC_REGISTER:
                ret = __register_launch_privilege(ad->pkg_name, ad->pkg_type);
-               break;          
+               break;
        case AC_UNREGISTER:
                ret = __unregister_launch_privilege(ad->pkg_name, ad->pkg_type);
-               break;          
+               break;
        default:
                _E("no support packet");
        }
 
        _send_result_to_server(clifd, ret);
-       
+
        g_free(ad);
        free(pkt);
        return TRUE;
@@ -232,7 +238,7 @@ static void __pkt_type_list_free()
        GSList *iter2 = NULL;
        ac_type_list_t *type_t;
        ac_so_list_t *so_t;
-       
+
        for (iter = pkg_type_list; iter != NULL; iter = g_slist_next(iter)) {
                type_t = iter->data;
                if(type_t) {
@@ -245,8 +251,8 @@ static void __pkt_type_list_free()
                                }
                        }
                        g_slist_free(type_t->so_list);
-               
-               
+
+
                        if(type_t->pkg_type)
                                free(type_t->pkg_type);
                        free(type_t);
@@ -270,6 +276,13 @@ int __initialize()
        src = g_source_new(&funcs, sizeof(GSource));
 
        gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+       if (gpollfd == NULL) {
+               _E("out of memory");
+               g_source_unref(src);
+               close(fd);
+               return AC_R_ERROR;
+       }
+
        gpollfd->events = POLLIN;
        gpollfd->fd = fd;
 
@@ -289,31 +302,32 @@ int __initialize()
 
        DIR *dp;
        struct dirent *dentry;
-       DIR *sub_dp;
+       DIR *sub_dp = NULL;
        struct dirent *sub_dentry;
        char buf[MAX_LOCAL_BUFSZ];
        char buf2[MAX_LOCAL_BUFSZ];
        ac_type_list_t *type_t = NULL;
        void *handle = NULL;
        ac_so_list_t *so_t = NULL;
-       
+
        dp = opendir(PLUGINS_PREFIX);
        if (dp == NULL) {
                return AC_R_ERROR;
        }
        while ((dentry = readdir(dp)) != NULL) {
-               
-               if(dentry->d_type != DT_DIR) 
+
+               if(dentry->d_type != DT_DIR)
                        continue;
                if(strcmp(dentry->d_name,".") == 0 || strcmp(dentry->d_name,"..") == 0) 
                        continue;
-               
+
                snprintf(buf,MAX_LOCAL_BUFSZ,"%s/%s",PLUGINS_PREFIX,dentry->d_name);
-               _D("type : %s", dentry->d_name);
+               SECURE_LOGD("type : %s", dentry->d_name);
 
                type_t = malloc(sizeof(ac_type_list_t));
                if(type_t == NULL) {
                        __pkt_type_list_free();
+                       closedir(dp);
                        return AC_R_ERROR;
                }
                memset(type_t, 0, sizeof(ac_type_list_t));
@@ -321,22 +335,31 @@ int __initialize()
                type_t->so_list = NULL;
 
                pkg_type_list = g_slist_append(pkg_type_list, (void *)type_t);
-               
+
                sub_dp = opendir(buf);
-               
+               if (sub_dp == NULL) {
+                       __pkt_type_list_free();
+                       closedir(dp);
+                       return AC_R_ERROR;
+               }
+
                while ((sub_dentry = readdir(sub_dp)) != NULL) {
-                       
-                       if(sub_dentry->d_type == DT_DIR) 
+
+                       if(sub_dentry->d_type == DT_DIR)
                                continue;
                        snprintf(buf2,MAX_LOCAL_BUFSZ,"%s/%s", buf, sub_dentry->d_name);
-                       _D("so_name : %s", buf2);
-                       
+                       SECURE_LOGD("so_name : %s", buf2);
+
                        handle = dlopen(buf2, RTLD_LAZY);
-                       if(handle == NULL) 
+                       if(handle == NULL)
                                continue;
                        so_t = malloc(sizeof(ac_so_list_t));
                        if(so_t == NULL) {
                                __pkt_type_list_free();
+                               dlclose(handle);
+                               handle = NULL;
+                               closedir(sub_dp);
+                               closedir(dp);
                                return AC_R_ERROR;
                        }
                        memset(so_t, 0, sizeof(ac_so_list_t));
@@ -348,17 +371,26 @@ int __initialize()
                        type_t->so_list = g_slist_append(type_t->so_list, (void *)so_t);
                        handle = NULL;
                }
+               closedir(sub_dp);
        }
+       closedir(dp);
 
        return AC_R_OK;
 }
 
-SLPAPI int ac_server_initailize()
+SLPAPI int ac_server_initialize()
 {
        int ret = AC_R_OK;
-       
+
        ret = __initialize();
-       
+
        return ret;
 }
 
+SLPAPI int ac_server_check_launch_privilege(const char *pkg_name, const char *pkg_type, int pid)
+{
+       int ret = -1;
+       ret = __check_launch_privilege(pkg_name, pkg_type, pid);
+
+       return ret;
+}
index 3f7d334..c57d8b6 100755 (executable)
@@ -37,14 +37,27 @@ static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, sockl
 
 static inline void __set_sock_option(int fd, int cli)
 {
+       int ret;
        int size;
        struct timeval tv = { 5, 200 * 1000 };  /*  5.2 sec */
 
        size = AC_SOCK_MAXBUFF;
-       setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
-       setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
-       if (cli)
-               setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+       ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
+       if ( ret < 0 ) {
+               _E("setsockopt error");
+       }
+
+       ret = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+       if ( ret < 0 ) {
+               _E("setsockopt error");
+       }
+
+       if (cli) {
+               ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+               if ( ret < 0 ) {
+                       _E("setsockopt error");
+               }
+       }
 }
 
 int _create_server_sock()
@@ -67,19 +80,21 @@ int _create_server_sock()
                }
        }
 
-       bzero(&saddr, sizeof(saddr));
+       memset(&saddr, 0, sizeof(saddr));
        saddr.sun_family = AF_UNIX;
        snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s",AC_SOCK_NAME);
        unlink(saddr.sun_path);
        
        if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
                _E("bind error");
+               close(fd);
                return -1;
        }
 
        if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
                /* Flawfinder: ignore*/
                _E("failed to change the socket permission");
+               close(fd);
                return -1;
        }
 
@@ -87,6 +102,7 @@ int _create_server_sock()
 
        if (listen(fd, 10) == -1) {
                _E("listen error");
+               close(fd);
                return -1;
        }       
 
@@ -155,7 +171,7 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t
        error = 0;
        if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {
                if (errno != EAGAIN && errno != EINPROGRESS) {
-                       fcntl(fd, F_SETFL, flags);      
+                       (void)fcntl(fd, F_SETFL, flags);        
                        return (-2);
                }
        }
@@ -185,7 +201,7 @@ static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t
                return (-1);    /* select error: sockfd not set*/
 
  done:
-       fcntl(fd, F_SETFL, flags);      
+       (void)fcntl(fd, F_SETFL, flags);
        if (error) {
                close(fd);      
                errno = error;