Add null checking and remove temporal test code for comparing mapping APIs 85/54985/5 accepted/tizen/mobile/20151221.101436 accepted/tizen/tv/20151221.101349 accepted/tizen/wearable/20151221.101520 submit/tizen/20151221.064656 submit/tizen_common/20151229.142028 submit/tizen_common/20151229.144031 submit/tizen_common/20151229.154718
authorYunjin Lee <yunjin-.lee@samsung.com>
Mon, 21 Dec 2015 06:19:34 +0000 (15:19 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Mon, 21 Dec 2015 06:29:22 +0000 (22:29 -0800)
Change-Id: Ieb1155b661494e6c3f623b76aba34269586f4d21
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
capi/src/privilege_manager.c
packaging/privilege-checker.spec
test/CMakeLists.txt
test/tc-privilege-db-manager.c

index 41c4230..192fc9b 100755 (executable)
@@ -219,6 +219,10 @@ int privilege_manager_verify_privilege(const char *api_version, privilege_manage
        }
        if (package_type == PRVMGR_PACKAGE_TYPE_WRT) {
                char *tmp_api_version = strdup(api_version);
+               TryReturn(tmp_api_version != NULL, , PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] tmp_api_version's strdup is failed.");
+               size_t new_size = snprintf(0, 0, "%s%s", tmp_api_version, API_VERSION_PADDING) + 1;
+               tmp_api_version = realloc(tmp_api_version, new_size * sizeof(char));
+               TryReturn(tmp_api_version != NULL, free(tmp_api_version), PRVMGR_ERR_OUT_OF_MEMORY, "[PRVMGR_ERR_OUT_OF_MEMORY] tmp_api_version's realloc is failed.");
                strncat(tmp_api_version, ".0", strlen(".0"));
 
                for (i = 0; i < 5; i++) {
index a67169c..de1201c 100644 (file)
@@ -45,7 +45,6 @@ The Privilege Manager API provides functions to verify privilege information of
 
 %package  -n tc-privilege-checker
 Summary:  tc-privilege-checker
-BuildRequires: pkgconfig(security-manager)
 
 %description -n tc-privilege-checker
 Testsuit for Privilege Manager APIs
index e542174..8b49a5a 100755 (executable)
@@ -20,7 +20,7 @@ ELSEIF("${PROFILE_TYPE}" STREQUAL "TV")
     ADD_DEFINITIONS("-DPROFILE_TYPE_TV")
 ENDIF()
 
-SET(requires glib-2.0 dlog security-manager)
+SET(requires glib-2.0 dlog)
 INCLUDE(FindPkgConfig)
 pkg_check_modules(${PACKAGE_NAME} REQUIRED ${requires})
 FOREACH(flag ${${PACKAGE_NAME}_CFLAGS})
@@ -38,10 +38,8 @@ ADD_EXECUTABLE(${TC1_NAME} ${TC1_SRCS})
 ADD_EXECUTABLE(${TC2_NAME} ${TC2_SRCS})
 ADD_EXECUTABLE(${TC3_NAME} ${TC3_SRCS})
 
-TARGET_LINK_LIBRARIES(${TC1_NAME} 
+TARGET_LINK_LIBRARIES(${TC1_NAME}
        "capi-security-privilege-manager"
-       "security-manager-client"
-       "security-manager-commons"
        )
 TARGET_LINK_LIBRARIES(${TC2_NAME} "capi-security-privilege-manager")
 TARGET_LINK_LIBRARIES(${TC3_NAME} "capi-security-privilege-manager")
index 349e716..827a22f 100755 (executable)
@@ -1,6 +1,5 @@
 #include <stdio.h>
 #include <privilege_db_manager.h>
-#include <security-manager.h>
 
 #define BRIGHTNESS 0
 #define RED 31
@@ -225,27 +224,8 @@ void __test_privilege_db_manager_get_mapped_privilege_list()
                printf("mapped_privilege_name = %s\n", privilege_name);
        }
 
-       printf("-----------------------------------------------------------\n");
-       printf("Compare with security_manager_get_privileges_mapping(const char *from_version, const char *to_version, char const * const *privileges, size_t privileges_count, char ***privileges_mappings, size_t *mappings_count)\n");
-
-       printf("privilege : http://tizen.org/privilege/internal/default/public\n");
-       printf("privilege : http://tizen.org/privilege/mediacapture\n");
-       printf("privilege : http://tizen.org/privilege/content.read\n");
-       printf("privilege : http://tizen.org/privilege/internal/webappdefault\n");
-
-       char **input_privileges = (char **)malloc(sizeof(char*) * 20);
-       size_t input_size = 0;
-       input_privileges[input_size++] = strdup("http://tizen.org/privilege/internal/webappdefault");
-       input_privileges[input_size++] = strdup("http://tizen.org/privilege/internal/default/public");
-       input_privileges[input_size++] = strdup("http://tizen.org/privilege/mediacapture");
-       input_privileges[input_size++] = strdup("http://tizen.org/privilege/content.read");
-       char **output_privileges = NULL;
-       size_t output_size;
-       ret = security_manager_get_privileges_mapping("2.2.1", "3.0", input_privileges, input_size, &output_privileges, &output_size);
-       int i;
-       printf("output_size = %d\n", output_size);
-       for (i = 0; i < output_size; i++)
-               printf("mapped_privilege_name = %s\n", output_privileges[i]);
+       g_list_free(privilege_list);
+       g_list_free(mapped_privilege_list);
 
        __change_color_to_green();
        printf("test success\n");
@@ -422,32 +402,32 @@ void __test_privilege_db_manager_get_privilege_description()
 
 int main()
 {
-/*    __change_color_to_yellow();
-    printf("Test function : privilege_db_manager_get_privilege_list\n");
-    __change_color_to_origin();
-    __test_privilege_db_manager_get_privilege_list();*/
+       __change_color_to_yellow();
+       printf("Test function : privilege_db_manager_get_privilege_list\n");
+       __change_color_to_origin();
+       __test_privilege_db_manager_get_privilege_list();
 
        __change_color_to_yellow();
        printf("Test function : privilege_db_manager_get_mapped_privilege_list\n");
        __change_color_to_origin();
        __test_privilege_db_manager_get_mapped_privilege_list();
 
-/*    __change_color_to_yellow();
-    printf("Test function : privilege_db_manager_get_privilege_display\n");
-    __change_color_to_origin();
-    __test_privilege_db_manager_get_privilege_display();
-
-    __change_color_to_yellow();
-    printf("Test function : privilege_db_manager_get_privilege_description\n");
-    __change_color_to_origin();
-    __test_privilege_db_manager_get_privilege_description();
-
-    __change_color_to_green();
-    printf("Test Complete\n");
-    printf("success : %d, ", success_cnt);
-    __change_color_to_red();
-    printf("fail : %d\n", fail_cnt);
-    __change_color_to_origin();*/
+       __change_color_to_yellow();
+       printf("Test function : privilege_db_manager_get_privilege_display\n");
+       __change_color_to_origin();
+       __test_privilege_db_manager_get_privilege_display();
+
+       __change_color_to_yellow();
+       printf("Test function : privilege_db_manager_get_privilege_description\n");
+       __change_color_to_origin();
+       __test_privilege_db_manager_get_privilege_description();
+
+       __change_color_to_green();
+       printf("Test Complete\n");
+       printf("success : %d, ", success_cnt);
+       __change_color_to_red();
+       printf("fail : %d\n", fail_cnt);
+       __change_color_to_origin();
 
        return 0;
 }