Fix test privilege_control05_add_shared_dir_readers
authorRadoslaw Bartosiak <r.bartosiak@samsung.com>
Thu, 25 Jul 2013 08:56:47 +0000 (10:56 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Thu, 23 Jan 2014 14:04:28 +0000 (15:04 +0100)
[Issue#] SSDWSSP-420
[Bug/Feature] The test fails the first time after the package installation.
[Cause] No cleaning of smack application files is performed.
[Solution] Calling functions  cleaning_smack_app_files(); cleaning_smack_database_files() at the test beginning.
[Verification] Adjust our tests

Change-Id: I8506e4de8ea2f60696cd0b0969848f03d3f67b7a

tests/libprivilege-control-tests/test_cases.cpp

index 8ff3dd9..7747023 100644 (file)
@@ -1001,9 +1001,13 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
     FILE *file = NULL;
     struct smack_accesses *rules = NULL;
 
+    //test environment cleaning
+    cleaning_smack_app_files();
+    cleaning_smack_database_files();
+
     //test what happens when the label is not correct SMACK label
     result = smack_accesses_new(&rules);
-    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new. Error: " << result);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new.");
 
     result = add_shared_dir_readers(TEST_OBJ,app_labels_wrong);
     RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "add_shared_dir_readers should fail here");
@@ -1015,10 +1019,14 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
 
     //ok, now the correct list of apps
     result = smack_accesses_new(&rules);
-    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new. Error: " << result);
+    RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in smack_accesses_new.");
 
     for (i = 0; i < 3; i++) {
-        (void)perm_app_uninstall(app_labels[i]);
+
+        result = perm_app_revoke_permissions(app_labels[i]);
+        RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions.");
+        result = perm_app_uninstall(app_labels[i]);
+        RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install.");
         result = perm_app_install(app_labels[i]);
         RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install.");
 
@@ -1078,7 +1086,7 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
 
     RUNNER_ASSERT(NULL != fgets(buf, READ_BUF_SIZE, file));
     result = strcmp(buf, test_string_01);
-    RUNNER_ASSERT_MSG( result != 0, "add_shared_dir_readers ERROR, file not formatted" << path );
+    RUNNER_ASSERT_MSG( result != 0, "add_shared_dir_readers ERROR, file not formatted" << path);
 
     free(path);
     fclose(file);
@@ -1091,11 +1099,11 @@ RUNNER_TEST(privilege_control05_add_shared_dir_readers)
 
     RUNNER_ASSERT(NULL != fgets(buf, READ_BUF_SIZE, file));
     result = strcmp(buf, test_string_21);
-    RUNNER_ASSERT_MSG( result == 0, "add_shared_dir_readers ERROR, file not formatted" );
+    RUNNER_ASSERT_MSG( result == 0, "add_shared_dir_readers ERROR, file not formatted" << path);
 
     RUNNER_ASSERT(NULL != fgets(buf, READ_BUF_SIZE, file));
     result = strcmp(buf, test_string_22);
-    RUNNER_ASSERT_MSG( result == 0, "add_shared_dir_readers ERROR, file not formatted" );
+    RUNNER_ASSERT_MSG( result == 0, "add_shared_dir_readers ERROR, file not formatted" << path);
 
     free(path);
     fclose(file);