X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2Fsecurity-server-tests%2Fsecurity_server_measurer_API_speed.cpp;h=db42e3aacc56b04fd4fa73c5f21e535661c37fdd;hb=6fdfd15692b25830947841f6a90110a052b2a7f1;hp=f3c0eca6d82076c03cd17ed2768ac8b6258c9e53;hpb=4c65df7da4945c20b8afc128f89ce9a76d00066a;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git diff --git a/tests/security-server-tests/security_server_measurer_API_speed.cpp b/tests/security-server-tests/security_server_measurer_API_speed.cpp index f3c0eca..db42e3a 100644 --- a/tests/security-server-tests/security_server_measurer_API_speed.cpp +++ b/tests/security-server-tests/security_server_measurer_API_speed.cpp @@ -29,7 +29,6 @@ */ #include -#include #include #include #include @@ -48,9 +47,14 @@ #include #include #include -#include +#include #include "security_server_mockup.h" #include +#include + +IMPLEMENT_SAFE_SINGLETON(DPL::Log::LogSystem); +#include +#include /*Number of calls in a single test*/ #define NUMBER_OF_CALLS (5) @@ -68,10 +72,6 @@ #define M160_CUSTOMER_LABEL "my_customer_label" #define M170_OBJECT_LABEL "myObject" - -IMPLEMENT_SAFE_SINGLETON(DPL::Log::LogSystem); -#include - namespace { void securityClientEnableLogSystem(void) { DPL::Log::LogSystemSingleton::Instance().SetTag("SEC_SRV_API_SPEED"); @@ -149,6 +149,7 @@ int my_pipe_write(int fd, void *buf, size_t count) { int communication_succeeded(int result_code) { switch(result_code) { + case SECURITY_SERVER_API_ERROR_NO_SUCH_SERVICE: case SECURITY_SERVER_API_ERROR_SOCKET: case SECURITY_SERVER_API_ERROR_BAD_REQUEST: case SECURITY_SERVER_API_ERROR_BAD_RESPONSE: @@ -251,12 +252,6 @@ void finish_stats(readwrite_stats *stats, const char* function_name) { LogDebug("No function call succeeded\n"); } -void closesockfdptr(int* sockfd_ptr) -{ - close(*sockfd_ptr); -} -typedef std::unique_ptr > SockFDUniquePtr; - /*TEST CASES*/ RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_API_SPEED_MEASURER) @@ -415,44 +410,36 @@ RUNNER_TEST(m050_security_server_check_privilege) { finish_stats(&stats, "security_server_check_privilege"); } -/* - * measurer: Fails only on connection error. - */ - -RUNNER_TEST(m060_security_server_check_privilege_by_cookie) { - size_t cookie_size; - cookie_size = security_server_get_cookie_size(); - char cookie[cookie_size]; +void testSecurityServerCheckPrivilegeByCookie(bool smack) { const char *object_label = M60_OBJECT_LABEL; const char *access_rights = "r"; const char *access_rights_ext = "rw"; const char *subject_label = M60_SUBJECT_LABEL; - smack_accesses *handle; int ret; readwrite_stats stats; initialize_stats(&stats); - RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(subject_label), - "Cannot prepare environment for test."); - RUNNER_ASSERT_MSG_BT(0 == (ret = smack_accesses_new(&handle)), "Error in smack_accesses_new()"); - RUNNER_ASSERT_MSG_BT(0 == smack_accesses_add(handle, - subject_label, - object_label, - access_rights), "Error in smack_accesses_add()" ); - RUNNER_ASSERT_MSG_BT(0 == (ret = smack_accesses_apply(handle)), "Error in smack_accesses_apply(); ret = " << ret); - smack_accesses_free(handle); - RUNNER_ASSERT_MSG_BT(0 == (ret = smack_set_label_for_self(subject_label)), "Error in smack_set_label_for_self(); ret = " << ret); - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_SUCCESS == security_server_request_cookie(cookie, cookie_size), "Error in security_server_request_cookie()"); + + if (smack) { + SmackAccess smackAccess; + smackAccess.add(subject_label, object_label, access_rights); + smackAccess.apply(); + RUNNER_ASSERT_MSG_BT(0 == (ret = smack_set_label_for_self(subject_label)), + "Error in smack_set_label_for_self(); ret = " << ret); + } + + Cookie cookie = getCookieFromSS(); + for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); /*odd(i) - ask for possessed privileges, even(i) ask for not possessed privileges */ if (i%2) ret = security_server_check_privilege_by_cookie( - cookie, + cookie.data(), object_label, access_rights); else ret = security_server_check_privilege_by_cookie( - cookie, + cookie.data(), object_label, access_rights_ext); @@ -466,7 +453,17 @@ RUNNER_TEST(m060_security_server_check_privilege_by_cookie) { * measurer: Fails only on connection error. */ -RUNNER_MULTIPROCESS_TEST(m070_security_server_check_privilege_by_sockfd) { +RUNNER_TEST_SMACK(m060_security_server_check_privilege_by_cookie_smack) { + RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success"); + testSecurityServerCheckPrivilegeByCookie(true); +} + +RUNNER_TEST_NOSMACK(m060_security_server_check_privilege_by_cookie_nosmack) { + RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success"); + testSecurityServerCheckPrivilegeByCookie(false); +} + +void testSecurityServerCheckPrivilegeBySockfd(bool smack) { const char *object_label = M70_OBJECT_LABEL; const char *access_rights = "r"; const char *access_rights_ext = "rw"; @@ -474,14 +471,13 @@ RUNNER_MULTIPROCESS_TEST(m070_security_server_check_privilege_by_sockfd) { int ret; readwrite_stats stats; initialize_stats(&stats); - smack_accesses *handle; - RUNNER_ASSERT_BT(0 == smack_accesses_new(&handle)); - RUNNER_ASSERT_BT(0 == smack_accesses_add(handle, - subject_label, - object_label, - access_rights)); - RUNNER_ASSERT_BT(0 == smack_accesses_apply(handle)); - smack_accesses_free(handle); + + if (smack) { + SmackAccess smackAccess; + smackAccess.add(subject_label, object_label, access_rights); + smackAccess.apply(); + } + int pid = fork(); RUNNER_ASSERT_BT(-1 != pid); if (0 == pid) { @@ -489,9 +485,10 @@ RUNNER_MULTIPROCESS_TEST(m070_security_server_check_privilege_by_sockfd) { int sockfd = create_new_socket(); RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed"); - SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr); + SockUniquePtr sockfd_ptr(&sockfd); - RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set"); + if (smack) + RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set"); RUNNER_ASSERT_MSG_BT(listen(sockfd, 5) >= 0, "child listen failed"); @@ -509,7 +506,7 @@ RUNNER_MULTIPROCESS_TEST(m070_security_server_check_privilege_by_sockfd) { int sockfd = connect_to_testserver(); RUNNER_ASSERT_MSG_BT(sockfd >= 0, "connect_to_testserver() failed"); - SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr); + SockUniquePtr sockfd_ptr(&sockfd); for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); @@ -535,6 +532,20 @@ RUNNER_MULTIPROCESS_TEST(m070_security_server_check_privilege_by_sockfd) { /* * measurer: Fails only on connection error. */ + +RUNNER_MULTIPROCESS_TEST_SMACK(m070_security_server_check_privilege_by_sockfd_smack) { + RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success"); + testSecurityServerCheckPrivilegeBySockfd(true); +} + +RUNNER_MULTIPROCESS_TEST_NOSMACK(m070_security_server_check_privilege_by_sockfd_nosmack) { + RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success"); + testSecurityServerCheckPrivilegeBySockfd(false); +} + +/* + * measurer: Fails only on connection error. + */ RUNNER_TEST(m080_security_server_get_cookie_pid) { int ret; size_t cookie_size; @@ -690,6 +701,7 @@ RUNNER_TEST(m160_security_server_app_give_access) { */ RUNNER_TEST(m170_security_server_check_privilege_by_pid) { + RUNNER_IGNORED_MSG("security_server_check_privilege_by_pid is temporarily disabled: always returns success"); int ret; readwrite_stats stats; initialize_stats(&stats);