Fixing libprivilege-control app_revoke_permissions() test to match actual requirement...
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Wed, 22 May 2013 12:28:22 +0000 (14:28 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 13:43:53 +0000 (14:43 +0100)
[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

tests/libprivilege-control-tests/test_cases.cpp

index 91a30a5..78bb804 100644 (file)
@@ -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<unsigned> &set, const char* file_path)