From: Jan Cybulski Date: Tue, 23 Apr 2013 11:11:42 +0000 (+0200) Subject: Add test for security_server_get_smacklabel_sockfd X-Git-Tag: security-manager_5.5_testing~427 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d6bbba1e3dabb3e27834b00dc436b05d3fed046d;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Add test for security_server_get_smacklabel_sockfd [Issue#] SSDWSSP-198 [Feature/Bug] security_server_get_smacklabel_sockfd has no tests yet [Problem] N/A [Cause] N/A [Solution] Add test for API in existing testcase tc06_check_privilege_by_sockfd [Verification] build, run the test, verify if it pass. Change-Id: I2cbc713c37ff77270e83855d51bddc5048cbd233 --- diff --git a/tests/security-server-tests/security_server_tests_client_smack.cpp b/tests/security-server-tests/security_server_tests_client_smack.cpp index 9df76cc..1e66948 100644 --- a/tests/security-server-tests/security_server_tests_client_smack.cpp +++ b/tests/security-server-tests/security_server_tests_client_smack.cpp @@ -174,6 +174,7 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd) smack_accesses_free(handle); int pid = fork(); + char *label; RUNNER_ASSERT(-1 != pid); if (0 == pid) { @@ -186,13 +187,25 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd) LogDebug("child, create_new_socket"); int sockfd = create_new_socket(); + + label = security_server_get_smacklabel_sockfd(sockfd); + RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed"); + RUNNER_ASSERT_MSG(strcmp(label,"")==0, "label is \""<< label<<"\""); + free(label); + LogDebug("child, listen"); if (listen(sockfd, 5) < 0) { LogDebug("child, exit"); exit(1); } - LogDebug("child, accept"); + label = security_server_get_smacklabel_sockfd(sockfd); + RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed"); + RUNNER_ASSERT_MSG(strcmp(label,"")==0, "label is \""<< label<<"\""); + free(label); + + + LogDebug("child, accept"); struct sockaddr_un client_addr; socklen_t client_len = sizeof(client_addr); int csockfd; @@ -200,6 +213,13 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd) LogDebug("child, loop"); close(csockfd); } + + + label = security_server_get_smacklabel_sockfd(sockfd); + RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed"); + RUNNER_ASSERT_MSG(strcmp(label,subject_label)==0, "label is \""<< label<<"\"" << "subject_label is \""<< subject_label<<"\"" ); + free(label); + LogDebug("Exit!"); exit(1); } else { @@ -207,6 +227,12 @@ RUNNER_TEST(tc06_check_privilege_by_sockfd) LogDebug("Parent, sleep 2"); sleep(1); int sockfd = connect_to_testserver(); + + label = security_server_get_smacklabel_sockfd(sockfd); + RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed"); + RUNNER_ASSERT_MSG(strcmp(label,subject_label)==0, "label is \""<< label<<"\"" << "subject_label is \""<< subject_label<<"\"" ); + free(label); + LogDebug("Parent: sockfd: " << sockfd); if (sockfd >= 0) { result1 = security_server_check_privilege_by_sockfd(