}
/*
- * Check perm_app_install function
+ * Check perm_app_uninstall function
*/
-RUNNER_TEST(privilege_control01_app_install)
+void check_perm_app_uninstall(const char* pkg_id)
{
int result;
DB_BEGIN
- perm_app_uninstall(APP_ID);
+ result = perm_app_uninstall(pkg_id);
+ RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_uninstall returned: " << perm_strerror(result));
- result = perm_app_install(APP_ID);
- RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno));
+ DB_END
- // try install second time app with the same ID - it should pass.
- result = perm_app_install(APP_ID);
- RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno));
+ TestLibPrivilegeControlDatabase db_test;
+ db_test.test_db_after__perm_app_uninstall(pkg_id);
+}
+
+RUNNER_TEST(privilege_control07_app_uninstall)
+{
+ check_perm_app_uninstall(APP_ID);
+}
+
+/*
+ * Check perm_app_install function
+ */
+void check_perm_app_install(const char* pkg_id)
+{
+ int result;
+
+ DB_BEGIN
+
+ result = perm_app_install(pkg_id);
+ RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned: " << perm_strerror(result));
DB_END
+
+ TestLibPrivilegeControlDatabase db_test;
+ db_test.test_db_after__perm_app_install(pkg_id);
+}
+
+RUNNER_TEST(privilege_control01_app_install)
+{
+ check_perm_app_uninstall(APP_ID);
+ check_perm_app_install(APP_ID);
+ // try install second time app with the same ID - it should pass.
+ check_perm_app_install(APP_ID);
}
/*
- * Check perm_app_uninstall function
+ * Check perm_rollback function
*/
-RUNNER_TEST(privilege_control07_app_uninstall)
+RUNNER_TEST(privilege_control07_app_rollback)
{
+ check_perm_app_uninstall(APP_ID);
+
int result;
DB_BEGIN
- result = perm_app_uninstall(APP_ID);
- RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno));
+ result = perm_app_install(APP_ID);
+ RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned: " << perm_strerror(result));
+
+ // transaction rollback
+ result = perm_rollback();
+ RUNNER_ASSERT_MSG_BT(result == 0, "perm_rollback returned: " << perm_strerror(result));
DB_END
TestLibPrivilegeControlDatabase db_test;
db_test.test_db_after__perm_app_uninstall(APP_ID);
+
}
+RUNNER_TEST(privilege_control07_app_rollback_2)
+{
+ check_perm_app_uninstall(APP_ID);
+
+ int result;
+
+ DB_BEGIN
+
+ result = perm_app_install(APP_ID);
+ RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned: " << perm_strerror(result));
+
+ // transaction rollback
+ result = perm_rollback();
+ RUNNER_ASSERT_MSG_BT(result == 0, "perm_rollback returned: " << perm_strerror(result));
+
+ // install once again after the rollback
+ result = perm_app_install(APP_ID);
+ RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned: " << perm_strerror(result));
+
+ DB_END
+
+ TestLibPrivilegeControlDatabase db_test;
+ db_test.test_db_after__perm_app_install(APP_ID);
+}
/*
* Check app_register_av function
* Notice that this test case may have no sense if previous would fail (privilege_control06_app_install)