* @file test_cases.cpp
* @author Jan Olszak (j.olszak@samsung.com)
* @author Rafal Krypa (r.krypa@samsung.com)
+ * @author Lukasz Wojciechowski (l.wojciechow@partner.samsung.com)
* @version 1.0
* @brief libprivilege-control test runner
*/
#include <dpl/log/log.h>
#include <tests_common.h>
#include <libprivilege-control_test_common.h>
+#include <tracker.h>
+#include "common/db.h"
#include <iostream>
#define SMACK_ACC_LEN 6
+// Error codes for test_libprivilege_strerror
+const std::vector<int> error_codes {
+ PC_OPERATION_SUCCESS, PC_ERR_FILE_OPERATION, PC_ERR_MEM_OPERATION, PC_ERR_NOT_PERMITTED,
+ PC_ERR_INVALID_PARAM, PC_ERR_INVALID_OPERATION, PC_ERR_DB_OPERATION, PC_ERR_DB_LABEL_TAKEN,
+ PC_ERR_DB_QUERY_PREP, PC_ERR_DB_QUERY_BIND, PC_ERR_DB_QUERY_STEP, PC_ERR_DB_CONNECTION,
+ PC_ERR_DB_NO_SUCH_APP, PC_ERR_DB_PERM_FORBIDDEN
+};
+
namespace {
std::vector<std::string> gen_names(std::string prefix, std::string suffix, size_t size)
RUNNER_TEST(privilege_control07_app_uninstall)
{
int result;
- int fd = -1;
DB_BEGIN
DB_END
- // checking if file really exists
- fd = open(SMACK_RULES_DIR APP_ID, O_RDONLY);
- RUNNER_ASSERT_MSG(fd == -1, "SMACK file NOT deleted after perm_app_uninstall");
- close(fd);
+ TestLibPrivilegeControlDatabase db_test;
+ db_test.test_db_after__perm_app_uninstall(TRACE_FROM_HERE, APP_ID);
}
/*
smack_revoke_subject(APP_TEST_AV_1);
smack_revoke_subject(APP_TEST_AV_2);
- cleaning_smack_app_files();
-
DB_BEGIN
// Adding two apps before antivir
// cleaning
smack_revoke_subject(APP_TEST_AV_1);
smack_revoke_subject(APP_TEST_AV_2);
-
- cleaning_smack_app_files();
}
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
RUNNER_IGNORED_MSG("early rules are not implemented");
int result;
- int fd = -1;
int pass_1 = 0;
int pass_2 = 0;
char *single_line_format = NULL;
char rule_add[SMACK_ACC_LEN + 1] = {0};
char rule_remove[SMACK_ACC_LEN + 1] = {0};
- unlink(SMACK_RULES_DIR APP_ID);
-
DB_BEGIN
perm_app_uninstall(APP_ID);
DB_END
- // checking if file really exists
- fd = open(SMACK_RULES_DIR APP_ID, O_RDONLY);
- close(fd);
- RUNNER_ASSERT_MSG(fd >= 0, "File open failed: " << SMACK_RULES_DIR << APP_ID << " : " << fd << ". Errno: " << strerror(errno));
- fd = -1;
+ TestLibPrivilegeControlDatabase db_test;
+ db_test.test_db_after__perm_app_install(TRACE_FROM_HERE, APP_ID);
+ db_test.test_db_after__perm_app_install(TRACE_FROM_HERE, APP_TEST_APP_1);
DB_BEGIN
CheckAVPrivilege(APP_TYPE_OSP, APP_PATH_PUBLIC_RO);
CheckAVPrivilege(APP_TYPE_EFL, APP_PATH_PUBLIC_RO);
}
+
+RUNNER_TEST(privilege_control25_test_libprivilege_strerror) {
+ int POSITIVE_ERROR_CODE = 1;
+ int NONEXISTING_ERROR_CODE = -239042;
+ const char *result;
+
+ for (auto itr = error_codes.begin(); itr != error_codes.end(); ++itr) {
+ RUNNER_ASSERT_MSG(strcmp(perm_strerror(*itr), "Unknown error") != 0,
+ "Returned invalid error code description.");
+ }
+
+ result = perm_strerror(POSITIVE_ERROR_CODE);
+ RUNNER_ASSERT_MSG(strcmp(result, "Unknown error") == 0,
+ "Bad message returned for invalid error code: \"" << result << "\"");
+
+ result = perm_strerror(NONEXISTING_ERROR_CODE);
+ RUNNER_ASSERT_MSG(strcmp(result, "Unknown error") == 0,
+ "Bad message returned for invalid error code: \"" << result << "\"");
+}