From: Marcin Niesluchowski Date: Wed, 22 May 2013 12:28:22 +0000 (+0200) Subject: Fixing libprivilege-control app_revoke_permissions() test to match actual requirement... X-Git-Tag: security-manager_5.5_testing~402 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=707035bed9d13d806fb3294693b752850889fb6f;p=platform%2Fcore%2Ftest%2Fsecurity-tests.git Fixing libprivilege-control app_revoke_permissions() test to match actual requirements (file should exist after function call). [Issue#] SSDWSSP-260 [Bug/Feature] app_revoke_permissions() should not remove permissions file. [Cause] Comment to function app_revoke_permissions() in libprivilege-control indicated that permissions file should be removed. [Solution] Tests change. [Verification] Running tests Change-Id: I119c370219ac014212269646c531d1f005aeb848 --- diff --git a/tests/libprivilege-control-tests/test_cases.cpp b/tests/libprivilege-control-tests/test_cases.cpp index 91a30a5..78bb804 100644 --- a/tests/libprivilege-control-tests/test_cases.cpp +++ b/tests/libprivilege-control-tests/test_cases.cpp @@ -593,29 +593,49 @@ RUNNER_CHILD_TEST(privilege_control06_revoke_permissions) result = test_have_any_accesses(rules_wgt_platform); RUNNER_ASSERT_MSG(result==0, "Not all permisions revoked."); - //// File exists? FILE *pFile = fopen(SMACK_RULES_DIR APP_ID, "rb"); - if(pFile!=NULL){ + RUNNER_ASSERT_MSG(pFile != NULL, + "SMACK file removed!. Errno: " << errno); + //// Is it empty? + fseek(pFile, 0L, SEEK_END); + int smack_file_length = ftell(pFile); + RUNNER_ASSERT_MSG(smack_file_length==0, + "SMACK file not empty.. Errno: " << errno); + if (pFile != NULL) fclose(pFile); - RUNNER_ASSERT_MSG(false, - "SMACK file exists after revoke!"); - } - fd = open(SMACK_RULES_DIR WGT_APP_ID, O_RDONLY); - RUNNER_ASSERT_MSG(fd >= 0, "SMACK file deleted after app_revoke_permissions"); - RUNNER_ASSERT_MSG(lseek(fd, 0, SEEK_END) == 0, "SMACK file not empty after app_revoke_permissions"); - close(fd); - - fd = open(SMACK_RULES_DIR WGT_PARTNER_APP_ID, O_RDONLY); - RUNNER_ASSERT_MSG(fd >= 0, "SMACK file deleted after app_revoke_permissions"); - RUNNER_ASSERT_MSG(lseek(fd, 0, SEEK_END) == 0, "SMACK file not empty after app_revoke_permissions"); - close(fd); + pFile = fopen(SMACK_RULES_DIR WGT_APP_ID, "rb"); + RUNNER_ASSERT_MSG(pFile != NULL, + "SMACK file removed!. Errno: " << errno); + //// Is it empty? + fseek(pFile, 0L, SEEK_END); + smack_file_length = ftell(pFile); + RUNNER_ASSERT_MSG(smack_file_length==0, + "SMACK file not empty.. Errno: " << errno); + if (pFile != NULL) + fclose(pFile); - fd = open(SMACK_RULES_DIR WGT_PLATFORM_APP_ID, O_RDONLY); - RUNNER_ASSERT_MSG(fd >= 0, "SMACK file deleted after app_revoke_permissions"); - RUNNER_ASSERT_MSG(lseek(fd, 0, SEEK_END) == 0, "SMACK file not empty after app_revoke_permissions"); - close(fd); + pFile = fopen(SMACK_RULES_DIR WGT_PARTNER_APP_ID, "rb"); + RUNNER_ASSERT_MSG(pFile != NULL, + "SMACK file removed!. Errno: " << errno); + //// Is it empty? + fseek(pFile, 0L, SEEK_END); + smack_file_length = ftell(pFile); + RUNNER_ASSERT_MSG(smack_file_length==0, + "SMACK file not empty.. Errno: " << errno); + if (pFile != NULL) + fclose(pFile); + pFile = fopen(SMACK_RULES_DIR WGT_PLATFORM_APP_ID, "rb"); + RUNNER_ASSERT_MSG(pFile != NULL, + "SMACK file removed!. Errno: " << errno); + //// Is it empty? + fseek(pFile, 0L, SEEK_END); + smack_file_length = ftell(pFile); + RUNNER_ASSERT_MSG(smack_file_length==0, + "SMACK file not empty.. Errno: " << errno); + if (pFile != NULL) + fclose(pFile); } static void read_gids(std::set &set, const char* file_path)