From eeca178b3431a347d508766f7fc96993c81afe69 Mon Sep 17 00:00:00 2001 From: Marcin Niesluchowski Date: Wed, 30 Jul 2014 09:54:08 +0200 Subject: [PATCH] Reorder and change test macros Change-Id: Id05a92516053ca7128198fe61f8f5c805637d645 --- tests/common/CMakeLists.txt | 1 - tests/common/access_provider.cpp | 8 +- tests/common/db_sqlite.cpp | 8 +- tests/common/dbus_access.cpp | 18 +- tests/common/fs_label_manager.cpp | 50 +- tests/common/smack_access.cpp | 6 +- tests/common/tests_common.cpp | 12 +- tests/common/tests_common.h | 13 +- tests/cynara-tests/common/cynara_test_admin.cpp | 8 +- tests/cynara-tests/common/cynara_test_client.cpp | 6 +- tests/cynara-tests/common/cynara_test_env.cpp | 35 +- tests/cynara-tests/test_cases.cpp | 6 +- tests/framework/config.cmake | 1 + .../include/dpl}/gdbbacktrace.h | 0 tests/framework/include/dpl/test/test_runner.h | 144 ++++-- tests/{common => framework/src}/gdbbacktrace.cpp | 3 +- tests/libprivilege-control-tests/common/db.cpp | 8 +- .../libprivilege-control_test_common.cpp | 183 +++---- tests/libprivilege-control-tests/test_cases.cpp | 275 +++++------ .../test_cases_incorrect_params.cpp | 58 +-- .../test_cases_nosmack.cpp | 97 ++-- .../test_cases_stress.cpp | 192 ++++---- tests/libsmack-tests/test_cases.cpp | 523 ++++++++++----------- tests/security-manager-tests/common/sm_db.cpp | 28 +- .../security_manager_tests.cpp | 135 +++--- .../common/security_server_tests_common.cpp | 2 +- tests/security-server-tests/cookie_api.cpp | 120 ++--- .../security_server_measurer_API_speed.cpp | 79 ++-- .../security_server_tests_client_smack.cpp | 147 +++--- .../security_server_tests_dbus.cpp | 56 +-- .../security_server_tests_password.cpp | 388 +++++++-------- .../security_server_tests_privilege.cpp | 18 +- .../security_server_tests_stress.cpp | 12 +- tests/security-server-tests/server.cpp | 110 ++--- tests/security-server-tests/weird_arguments.cpp | 44 +- 35 files changed, 1399 insertions(+), 1395 deletions(-) rename tests/{common => framework/include/dpl}/gdbbacktrace.h (100%) rename tests/{common => framework/src}/gdbbacktrace.cpp (99%) diff --git a/tests/common/CMakeLists.txt b/tests/common/CMakeLists.txt index 85d4ac1..0fa8305 100644 --- a/tests/common/CMakeLists.txt +++ b/tests/common/CMakeLists.txt @@ -19,7 +19,6 @@ SET(COMMON_TARGET_TEST_SOURCES ${PROJECT_SOURCE_DIR}/tests/common/smack_access.cpp ${PROJECT_SOURCE_DIR}/tests/common/summary_collector.cpp ${PROJECT_SOURCE_DIR}/tests/common/dbus_access.cpp - ${PROJECT_SOURCE_DIR}/tests/common/gdbbacktrace.cpp ${PROJECT_SOURCE_DIR}/tests/common/memory.cpp ${PROJECT_SOURCE_DIR}/tests/common/db_sqlite.cpp ${PROJECT_SOURCE_DIR}/tests/common/fs_label_manager.cpp diff --git a/tests/common/access_provider.cpp b/tests/common/access_provider.cpp index 476579d..e9f91dc 100644 --- a/tests/common/access_provider.cpp +++ b/tests/common/access_provider.cpp @@ -48,14 +48,14 @@ void AccessProvider::apply() { } void AccessProvider::applyAndSwithToUser(int uid, int gid) { - RUNNER_ASSERT_MSG_BT(0 == smack_revoke_subject(m_mySubject.c_str()), + RUNNER_ASSERT_MSG(0 == smack_revoke_subject(m_mySubject.c_str()), "Error in smack_revoke_subject(" << m_mySubject << ")"); apply(); - RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(m_mySubject.c_str()), + RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(m_mySubject.c_str()), "Error in smack_set_label_for_self."); - RUNNER_ASSERT_MSG_BT(0 == setgid(gid), + RUNNER_ASSERT_MSG(0 == setgid(gid), "Error in setgid."); - RUNNER_ASSERT_MSG_BT(0 == setuid(uid), + RUNNER_ASSERT_MSG(0 == setuid(uid), "Error in setuid."); } diff --git a/tests/common/db_sqlite.cpp b/tests/common/db_sqlite.cpp index e24003a..f6852aa 100644 --- a/tests/common/db_sqlite.cpp +++ b/tests/common/db_sqlite.cpp @@ -42,15 +42,15 @@ void Sqlite3DBase::open(void) return; int ret = sqlite3_open_v2(m_db_path.c_str(), &m_db_handle, m_flags, VFS_NOT_USED); - RUNNER_ASSERT_MSG_BT(m_db_handle, "Error opening the database: Unable to allocate memory."); - RUNNER_ASSERT_MSG_BT(ret == SQLITE_OK, "Error opening the database: " << + RUNNER_ASSERT_MSG(m_db_handle, "Error opening the database: Unable to allocate memory."); + RUNNER_ASSERT_MSG(ret == SQLITE_OK, "Error opening the database: " << sqlite3_errmsg(m_db_handle)); } void Sqlite3DBase::close(void) { int ret = sqlite3_close(m_db_handle); - RUNNER_ASSERT_MSG_BT(ret == SQLITE_OK, "Error closing the database: " << + RUNNER_ASSERT_MSG(ret == SQLITE_OK, "Error closing the database: " << sqlite3_errmsg(m_db_handle)); m_db_handle = NULL; @@ -72,7 +72,7 @@ void Sqlite3DBase::execute(const std::string& sql_query, Sqlite3DBaseSelectResul } sqlite3_free(tmp); - RUNNER_ASSERT_MSG_BT(ret == SQLITE_OK || ret == SQLITE_ABORT, "Error executing statement <" << + RUNNER_ASSERT_MSG(ret == SQLITE_OK || ret == SQLITE_ABORT, "Error executing statement <" << sql_query << "> : " << errmsg); } diff --git a/tests/common/dbus_access.cpp b/tests/common/dbus_access.cpp index be8eb4e..d214b1a 100644 --- a/tests/common/dbus_access.cpp +++ b/tests/common/dbus_access.cpp @@ -56,7 +56,7 @@ DBusAccess::DBusAccess(const char *service_name) void DBusAccess::connect() { m_conn = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_err); - RUNNER_ASSERT_MSG_BT(dbus_error_is_set(&m_err) != 1, + RUNNER_ASSERT_MSG(dbus_error_is_set(&m_err) != 1, "Error in dbus_bus_get: " << m_err.message); dbus_connection_set_exit_on_disconnect(m_conn, FALSE); } @@ -64,7 +64,7 @@ void DBusAccess::connect() { void DBusAccess::requestName() { dbus_bus_request_name(m_conn, m_dbus_client_name.c_str(), DBUS_NAME_FLAG_REPLACE_EXISTING , &m_err); - RUNNER_ASSERT_MSG_BT(dbus_error_is_set(&m_err) != 1, + RUNNER_ASSERT_MSG(dbus_error_is_set(&m_err) != 1, "Error in dbus_bus_request_name: " << m_err.message); } @@ -76,7 +76,7 @@ void DBusAccess::newMethodCall(const char *method) { dbus_systemd_object.c_str(), dbus_systemd_interface.c_str(), method); - RUNNER_ASSERT_MSG_BT(NULL != m_msg, + RUNNER_ASSERT_MSG(NULL != m_msg, "Error in dbus_message_new_method_call"); } @@ -86,16 +86,16 @@ void DBusAccess::appendToMsg(const char *argument) { dbus_message_iter_init_append(m_msg, &iter); int ret = dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &argument); - RUNNER_ASSERT_MSG_BT(ret != 0, + RUNNER_ASSERT_MSG(ret != 0, "Error in dbus_message_iter_append_basic"); } void DBusAccess::sendMsgWithReply() { int ret = dbus_connection_send_with_reply(m_conn, m_msg, &m_pending, -1); - RUNNER_ASSERT_MSG_BT(ret == 1, + RUNNER_ASSERT_MSG(ret == 1, "Error in dbus_connection_send_with_reply"); - RUNNER_ASSERT_MSG_BT(NULL != m_pending, "Pending call null"); + RUNNER_ASSERT_MSG(NULL != m_pending, "Pending call null"); dbus_connection_flush(m_conn); dbus_pending_call_block(m_pending); @@ -106,17 +106,17 @@ void DBusAccess::sendMsgWithReply() { void DBusAccess::getMsgReply() { m_msg = dbus_pending_call_steal_reply(m_pending); - RUNNER_ASSERT_MSG_BT(NULL != m_msg, + RUNNER_ASSERT_MSG(NULL != m_msg, "Error in dbus_pending_call_steal_reply"); } void DBusAccess::handleMsgReply() { DBusMessageIter iter; - RUNNER_ASSERT_MSG_BT(dbus_message_iter_init(m_msg, &iter) != 0, + RUNNER_ASSERT_MSG(dbus_message_iter_init(m_msg, &iter) != 0, "Message has no arguments"); if (DBUS_TYPE_OBJECT_PATH != dbus_message_iter_get_arg_type(&iter)) { - RUNNER_ASSERT_MSG_BT(false, "No job path in msg"); + RUNNER_FAIL_MSG("No job path in msg"); } dbus_message_unref(m_msg); dbus_pending_call_unref(m_pending); diff --git a/tests/common/fs_label_manager.cpp b/tests/common/fs_label_manager.cpp index 6c8d226..bd8fccb 100644 --- a/tests/common/fs_label_manager.cpp +++ b/tests/common/fs_label_manager.cpp @@ -47,10 +47,10 @@ FsLabelManager::FsLabelManager(const std::string &path, const std::string &label std::string data = std::string("mode=0777,uid=0,smackfsdef=") + label; int ret = mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); - RUNNER_ASSERT_MSG_BT(ret == 0, "Unable to make directory"); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Unable to make directory"); ret = mount("none", path.c_str(), "tmpfs", 0, data.c_str()); - RUNNER_ASSERT_MSG_BT(ret == 0, "Unable to mount filesystem"); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Unable to mount filesystem"); if (m_path[m_path.length()-1] != '/') m_path += '/'; @@ -69,12 +69,12 @@ void FsLabelManager::createFile(const std::string &relativePath) mode_t systemMask = umask(0000); int fd = open(path.c_str(), O_RDWR | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); umask(systemMask); - RUNNER_ASSERT_MSG_BT(fd > -1, "Unable to create file for tests: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(fd > -1, "Unable to create file for tests"); close(fd); int ret = chown(path.c_str(), APP_UID, APP_GID); - RUNNER_ASSERT_MSG_BT(ret == 0, "Unable to change file owner: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Unable to change file owner"); } void FsLabelManager::createLink(const std::string &relativeLinkPath, const std::string &relativeRealPath) @@ -83,13 +83,13 @@ void FsLabelManager::createLink(const std::string &relativeLinkPath, const std:: std::string realPath = m_path + relativeRealPath; int ret = unlink(linkPath.c_str()); - RUNNER_ASSERT_MSG_BT(ret == 0 || errno == ENOENT, "Unable to unlink file." << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0 || errno == ENOENT, "Unable to unlink file"); ret = symlink(realPath.c_str(), linkPath.c_str()); - RUNNER_ASSERT_MSG_BT(ret == 0, "Unable to create symlink." << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Unable to create symlink"); ret = lchown(linkPath.c_str(), APP_UID, APP_GID); - RUNNER_ASSERT_MSG_BT(ret == 0, "Unable to change file owner: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Unable to change file owner"); } void FsLabelManager::testSmackSetLabel(const std::string &relativePath, @@ -99,7 +99,7 @@ void FsLabelManager::testSmackSetLabel(const std::string &relativePath, std::string path = m_path + relativePath; int ret = smack_setlabel(path.c_str(), label, labelType); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in normal setting label " << label); + RUNNER_ASSERT_MSG(ret == 0, "Error in normal setting label " << label); checkLabel(path, label, labelType); } @@ -111,7 +111,7 @@ void FsLabelManager::testSmackLSetLabel(const std::string &relativePath, std::string path = m_path + relativePath; int ret = smack_lsetlabel(path.c_str(), label, labelType); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in link setting label " << label); + RUNNER_ASSERT_MSG(ret == 0, "Error in link setting label " << label); checkLinkLabel(path, label, labelType); } @@ -123,11 +123,11 @@ void FsLabelManager::testSmackFSetLabel(const std::string &relativePath, std::string path = m_path + relativePath; int fd = open(path.c_str(), O_WRONLY); - RUNNER_ASSERT_MSG_BT(fd > -1, "Unable to open file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(fd > -1, "Unable to open file"); int ret = smack_fsetlabel(fd, label, labelType); close(fd); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in fd setting " << label); + RUNNER_ASSERT_MSG(ret == 0, "Error in fd setting " << label); checkLabel(path, label, labelType); } @@ -140,16 +140,16 @@ void FsLabelManager::testSmackGetLabel(const std::string &relativePath, char *tmpLabel; int ret = smack_getlabel(path.c_str(), &tmpLabel, labelType); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in normal getting label"); + RUNNER_ASSERT_MSG(ret == 0, "Error in normal getting label"); SmackLabelPtr labelPtr(tmpLabel); if (label == NULL && !m_label.compare(tmpLabel)) return; - RUNNER_ASSERT_MSG_BT(label != NULL, "Path should be related with file system default label. " + RUNNER_ASSERT_MSG(label != NULL, "Path should be related with file system default label. " << tmpLabel << " != " << m_label); ret = strcmp(tmpLabel, label); - RUNNER_ASSERT_MSG_BT(ret == 0, "Wrong label. " << tmpLabel << " != " << label); + RUNNER_ASSERT_MSG(ret == 0, "Wrong label. " << tmpLabel << " != " << label); checkLabel(path, tmpLabel, labelType); } @@ -162,16 +162,16 @@ void FsLabelManager::testSmackLGetLabel(const std::string &relativePath, char *tmpLabel; int ret = smack_lgetlabel(path.c_str(), &tmpLabel, labelType); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in link getting label"); + RUNNER_ASSERT_MSG(ret == 0, "Error in link getting label"); SmackLabelPtr labelPtr(tmpLabel); if (label == NULL && !m_label.compare(tmpLabel)) return; - RUNNER_ASSERT_MSG_BT(label != NULL, "Path should be related with file system default label. " + RUNNER_ASSERT_MSG(label != NULL, "Path should be related with file system default label. " << tmpLabel << " != " << m_label); ret = strcmp(tmpLabel, label); - RUNNER_ASSERT_MSG_BT(ret == 0, "Wrong label. " << tmpLabel << " != " << label); + RUNNER_ASSERT_MSG(ret == 0, "Wrong label. " << tmpLabel << " != " << label); checkLinkLabel(path, tmpLabel, labelType); } @@ -182,21 +182,21 @@ void FsLabelManager::testSmackFGetLabel(const std::string &relativePath, { std::string path = m_path + relativePath; int fd = open(path.c_str(), O_WRONLY); - RUNNER_ASSERT_MSG_BT(fd > -1, "Unable to open file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(fd > -1, "Unable to open file"); char *tmpLabel; int ret = smack_fgetlabel(fd, &tmpLabel, labelType); close(fd); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in fd getting label"); + RUNNER_ASSERT_MSG(ret == 0, "Error in fd getting label"); SmackLabelPtr labelPtr(tmpLabel); if (label == NULL && !m_label.compare(tmpLabel)) return; - RUNNER_ASSERT_MSG_BT(label != NULL, "Fd should be related with file system default label. " + RUNNER_ASSERT_MSG(label != NULL, "Fd should be related with file system default label. " << tmpLabel << " != " << m_label); ret = strcmp(tmpLabel, label); - RUNNER_ASSERT_MSG_BT(ret == 0, "Wrong label. " << tmpLabel << " != " << label); + RUNNER_ASSERT_MSG(ret == 0, "Wrong label. " << tmpLabel << " != " << label); checkLabel(path, tmpLabel, labelType); } @@ -215,7 +215,7 @@ void FsLabelManager::checkLabel(const std::string &path, { char buf[SMACK_LABEL_LEN+2] = { 0, }; int ret = getxattr(path.c_str(), get_xattr_name(labelType), buf, SMACK_LABEL_LEN+1); - RUNNER_ASSERT_MSG_BT(ret > 0, "Error in getting xattr. " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret > 0, "Error in getting xattr"); const char *tmpLabel; if (label == NULL) @@ -224,7 +224,7 @@ void FsLabelManager::checkLabel(const std::string &path, tmpLabel = label; ret = strncmp(tmpLabel, buf, SMACK_LABEL_LEN+1); - RUNNER_ASSERT_MSG_BT(ret == 0, "Wrong label. " << tmpLabel << " != " << buf); + RUNNER_ASSERT_MSG(ret == 0, "Wrong label. " << tmpLabel << " != " << buf); } void FsLabelManager::checkLinkLabel(const std::string &path, @@ -233,7 +233,7 @@ void FsLabelManager::checkLinkLabel(const std::string &path, { char buf[SMACK_LABEL_LEN+2] = { 0, }; int ret = lgetxattr(path.c_str(), get_xattr_name(labelType), buf, SMACK_LABEL_LEN+1); - RUNNER_ASSERT_MSG_BT(ret > 0, "Error in getting xattr. " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret > 0, "Error in getting xattr"); const char *tmpLabel; if (label == NULL) @@ -242,5 +242,5 @@ void FsLabelManager::checkLinkLabel(const std::string &path, tmpLabel = label; ret = strncmp(tmpLabel, buf, SMACK_LABEL_LEN+1); - RUNNER_ASSERT_MSG_BT(ret == 0, "Wrong label. " << tmpLabel << " != " << buf); + RUNNER_ASSERT_MSG(ret == 0, "Wrong label. " << tmpLabel << " != " << buf); } diff --git a/tests/common/smack_access.cpp b/tests/common/smack_access.cpp index f2c81e9..a9bf5b4 100644 --- a/tests/common/smack_access.cpp +++ b/tests/common/smack_access.cpp @@ -29,7 +29,7 @@ SmackAccess::SmackAccess() : m_handle(NULL) { - RUNNER_ASSERT_MSG_BT(0 == smack_accesses_new(&m_handle), + RUNNER_ASSERT_MSG(0 == smack_accesses_new(&m_handle), "Error in smack_accesses_new"); } @@ -38,7 +38,7 @@ void SmackAccess::add( const std::string &object, const std::string &rights) { - RUNNER_ASSERT_MSG_BT(0 == smack_accesses_add(m_handle, + RUNNER_ASSERT_MSG(0 == smack_accesses_add(m_handle, subject.c_str(), object.c_str(), rights.c_str()), @@ -46,7 +46,7 @@ void SmackAccess::add( } void SmackAccess::apply() { - RUNNER_ASSERT_MSG_BT(0 == smack_accesses_apply(m_handle), + RUNNER_ASSERT_MSG(0 == smack_accesses_apply(m_handle), "Error in smack_accessses_apply."); } diff --git a/tests/common/tests_common.cpp b/tests/common/tests_common.cpp index 555b8b5..318fee2 100644 --- a/tests/common/tests_common.cpp +++ b/tests/common/tests_common.cpp @@ -77,7 +77,7 @@ int drop_root_privileges(void) void setLabelForSelf(const int line, const char *label) { int ret = smack_set_label_for_self(label); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in smack_set_label_for_self(): " << ret << ", line: " << line); + RUNNER_ASSERT_MSG(ret == 0, "Error in smack_set_label_for_self(): " << ret << ", line: " << line); } /* @@ -87,7 +87,7 @@ void add_process_group(const char* group_name) { // get group ID by group name group *gr = getgrnam(group_name); - RUNNER_ASSERT_MSG_BT(gr != NULL, "Group '" << group_name << "' does not exist."); + RUNNER_ASSERT_ERRNO_MSG(gr != NULL, "getgrnam failed on '" << group_name << "' group"); const gid_t new_group_id = gr->gr_gid; // get number of groups that the current process belongs to @@ -103,8 +103,7 @@ void add_process_group(const char* group_name) // add new group & apply change groups[ngroups] = new_group_id; int ret = setgroups(groups.size(), groups.data()); - int error = errno; - RUNNER_ASSERT_MSG_BT(ret == 0, "setgroups() failed. " << strerror(error)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "setgroups() failed"); } /* @@ -114,7 +113,7 @@ void remove_process_group(const char* group_name) { // get group ID by group name group *gr = getgrnam(group_name); - RUNNER_ASSERT_MSG_BT(gr != NULL, "Group '" << group_name << "' does not exist."); + RUNNER_ASSERT_ERRNO_MSG(gr != NULL, "getgrnam failed on '" << group_name << "' group"); const gid_t new_group_id = gr->gr_gid; int ngroups = getgroups(0, NULL); @@ -127,8 +126,7 @@ void remove_process_group(const char* group_name) if (groups.size() != (size_t)ngroups) { // apply change int ret = setgroups(groups.size(), groups.data()); - int error = errno; - RUNNER_ASSERT_MSG_BT(ret == 0, "setgroups() failed. " << strerror(error)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "setgroups() failed"); } } diff --git a/tests/common/tests_common.h b/tests/common/tests_common.h index 0307b95..4fdbc14 100644 --- a/tests/common/tests_common.h +++ b/tests/common/tests_common.h @@ -34,8 +34,6 @@ #include #include -#include "gdbbacktrace.h" - const uid_t APP_UID = 5000; const gid_t APP_GID = 5000; const uid_t DB_ALARM_UID = 6001; @@ -133,13 +131,6 @@ std::string formatCstr(const char *cstr); } \ void Proc##Multi() -#define RUNNER_ASSERT_MSG_BT(test, msg) RUNNER_ASSERT_MSG(test,\ - msg << gdbbacktrace()) -#define RUNNER_ASSERT_BT(test) RUNNER_ASSERT_MSG_BT(test, "") - -#define RUNNER_ASSERT_MSG_ERRNO_BT(test, msg) \ - RUNNER_ASSERT_MSG_BT(test, msg << strerror(errno)) - namespace DB { class Transaction @@ -150,7 +141,7 @@ namespace DB { Transaction() { db_result = perm_begin(); - RUNNER_ASSERT_MSG_BT(PC_OPERATION_SUCCESS == db_result, + RUNNER_ASSERT_MSG(PC_OPERATION_SUCCESS == db_result, "perm_begin returned: " << db_result); } @@ -170,7 +161,7 @@ namespace DB { DB::Transaction db_transaction; #define DB_END } \ - RUNNER_ASSERT_MSG_BT(PC_OPERATION_SUCCESS == DB::Transaction::db_result, \ + RUNNER_ASSERT_MSG(PC_OPERATION_SUCCESS == DB::Transaction::db_result, \ "perm_end returned: " << DB::Transaction::db_result); // Common macros and labels used in tests diff --git a/tests/cynara-tests/common/cynara_test_admin.cpp b/tests/cynara-tests/common/cynara_test_admin.cpp index 2c4c458..0270510 100644 --- a/tests/cynara-tests/common/cynara_test_admin.cpp +++ b/tests/cynara-tests/common/cynara_test_admin.cpp @@ -70,9 +70,9 @@ CynaraTestAdmin::CynaraTestAdmin() : m_admin(nullptr) { int ret = cynara_admin_initialize(&m_admin); - RUNNER_ASSERT_MSG_BT(ret == CYNARA_ADMIN_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == CYNARA_ADMIN_API_SUCCESS, "cynara_admin_initialize failed. ret: " << ret); - RUNNER_ASSERT_MSG_BT(m_admin != nullptr, "cynara_admin struct was not initialized"); + RUNNER_ASSERT_MSG(m_admin != nullptr, "cynara_admin struct was not initialized"); } CynaraTestAdmin::~CynaraTestAdmin() @@ -91,7 +91,7 @@ void CynaraTestAdmin::setPolicies(const CynaraPoliciesContainer &policiesContain policies[policiesContainer.m_policies.size()] = nullptr; int ret = cynara_admin_set_policies(m_admin, policies); - RUNNER_ASSERT_MSG_BT(ret == expectedResult, + RUNNER_ASSERT_MSG(ret == expectedResult, "cynara_admin_set_policies returned wrong value: " << ret << " != " << expectedResult << ". " << "policies:\n" << policies); @@ -101,7 +101,7 @@ void CynaraTestAdmin::setBucket(const char *bucket, int operation, const char *e int expectedResult) { int ret = cynara_admin_set_bucket(m_admin, bucket, operation, extra); - RUNNER_ASSERT_MSG_BT(ret == expectedResult, + RUNNER_ASSERT_MSG(ret == expectedResult, "cynara_admin_set_bucket returned wrong value: " << ret << " != " << expectedResult << "." << " bucket: " << formatCstr(bucket) << "," diff --git a/tests/cynara-tests/common/cynara_test_client.cpp b/tests/cynara-tests/common/cynara_test_client.cpp index 4ac7a79..97fb8fa 100644 --- a/tests/cynara-tests/common/cynara_test_client.cpp +++ b/tests/cynara-tests/common/cynara_test_client.cpp @@ -6,9 +6,9 @@ CynaraTestClient::CynaraTestClient() : m_cynara(nullptr) { int ret = cynara_initialize(&m_cynara, nullptr); - RUNNER_ASSERT_MSG_BT(ret == CYNARA_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == CYNARA_API_SUCCESS, "cynara_initialize failed. ret: " << ret); - RUNNER_ASSERT_MSG_BT(m_cynara != nullptr, "cynara struct was not initialized"); + RUNNER_ASSERT_MSG(m_cynara != nullptr, "cynara struct was not initialized"); } CynaraTestClient::~CynaraTestClient() @@ -21,7 +21,7 @@ void CynaraTestClient::check(const char *client, const char *session, int expectedResult) { int ret = cynara_check(m_cynara, client, session, user, privilege); - RUNNER_ASSERT_MSG_BT(ret == expectedResult, + RUNNER_ASSERT_MSG(ret == expectedResult, "cynara_check returned wrong value: " << ret << " != " << expectedResult << "." << " client: " << formatCstr(client) << "," diff --git a/tests/cynara-tests/common/cynara_test_env.cpp b/tests/cynara-tests/common/cynara_test_env.cpp index 65bf254..1ab3dfb 100644 --- a/tests/cynara-tests/common/cynara_test_env.cpp +++ b/tests/cynara-tests/common/cynara_test_env.cpp @@ -29,25 +29,24 @@ int removeContents(const char *fpath, const struct stat * /*sb*/, int tflag, struct FTW * /*ftwbuf*/) { if (tflag == FTW_F) - RUNNER_ASSERT_MSG_BT(!unlink(fpath), "Unable to unlink " << fpath << " file. " - << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(!unlink(fpath), "Unable to unlink " << fpath << " file"); else - RUNNER_ASSERT_MSG_BT(tflag == FTW_DP, "Visited file should not exist. Path: " << fpath); + RUNNER_ASSERT_MSG(tflag == FTW_DP, "Visited file should not exist. Path: " << fpath); return 0; } void copyFile(const std::string &src, const std::string &dst) { int inFd = TEMP_FAILURE_RETRY(open(src.c_str(), O_RDONLY)); - RUNNER_ASSERT_MSG_ERRNO_BT(inFd > 0, "Opening " << src << " file failed"); + RUNNER_ASSERT_ERRNO_MSG(inFd > 0, "Opening " << src << " file failed"); FdUniquePtr inFdPtr(&inFd); int outFd = TEMP_FAILURE_RETRY(creat(dst.c_str(), 0700)); - RUNNER_ASSERT_MSG_ERRNO_BT(outFd > 0, "Creating " << dst << " file failed"); + RUNNER_ASSERT_ERRNO_MSG(outFd > 0, "Creating " << dst << " file failed"); FdUniquePtr outFdPtr(&outFd); long int len = sysconf(_SC_GETPW_R_SIZE_MAX); - RUNNER_ASSERT_MSG_BT(len != -1, "No suggested buflen"); + RUNNER_ASSERT_MSG(len != -1, "No suggested buflen"); size_t buflen = len; char *buf = static_cast(malloc(buflen)); @@ -56,21 +55,21 @@ void copyFile(const std::string &src, const std::string &dst) struct passwd pwbuf, *pwbufp = nullptr; int ret = TEMP_FAILURE_RETRY(getpwnam_r(cynaraUser.c_str(), &pwbuf, buf, buflen, &pwbufp)); - RUNNER_ASSERT_MSG_ERRNO_BT(ret == 0, "getpwnam_r failed on " << cynaraUser << " user"); - RUNNER_ASSERT_MSG_BT(pwbufp, "User " << cynaraUser << " does not exist"); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "getpwnam_r failed on " << cynaraUser << " user"); + RUNNER_ASSERT_MSG(pwbufp, "User " << cynaraUser << " does not exist"); ret = fchown(outFd, pwbufp->pw_uid, pwbufp->pw_gid); - RUNNER_ASSERT_MSG_ERRNO_BT(ret != -1, "fchown failed"); + RUNNER_ASSERT_ERRNO_MSG(ret != -1, "fchown failed"); ret = smack_fsetlabel(outFd, cynaraLabel.c_str(), SMACK_LABEL_ACCESS); - RUNNER_ASSERT_MSG_BT(ret == 0, "Setting smack label failed"); + RUNNER_ASSERT_MSG(ret == 0, "Setting smack label failed"); struct stat statSrc; ret = fstat(inFd, &statSrc); - RUNNER_ASSERT_MSG_ERRNO_BT(ret != -1, "fstat failed"); + RUNNER_ASSERT_ERRNO_MSG(ret != -1, "fstat failed"); ret = sendfile(outFd, inFd, 0, statSrc.st_size); - RUNNER_ASSERT_MSG_ERRNO_BT(ret != -1, "sendfile failed"); + RUNNER_ASSERT_ERRNO_MSG(ret != -1, "sendfile failed"); } void copyDir(const std::string &source, const std::string &destination) @@ -78,7 +77,7 @@ void copyDir(const std::string &source, const std::string &destination) DIR *dirPtr = nullptr; struct dirent *direntPtr; - RUNNER_ASSERT_MSG_ERRNO_BT(dirPtr = opendir(source.c_str()), + RUNNER_ASSERT_ERRNO_MSG(dirPtr = opendir(source.c_str()), "opening " << source << " dir failed"); DirPtr dirScopedPtr(dirPtr); @@ -96,12 +95,12 @@ void clear(const std::string &dir) { int ret = nftw(dir.c_str(), removeContents, 2, FTW_DEPTH | FTW_PHYS); if (ret == -1) - RUNNER_ASSERT_MSG_ERRNO_BT(errno == ENOENT, "nftw failed"); + RUNNER_ASSERT_ERRNO_MSG(errno == ENOENT, "nftw failed"); } void removeDirIfExists(const std::string &dir) { - RUNNER_ASSERT_MSG_ERRNO_BT(!rmdir(dir.c_str()) || errno == ENOENT, + RUNNER_ASSERT_ERRNO_MSG(!rmdir(dir.c_str()) || errno == ENOENT, "Removing " << dir << " dir failed"); } @@ -112,10 +111,10 @@ bool cynaraDbExists() if (ret == -1 && errno == ENOENT) { return false; } else if (ret == -1) { - RUNNER_ASSERT_MSG_ERRNO_BT(false, "Cannot stat " << cynaraDbDir + RUNNER_ASSERT_ERRNO_MSG(false, "Cannot stat " << cynaraDbDir << " not due to its nonexistence"); } - RUNNER_ASSERT_MSG_BT(st.st_mode & S_IFDIR, cynaraDbDir << " is not a directory"); + RUNNER_ASSERT_MSG(st.st_mode & S_IFDIR, cynaraDbDir << " is not a directory"); return true; } @@ -141,7 +140,7 @@ void CynaraTestEnv::save() m_dbPresent = cynaraDbExists(); if (m_dbPresent) { - RUNNER_ASSERT_MSG_ERRNO_BT(!mkdir(m_dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO), + RUNNER_ASSERT_ERRNO_MSG(!mkdir(m_dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO), "Unable to make " << m_dir << " test directory"); copyDir(cynaraDbDir, m_dir); } diff --git a/tests/cynara-tests/test_cases.cpp b/tests/cynara-tests/test_cases.cpp index aeeed20..be3ca37 100644 --- a/tests/cynara-tests/test_cases.cpp +++ b/tests/cynara-tests/test_cases.cpp @@ -333,7 +333,7 @@ void checkAllDeny(const std::vector< std::vector > &data, CynaraTestClient cynara; for (auto it = data.begin(); it != data.end(); ++it) { - RUNNER_ASSERT_MSG_BT(it->size() == 3, "Wrong test data size"); + RUNNER_ASSERT_MSG(it->size() == 3, "Wrong test data size"); } for (auto itClient = data.begin(); itClient != data.end(); ++itClient) { @@ -347,9 +347,9 @@ void checkAllDeny(const std::vector< std::vector > &data, void checkSingleWildcardData(const std::vector< std::vector > &data) { - RUNNER_ASSERT_MSG_BT(data.size() == 3, "Wrong test data size"); + RUNNER_ASSERT_MSG(data.size() == 3, "Wrong test data size"); for (auto it = data.begin(); it != data.end(); ++it) { - RUNNER_ASSERT_MSG_BT(it->size() == 3, "Wrong test data size"); + RUNNER_ASSERT_MSG(it->size() == 3, "Wrong test data size"); } } diff --git a/tests/framework/config.cmake b/tests/framework/config.cmake index 4ec039a..a2f407c 100644 --- a/tests/framework/config.cmake +++ b/tests/framework/config.cmake @@ -25,6 +25,7 @@ SET(DPL_FRAMEWORK_TEST_SOURCES ${PROJECT_SOURCE_DIR}/tests/framework/src/binary_queue.cpp ${PROJECT_SOURCE_DIR}/tests/framework/src/colors.cpp ${PROJECT_SOURCE_DIR}/tests/framework/src/exception.cpp + ${PROJECT_SOURCE_DIR}/tests/framework/src/gdbbacktrace.cpp ${PROJECT_SOURCE_DIR}/tests/framework/src/noncopyable.cpp ${PROJECT_SOURCE_DIR}/tests/framework/src/singleton.cpp ${PROJECT_SOURCE_DIR}/tests/framework/src/abstract_log_provider.cpp diff --git a/tests/common/gdbbacktrace.h b/tests/framework/include/dpl/gdbbacktrace.h similarity index 100% rename from tests/common/gdbbacktrace.h rename to tests/framework/include/dpl/gdbbacktrace.h diff --git a/tests/framework/include/dpl/test/test_runner.h b/tests/framework/include/dpl/test/test_runner.h index 4893ee5..c7071f4 100644 --- a/tests/framework/include/dpl/test/test_runner.h +++ b/tests/framework/include/dpl/test/test_runner.h @@ -20,20 +20,23 @@ * @version 1.0 * @brief This file is the header file of test runner */ + #ifndef DPL_TEST_RUNNER_H #define DPL_TEST_RUNNER_H -#include -#include -#include -#include -#include -#include -#include #include #include -#include #include +#include +#include +#include +#include + +#include +#include +#include +#include +#include namespace DPL { namespace Test { @@ -204,54 +207,97 @@ typedef DPL::Singleton TestRunnerSingleton; } } // namespace DPL -#define RUNNER_TEST_GROUP_INIT(GroupName) \ - static int Static##GroupName##Init() \ - { \ +#define RUNNER_TEST_GROUP_INIT(GroupName) \ + static int Static##GroupName##Init() \ + { \ DPL::Test::TestRunnerSingleton::Instance().InitGroup(#GroupName); \ - return 0; \ - } \ - const int DPL_UNUSED Static##GroupName##InitVar = \ + return 0; \ + } \ + const int DPL_UNUSED Static##GroupName##InitVar = \ Static##GroupName##Init(); -#define RUNNER_TEST(Proc) \ - void Proc(); \ - static int Static##Proc##Init() \ - { \ +#define RUNNER_TEST(Proc) \ + void Proc(); \ + static int Static##Proc##Init() \ + { \ DPL::Test::TestRunnerSingleton::Instance().RegisterTest(#Proc, &Proc); \ - return 0; \ - } \ - const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \ + return 0; \ + } \ + const int DPL_UNUSED Static##Proc##InitVar = Static##Proc##Init(); \ void Proc() -//! \brief Returns base name for path - -#define RUNNER_ASSERT_MSG(test, message) \ - do \ - { \ - DPL::Test::TestRunnerSingleton::Instance().MarkAssertion(); \ - \ - if (!(test)) \ - { \ - std::ostringstream assertMsg; \ - assertMsg << message; \ - throw DPL::Test::TestRunner::TestFailed(#test, \ - __FILE__, \ - __LINE__, \ + +/** + * ASSERT MACROS + * + * Use them to create assertions in test cases. To do that put them inside test + * body. Failing assertion indicates failing test. + */ + +#define RUNNER_ASSERT_MSG(test, message) \ + do \ + { \ + DPL::Test::TestRunnerSingleton::Instance().MarkAssertion(); \ + \ + if (!(test)) \ + { \ + std::ostringstream assertMsg; \ + assertMsg << message << gdbbacktrace(); \ + throw DPL::Test::TestRunner::TestFailed(#test, \ + __FILE__, \ + __LINE__, \ assertMsg.str()); \ - } \ + } \ } while (0) -#define RUNNER_ASSERT(test) RUNNER_ASSERT_MSG(test, "") +#define RUNNER_ASSERT_ERRNO_MSG(test, message) \ + do \ + { \ + DPL::Test::TestRunnerSingleton::Instance().MarkAssertion(); \ + \ + if (!(test)) \ + { \ + const char *err = strerror(errno); \ + std::ostringstream assertMsg; \ + assertMsg << message; \ + if (!assertMsg.str().empty()) \ + assertMsg << ". "; \ + assertMsg << err << gdbbacktrace(); \ + throw DPL::Test::TestRunner::TestFailed(#test, \ + __FILE__, \ + __LINE__, \ + assertMsg.str()); \ + } \ + } while (0) -#define RUNNER_FAIL RUNNER_ASSERT(false) +#define RUNNER_ASSERT_ERRNO(test) \ + RUNNER_ASSERT_ERRNO_MSG(test, "") -#define RUNNER_IGNORED_MSG(message) do { std::ostringstream assertMsg; \ - assertMsg << message; \ - throw DPL::Test::TestRunner::Ignored( \ - assertMsg.str()); \ -} while (0) +#define RUNNER_FAIL_MSG(message) \ + RUNNER_ASSERT_MSG(false, message) -/* +#define RUNNER_ASSERT(test) \ + RUNNER_ASSERT_MSG(test, "") + +/** + * IGNORE MACRO + * + * When test reaches this macro call, its furhter code will be ignored. + * To ignore whole test, put this macro call at the beginning of this tests + * body. + */ + +#define RUNNER_IGNORED_MSG(message) \ + do \ + { \ + std::ostringstream assertMsg; \ + assertMsg << message; \ + throw DPL::Test::TestRunner::Ignored(assertMsg.str()); \ + } while (0) + +/** + * PERF MACROS + * * Use these macros to do the time measurement. The first macro will start time measurement, * the second will gather the result. These macros can be used only once per test-case. * The result of time measurement will be displayed only if the test will pass. @@ -268,10 +314,11 @@ typedef DPL::Singleton TestRunnerSingleton; * - csv * In TAP format performance result will not be displayed. */ -#define RUNNER_PERF_TEST_BEGIN(maxTime) \ - do { \ - DPL::Test::TestRunnerSingleton::Instance().beginPerformanceTestTime( \ - std::chrono::microseconds{static_cast(maxTime*1000000.0)}); \ + +#define RUNNER_PERF_TEST_BEGIN(maxTime) \ + do { \ + DPL::Test::TestRunnerSingleton::Instance().beginPerformanceTestTime( \ + std::chrono::microseconds{static_cast(maxTime*1000000.0)}); \ } while (0) #define RUNNER_PERF_TEST_END() \ @@ -279,4 +326,5 @@ typedef DPL::Singleton TestRunnerSingleton; DPL::Test::TestRunnerSingleton::Instance().endPerformanceTestTime(); \ } while (0) + #endif // DPL_TEST_RUNNER_H diff --git a/tests/common/gdbbacktrace.cpp b/tests/framework/src/gdbbacktrace.cpp similarity index 99% rename from tests/common/gdbbacktrace.cpp rename to tests/framework/src/gdbbacktrace.cpp index b44e30f..a585285 100644 --- a/tests/common/gdbbacktrace.cpp +++ b/tests/framework/src/gdbbacktrace.cpp @@ -28,7 +28,8 @@ #include #include #include -#include "gdbbacktrace.h" + +#include namespace { const size_t MAX_BACKTRACE_LINE_LENGTH = 1024; diff --git a/tests/libprivilege-control-tests/common/db.cpp b/tests/libprivilege-control-tests/common/db.cpp index b7f4ee4..67a3fac 100644 --- a/tests/libprivilege-control-tests/common/db.cpp +++ b/tests/libprivilege-control-tests/common/db.cpp @@ -85,7 +85,7 @@ void TestLibPrivilegeControlDatabase::test_db_after__perm_app_enable_permissions continue; ret = base_name_from_perm(perm_list[i], permission_name); - RUNNER_ASSERT_MSG_BT(ret == PC_OPERATION_SUCCESS, "permission : <" << perm_list[i] << + RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "permission : <" << perm_list[i] << "> cannot be converted to basename (iri parse error)"); app_permission(name, permission_name, permission_group_type_name, is_volatile, PERMISSION_ENABLED); @@ -101,7 +101,7 @@ void TestLibPrivilegeControlDatabase::app_label(const std::string& app_name) "WHERE name == '" << app_name << "' ;"; m_base.execute(sql.str(), result); - RUNNER_ASSERT_MSG_BT(result.rows.size() == 1 && result.rows[0].size() == 1, "query : <" << + RUNNER_ASSERT_MSG(result.rows.size() == 1 && result.rows[0].size() == 1, "query : <" << sql.str() << "> returned [" << result.rows.size() << "] rows"); } @@ -113,7 +113,7 @@ void TestLibPrivilegeControlDatabase::app_not_label(const std::string& app_name) "WHERE name == '" << app_name << "' ;"; m_base.execute(sql.str(), result); - RUNNER_ASSERT_MSG_BT(result.rows.size() == 0, "query : <" << sql.str() << "> returned [" << + RUNNER_ASSERT_MSG(result.rows.size() == 0, "query : <" << sql.str() << "> returned [" << result.rows.size() << "] rows"); } @@ -137,6 +137,6 @@ void TestLibPrivilegeControlDatabase::app_permission(const std::string& app_name ";"; m_base.execute(sql.str(), result); - RUNNER_ASSERT_MSG_BT(result.rows.size() == 1, "query : <" << sql.str() << "> returned [" << + RUNNER_ASSERT_MSG(result.rows.size() == 1, "query : <" << sql.str() << "> returned [" << result.rows.size() << "] rows"); } diff --git a/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp b/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp index 6eaa018..d45ac7c 100644 --- a/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp +++ b/tests/libprivilege-control-tests/libprivilege-control_test_common.cpp @@ -123,7 +123,7 @@ bool check_no_accesses(bool smack, const rules_t &rules) void read_gids(std::set &set, const char *file_path) { FILE *f = fopen(file_path, "r"); - RUNNER_ASSERT_MSG_BT(f != NULL, "Unable to open file " << file_path); + RUNNER_ASSERT_ERRNO_MSG(f != NULL, "Unable to open file " << file_path); unsigned gid; while (fscanf(f, "%u\n", &gid) == 1) { set.insert(gid); @@ -135,22 +135,23 @@ void read_user_gids(std::set &set, const uid_t user_id) { int ret; + errno = 0; struct passwd *pw = getpwuid(user_id); - RUNNER_ASSERT_MSG_BT(pw != NULL, "getpwuid() failed."); + RUNNER_ASSERT_ERRNO_MSG(pw != NULL, "getpwuid() failed"); int groups_cnt = 0; gid_t *groups_list = NULL; ret = getgrouplist(pw->pw_name, pw->pw_gid, groups_list, &groups_cnt); - RUNNER_ASSERT_MSG_BT(ret == -1, "getgrouplist() failed."); + RUNNER_ASSERT_MSG(ret == -1, "getgrouplist() failed."); if (groups_cnt == 0) return; groups_list = (gid_t*) calloc(groups_cnt, sizeof(gid_t)); - RUNNER_ASSERT_MSG_BT(groups_list != NULL, "Memory allocation failed."); + RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed."); ret = getgrouplist(pw->pw_name, pw->pw_gid, groups_list, &groups_cnt); if (ret == -1) { free(groups_list); - RUNNER_ASSERT_MSG_BT(false, "getgrouplist() failed."); + RUNNER_FAIL_MSG("getgrouplist() failed."); } for (int i = 0; i < groups_cnt; ++i) { @@ -162,12 +163,12 @@ void read_user_gids(std::set &set, const uid_t user_id) void read_current_gids(std::set &set) { int groups_cnt = getgroups(0, NULL); - RUNNER_ASSERT_MSG_BT(groups_cnt > 0, "Wrong number of supplementary groups."); + RUNNER_ASSERT_ERRNO_MSG(groups_cnt > 0, "Wrong number of supplementary groups"); gid_t *groups_list = (gid_t*) calloc(groups_cnt, sizeof(gid_t)); - RUNNER_ASSERT_MSG_BT(groups_list != NULL, "Memory allocation failed."); + RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed."); if (getgroups(groups_cnt, groups_list) == -1){ free(groups_list); - RUNNER_ASSERT_MSG_BT(false, "getgroups failed."); + RUNNER_FAIL_MSG("getgroups failed."); } for (int i = 0; i < groups_cnt; ++i) { @@ -191,7 +192,7 @@ void check_groups(const std::set &groups_prev, const char *dac_file) if(groups_current.erase(*it) == 0) groups_left.append(std::to_string(*it)).append(" "); } - RUNNER_ASSERT_MSG_BT(groups_left.empty(), + RUNNER_ASSERT_MSG(groups_left.empty(), "Application lost some groups: " << groups_left); for (auto it = groups_check.begin(); it != groups_check.end(); ++it) @@ -199,14 +200,14 @@ void check_groups(const std::set &groups_prev, const char *dac_file) if(groups_current.erase(*it) == 0) groups_left.append(std::to_string(*it)).append(" "); } - RUNNER_ASSERT_MSG_BT(groups_left.empty(), + RUNNER_ASSERT_MSG(groups_left.empty(), "Application doesn't belong to some required groups: " << groups_left); for (auto it = groups_current.begin(); it != groups_current.end(); ++it) { groups_left.append(std::to_string(*it)).append(" "); } - RUNNER_ASSERT_MSG_BT(groups_left.empty(), + RUNNER_ASSERT_MSG(groups_left.empty(), "Application belongs to groups it should't belong to: " << groups_left); } @@ -222,7 +223,7 @@ int file_exists(const char *path) void check_app_installed(const char *app_path) { - RUNNER_ASSERT_MSG_BT(file_exists(app_path) == 0, + RUNNER_ASSERT_MSG(file_exists(app_path) == 0, " App not installed: " << app_path); } @@ -244,10 +245,10 @@ void check_perm_app_has_permission(const char *app_label, bool is_enabled_result; result = perm_app_has_permission(app_label, APP_TYPE_WGT, permission, &is_enabled_result); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error calling perm_app_has_permission. Result: " << result); - RUNNER_ASSERT_MSG_BT(is_enabled_result == is_enabled_expected, + RUNNER_ASSERT_MSG(is_enabled_result == is_enabled_expected, " Result of perm_app_has_permission should be: " << is_enabled_expected); } @@ -260,28 +261,28 @@ int nftw_check_labels_app_dir(const char *fpath, const struct stat *sb, /* ACCESS */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); labelPtr.reset(label); - RUNNER_ASSERT_MSG_BT(label != NULL, "ACCESS label on " << fpath << " is not set"); + RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set"); result = strcmp(correctLabel, label); - RUNNER_ASSERT_MSG_BT(result == 0, "ACCESS label on " << fpath << " is incorrect"); + RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect"); /* EXEC */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_EXEC); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); labelPtr.reset(label); if (S_ISREG(sb->st_mode) && (sb->st_mode & S_IXUSR)) { - RUNNER_ASSERT_MSG_BT(label != NULL, "EXEC label on " << fpath << " is not set"); + RUNNER_ASSERT_MSG(label != NULL, "EXEC label on " << fpath << " is not set"); result = strcmp(correctLabel, label); - RUNNER_ASSERT_MSG_BT(result == 0, "EXEC label on executable file " << fpath << " is incorrect"); + RUNNER_ASSERT_MSG(result == 0, "EXEC label on executable file " << fpath << " is incorrect"); } else - RUNNER_ASSERT_MSG_BT(label == NULL, "EXEC label on " << fpath << " is set"); + RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set"); /* TRANSMUTE */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); labelPtr.reset(label); - RUNNER_ASSERT_MSG_BT(label == NULL, "TRANSMUTE label on " << fpath << " is set"); + RUNNER_ASSERT_MSG(label == NULL, "TRANSMUTE label on " << fpath << " is set"); return 0; } @@ -308,28 +309,28 @@ int nftw_check_labels_app_public_ro_dir(const char *fpath, const struct stat *sb /* ACCESS */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); labelPtr.reset(label); - RUNNER_ASSERT_MSG_BT(label != NULL, "ACCESS label on " << fpath << " is not set"); + RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set"); result = strcmp(LABEL_FOR_PUBLIC_SHARED_DIRS, label); - RUNNER_ASSERT_MSG_BT(result == 0, "ACCESS label on " << fpath << " is incorrect"); + RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect"); /* EXEC */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_EXEC); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); labelPtr.reset(label); - RUNNER_ASSERT_MSG_BT(label == NULL, "EXEC label on " << fpath << " is set"); + RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set"); /* TRANSMUTE */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); labelPtr.reset(label); if (S_ISDIR(sb->st_mode)) { - RUNNER_ASSERT_MSG_BT(label != NULL, "TRANSMUTE label on " << fpath << " is not set"); + RUNNER_ASSERT_MSG(label != NULL, "TRANSMUTE label on " << fpath << " is not set"); result = strcmp("TRUE", label); - RUNNER_ASSERT_MSG_BT(result == 0, "TRANSMUTE label on " << fpath << " is not set"); + RUNNER_ASSERT_MSG(result == 0, "TRANSMUTE label on " << fpath << " is not set"); } else - RUNNER_ASSERT_MSG_BT(label == NULL, "TRANSMUTE label on " << fpath << " is set"); + RUNNER_ASSERT_MSG(label == NULL, "TRANSMUTE label on " << fpath << " is set"); return 0; } @@ -354,22 +355,22 @@ int nftw_check_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/, /* ACCESS */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS); labelPtr.reset(label); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); result = strcmp(CANARY_LABEL, labelPtr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "ACCESS label on " << fpath << " is overwritten"); + RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is overwritten"); /* EXEC */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_EXEC); labelPtr.reset(label); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); result = strcmp(CANARY_LABEL, labelPtr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "EXEC label on " << fpath << " is overwritten"); + RUNNER_ASSERT_MSG(result == 0, "EXEC label on " << fpath << " is overwritten"); /* TRANSMUTE */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE); labelPtr.reset(label); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); - RUNNER_ASSERT_MSG_BT(labelPtr.get() == NULL, "TRANSMUTE label on " << fpath << " is set"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(labelPtr.get() == NULL, "TRANSMUTE label on " << fpath << " is set"); return 0; } @@ -379,25 +380,25 @@ void test_perm_app_setup_path_PUBLIC_RO(bool smack) int result; result = nftw(TEST_APP_DIR, &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to clean Smack labels in " << TEST_APP_DIR); + RUNNER_ASSERT_MSG(result == 0, "Unable to clean Smack labels in " << TEST_APP_DIR); result = nftw(TEST_NON_APP_DIR, &nftw_set_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to set Smack labels in " << TEST_NON_APP_DIR); + RUNNER_ASSERT_MSG(result == 0, "Unable to set Smack labels in " << TEST_NON_APP_DIR); DB_BEGIN result = perm_app_setup_path(APP_ID, TEST_APP_DIR, APP_PATH_PUBLIC_RO); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_setup_path() failed"); + RUNNER_ASSERT_MSG(result == 0, "perm_app_setup_path() failed"); DB_END result = nftw(TEST_APP_DIR, &nftw_check_labels_app_public_ro_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to check Smack labels for app dir"); + RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for app dir"); result = nftw(TEST_NON_APP_DIR, &nftw_check_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to check Smack labels for non-app dir"); + RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for non-app dir"); - RUNNER_ASSERT_BT(check_all_accesses(smack, {{ USER_APP_ID, LABEL_FOR_PUBLIC_SHARED_DIRS, "r"}})); + RUNNER_ASSERT(check_all_accesses(smack, {{ USER_APP_ID, LABEL_FOR_PUBLIC_SHARED_DIRS, "r"}})); } void test_revoke_permissions(int line_no, const char* app_id) @@ -408,7 +409,7 @@ void test_revoke_permissions(int line_no, const char* app_id) DB_BEGIN result = perm_app_uninstall(app_id); - RUNNER_ASSERT_MSG_BT(result == 0, "Line: " << line_no << + RUNNER_ASSERT_MSG(result == 0, "Line: " << line_no << "perm_app_uninstall returned " << result); // Close transaction to commit uninstallation before further actions @@ -418,7 +419,7 @@ void test_revoke_permissions(int line_no, const char* app_id) // Install test apps result = perm_app_install(app_id); - RUNNER_ASSERT_MSG_BT(result == 0, "Line: " << line_no << + RUNNER_ASSERT_MSG(result == 0, "Line: " << line_no << "perm_app_install returned " << result); // Close transaction to commit installation before further actions @@ -429,7 +430,7 @@ void test_revoke_permissions(int line_no, const char* app_id) // TEST: // Revoke permissions result = perm_app_revoke_permissions(app_id); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "Line: " << line_no << + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Line: " << line_no << "Error revoking app permissions. Result: " << result); DB_END @@ -438,7 +439,7 @@ void test_revoke_permissions(int line_no, const char* app_id) // Cleanup - uninstall test apps result = perm_app_uninstall(app_id); - RUNNER_ASSERT_MSG_BT(result == 0, "Line: " << line_no << + RUNNER_ASSERT_MSG(result == 0, "Line: " << line_no << "perm_app_uninstall returned " << result); DB_END @@ -452,27 +453,27 @@ void test_app_enable_permissions_efl(bool smack) // Prepare result = perm_app_uninstall(EFL_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall failed: " << result); result = perm_app_install(EFL_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_install failed: " << result); // Register a permission: result = perm_app_enable_permissions(EFL_APP_ID, APP_TYPE_EFL, PRIVS_EFL, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error registering app permissions. Result: " << result); DB_END - RUNNER_ASSERT_MSG_BT(check_all_accesses(smack, {{USER_APP_ID,"test_book_efl", "r"}}), + RUNNER_ASSERT_MSG(check_all_accesses(smack, {{USER_APP_ID,"test_book_efl", "r"}}), "SMACK accesses not granted for EFL_APP"); DB_BEGIN // Cleanup result = perm_app_uninstall(EFL_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall failed: " << result); DB_END @@ -486,51 +487,51 @@ void test_app_disable_permissions_efl(bool smack) // Prepare result = perm_app_uninstall(EFL_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall failed: " << result); result = perm_app_install(EFL_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_install failed: " << result); result = perm_app_disable_permissions(EFL_APP_ID, APP_TYPE_EFL, PRIVS_EFL); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); DB_END - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, {{USER_APP_ID,"test_book_efl", "r"}}), + RUNNER_ASSERT_MSG(check_no_accesses(smack, {{USER_APP_ID,"test_book_efl", "r"}}), "SMACK accesses not disabled for EFL_APP"); DB_BEGIN // Register a permission result = perm_app_enable_permissions(EFL_APP_ID, APP_TYPE_EFL, PRIVS_EFL, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error registering app permissions. Result: " << result); DB_END - RUNNER_ASSERT_MSG_BT(check_all_accesses(smack, {{USER_APP_ID,"test_book_efl", "r"}}), + RUNNER_ASSERT_MSG(check_all_accesses(smack, {{USER_APP_ID,"test_book_efl", "r"}}), "SMACK accesses not granted for EFL_APP"); DB_BEGIN // Disable a permission result = perm_app_disable_permissions(EFL_APP_ID, APP_TYPE_EFL, PRIVS_EFL); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); DB_END - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, {{USER_APP_ID,"test_book_efl", "r"}}), + RUNNER_ASSERT_MSG(check_no_accesses(smack, {{USER_APP_ID,"test_book_efl", "r"}}), "SMACK accesses not disabled for EFL_APP"); DB_BEGIN // Cleanup result = perm_app_uninstall(EFL_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall failed: " << result); DB_END @@ -544,35 +545,35 @@ void test_app_disable_permissions(bool smack) // Prepare result = perm_app_uninstall(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall failed: " << result); result = perm_app_install(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_install failed: " << result); result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app first permissions. Result: " << result); result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_NO_R); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app no r permissions. Result: " << result); result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_R); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app r permissions. Result: " << result); DB_END - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, rules2), + RUNNER_ASSERT_MSG(check_no_accesses(smack, rules2), "SMACK accesses not disabled."); - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, rules1), + RUNNER_ASSERT_MSG(check_no_accesses(smack, rules1), "SMACK accesses not disabled."); DB_BEGIN @@ -583,25 +584,25 @@ void test_app_disable_permissions(bool smack) // Prepare permissions that we want to disable result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions. Result: " << result); DB_END // Are all the permissions enabled? - RUNNER_ASSERT_MSG_BT(check_all_accesses(smack, rules2), "Not all permisions enabled."); + RUNNER_ASSERT_MSG(check_all_accesses(smack, rules2), "Not all permisions enabled."); DB_BEGIN // Disable permissions result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); DB_END // Are all the permissions disabled? - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, rules2), "Not all permisions disabled."); + RUNNER_ASSERT_MSG(check_no_accesses(smack, rules2), "Not all permisions disabled."); /** * Test - disable some granted permissions leaving non complementary and then disabling those too. @@ -611,38 +612,38 @@ void test_app_disable_permissions(bool smack) // Prepare permissions that will not be disabled result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS1, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error adding app first permissions. Result: " << result); // Prepare permissions that we want to disable result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error adding app second permissions. Result: " << result); // Disable second permissions result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app second permissions. Result: " << result); DB_END // Are all second permissions disabled? - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, rules2), "Not all first permisions disabled."); + RUNNER_ASSERT_MSG(check_no_accesses(smack, rules2), "Not all first permisions disabled."); // Are all first permissions not disabled? - RUNNER_ASSERT_MSG_BT(check_all_accesses(smack, rules1), "Some of second permissions disabled."); + RUNNER_ASSERT_MSG(check_all_accesses(smack, rules1), "Some of second permissions disabled."); DB_BEGIN // Disable first permissions result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app first permissions. Result: " << result); DB_END // Are all second permissions disabled? - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, rules1), "Not all second permisions disabled."); + RUNNER_ASSERT_MSG(check_no_accesses(smack, rules1), "Not all second permisions disabled."); /** * Test - disable only no r granted permissions. @@ -652,52 +653,52 @@ void test_app_disable_permissions(bool smack) // Prepare permissions result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app r permissions. Result: " << result); result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_NO_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app no r permissions. Result: " << result); // Disable same permissions without r result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_NO_R); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app no r permissions. Result: " << result); DB_END // Is any r permissions disabled? - RUNNER_ASSERT_MSG_BT(check_all_accesses(smack, rules2_r), "Some of r permissions disabled."); + RUNNER_ASSERT_MSG(check_all_accesses(smack, rules2_r), "Some of r permissions disabled."); // Are all no r permissions disabled? - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, rules2_no_r), "Not all no r permissions disabled."); + RUNNER_ASSERT_MSG(check_no_accesses(smack, rules2_no_r), "Not all no r permissions disabled."); DB_BEGIN // Prepare permissions result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_NO_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error adding app no r permissions. Result: " << result); DB_END - RUNNER_ASSERT_MSG_BT(check_all_accesses(smack, rules2_no_r), "Not all no r permissions enabled."); + RUNNER_ASSERT_MSG(check_all_accesses(smack, rules2_no_r), "Not all no r permissions enabled."); DB_BEGIN // Disable all permissions result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_R); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); DB_END - RUNNER_ASSERT_MSG_BT(check_no_accesses(smack, rules2_r), "Not all r permissions disabled."); + RUNNER_ASSERT_MSG(check_no_accesses(smack, rules2_r), "Not all r permissions disabled."); DB_BEGIN // Clean up after test: result = perm_app_uninstall(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); DB_END } diff --git a/tests/libprivilege-control-tests/test_cases.cpp b/tests/libprivilege-control-tests/test_cases.cpp index 55c16ec..58c50f4 100644 --- a/tests/libprivilege-control-tests/test_cases.cpp +++ b/tests/libprivilege-control-tests/test_cases.cpp @@ -81,7 +81,7 @@ const std::vector BLAHBLAH_FEATURE = gen_names("http://feature/blah void osp_blahblah_dac_check(int line_no, const std::vector &gids, std::string dac_file_path) { std::ifstream dac_file(dac_file_path); - RUNNER_ASSERT_MSG_BT(dac_file, "Line: " << line_no << " Failed to create " << dac_file_path); + RUNNER_ASSERT_MSG(dac_file, "Line: " << line_no << " Failed to create " << dac_file_path); auto it = gids.begin(); std::string line; @@ -89,12 +89,12 @@ void osp_blahblah_dac_check(int line_no, const std::vector &gids, std: std::istringstream is(line); unsigned gid; is >> gid; - RUNNER_ASSERT_MSG_BT(it != gids.end(), "Line: " << line_no << "Additional line in file: " << gid); - RUNNER_ASSERT_MSG_BT(*it == gid, "Line: " << line_no << " " << *it << "!=" << gid); + RUNNER_ASSERT_MSG(it != gids.end(), "Line: " << line_no << "Additional line in file: " << gid); + RUNNER_ASSERT_MSG(*it == gid, "Line: " << line_no << " " << *it << "!=" << gid); it++; } - RUNNER_ASSERT_MSG_BT(it == gids.end(), "Line: " << line_no << " Missing line in file: " << *it); + RUNNER_ASSERT_MSG(it == gids.end(), "Line: " << line_no << " Missing line in file: " << *it); dac_file.close(); } @@ -124,23 +124,23 @@ RUNNER_TEST(privilege_control02_perm_app_setup_path_01_PRIVATE) int result; result = nftw(TEST_APP_DIR, &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to clean Smack labels in " << TEST_APP_DIR); + RUNNER_ASSERT_MSG(result == 0, "Unable to clean Smack labels in " << TEST_APP_DIR); result = nftw(TEST_NON_APP_DIR, &nftw_set_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to set Smack labels in " << TEST_NON_APP_DIR); + RUNNER_ASSERT_MSG(result == 0, "Unable to set Smack labels in " << TEST_NON_APP_DIR); DB_BEGIN result = perm_app_setup_path(APPID_DIR, TEST_APP_DIR, APP_PATH_PRIVATE); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_setup_path() for APP_PATH_PRIVATE failed"); + RUNNER_ASSERT_MSG(result == 0, "perm_app_setup_path() for APP_PATH_PRIVATE failed"); DB_END result = nftw(TEST_APP_DIR, &nftw_check_labels_app_private_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to check Smack labels for app dir"); + RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for app dir"); result = nftw(TEST_NON_APP_DIR, &nftw_check_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to check Smack labels for non-app dir"); + RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for non-app dir"); } RUNNER_TEST(privilege_control02_perm_app_setup_path_02_FLOOR) @@ -148,23 +148,23 @@ RUNNER_TEST(privilege_control02_perm_app_setup_path_02_FLOOR) int result; result = nftw(TEST_APP_DIR, &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to clean Smack labels in " << TEST_APP_DIR); + RUNNER_ASSERT_MSG(result == 0, "Unable to clean Smack labels in " << TEST_APP_DIR); result = nftw(TEST_NON_APP_DIR, &nftw_set_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to set Smack labels in " << TEST_NON_APP_DIR); + RUNNER_ASSERT_MSG(result == 0, "Unable to set Smack labels in " << TEST_NON_APP_DIR); DB_BEGIN result = perm_app_setup_path(APPID_DIR, TEST_APP_DIR, APP_PATH_FLOOR); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_setup_path() for APP_PATH_FLOOR type failed"); + RUNNER_ASSERT_MSG(result == 0, "perm_app_setup_path() for APP_PATH_FLOOR type failed"); DB_END result = nftw(TEST_APP_DIR, &nftw_check_labels_app_floor_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to check Smack labels for app dir"); + RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for app dir"); result = nftw(TEST_NON_APP_DIR, &nftw_check_labels_non_app_dir, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to check Smack labels for non-app dir"); + RUNNER_ASSERT_MSG(result == 0, "Unable to check Smack labels for non-app dir"); } @@ -201,42 +201,42 @@ void test_set_app_privilege( DB_BEGIN result = perm_app_uninstall(app_id); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, " perm_app_uninstall returned " << result << ". " "Errno: " << strerror(errno)); result = perm_app_install(app_id); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, " perm_app_install returned " << result << ". " "Errno: " << strerror(errno)); // TEST: result = perm_app_enable_permissions(app_id, APP_TYPE, privileges, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions. Result: " << result); DB_END result = test_have_all_accesses(rules); - RUNNER_ASSERT_MSG_BT(result == 1, "Permissions not added."); + RUNNER_ASSERT_MSG(result == 1, "Permissions not added."); std::set groups_before; read_user_gids(groups_before, APP_UID); result = perm_app_set_privilege(app_id, type, app_path); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error in perm_app_set_privilege. Error: " << result); // Check if SMACK label really set char *label; result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result >= 0, + RUNNER_ASSERT_MSG(result >= 0, " Error getting current process label"); - RUNNER_ASSERT_MSG_BT(label != NULL, + RUNNER_ASSERT_MSG(label != NULL, " Process label is not set"); result = strcmp(USER_APP_ID, label); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, " Process label " << label << " is incorrect"); check_groups(groups_before, dac_file); @@ -280,60 +280,60 @@ RUNNER_TEST(privilege_control08_add_api_feature) // argument validation result = perm_add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0); - RUNNER_ASSERT_BT(result == PC_ERR_INVALID_PARAM); + RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM); result = perm_add_api_feature(APP_TYPE_OSP,"", NULL, NULL, 0); - RUNNER_ASSERT_BT(result == PC_ERR_INVALID_PARAM); + RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM); // Already existing feature: // TODO: Database will be malformed. (Rules for these features will be removed.) result = perm_add_api_feature(APP_TYPE_OSP,"http://tizen.org/privilege/messaging.read", NULL, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); result = perm_add_api_feature(APP_TYPE_WGT,"http://tizen.org/privilege/messaging.sms", NULL, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); // empty features result = perm_add_api_feature(APP_TYPE_OSP,"blahblah", NULL, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); result = perm_add_api_feature(APP_TYPE_WGT,"blahblah", NULL, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); // empty rules const char *test1[] = { NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[0].c_str(), test1, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); const char *test2[] = { "", NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[1].c_str(), test2, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); const char *test3[] = { " \t\n", "\t \n", "\n\t ", NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[2].c_str(), test3, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); // malformed rules const char *test4[] = { "malformed", NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[3].c_str(), test4, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); const char *test5[] = { "malformed malformed", NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[4].c_str(), test5, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); const char *test6[] = { "-malformed malformed rwxat", NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[5].c_str(), test6, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); const char *test7[] = { "~/\"\\ malformed rwxat", NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[6].c_str(), test7, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); const char *test8[] = { "subject object rwxat something else", NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[7].c_str(), test8, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result); // correct rules @@ -345,15 +345,15 @@ RUNNER_TEST(privilege_control08_add_api_feature) NULL}; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[8].c_str(), test9, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); const char *test10[] = { "Sub::jE,ct ~APP~ a-rwxl", NULL }; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[9].c_str(), test10, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); const char *test11[] = { "Sub::sjE,ct ~APP~ a-RwXL", NULL }; // TODO This fails. result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[10].c_str(), test11, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); // TODO For now identical/complementary rules are not merged. @@ -364,30 +364,30 @@ RUNNER_TEST(privilege_control08_add_api_feature) "", NULL}; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[11].c_str(), test12, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); // empty group ids const char *test13[] = { "~APP~ b a", NULL}; result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[12].c_str(), test13,(const gid_t[]) {0,1,2},0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); result = file_exists(OSP_BLAHBLAH_DAC[12].c_str()); - RUNNER_ASSERT_BT(result == -1); + RUNNER_ASSERT(result == -1); remove_smack_files(); // valid group ids result = perm_add_api_feature(APP_TYPE_OSP,BLAHBLAH_FEATURE[13].c_str(), test13,(const gid_t[]) {0,1,2},3); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); osp_blahblah_dac_check(__LINE__, {0,1,2}, OSP_BLAHBLAH_DAC[13]); remove_smack_files(); result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[14].c_str(), test13,(const gid_t[]) {0,1,2},1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); osp_blahblah_dac_check(__LINE__, {0}, OSP_BLAHBLAH_DAC[14]); remove_smack_files(); result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[15].c_str(), test13,(const gid_t[]) {1,1,1},3); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result); osp_blahblah_dac_check(__LINE__, {1,1,1},OSP_BLAHBLAH_DAC[15]); remove_smack_files(); @@ -443,42 +443,42 @@ RUNNER_TEST_SMACK(privilege_control09_perm_add_api_feature_redefine) // uninstall app to make sure that all rules and permissions are revoked result = perm_app_uninstall(APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall failed: " << perm_strerror(result)); result = perm_app_install(APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_install failed: " << perm_strerror(result)); result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules1, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature failed: " << result); result = perm_app_enable_permissions(APP_ID, APP_TYPE_OSP, permissionName, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_enable_permissions failed: " << perm_strerror(result)); DB_END // Check if rules are applied result = test_have_all_accesses(test_rules1); - RUNNER_ASSERT_MSG_BT(result == 1, "Not all permissions added."); + RUNNER_ASSERT_MSG(result == 1, "Not all permissions added."); DB_BEGIN // Redefine the permission result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules2, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature failed: " << result); DB_END // Check if rules are updated result = test_have_all_accesses(test_rules2); - RUNNER_ASSERT_MSG_BT(result == 1, "Not all permissions added after update."); + RUNNER_ASSERT_MSG(result == 1, "Not all permissions added after update."); // The difference between rules1 and rules2 should be revoked! result = test_have_any_accesses(diff_rules); - RUNNER_ASSERT_MSG_BT(result == 0, "Permissions are not fully updated."); + RUNNER_ASSERT_MSG(result == 0, "Permissions are not fully updated."); } /* @@ -491,7 +491,7 @@ void check_perm_app_uninstall(const char* pkg_id) DB_BEGIN result = perm_app_uninstall(pkg_id); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_uninstall returned: " << perm_strerror(result)); + RUNNER_ASSERT_MSG(result == 0, "perm_app_uninstall returned: " << perm_strerror(result)); DB_END } @@ -511,7 +511,7 @@ void check_perm_app_install(const char* pkg_id) DB_BEGIN result = perm_app_install(pkg_id); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned: " << perm_strerror(result)); + RUNNER_ASSERT_MSG(result == 0, "perm_app_install returned: " << perm_strerror(result)); DB_END @@ -539,11 +539,11 @@ RUNNER_TEST(privilege_control07_app_rollback) DB_BEGIN result = perm_app_install(APP_ID); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned: " << perm_strerror(result)); + RUNNER_ASSERT_MSG(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)); + RUNNER_ASSERT_MSG(result == 0, "perm_rollback returned: " << perm_strerror(result)); DB_END } @@ -557,15 +557,15 @@ RUNNER_TEST(privilege_control07_app_rollback_2) DB_BEGIN result = perm_app_install(APP_ID); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned: " << perm_strerror(result)); + RUNNER_ASSERT_MSG(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)); + RUNNER_ASSERT_MSG(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)); + RUNNER_ASSERT_MSG(result == 0, "perm_app_install returned: " << perm_strerror(result)); DB_END @@ -584,32 +584,32 @@ RUNNER_TEST_SMACK(privilege_control11_app_enable_permissions) DB_BEGIN result = perm_app_uninstall(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); result = perm_app_install(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_app_install returned " << result << ". Errno: " << strerror(errno)); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_install returned " << result << ". Errno: " << strerror(errno)); /** * Test - Enabling all permissions with persistant mode enabled */ result = perm_app_revoke_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error revoking app permissions. Result: " << result); result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions. Result: " << result); DB_END // Check if the accesses are realy applied.. result = test_have_all_accesses(rules2); - RUNNER_ASSERT_MSG_BT(result == 1, "Permissions not added."); + RUNNER_ASSERT_MSG(result == 1, "Permissions not added."); DB_BEGIN // Clean up result = perm_app_revoke_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error revoking app permissions. Result: " << result); DB_END @@ -620,24 +620,24 @@ RUNNER_TEST_SMACK(privilege_control11_app_enable_permissions) DB_BEGIN result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions. Result: " << result); result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error enabling app permissions. Result: " << result); DB_END // Check if the accesses are realy applied.. result = test_have_all_accesses(rules2); - RUNNER_ASSERT_MSG_BT(result == 1, "Permissions not added."); + RUNNER_ASSERT_MSG(result == 1, "Permissions not added."); DB_BEGIN // Clean up result = perm_app_revoke_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error revoking app permissions. Result: " << result); DB_END @@ -649,20 +649,20 @@ RUNNER_TEST_SMACK(privilege_control11_app_enable_permissions) DB_BEGIN result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_R_AND_NO_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions. Result: " << result); DB_END // Check if the accesses are realy applied.. result = test_have_all_accesses(rules2_no_r); - RUNNER_ASSERT_MSG_BT(result == 1, "Permissions not added."); + RUNNER_ASSERT_MSG(result == 1, "Permissions not added."); DB_BEGIN // Clean up result = perm_app_revoke_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error revoking app permissions. Result: " << result); DB_END @@ -675,33 +675,33 @@ RUNNER_TEST_SMACK(privilege_control11_app_enable_permissions) // Register permission for rules 2 no r result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_NO_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions without r. Result: " << result); DB_END // Check if the accesses are realy applied.. result = test_have_all_accesses(rules2_no_r); - RUNNER_ASSERT_MSG_BT(result == 1, "Permissions without r not added."); + RUNNER_ASSERT_MSG(result == 1, "Permissions without r not added."); DB_BEGIN // Register permission for rules 2 result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app all permissions. Result: " << result); DB_END // Check if the accesses are realy applied.. result = test_have_all_accesses(rules2); - RUNNER_ASSERT_MSG_BT(result == 1, "Permissions all not added."); + RUNNER_ASSERT_MSG(result == 1, "Permissions all not added."); DB_BEGIN // Clean up result = perm_app_revoke_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error revoking app permissions. Result: " << result); /** @@ -710,40 +710,40 @@ RUNNER_TEST_SMACK(privilege_control11_app_enable_permissions) // Enable permission for rules 2 no r result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_NO_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions without r. Result: " << result); DB_END // Check if the accesses are realy applied.. result = test_have_all_accesses(rules2_no_r); - RUNNER_ASSERT_MSG_BT(result == 1, "Permissions without r not added."); + RUNNER_ASSERT_MSG(result == 1, "Permissions without r not added."); DB_BEGIN // Enable permission for rules 2 result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions with only r. Result: " << result); DB_END // Check if the accesses are realy applied.. result = test_have_all_accesses(rules2_r); - RUNNER_ASSERT_MSG_BT(result == 1, "Permissions with only r not added."); + RUNNER_ASSERT_MSG(result == 1, "Permissions with only r not added."); DB_BEGIN // Clean up result = perm_app_revoke_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error revoking app permissions. Result: " << result); // Clean up after test: result = perm_app_uninstall(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); DB_END } @@ -786,38 +786,38 @@ RUNNER_TEST_SMACK(privilege_control13_app_reset_permissions) DB_BEGIN result = perm_app_install(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno)); + RUNNER_ASSERT_MSG(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno)); // Disable permissions result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); // Prepare permissions to reset result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error registering app permissions. Result: " << result); // Reset permissions result = perm_app_reset_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error reseting app permissions. Result: " << result); DB_END // Are all second permissions not disabled? result = test_have_all_accesses(rules2); - RUNNER_ASSERT_MSG_BT(result == 1, "Not all permissions added."); + RUNNER_ASSERT_MSG(result == 1, "Not all permissions added."); DB_BEGIN // Disable permissions result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); result = perm_app_uninstall(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == 0, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); + RUNNER_ASSERT_MSG(result == 0, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); DB_END } @@ -829,7 +829,7 @@ static void smack_set_random_label_based_on_pid_on_self(void) ss << "s-" << getpid() << "-" << getppid(); result = smack_set_label_for_self(ss.str().c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "smack_set_label_for_self(" + RUNNER_ASSERT_MSG(result == 0, "smack_set_label_for_self(" << ss.str().c_str() << ") failed"); } @@ -843,22 +843,16 @@ static void smack_unix_sock_server(int sock) alarm(0); if (fd < 0) return; + + FdUniquePtr fdPtr(&fd); + result = smack_new_label_from_self(&smack_label); - if (result < 0) { - close(fd); - close(sock); - free(smack_label); - RUNNER_ASSERT_MSG_BT(0, "smack_new_label_from_self() failed"); - } - result = write(fd, smack_label, strlen(smack_label)); - if (result != (int)strlen(smack_label)) { - close(fd); - close(sock); - free(smack_label); - RUNNER_ASSERT_MSG_BT(0, "write() failed: " << strerror(errno)); - } - close(fd); - free(smack_label); + RUNNER_ASSERT_MSG(result >= 0, "smack_new_label_from_self() failed"); + SmackLabelPtr smackLabelPtr(smack_label); + + ssize_t bitsNum = write(fd, smack_label, strlen(smack_label)); + RUNNER_ASSERT_ERRNO_MSG(bitsNum >= 0 && static_cast(bitsNum) == strlen(smack_label), + "write() failed"); } RUNNER_MULTIPROCESS_TEST_SMACK(privilege_control15_app_id_from_socket) @@ -868,7 +862,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(privilege_control15_app_id_from_socket) unlink(SOCK_PATH); pid = fork(); - RUNNER_ASSERT_MSG_BT(pid >= 0, "Fork failed"); + RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed"); smack_set_random_label_based_on_pid_on_self(); @@ -877,31 +871,26 @@ RUNNER_MULTIPROCESS_TEST_SMACK(privilege_control15_app_id_from_socket) /* Set the process label before creating a socket */ sock = socket(AF_UNIX, SOCK_STREAM, 0); - RUNNER_ASSERT_MSG_BT(sock >= 0, "socket failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(sock >= 0, "socket failed"); + result = bind(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un)); - if (result != 0) { - close(sock); - RUNNER_ASSERT_MSG_BT(0, "bind failed: " << strerror(errno)); - } + RUNNER_ASSERT_ERRNO_MSG(result == 0, "bind failed"); + result = listen(sock, 1); - if (result != 0) { - close(sock); - RUNNER_ASSERT_MSG_BT(0, "listen failed: " << strerror(errno)); - } + RUNNER_ASSERT_ERRNO_MSG(result == 0, "listen failed"); smack_unix_sock_server(sock); /* Change the process label with listening socket */ smack_unix_sock_server(sock); pid = fork(); - RUNNER_ASSERT_MSG_BT(pid >= 0, "Fork failed"); + RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed"); /* Now running two concurrent servers. Test if socket label was unaffected by fork() */ smack_unix_sock_server(sock); /* Let's give the two servers different labels */ smack_unix_sock_server(sock); - close(sock); exit(0); } else { /* parent process, client */ @@ -914,35 +903,23 @@ RUNNER_MULTIPROCESS_TEST_SMACK(privilege_control15_app_id_from_socket) char *smack_label2; sock = socket(AF_UNIX, SOCK_STREAM, 0); - RUNNER_ASSERT_MSG_BT(sock >= 0, - "socket failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(sock >= 0, "socket failed"); + result = connect(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un)); - if (result != 0) { - close(sock); - RUNNER_ASSERT_MSG_BT(0, "connect failed: " << strerror(errno)); - } + RUNNER_ASSERT_ERRNO_MSG(result == 0, "connect failed"); alarm(2); result = read(sock, smack_label1, SMACK_LABEL_LEN); alarm(0); - if (result < 0) { - close(sock); - RUNNER_ASSERT_MSG_BT(0, "read failed: " << strerror(errno)); - } + RUNNER_ASSERT_ERRNO_MSG(result >= 0, "read failed"); + smack_label1[result] = '\0'; smack_label2 = perm_app_id_from_socket(sock); - if (smack_label2 == NULL) { - close(sock); - RUNNER_ASSERT_MSG_BT(0, "perm_app_id_from_socket failed"); - } + RUNNER_ASSERT_MSG(smack_label2 != NULL, "perm_app_id_from_socket failed"); result = strcmp(smack_label1, smack_label2); - if (result != 0) { - close(sock); - RUNNER_ASSERT_MSG_BT(0, "smack labels differ: '" << smack_label1 - << "' != '" << smack_label2 << "-" << random() << "'"); - } - close(sock); + RUNNER_ASSERT_MSG(result == 0, "smack labels differ: '" << smack_label1 + << "' != '" << smack_label2 << "-" << random() << "'"); } } } @@ -955,15 +932,15 @@ RUNNER_TEST(privilege_control20_perm_app_has_permission) DB_BEGIN result = perm_app_uninstall(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error uninstalling app. Result" << result); result = perm_app_install(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error installing app. Result" << result); result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_R_AND_NO_R); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app r and no r permissions. Result: " << result); DB_END @@ -976,7 +953,7 @@ RUNNER_TEST(privilege_control20_perm_app_has_permission) DB_BEGIN result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error registering app r permissions. Result: " << result); DB_END @@ -989,7 +966,7 @@ RUNNER_TEST(privilege_control20_perm_app_has_permission) DB_BEGIN result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_NO_R, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error registering app r permissions. Result: " << result); DB_END @@ -1002,7 +979,7 @@ RUNNER_TEST(privilege_control20_perm_app_has_permission) DB_BEGIN result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_R); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app r and no r permissions. Result: " << result); DB_END @@ -1015,7 +992,7 @@ RUNNER_TEST(privilege_control20_perm_app_has_permission) DB_BEGIN result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2_NO_R); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app r and no r permissions. Result: " << result); DB_END @@ -1032,15 +1009,15 @@ RUNNER_TEST(privilege_control25_test_libprivilege_strerror) { const char *result; for (auto itr = error_codes.begin(); itr != error_codes.end(); ++itr) { - RUNNER_ASSERT_MSG_BT(strcmp(perm_strerror(*itr), "Unknown error") != 0, + RUNNER_ASSERT_MSG(strcmp(perm_strerror(*itr), "Unknown error") != 0, "Returned invalid error code description."); } result = perm_strerror(POSITIVE_ERROR_CODE); - RUNNER_ASSERT_MSG_BT(strcmp(result, "Unknown error") == 0, + 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_BT(strcmp(result, "Unknown error") == 0, + RUNNER_ASSERT_MSG(strcmp(result, "Unknown error") == 0, "Bad message returned for invalid error code: \"" << result << "\""); } diff --git a/tests/libprivilege-control-tests/test_cases_incorrect_params.cpp b/tests/libprivilege-control-tests/test_cases_incorrect_params.cpp index 7735694..2fbea88 100644 --- a/tests/libprivilege-control-tests/test_cases_incorrect_params.cpp +++ b/tests/libprivilege-control-tests/test_cases_incorrect_params.cpp @@ -39,87 +39,87 @@ RUNNER_TEST_GROUP_INIT(libprivilegecontrol_incorrect_params) RUNNER_TEST(privilege_control21c_incorrect_params_perm_app_set_privilege) { - RUNNER_ASSERT_MSG_BT(perm_app_set_privilege(NULL, NULL, APP_SET_PRIV_PATH) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_set_privilege(NULL, NULL, APP_SET_PRIV_PATH) == PC_ERR_INVALID_PARAM, "perm_app_set_privilege didn't check if package name isn't NULL."); } RUNNER_TEST(privilege_control21d_incorrect_params_perm_app_install) { - RUNNER_ASSERT_MSG_BT(perm_app_install(NULL) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_install(NULL) == PC_ERR_INVALID_PARAM, "perm_app_install didn't check if pkg_id isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_install("") == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_install("") == PC_ERR_INVALID_PARAM, "perm_app_install didn't check if pkg_id isn't empty."); } RUNNER_TEST(privilege_control21e_incorrect_params_perm_app_uninstall) { - RUNNER_ASSERT_MSG_BT(perm_app_uninstall(NULL) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_uninstall(NULL) == PC_ERR_INVALID_PARAM, "perm_app_uninstall didn't check if pkg_id isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_uninstall("") == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_uninstall("") == PC_ERR_INVALID_PARAM, "perm_app_uninstall didn't check if pkg_id isn't empty."); } RUNNER_TEST(privilege_control21f_incorrect_params_perm_app_enable_permissions) { - RUNNER_ASSERT_MSG_BT(perm_app_enable_permissions(APP_ID, APP_TYPE_OTHER, NULL, 1) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_enable_permissions(APP_ID, APP_TYPE_OTHER, NULL, 1) == PC_ERR_INVALID_PARAM, "perm_app_enable_permissions didn't check if perm_list isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_enable_permissions(NULL, APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_enable_permissions(NULL, APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM, "perm_app_enable_permissions didn't check if pkg_id isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_enable_permissions("", APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_enable_permissions("", APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM, "perm_app_enable_permissions didn't check if pkg_id isn't empty."); - RUNNER_ASSERT_MSG_BT(perm_app_enable_permissions("~APP~", APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_enable_permissions("~APP~", APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM, "perm_app_enable_permissions didn't check if pkg_id is valid"); } RUNNER_TEST(privilege_control21g_incorrect_params_app_revoke_permissions) { - RUNNER_ASSERT_MSG_BT(perm_app_revoke_permissions(NULL) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_revoke_permissions(NULL) == PC_ERR_INVALID_PARAM, "perm_app_revoke_permissions didn't check if pkg_id isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_revoke_permissions("") == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_revoke_permissions("") == PC_ERR_INVALID_PARAM, "perm_app_revoke_permissions didn't check if pkg_id isn't empty."); - RUNNER_ASSERT_MSG_BT(perm_app_revoke_permissions("~APP~") == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_revoke_permissions("~APP~") == PC_ERR_INVALID_PARAM, "perm_app_revoke_permissions didn't check if pkg_id is valid."); } RUNNER_TEST(privilege_control21h_incorrect_params_app_reset_permissions) { - RUNNER_ASSERT_MSG_BT(perm_app_reset_permissions(NULL) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_reset_permissions(NULL) == PC_ERR_INVALID_PARAM, "perm_app_reset_permissions didn't check if pkg_id isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_reset_permissions("") == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_reset_permissions("") == PC_ERR_INVALID_PARAM, "perm_app_reset_permissions didn't check if pkg_id isn't empty."); - RUNNER_ASSERT_MSG_BT(perm_app_reset_permissions("~APP~") == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_reset_permissions("~APP~") == PC_ERR_INVALID_PARAM, "perm_app_reset_permissions didn't check if pkg_id is valid."); } RUNNER_TEST(privilege_control21i_incorrect_params_app_setup_path) { - RUNNER_ASSERT_MSG_BT(perm_app_setup_path(APPID_DIR, NULL, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_setup_path(APPID_DIR, NULL, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM, "perm_app_setup_path didn't check if path isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_setup_path(NULL, TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_setup_path(NULL, TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM, "perm_app_setup_path didn't check if pkg_id isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_setup_path("", TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_setup_path("", TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM, "perm_app_setup_path didn't check if pkg_id isn't empty."); - RUNNER_ASSERT_MSG_BT(perm_app_setup_path("~APP~", TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_setup_path("~APP~", TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM, "perm_app_setup_path didn't check if pkg_id is valid."); } RUNNER_TEST(privilege_control21k_incorrect_params_add_api_feature) { - RUNNER_ASSERT_MSG_BT(perm_add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0) == PC_ERR_INVALID_PARAM, "perm_add_api_feature didn't check if api_feature_name isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_add_api_feature(APP_TYPE_OSP, "", NULL, NULL, 0) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, "", NULL, NULL, 0) == PC_ERR_INVALID_PARAM, "perm_add_api_feature didn't check if api_feature_name isn't empty."); } RUNNER_TEST(privilege_control21l_incorrect_params_ignored_disable_permissions) { - RUNNER_ASSERT_MSG_BT(perm_app_disable_permissions(APP_ID, APP_TYPE_OTHER, NULL) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_disable_permissions(APP_ID, APP_TYPE_OTHER, NULL) == PC_ERR_INVALID_PARAM, "perm_app_disable_permissions didn't check if perm_list isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_disable_permissions(NULL, APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_disable_permissions(NULL, APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM, "perm_app_disable_permissions didn't check if pkg_id isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_disable_permissions("", APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_disable_permissions("", APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM, "perm_app_disable_permissions didn't check if pkg_id isn't empty."); - RUNNER_ASSERT_MSG_BT(perm_app_disable_permissions("~APP~", APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM, + RUNNER_ASSERT_MSG(perm_app_disable_permissions("~APP~", APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM, "perm_app_disable_permissions didn't check if pkg_id is valid."); } @@ -128,16 +128,16 @@ RUNNER_TEST(privilege_control21m_incorrect_params_perm_app_has_permission) bool has_permission; const char *app_label = "test_app_label"; - RUNNER_ASSERT_MSG_BT(perm_app_has_permission(NULL, APP_TYPE_WGT, + RUNNER_ASSERT_MSG(perm_app_has_permission(NULL, APP_TYPE_WGT, PRIVS2[0], &has_permission) == PC_ERR_INVALID_PARAM, "perm_app_has_permission didn't check if pkg_id isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_has_permission(app_label, APP_TYPE_OTHER, + RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_OTHER, PRIVS2[0], &has_permission) == PC_ERR_INVALID_PARAM, "perm_app_has_permission should not accept app_type = OTHER."); - RUNNER_ASSERT_MSG_BT(perm_app_has_permission(app_label, APP_TYPE_WGT, + RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_WGT, NULL, &has_permission) == PC_ERR_INVALID_PARAM, "perm_app_has_permission didn't check if permission_name isn't NULL."); - RUNNER_ASSERT_MSG_BT(perm_app_has_permission(app_label, APP_TYPE_WGT, + RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_WGT, PRIVS2[0], NULL) == PC_ERR_INVALID_PARAM, "perm_app_has_permission didn't check if has_permission isn't NULL."); } diff --git a/tests/libprivilege-control-tests/test_cases_nosmack.cpp b/tests/libprivilege-control-tests/test_cases_nosmack.cpp index b085f14..89d62ec 100644 --- a/tests/libprivilege-control-tests/test_cases_nosmack.cpp +++ b/tests/libprivilege-control-tests/test_cases_nosmack.cpp @@ -43,6 +43,7 @@ #include #include #include "common/db.h" +#include #define APP_USER_NAME "app" #define APP_HOME_DIR "/opt/home/app" @@ -75,23 +76,23 @@ RUNNER_TEST_NOSMACK(privilege_control04_add_permissions_nosmack) DB_BEGIN result = perm_app_uninstall(APP_ID); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); result = perm_app_install(APP_ID); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno)); //Add permissions result = perm_app_enable_permissions(APP_ID, APP_TYPE_EFL, PRIVS_EFL, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error adding app permissions. Result: " << result); DB_END //Check if smack_have_access always fails on every rule result = test_have_nosmack_accesses(rules_efl); - RUNNER_ASSERT_MSG_BT(result == -1, + RUNNER_ASSERT_MSG(result == -1, "Despite SMACK being off some accesses were added. Result: " << result); TestLibPrivilegeControlDatabase db_test; @@ -101,7 +102,7 @@ RUNNER_TEST_NOSMACK(privilege_control04_add_permissions_nosmack) DB_BEGIN result = perm_app_disable_permissions(USER_APP_ID, APP_TYPE_EFL, PRIVS_EFL); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling permissions: " << perm_strerror(result)); DB_END } @@ -119,36 +120,36 @@ void test_set_app_privilege_nosmack( DB_BEGIN result = perm_app_uninstall(app_id); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); result = perm_app_install(app_id); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "perm_app_install returned " << result << ". Errno: " << strerror(errno)); result = perm_app_enable_permissions(app_id, app_type, privileges, 1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error enabling app permissions. Result: " << result); DB_END result = test_have_nosmack_accesses(rules); - RUNNER_ASSERT_MSG_BT(result == -1, + RUNNER_ASSERT_MSG(result == -1, " Permissions shouldn't be added. Result: " << result); std::set groups_before; read_user_gids(groups_before, APP_UID); result = perm_app_set_privilege(app_id, type, app_path); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error in perm_app_set_privilege. Error: " << result); //Even though app privileges are set, no smack label should be extracted. char* label = NULL; result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result == -1, + RUNNER_ASSERT_MSG(result == -1, " new_label_from_self should return error (SMACK is off). Result: " << result); - RUNNER_ASSERT_MSG_BT(label == NULL, + RUNNER_ASSERT_MSG(label == NULL, " new_label_from_self shouldn't allocate memory for label."); check_groups(groups_before, dac_file); @@ -179,25 +180,25 @@ RUNNER_CHILD_TEST_NOSMACK(privilege_control05_set_app_privilege_nosmack) //Set app privileges result = perm_app_set_privilege(APP_ID, NULL, APP_SET_PRIV_PATH); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_set_privilege. Error: " << result); //Even though app privileges are set, no smack label should be extracted. char* label = NULL; result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result == -1, + RUNNER_ASSERT_MSG(result == -1, "new_label_from_self should return error (SMACK is off). Result: " << result); - RUNNER_ASSERT_MSG_BT(label == NULL, "new_label_from_self shouldn't allocate memory for label."); + RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory for label."); //Check if DAC privileges really set - RUNNER_ASSERT_MSG_BT(getuid() == APP_UID, "Wrong UID"); - RUNNER_ASSERT_MSG_BT(getgid() == APP_GID, "Wrong GID"); + RUNNER_ASSERT_MSG(getuid() == APP_UID, "Wrong UID"); + RUNNER_ASSERT_MSG(getgid() == APP_GID, "Wrong GID"); result = strcmp(getenv("HOME"), APP_HOME_DIR); - RUNNER_ASSERT_MSG_BT(result == 0, "Wrong HOME DIR. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Wrong HOME DIR. Result: " << result); result = strcmp(getenv("USER"), APP_USER_NAME); - RUNNER_ASSERT_MSG_BT(result == 0, "Wrong user USER NAME. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Wrong user USER NAME. Result: " << result); check_groups(groups_before, NULL); } @@ -262,26 +263,26 @@ RUNNER_TEST_NOSMACK(privilege_control11_app_enable_permissions_nosmack) DB_BEGIN result = perm_app_uninstall(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); result = perm_app_install(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_install returned " << result << ". Errno: " << strerror(errno)); result = perm_app_revoke_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error revoking app permissions. Result: " << result); result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, 1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error enabling app permissions. Result: " << result); DB_END //Check if accesses aren't added result = test_have_nosmack_accesses(rules2); - RUNNER_ASSERT_MSG_BT(result == -1, "Permissions shouldn't be added. Result: " << result); + RUNNER_ASSERT_MSG(result == -1, "Permissions shouldn't be added. Result: " << result); TestLibPrivilegeControlDatabase db_test; db_test.test_db_after__perm_app_install(USER_APP_ID); @@ -291,7 +292,7 @@ RUNNER_TEST_NOSMACK(privilege_control11_app_enable_permissions_nosmack) //Clean up result = perm_app_revoke_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error revoking app permissions. Result: " << result); DB_END @@ -333,38 +334,38 @@ RUNNER_TEST_NOSMACK(privilege_control13_app_reset_permissions_nosmack) DB_BEGIN result = perm_app_uninstall(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_uninstall returned " << result << ". Errno: " << strerror(errno)); result = perm_app_install(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_app_install returned " << result << ". Errno: " << strerror(errno)); // Disable permissions result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); // Prepare permissions to reset result = perm_app_enable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error adding app permissions. Result: " << result); // Reset permissions result = perm_app_reset_permissions(WGT_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error reseting app permissions. Result: " << result); DB_END result = test_have_nosmack_accesses(rules2); - RUNNER_ASSERT_MSG_BT(result == -1, "Permissions shouldn't be changed. Result: " << result); + RUNNER_ASSERT_MSG(result == -1, "Permissions shouldn't be changed. Result: " << result); DB_BEGIN // Disable permissions result = perm_app_disable_permissions(WGT_APP_ID, APP_TYPE_WGT, PRIVS2); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app permissions. Result: " << result); DB_END @@ -392,40 +393,33 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(privilege_control15_app_id_from_socket_nosmack) //Create our server and client with fork pid = fork(); - RUNNER_ASSERT_MSG_BT(pid >= 0, "Fork failed"); + RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed"); if (!pid) { //child (server) int sock, result, fd; //Create a socket sock = socket(AF_UNIX, SOCK_STREAM, 0); - RUNNER_ASSERT_MSG_BT(sock >= 0, "socket failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(sock >= 0, "socket failed"); //Bind socket to address result = bind(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un)); - if (result != 0) { - close(sock); - RUNNER_ASSERT_MSG_BT(false, "bind failed: " << strerror(errno)); - } + RUNNER_ASSERT_ERRNO_MSG(result == 0, "bind failed"); //Prepare for listening result = listen(sock, 1); - if (result != 0) { - close(sock); - RUNNER_ASSERT_MSG_BT(false, "listen failed: " << strerror(errno)); - } + RUNNER_ASSERT_ERRNO_MSG(result == 0, "listen failed"); //Accept connection alarm(2); fd = accept(sock, NULL, NULL); alarm(0); - RUNNER_ASSERT_MSG_BT(fd >= 0, "accept failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "accept failed"); //Wait a little bit for client to use perm_app_id_from_socket usleep(200); //cleanup - close(sock); exit(0); } else { //parent (client) // Give server some time to setup listening socket @@ -435,24 +429,17 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(privilege_control15_app_id_from_socket_nosmack) //Create socket sock = socket(AF_UNIX, SOCK_STREAM, 0); - RUNNER_ASSERT_MSG_BT(sock >= 0, "socket failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(sock >= 0, "socket failed"); //Try connecting to address result = connect(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un)); - if (result != 0) { - close(sock); - RUNNER_ASSERT_MSG_BT(0, "connect failed: " << strerror(errno)); - } + RUNNER_ASSERT_ERRNO_MSG(result == 0, "connect failed"); //Use perm_app_id_from_socket. Should fail and return NULL smack_label. smack_label = perm_app_id_from_socket(sock); - if (smack_label != NULL) { - close(sock); - RUNNER_ASSERT_MSG_BT(0, "perm_app_id_from_socket should fail."); - } + RUNNER_ASSERT_MSG(!smack_label, "perm_app_id_from_socket should fail."); //cleanup - close(sock); - RUNNER_ASSERT_MSG_BT(smack_label == NULL, "perm_app_id_from_socket should fail."); + RUNNER_ASSERT_MSG(smack_label == NULL, "perm_app_id_from_socket should fail."); } } diff --git a/tests/libprivilege-control-tests/test_cases_stress.cpp b/tests/libprivilege-control-tests/test_cases_stress.cpp index 61948ad..71277d6 100644 --- a/tests/libprivilege-control-tests/test_cases_stress.cpp +++ b/tests/libprivilege-control-tests/test_cases_stress.cpp @@ -90,72 +90,72 @@ void privilege_control22_app_installation_1x100(bool smack) // Clear any previously created apps, files, labels and permissions result = nftw(TEST_APP_DIR, &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Unable to clean up Smack labels in: " << TEST_APP_DIR << ". Result: " << result); result = nftw(TEST_NON_APP_DIR, &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Unable to clean up Smack labels in: " << TEST_NON_APP_DIR << ". Result: " << result); DB_BEGIN result = perm_app_revoke_permissions(APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions. Result: " << result); result = perm_app_uninstall(APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall. Result: " << result); // Install setting app and give it app-setting permissions result = perm_app_revoke_permissions(APP_TEST_SETTINGS_ASP1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions. Result: " << result); result = perm_app_uninstall(APP_TEST_SETTINGS_ASP1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall. Result: " << result); result = perm_app_install(APP_TEST_SETTINGS_ASP1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install. Result: " << result); // Register appsettings feature result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error while registering api feature. Result: " << result); result = perm_app_enable_permissions(APP_TEST_SETTINGS_ASP1, APP_TYPE_OSP, PRIV_APPSETTING, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error enabling App-Setting permissions. Result: " << result); // Install one additional app (used to check perm to shared directories) result = perm_app_revoke_permissions(TEST_OSP_FEATURE_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions. Result: " << result); result = perm_app_uninstall(TEST_OSP_FEATURE_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall. Result: " << result); result = perm_app_install(TEST_OSP_FEATURE_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install. Result: " << result); const char *test1[] = { NULL }; result = perm_app_enable_permissions(TEST_OSP_FEATURE_APP_ID, APP_TYPE_OSP, test1, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error enabling permissions. Result: " << result); // Register two valid api features result = perm_add_api_feature(APP_TYPE_OSP, TEST_OSP_FEATURE, test_osp_feature_rule_set, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_add_api_feature. Cannot add TEST_OSP_FEATURE: " << TEST_OSP_FEATURE << ". Result: " << result); result = perm_add_api_feature(APP_TYPE_WGT, TEST_WGT_FEATURE, test_wgt_feature_rule_set, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_add_api_feature. Cannot add TEST_WGT_FEATURE: " << TEST_WGT_FEATURE << ". Result: " << result); @@ -169,20 +169,20 @@ void privilege_control22_app_installation_1x100(bool smack) // Add application result = perm_app_install(APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install. Loop index: " << i << ". Result: " << result); // Add persistent permissions result = perm_app_enable_permissions(APP_ID, APP_TYPE_OSP, TEST_OSP_FEATURE_PRIVS, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_enable_permissions from OSP Feature. Loop index: " << i << ". Result: " << result); result = perm_app_enable_permissions(APP_ID, APP_TYPE_WGT, TEST_WGT_FEATURE_PRIVS, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_enable_permissions from WGT Feature. Loop index: " << i << ". Result: " << result); @@ -198,14 +198,14 @@ void privilege_control22_app_installation_1x100(bool smack) // Add app shared dir - APP_PATH_PRIVATE result = perm_app_setup_path(APP_ID, TEST_APP_DIR, APP_PATH_PRIVATE); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. Loop index: " << i << ". Result: " << result); // Add app shared dir - APP_PATH_PUBLIC_RO result = perm_app_setup_path(APP_ID, TEST_NON_APP_DIR, APP_PATH_PUBLIC_RO); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. Loop index: " << i << ". Result: " << result); @@ -214,7 +214,7 @@ void privilege_control22_app_installation_1x100(bool smack) // Verify that some previously installed app does not have any access // to APP_ID private label result = check_no_accesses(smack, rules_to_test_any_access1); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Error - other app has access to private label. Loop index: " << i); @@ -222,7 +222,7 @@ void privilege_control22_app_installation_1x100(bool smack) char *label; result = smack_getlabel(TEST_NON_APP_DIR, &label, SMACK_LABEL_ACCESS ); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Cannot get access label from Public RO shared dir. Loop index: " << i << ". Result: " << result); shared_dir_auto_label = label; @@ -232,12 +232,12 @@ void privilege_control22_app_installation_1x100(bool smack) // correctly, also to other app result = smack_have_access(APP_ID, shared_dir_auto_label.c_str(), "rwxatl"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to Public RO dir are granted. Loop index: " << i); result = smack_have_access(TEST_OSP_FEATURE_APP_ID, shared_dir_auto_label.c_str(), "rx" ); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to Public RO dir are granted. Loop index: " << i); @@ -250,14 +250,14 @@ void privilege_control22_app_installation_1x100(bool smack) // Add app shared dir - APP_PATH_SETTINGS_RW result = perm_app_setup_path(APP_ID, TEST_APP_DIR, APP_PATH_SETTINGS_RW); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. Loop index: " << i << ". Result: " << result); // Add app shared dir - APP_PATH_GROUP_RW result = perm_app_setup_path(APP_ID, TEST_NON_APP_DIR, APP_PATH_GROUP_RW); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. Loop index: " << i << ". Result: " << result); @@ -267,7 +267,7 @@ void privilege_control22_app_installation_1x100(bool smack) char *label; result = smack_getlabel(TEST_APP_DIR, &label, SMACK_LABEL_ACCESS ); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Cannot get access label from App-Setting shared dir. Loop index: " << i << ". Result: " << result); shared_dir_auto_label = label; @@ -276,19 +276,19 @@ void privilege_control22_app_installation_1x100(bool smack) // Verify that setting app has rwx permission to app dir // and rx permissions to app result = smack_have_access(APP_ID, shared_dir_auto_label.c_str(), "rwxatl"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted. " << APP_ID << " "<< shared_dir_auto_label << " rwxatl " << "Loop index: " << i); result = smack_have_access(APP_TEST_SETTINGS_ASP1, shared_dir_auto_label.c_str(), "rwx"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted. " << APP_TEST_SETTINGS_ASP1 << " " << shared_dir_auto_label << " rwx. " << "Loop index: " << i); result = smack_have_access(APP_TEST_SETTINGS_ASP1, APP_ID, "rx"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted. " << APP_TEST_SETTINGS_ASP1 << " " << APP_ID << " rx" << "Loop index: " << i); @@ -296,7 +296,7 @@ void privilege_control22_app_installation_1x100(bool smack) // Verify that all permissions to public dir have been added // correctly, also to other app result = smack_have_access(APP_ID, LABEL_FOR_PUBLIC_SHARED_DIRS, "rwxatl"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to Group RW dir are granted. Loop index: " << i); @@ -309,36 +309,36 @@ void privilege_control22_app_installation_1x100(bool smack) (const rules_t) { { APP_ID, TEST_OSP_FEATURE_APP_ID, "rxl" }, { APP_ID, TEST_WGT_FEATURE_APP_ID, "rwxl" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all permisions from api features added. Loop index: " << i); // revoke permissions result = perm_app_revoke_permissions(APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions. Loop index: " << i << ". Result: " << result); // check if api-features permissions are removed properly result = check_no_accesses(smack, rules_to_test_any_access2); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all permisions revoked. Loop index: " << i); // remove labels from app folder result = nftw(TEST_APP_DIR, &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Unable to clean up Smack labels in " << TEST_APP_DIR << " . Loop index: " << i << ". Result: " << result); // remove labels from shared folder result = nftw(TEST_NON_APP_DIR, &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Unable to clean up Smack labels in " << TEST_NON_APP_DIR << " . Loop index: " << i << ". Result: " << result); // uninstall app result = perm_app_uninstall(APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall. Loop index: " << i << ". Result: " << result); } // END Install app loop @@ -347,10 +347,10 @@ void privilege_control22_app_installation_1x100(bool smack) // Uninstall setting app and additional app result = perm_app_uninstall(TEST_OSP_FEATURE_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall. Result: " << result); result = perm_app_uninstall(APP_TEST_SETTINGS_ASP1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall. Result: " << result); DB_END @@ -407,7 +407,7 @@ void privilege_control23_app_installation2_10x10(bool smack) for (int i = 0; i < app_count; ++i) { result = sprintf(app_ids[i], APP_ID "%d", i); - RUNNER_ASSERT_MSG_BT(result > 0, "Cannot generate name for app nr: " << i); + RUNNER_ASSERT_MSG(result > 0, "Cannot generate name for app nr: " << i); } DB_BEGIN @@ -416,51 +416,51 @@ void privilege_control23_app_installation2_10x10(bool smack) for (int i = 0; i < app_count; ++i) { result = perm_app_revoke_permissions(app_ids[i]); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions for app: " << app_ids[i] << ". Result: " << result); result = perm_app_uninstall(app_ids[i]); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall for app: " << app_ids[i] << ". Result: " << result); } // Install setting app and give it app-setting permissions result = perm_app_revoke_permissions(APP_TEST_SETTINGS_ASP1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions." << " Result: " << result); result = perm_app_uninstall(APP_TEST_SETTINGS_ASP1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall." << " Result: " << result); result = perm_app_install(APP_TEST_SETTINGS_ASP1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install." << " Result: " << result); // Register appsettings feature result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, " Error while registering api feature. Result: " << result); result = perm_app_enable_permissions(APP_TEST_SETTINGS_ASP1, APP_TYPE_OSP, PRIV_APPSETTING, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error registering App-Setting permissions." << " Result: " << result); // Register two valid api features result = perm_add_api_feature(APP_TYPE_OSP, TEST_OSP_FEATURE, test_osp_feature_rule_set2, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_add_api_feature. Cannot add TEST_OSP_FEATURE: " << TEST_OSP_FEATURE << ". Result: " << result); result = perm_add_api_feature(APP_TYPE_WGT, TEST_WGT_FEATURE, test_wgt_feature_rule_set2, NULL, 0); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_add_api_feature. Cannot add TEST_WGT_FEATURE: " << TEST_WGT_FEATURE << ". Result: " << result); @@ -476,7 +476,7 @@ void privilege_control23_app_installation2_10x10(bool smack) for (int j = 0; j < app_count; ++j) { result = perm_app_install(app_ids[j]); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_install. App id: " << app_ids[j] << " Loop index: " << i @@ -484,14 +484,14 @@ void privilege_control23_app_installation2_10x10(bool smack) // Create 10 directories result = sprintf(app_dirs[j],"/tmp/" APP_ID "%d_%d", j, i); - RUNNER_ASSERT_MSG_BT(result > 0, + RUNNER_ASSERT_MSG(result > 0, "Cannot generate directory name for app nr: " << j << " Loop index: " << i); result = mkdir(app_dirs[j], S_IRWXU | S_IRGRP | S_IXGRP); - RUNNER_ASSERT_MSG_BT(result == 0 || errno == EEXIST, - "Cannot create directory: " << app_dirs[j]); + RUNNER_ASSERT_ERRNO_MSG(result == 0 || errno == EEXIST, + "Cannot create directory: " << app_dirs[j]); result = nftw(app_dirs[j], &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Unable to clean up Smack labels in: " << app_dirs[j] << ". Result: " << result); } @@ -502,70 +502,70 @@ void privilege_control23_app_installation2_10x10(bool smack) // add persistent api feature permissions result = perm_app_enable_permissions(app_ids[j], APP_TYPE_OSP, TEST_OSP_FEATURE_PRIVS, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app__permissions from OSP Feature. App id: " << app_ids[j] << " Loop index: " << i << ". Result: " << result); result = perm_app_enable_permissions(app_ids[j+5], APP_TYPE_WGT, TEST_WGT_FEATURE_PRIVS, true); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_enable_permissions from WGT Feature. App id: " << app_ids[j+5] << " Loop index: " << i << ". Result: " << result); } // Add app shared dirs - APP_PATH_PRIVATE (apps 0, 5) result = perm_app_setup_path(app_ids[0], app_dirs[0], APP_PATH_PRIVATE); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[0] << " Loop index: " << i << ". Result: " << result); result = perm_app_setup_path(app_ids[5], app_dirs[5], APP_PATH_PRIVATE); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[5] << " Loop index: " << i << ". Result: " << result); // Add app shared dir - APP_PATH_GROUP_RW (apps 1, 2, 6) result = perm_app_setup_path(app_ids[1], app_dirs[1], APP_PATH_GROUP_RW); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[1] << " Loop index: " << i << ". Result: " << result); result = perm_app_setup_path(app_ids[2], app_dirs[2], APP_PATH_GROUP_RW); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[2] << " Loop index: " << i << ". Result: " << result); result = perm_app_setup_path(app_ids[6], app_dirs[6], APP_PATH_GROUP_RW); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[6] << " Loop index: " << i << ". Result: " << result); // Add app shared dir - APP_PATH_PUBLIC_RO (apps 3, 7, 8) result = perm_app_setup_path(app_ids[3], app_dirs[3], APP_PATH_PUBLIC_RO); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[1] << " Loop index: " << i << ". Result: " << result); result = perm_app_setup_path(app_ids[7], app_dirs[7], APP_PATH_PUBLIC_RO); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[7] << " Loop index: " << i << ". Result: " << result); result = perm_app_setup_path(app_ids[8], app_dirs[8], APP_PATH_PUBLIC_RO); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[8] << " Loop index: " << i << ". Result: " << result); // Add app shared dir - APP_PATH_SETTINGS_RW (apps ,4, 9) result = perm_app_setup_path(app_ids[4], app_dirs[4], APP_PATH_SETTINGS_RW); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[4] << " Loop index: " << i << ". Result: " << result); result = perm_app_setup_path(app_ids[9], app_dirs[9], APP_PATH_SETTINGS_RW); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_setup_path. App id: " << app_ids[9] << " Loop index: " << i << ". Result: " << result); @@ -581,7 +581,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = check_no_accesses(smack, FMT_VECTOR_TO_TEST_ANY_ACCESS(app_ids[j], app_ids[0]) ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Other app (app id: " << app_ids[j] << ") has access to private label of: " << app_ids[0] << ". It may not be shared. Loop index: " << i << "."); @@ -593,7 +593,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = check_no_accesses(smack, FMT_VECTOR_TO_TEST_ANY_ACCESS(app_ids[j], app_ids[5]) ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Other app (app id: " << app_ids[j] << ") has access to private label of: " << app_ids[5] << ". It may not be shared. Loop index: " << i << "."); @@ -606,7 +606,7 @@ void privilege_control23_app_installation2_10x10(bool smack) { app_ids[1], LABEL_FOR_PUBLIC_SHARED_DIRS, "rwxatl" }, { app_ids[2], LABEL_FOR_PUBLIC_SHARED_DIRS, "rwxatl" }, { app_ids[6], LABEL_FOR_PUBLIC_SHARED_DIRS, "rwxatl" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all accesses to Group RW dir are granted. Loop index: " << i); @@ -614,7 +614,7 @@ void privilege_control23_app_installation2_10x10(bool smack) char *label; result = smack_getlabel(app_dirs[3], &label, SMACK_LABEL_ACCESS ); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Cannot get access label from Public RO shared dir: " << app_dirs[3] << " . Loop index: " << i << ". Result: " << result); shared_dir3_auto_label = label; @@ -622,7 +622,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = smack_getlabel(app_dirs[7], &label, SMACK_LABEL_ACCESS ); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Cannot get access label from Public RO shared dir: " << app_dirs[7] << " . Loop index: " << i << ". Result: " << result); shared_dir7_auto_label = label; @@ -630,7 +630,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = smack_getlabel(app_dirs[8], &label, SMACK_LABEL_ACCESS ); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Cannot get access label from Public RO shared dir: " << app_dirs[8] << " . Loop index: " << i << ". Result: " << result); shared_dir8_auto_label = label; @@ -645,7 +645,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = check_all_accesses(smack, (const rules_t) { { app_ids[j], shared_dir3_auto_label.c_str(), "rwxatl" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all accesses to owned Public RO dir are granted. App id: " << app_ids[j] << " Loop index: " << i); // Verify that there are no extra permissions to public dirs @@ -655,7 +655,7 @@ void privilege_control23_app_installation2_10x10(bool smack) { app_ids[j], shared_dir7_auto_label.c_str(), "t" }, { app_ids[j], shared_dir8_auto_label.c_str(), "w" }, { app_ids[j], shared_dir8_auto_label.c_str(), "t" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Unexpected extra permissions added for app:" << app_ids[j] << ". Loop index: " << i); } @@ -664,7 +664,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = check_all_accesses(smack, (const rules_t) { { app_ids[j], shared_dir7_auto_label.c_str(), "rwxatl" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all accesses to owned Public RO dir are granted. App id: " << app_ids[j] << " Loop index: " << i); // Verify that there are no extra permissions to public dirs @@ -674,7 +674,7 @@ void privilege_control23_app_installation2_10x10(bool smack) { app_ids[j], shared_dir3_auto_label.c_str(), "t" }, { app_ids[j], shared_dir8_auto_label.c_str(), "w" }, { app_ids[j], shared_dir8_auto_label.c_str(), "t" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Unexpected extra permissions added for app:" << app_ids[j] << ". Loop index: " << i); } @@ -683,7 +683,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = check_all_accesses(smack, (const rules_t) { { app_ids[j], shared_dir8_auto_label.c_str(), "rwxatl" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all accesses to owned Public RO dir are granted. App id: " << app_ids[j] << " Loop index: " << i); // Verify that there are no extra permissions to other public dirs @@ -693,7 +693,7 @@ void privilege_control23_app_installation2_10x10(bool smack) { app_ids[j], shared_dir3_auto_label.c_str(), "t" }, { app_ids[j], shared_dir7_auto_label.c_str(), "w" }, { app_ids[j], shared_dir7_auto_label.c_str(), "t" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Unexpected extra permissions added for app:" << app_ids[j] << ". Loop index: " << i); } @@ -703,7 +703,7 @@ void privilege_control23_app_installation2_10x10(bool smack) { app_ids[j], shared_dir3_auto_label.c_str(), "rx" }, { app_ids[j], shared_dir7_auto_label.c_str(), "rx" }, { app_ids[j], shared_dir8_auto_label.c_str(), "rx" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all accesses to Public RO dirs are granted. App id: " << app_ids[j] << ". Loop index: " << i); } // End for Verify PUBLIC_RO @@ -711,7 +711,7 @@ void privilege_control23_app_installation2_10x10(bool smack) // Get autogenerated SETTING_RW labels result = smack_getlabel(app_dirs[4], &label, SMACK_LABEL_ACCESS ); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Cannot get access label from App-Setting shared dir: " << app_dirs[4] << " . Loop index: " << i << ". Result: " << result); @@ -720,7 +720,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = smack_getlabel(app_dirs[9], &label, SMACK_LABEL_ACCESS ); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Cannot get access label from App-Setting shared dir: " << app_dirs[9] << " . Loop index: " << i << ". Result: " << result); @@ -729,32 +729,32 @@ void privilege_control23_app_installation2_10x10(bool smack) // Verify that setting app has rwx permission to app-settings dirs and rx to apps result = smack_have_access(app_ids[4], setting_dir4_auto_label.c_str(), "rwxatl"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted." << app_ids[4] << " " << setting_dir4_auto_label << " Loop index: " << i); result = smack_have_access(app_ids[9], setting_dir9_auto_label.c_str(), "rwxatl"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted." << app_ids[9] << " " << setting_dir9_auto_label << " Loop index: " << i); result = smack_have_access(APP_TEST_SETTINGS_ASP1, app_ids[4], "rx"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted." << APP_TEST_SETTINGS_ASP1 << " " << app_ids[4] << " Loop index: " << i); result = smack_have_access(APP_TEST_SETTINGS_ASP1, app_ids[9], "rx"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted." << APP_TEST_SETTINGS_ASP1 << " " << app_ids[9] << " Loop index: " << i); result = smack_have_access(APP_TEST_SETTINGS_ASP1, setting_dir4_auto_label.c_str(), "rwx"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted." << APP_TEST_SETTINGS_ASP1 << " " << setting_dir4_auto_label << " Loop index: " << i); result = smack_have_access(APP_TEST_SETTINGS_ASP1, setting_dir9_auto_label.c_str(), "rwx"); - RUNNER_ASSERT_MSG_BT(result == expected_smack_result, + RUNNER_ASSERT_MSG(result == expected_smack_result, "Not all accesses to App-Setting dir are granted." << APP_TEST_SETTINGS_ASP1 << " " << setting_dir9_auto_label << " Loop index: " << i); @@ -770,7 +770,7 @@ void privilege_control23_app_installation2_10x10(bool smack) { app_ids[j], app_ids[7], "rxl" }, { app_ids[j], app_ids[8], "rwxal" }, { app_ids[j], app_ids[9], "rwxatl" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all permisions from api features added for app id: " << app_ids[j] << ". Loop index: " << i); } @@ -783,7 +783,7 @@ void privilege_control23_app_installation2_10x10(bool smack) { app_ids[j], app_ids[2], "rxl" }, { app_ids[j], app_ids[3], "rwxal" }, { app_ids[j], app_ids[4], "rwxatl" } } ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all permisions from api features added for app id: " << app_ids[j] << ". Loop index: " << i); } @@ -794,7 +794,7 @@ void privilege_control23_app_installation2_10x10(bool smack) for (int j = 0; j < app_count; ++j) { result = perm_app_revoke_permissions(app_ids[j]); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_revoke_permissions. App id: " << app_ids[j] << " Loop index: " << i << ". Result: " << result); @@ -812,7 +812,7 @@ void privilege_control23_app_installation2_10x10(bool smack) result = check_no_accesses(smack, FMT_VECTOR_TO_TEST_ANY_ACCESS(app_ids[j], app_ids[k]) ); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, "Not all permisions revoked. Subject: " << app_ids[j] << " Object: " << app_ids[k] << " Loop index: " << i); } @@ -825,13 +825,13 @@ void privilege_control23_app_installation2_10x10(bool smack) { result = nftw(app_dirs[j], &nftw_remove_labels, FTW_MAX_FDS, FTW_PHYS); // rm labels from app folder - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Unable to clean up Smack labels in: " << app_dirs[j] << " . Loop index: " << i << ". Result: " << result); result = perm_app_uninstall(app_ids[j]); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall for app: " << app_ids[j] << " . Loop index: " << i << ". Result: " << result); @@ -843,14 +843,14 @@ void privilege_control23_app_installation2_10x10(bool smack) for (int j = 0; j < app_count; ++j) { result = rmdir(app_dirs[j]); - RUNNER_ASSERT_MSG_BT(result == 0, - "Cannot remove directory: " << app_dirs[j]); + RUNNER_ASSERT_ERRNO_MSG(result == 0, + "Cannot remove directory: " << app_dirs[j]); } } // END Install app loop // Uninstall setting app result = perm_app_uninstall(APP_TEST_SETTINGS_ASP1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error in perm_app_uninstall. Result: " << result); } diff --git a/tests/libsmack-tests/test_cases.cpp b/tests/libsmack-tests/test_cases.cpp index 764b465..6ae3ea4 100644 --- a/tests/libsmack-tests/test_cases.cpp +++ b/tests/libsmack-tests/test_cases.cpp @@ -64,20 +64,20 @@ int files_compare(int fd1, int fd2) void *h2 = MAP_FAILED; //getting files information - RUNNER_ASSERT_MSG_BT(fstat(fd1, &fs1) == 0, "fstat failed: " << strerror(errno)); - RUNNER_ASSERT_MSG_BT(fstat(fd2, &fs2) == 0, "fstat failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(fstat(fd1, &fs1) == 0, "fstat failed"); + RUNNER_ASSERT_ERRNO_MSG(fstat(fd2, &fs2) == 0, "fstat failed"); if (fs1.st_size != fs2.st_size) //if files are identical size will be the same return -1; //mapping files to process memory - RUNNER_ASSERT_MSG_BT((h1 = mmap(0, fs1.st_size, PROT_READ, MAP_SHARED, fd1, 0 )) != MAP_FAILED, - "mmap failed for fd=" << fd1 << " : " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG((h1 = mmap(0, fs1.st_size, PROT_READ, MAP_SHARED, fd1, 0 )) != MAP_FAILED, + "mmap failed for fd=" << fd1); if ((h2 = mmap(0, fs2.st_size, PROT_READ, MAP_SHARED, fd2, 0 )) == MAP_FAILED) { munmap(h1, fs1.st_size); - RUNNER_ASSERT_MSG_BT(h2 != MAP_FAILED, "mmap failed for fd=" << fd2 - << " : " << strerror(errno)); + RUNNER_ASSERT_MSG(h2 != MAP_FAILED, "mmap failed for fd=" << fd2 + << ". " << strerror(errno)); } int result = memcmp(h1, h2, fs1.st_size); @@ -129,16 +129,16 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_1){ clean_up(); struct smack_accesses *rules = NULL; - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); // THE TEST result = smack_accesses_add_modify(rules,TEST_SUBJECT, TEST_OBJECT,"xr",""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add modify by empty rules"); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add modify by empty rules"); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,"xr"); - RUNNER_ASSERT_MSG_BT(result == 1, "Rule modified (added 'xr'), but no change made."); + RUNNER_ASSERT_MSG(result == 1, "Rule modified (added 'xr'), but no change made."); // CLEAN UP clean_up(); @@ -151,20 +151,20 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_1){ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_2){ int result; struct smack_accesses *rules = NULL; - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); clean_up(); // THE TEST result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"r",""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"","r"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); - RUNNER_ASSERT_MSG_BT(smack_have_access(TEST_SUBJECT, TEST_OBJECT,"r") == 0, + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(smack_have_access(TEST_SUBJECT, TEST_OBJECT,"r") == 0, "Modification didn't work"); // CLEAN UP @@ -179,7 +179,7 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_2){ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_3){ int result; struct smack_accesses *rules = NULL; - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); clean_up(); @@ -187,21 +187,21 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_3){ // THE TEST // Add r privilage result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"r",""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); - RUNNER_ASSERT_MSG_BT(smack_have_access(TEST_SUBJECT, TEST_OBJECT,"r") == 1, + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(smack_have_access(TEST_SUBJECT, TEST_OBJECT,"r") == 1, "Adding privileges didn't work"); // Revoke r privilege rules_ptr.release(); - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); rules_ptr.reset(rules); result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"","r"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,"r"); - RUNNER_ASSERT_MSG_BT(result == 0, "Modification didn't work, rule has still 'r' privileges."); + RUNNER_ASSERT_MSG(result == 0, "Modification didn't work, rule has still 'r' privileges."); // CLEAN UP clean_up(); @@ -213,24 +213,24 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_3){ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_4){ int result; struct smack_accesses *rules = NULL; - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); clean_up(); // THE TEST result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"rwxat",""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"","r"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,"awxt"); - RUNNER_ASSERT_MSG_BT(result == 1, "Modification didn't work. Rule should have 'awxt' privileges."); + RUNNER_ASSERT_MSG(result == 1, "Modification didn't work. Rule should have 'awxt' privileges."); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,"r"); - RUNNER_ASSERT_MSG_BT(result != 1, "Modification didn't work. Rule should NOT have 'r' privilege."); + RUNNER_ASSERT_MSG(result != 1, "Modification didn't work. Rule should NOT have 'r' privilege."); // CLEAN UP clean_up(); @@ -243,23 +243,23 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_4){ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_5){ int result; struct smack_accesses *rules = NULL; - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); clean_up(); // THE TEST result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"rwxat",""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"","r"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,"awxt"); - RUNNER_ASSERT_MSG_BT(result == 1, "Modification didn't work. Rule should have 'awxt' privileges."); + RUNNER_ASSERT_MSG(result == 1, "Modification didn't work. Rule should have 'awxt' privileges."); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,"r"); - RUNNER_ASSERT_MSG_BT(result != 1, "Modification didn't work. Rule should NOT have 'r' privilege."); + RUNNER_ASSERT_MSG(result != 1, "Modification didn't work. Rule should NOT have 'r' privilege."); // CLEAN UP clean_up(); @@ -272,24 +272,24 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_5){ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_6){ int result; struct smack_accesses *rules = NULL; - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); clean_up(); // THE TEST result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"rwt",""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"ax","rt"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule."); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule."); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,"wax"); - RUNNER_ASSERT_MSG_BT(result == 1, "Modification didn't work. Rule should have 'wax' privileges."); + RUNNER_ASSERT_MSG(result == 1, "Modification didn't work. Rule should have 'wax' privileges."); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,"r"); - RUNNER_ASSERT_MSG_BT(result != 1, "Modification didn't work. Rule should NOT have 'r' privilege."); + RUNNER_ASSERT_MSG(result != 1, "Modification didn't work. Rule should NOT have 'r' privilege."); // CLEAN UP clean_up(); @@ -305,15 +305,15 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_7){ struct smack_accesses *rules = NULL; for (i = 0; i < accessesBasic.size(); ++i) { - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str(), accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify accesses instance"); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance"); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); - RUNNER_ASSERT_MSG_BT(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT), + RUNNER_ASSERT_MSG(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT), " Error while checking smack access. Accesses exist."); // CLEAN UP @@ -332,39 +332,39 @@ RUNNER_TEST_SMACK(smack_revoke_subject_test_1){ for (i = 0; i < accessesBasic.size(); ++i) { // Creating and adding rules with TEST_OBJECT and TEST_OBJECT_2 - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str(),""); result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT_2, accessesBasic[i].c_str(),""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify accesses instance"); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance"); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, "Modification didn't work. " + RUNNER_ASSERT_MSG(result == 1, "Modification didn't work. " "Rule " << accessesBasic[i].c_str() << " does not exist."); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT_2,accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, "Modification didn't work. " + RUNNER_ASSERT_MSG(result == 1, "Modification didn't work. " "Rule " << accessesBasic[i].c_str() << " does not exist."); // Revoking subject result = smack_revoke_subject(TEST_SUBJECT); - RUNNER_ASSERT_MSG_BT(result == 0, "Revoking subject didn't work."); + RUNNER_ASSERT_MSG(result == 0, "Revoking subject didn't work."); - RUNNER_ASSERT_MSG_BT(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT), + RUNNER_ASSERT_MSG(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT), " Revoke didn't work. Accesses exist."); - RUNNER_ASSERT_MSG_BT(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT_2), + RUNNER_ASSERT_MSG(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT_2), " Revoke didn't work. Accesses exist."); // Revoking subject again result = smack_revoke_subject(TEST_SUBJECT); - RUNNER_ASSERT_MSG_BT(result == 0, "Revoking subject didn't work."); + RUNNER_ASSERT_MSG(result == 0, "Revoking subject didn't work."); - RUNNER_ASSERT_MSG_BT(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT), + RUNNER_ASSERT_MSG(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT), " Revoke didn't work. Accesses exist."); - RUNNER_ASSERT_MSG_BT(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT_2), + RUNNER_ASSERT_MSG(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT_2), " Revoke didn't work. Accesses exist."); } @@ -381,54 +381,54 @@ RUNNER_TEST_SMACK(smack_accesses_clear_test_1){ for (i = 0; i < accessesBasic.size(); ++i) { // Creating and adding rules with TEST_OBJECT and TEST_OBJECT_2 - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); result = smack_accesses_add(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify accesses instance"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance"); result = smack_accesses_add(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT_2, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify accesses instance"); - RUNNER_ASSERT_MSG_BT(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance"); + RUNNER_ASSERT_MSG(smack_accesses_apply(rules_ptr.get()) == 0, "Unable to apply rules"); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, "Modification didn't work. Rule " + RUNNER_ASSERT_MSG(result == 1, "Modification didn't work. Rule " << accessesBasic[i].c_str() << " does not exist."); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT_2,accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, "Modification didn't work. Rule " + RUNNER_ASSERT_MSG(result == 1, "Modification didn't work. Rule " << accessesBasic[i].c_str() << " does not exist."); // Creating and clearing rules with TEST_OBJECT rules_ptr.release(); - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); rules_ptr.reset(rules); result = smack_accesses_add(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify accesses instance"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance"); result = smack_accesses_clear(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Clearing rules didn't work."); + RUNNER_ASSERT_MSG(result == 0, "Clearing rules didn't work."); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT,accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Clearing rules didn't work. Rule " + RUNNER_ASSERT_MSG(result == 0, "Clearing rules didn't work. Rule " << accessesBasic[i].c_str() << " does exist."); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT_2,accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, "Clearing rules didn't work. Rule " + RUNNER_ASSERT_MSG(result == 1, "Clearing rules didn't work. Rule " << accessesBasic[i].c_str() << " does not exist."); // Creating and clearing rules with TEST_OBJECT rules_ptr.release(); - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); rules_ptr.reset(rules); result = smack_accesses_add(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT_2, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify accesses instance"); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify accesses instance"); result = smack_accesses_clear(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Clearing rules didn't work."); + RUNNER_ASSERT_MSG(result == 0, "Clearing rules didn't work."); - RUNNER_ASSERT_MSG_BT(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT), + RUNNER_ASSERT_MSG(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT), " Clear didn't work. Accesses exist."); - RUNNER_ASSERT_MSG_BT(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT_2), + RUNNER_ASSERT_MSG(checkNoAccesses(TEST_SUBJECT, TEST_OBJECT_2), " Clear didn't work. Accesses exist."); } } @@ -451,48 +451,48 @@ RUNNER_TEST(smack01_storing_and_restoring_rules) int fd, tmp, sample; //file descripptors for save / restore rules tests //int smack_accesses_new(struct smack_accesses **accesses); - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); - RUNNER_ASSERT_BT(smack_accesses_new(&import_test) == 0); + RUNNER_ASSERT(smack_accesses_new(&import_test) == 0); SmackAccessesPtr import_ptr(import_test); //opening files fd = open("/tmp/smack01_rules", O_RDWR | O_CREAT | O_TRUNC, 0644); //for export prepared rules - RUNNER_ASSERT_MSG_BT(fd >= 0, "Unable to create /tmp/smack01_rules"); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Unable to create /tmp/smack01_rules"); FdUniquePtr fd_ptr(&fd); tmp = open("/tmp/smack01_tmp", O_RDWR | O_CREAT | O_TRUNC, 0644); //for import rules exported before - RUNNER_ASSERT_MSG_BT(fd >= 0, "Unable to create /tmp/smack01_tmp"); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Unable to create /tmp/smack01_tmp"); FdUniquePtr tmp_ptr(&tmp); sample = open("/etc/smack/test_smack_rules", O_RDONLY, 0644); //reference preinstalled rules - RUNNER_ASSERT_MSG_BT(sample >= 0, "Unable to open /etc/smack/test_smack_rules"); + RUNNER_ASSERT_ERRNO_MSG(sample >= 0, "Unable to open /etc/smack/test_smack_rules"); FdUniquePtr sample_ptr(&sample); result = smack_accesses_add(rules_ptr.get(), "writer", "book", "rw"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); result = smack_accesses_add(rules_ptr.get(), "reader", "book", "wx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); result = smack_accesses_add_modify(rules_ptr.get(), "reader", "book", "r", "wx"); - RUNNER_ASSERT_MSG_BT(0 == result, "Unable to modify smack rules"); + RUNNER_ASSERT_MSG(0 == result, "Unable to modify smack rules"); result = smack_accesses_save(rules_ptr.get(), fd); - RUNNER_ASSERT_MSG_BT(0 == result, "Unable to save smack_accesses instance in file"); + RUNNER_ASSERT_MSG(0 == result, "Unable to save smack_accesses instance in file"); result = lseek(fd, 0, SEEK_SET); - RUNNER_ASSERT_MSG_BT(result == 0, "lseek() error"); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "lseek() error"); result = smack_accesses_add_from_file(import_ptr.get(), fd); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to import rules from file"); + RUNNER_ASSERT_MSG(result == 0, "Unable to import rules from file"); result = smack_accesses_save(import_ptr.get(), tmp); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to save smack_accesses instance in file"); + RUNNER_ASSERT_MSG(result == 0, "Unable to save smack_accesses instance in file"); //comparing rules saved in file, restored from it and stored one more time result = files_compare(fd, tmp); - RUNNER_ASSERT_MSG_BT(result == 0, "No match in stored and restored rules"); + RUNNER_ASSERT_MSG(result == 0, "No match in stored and restored rules"); //comparing rules stored in file with reference preinstalled rules result = files_compare(tmp, sample); - RUNNER_ASSERT_MSG_BT(result == 0, "No match in stored rules and pattern file"); + RUNNER_ASSERT_MSG(result == 0, "No match in stored rules and pattern file"); } RUNNER_TEST_SMACK(smack02_aplying_rules_into_kernel) @@ -511,53 +511,53 @@ RUNNER_TEST_SMACK(smack02_aplying_rules_into_kernel) struct smack_accesses *rules = NULL; //rules prepared in this test case int result; //for storing functions results - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); //adding test rules to struct result = smack_accesses_add(rules_ptr.get(), "writer", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); result = smack_accesses_add(rules_ptr.get(), "reader", "book", "r"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); result = smack_accesses_add(rules_ptr.get(), "spy", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); result = smack_accesses_apply(rules_ptr.get()); //applying rules to kernel - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to apply rules into kernel"); + RUNNER_ASSERT_MSG(result == 0, "Unable to apply rules into kernel"); //should have access - rule exist result = smack_have_access("spy", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 1, "Error while checking Smack access"); + RUNNER_ASSERT_MSG(result == 1, "Error while checking Smack access"); //should have no access - wrong rule, should be "r" only result = smack_have_access("reader", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while checking Smack access"); + RUNNER_ASSERT_MSG(result == 0, "Error while checking Smack access"); //should have no access - rule not exist result = smack_have_access("s02badsubjectlabel", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while checking Smack access"); + RUNNER_ASSERT_MSG(result == 0, "Error while checking Smack access"); //this subject do not exist in kernel rules result = smack_revoke_subject("s02nonexistinglabel"); - RUNNER_ASSERT_MSG_BT(result == 0, "Error in removing not existing subject from kernel"); + RUNNER_ASSERT_MSG(result == 0, "Error in removing not existing subject from kernel"); result = smack_revoke_subject("spy"); //this subject exist in kernel rules - RUNNER_ASSERT_MSG_BT(result == 0, "Error in removing existing subject from kernel"); + RUNNER_ASSERT_MSG(result == 0, "Error in removing existing subject from kernel"); //testing access after revoke_subject() from kernel result = smack_have_access("spy", "book", "rwx"); //now spy should have no access - RUNNER_ASSERT_MSG_BT(result == 0, "Error in acces aplied to kernel"); + RUNNER_ASSERT_MSG(result == 0, "Error in acces aplied to kernel"); //for create new rule as a consequence of use accesses_clear() below result = smack_accesses_add(rules_ptr.get(), "s02subjectlabel", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); //"spy" removed before by using smack_revoke_subject() result = smack_accesses_clear(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error in clearing rules in kernel"); + RUNNER_ASSERT_MSG(result == 0, "Error in clearing rules in kernel"); //testing acces after acces_clear() result = smack_have_access("writer", "book", "rwx"); //now writer also should have no access - RUNNER_ASSERT_MSG_BT(result == 0, "Error in acces aplied to kernel"); + RUNNER_ASSERT_MSG(result == 0, "Error in acces aplied to kernel"); } @@ -589,7 +589,7 @@ RUNNER_TEST_SMACK(smack03_mixed_rule_string_add) int result; //for storing functions results int expected; - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); //adding test rules with mixed string @@ -599,17 +599,17 @@ RUNNER_TEST_SMACK(smack03_mixed_rule_string_add) (*rule)[0].c_str(), "book", (*rule)[1].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); } //clearing //FIXME: Using clear() here can cover error in accesses_apply() function //result = smack_accesses_clear(rules); - //RUNNER_ASSERT_MSG_BT(result == 0, "Error in clearing rules in kernel"); + //RUNNER_ASSERT_MSG(result == 0, "Error in clearing rules in kernel"); //applying rules to kernel result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to apply rules into kernel"); + RUNNER_ASSERT_MSG(result == 0, "Unable to apply rules into kernel"); //checking accesses using normal rules for (auto rule=correct_rules.begin(); rule != correct_rules.end(); ++rule) { @@ -621,7 +621,7 @@ RUNNER_TEST_SMACK(smack03_mixed_rule_string_add) result = smack_have_access((*rule)[0].c_str(), "book", (*rule)[2].c_str()); - RUNNER_ASSERT_MSG_BT(result == expected, "Error while checking Smack access"); + RUNNER_ASSERT_MSG(result == expected, "Error while checking Smack access"); } } @@ -650,7 +650,7 @@ RUNNER_TEST_SMACK(smack04_mixed_rule_string_have_access) result = smack_have_access((*rule)[0].c_str(), "book", (*rule)[1].c_str()); - RUNNER_ASSERT_MSG_BT(result == expected, "Error while checking Smack access"); + RUNNER_ASSERT_MSG(result == expected, "Error while checking Smack access"); } } @@ -684,40 +684,40 @@ RUNNER_TEST_SMACK(smack05_self_label) const char *def_rule = "_"; result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result >= 0, "Error in getting self label"); + RUNNER_ASSERT_MSG(result >= 0, "Error in getting self label"); //comparing this label with default one "_" result = strcmp(label, def_rule); free(label); - RUNNER_ASSERT_MSG_BT(result == 0, "Wrong default process label"); + RUNNER_ASSERT_MSG(result == 0, "Wrong default process label"); //comparing this rule with received from /proc/self/attr/current fd = open("/proc/self/attr/current", O_RDONLY, 0644); - RUNNER_ASSERT_MSG_BT(fd >= 0, "Unable to open /proc/self/attr/current"); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Unable to open /proc/self/attr/current"); FdUniquePtr fd_ptr(&fd); result = read(fd, buff, B_SIZE); - RUNNER_ASSERT_MSG_BT(result >= 0, "Error in reading from file /proc/self/attr/current"); + RUNNER_ASSERT_ERRNO_MSG(result >= 0, "Error in reading from file /proc/self/attr/current"); result = strncmp(buff, def_rule, result); - RUNNER_ASSERT_MSG_BT(result == 0, "Wrong default process rule"); + RUNNER_ASSERT_MSG(result == 0, "Wrong default process rule"); //now time for setting labels: result = smack_set_label_for_self("cola"); - RUNNER_ASSERT_MSG_BT(result == 0, "Error in setting self label"); + RUNNER_ASSERT_MSG(result == 0, "Error in setting self label"); //checking new label using smack function result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result >= 0, "Error in getting self label"); + RUNNER_ASSERT_MSG(result >= 0, "Error in getting self label"); result = strcmp(label, "cola"); free(label); - RUNNER_ASSERT_MSG_BT(result == 0, "Wrong process label"); + RUNNER_ASSERT_MSG(result == 0, "Wrong process label"); //checking new label using /proc/self/attr/current result = lseek(fd, 0, SEEK_SET); //going to the file beginning - RUNNER_ASSERT_MSG_BT(result == 0, "lseek() error"); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "lseek() error"); result = read(fd, buff, B_SIZE); - RUNNER_ASSERT_MSG_BT(result >= 0, "Error in reading from file /proc/self/attr/current"); + RUNNER_ASSERT_ERRNO_MSG(result >= 0, "Error in reading from file /proc/self/attr/current"); result = strncmp(buff, "cola", result); - RUNNER_ASSERT_MSG_BT(result == 0, "Proces rule in /proc/self/attr/current other than set"); + RUNNER_ASSERT_MSG(result == 0, "Proces rule in /proc/self/attr/current other than set"); } RUNNER_TEST_SMACK(smack06_setlabel_getlabel_test_0) @@ -857,20 +857,20 @@ RUNNER_TEST_SMACK(smack10_adding_removing_rules) for (i = 0; i < accessesBasic.size(); ++i) { // Creating rules - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); // Adding accesses result = smack_accesses_add(rules_ptr.get(), TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add modify rulesBasic. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to add modify rulesBasic. Result: " << result); // Applying rules result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while applying accesses. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result); // Checking if accesses were created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access. Result: " << result); // Deleting all rules @@ -880,113 +880,113 @@ RUNNER_TEST_SMACK(smack10_adding_removing_rules) for (i = 0; i < 3; ++i) { // --- Creating rules (r or w or x) - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); // Adding accesses result = smack_accesses_add(rules_ptr.get(), TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add rulesBasic. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to add rulesBasic. Result: " << result); // Applying rules result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while applying accesses. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result); // Checking if accesses were created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access. Result: " << result); // Checking if wrong accesses were not created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, " Error while checking smack access. Result: " << result); // --- Modifying accesses (r for wx or w for rx or x for rw) result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str(),accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add modify rulesBasic. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to add modify rulesBasic. Result: " << result); // Applying rules result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while applying accesses. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result); // Checking if accesses were created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access. Result: " << result); // Checking if wrong accesses were not created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, " Error while checking smack access. Result: " << result); rules_ptr.release(); // --- Creating complementary rules (r or w or x) - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); rules_ptr.reset(rules); // Adding accesses result = smack_accesses_add(rules_ptr.get(), TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add rulesBasic. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to add rulesBasic. Result: " << result); // Checking if accesses were created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access. Result: " << result); // Applying rules result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while applying accesses. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result); // Checking if accesses were created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access. Result: " << result); // --- Modifying accesses (adding rwx and removing r or w or x) result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT,"rwx", accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add modify rulesBasic. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to add modify rulesBasic. Result: " << result); // Applying rules result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while applying accesses. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result); // Checking if accesses were created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i + 3].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access. Result: " << result); // Checking if wrong accesses were not created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[i].c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, " Error while checking smack access. Result: " << result); // --- Adding crossing accesses (rx or rw or wx) result = smack_accesses_add_modify(rules_ptr.get(),TEST_SUBJECT, TEST_OBJECT, accessesBasic[3 + ((i + 1) % 3)].c_str(),""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add modify rulesBasic. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to add modify rulesBasic. Result: " << result); // Applying rules result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while applying accesses. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result); // Checking if accesses were created result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, accessesBasic[3 + ((i + 1) % 3)].c_str()); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access. Result: " << result); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, "rwx"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access. Result: " << result); // Deleting all rules result = smack_accesses_add_modify(rules,TEST_SUBJECT, TEST_OBJECT,"","rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add modify rulesBasic. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to add modify rulesBasic. Result: " << result); result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while checking smack access. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while checking smack access. Result: " << result); // Deleting all rules clean_up(); @@ -1003,46 +1003,46 @@ RUNNER_TEST_SMACK(smack11_saving_loading_rules) // Pre-cleanup removeAccessesAll(); - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); // Loading file with rwxat rules - test_smack_rules_full fd = open("/etc/smack/test_smack_rules_full", O_RDONLY, 0644); - RUNNER_ASSERT_MSG_BT(fd >= 0, "Unable to open /etc/smack/test_smack_rules_full"); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Unable to open /etc/smack/test_smack_rules_full"); // Adding rules from file result = smack_accesses_add_from_file(rules_ptr.get(), fd); close(fd); - RUNNER_ASSERT_MSG_BT(result == 0, "Error importing accesses from file"); + RUNNER_ASSERT_MSG(result == 0, "Error importing accesses from file"); // Applying rules result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while applying accesses. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result); // Checking rules result = smack_have_access("test_subject_01", "test_object_02", "rwxat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack accesses."); result = smack_have_access("test_subject_01", "test_object_03", "rwxat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack accesses."); result = smack_have_access("test_subject_02", "test_object_01", "rwxat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack accesses."); result = smack_have_access("test_subject_02", "test_object_02", "rwxat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack accesses."); result = smack_have_access("test_subject_02", "test_object_03", "rwxat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack accesses."); result = smack_have_access("test_subject_03", "test_object_01", "rwxat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack accesses."); result = smack_have_access("test_subject_03", "test_object_02", "rwxat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack accesses."); result = smack_have_access("test_subject_03", "test_object_03", "rwxat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack accesses."); // Removing rules @@ -1050,47 +1050,47 @@ RUNNER_TEST_SMACK(smack11_saving_loading_rules) // Creating rules rules_ptr.release(); - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); rules_ptr.reset(rules); // Loading file with partial wrong rules - test_smack_rules2 fd = open("/etc/smack/test_smack_rules2", O_RDONLY, 0644); - RUNNER_ASSERT_MSG_BT(fd >= 0, "Unable to open /etc/smack/test_smack_rules2"); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Unable to open /etc/smack/test_smack_rules2"); // Adding rules from file result = smack_accesses_add_from_file(rules_ptr.get(), fd); close(fd); - RUNNER_ASSERT_MSG_BT(result == 0, "Error importing accesses from file"); + RUNNER_ASSERT_MSG(result == 0, "Error importing accesses from file"); // Applying rules result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while applying accesses. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while applying accesses. Result: " << result); // Checking rules - RUNNER_ASSERT_MSG_BT(checkNoAccesses("test_subject_01", "test_object_01"), + RUNNER_ASSERT_MSG(checkNoAccesses("test_subject_01", "test_object_01"), " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Accesses exist."); result = smack_have_access("test_subject_01", "test_object_02", "rwatl"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Result: " << result ); result = smack_have_access("test_subject_01", "test_object_03", "wat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Result: " << result ); - RUNNER_ASSERT_MSG_BT(checkNoAccesses("test_subject_02", "test_object_01"), + RUNNER_ASSERT_MSG(checkNoAccesses("test_subject_02", "test_object_01"), " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Accesses exist."); result = smack_have_access("test_subject_02", "test_object_02", "wa-lt"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Result: " << result ); result = smack_have_access("test_subject_02", "test_object_03", "wr"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Result: " << result ); result = smack_have_access("test_subject_03", "test_object_01", "a"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Result: " << result ); result = smack_have_access("test_subject_03", "test_object_02", "rwat"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Result: " << result ); result = smack_have_access("test_subject_03", "test_object_03", "w---l-"); - RUNNER_ASSERT_MSG_BT(result == 1, + RUNNER_ASSERT_MSG(result == 1, " Error while checking smack access loaded from /etc/smack/test_smack_rules2. Result: " << result ); // Removing rules @@ -1098,34 +1098,34 @@ RUNNER_TEST_SMACK(smack11_saving_loading_rules) // Creating rules rules_ptr.release(); - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); rules_ptr.reset(rules); // Loading file with partial wrong rules - test_smack_rules3 fd = open("/etc/smack/test_smack_rules3", O_RDONLY, 0644); - RUNNER_ASSERT_MSG_BT(fd >= 0, "Unable to open /etc/smack/test_smack_rules3"); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Unable to open /etc/smack/test_smack_rules3"); // Adding rules from file result = smack_accesses_add_from_file(rules_ptr.get(), fd); close(fd); - RUNNER_ASSERT_MSG_BT(result != 0, "Accesses were loaded from file"); + RUNNER_ASSERT_MSG(result != 0, "Accesses were loaded from file"); // Removing rules removeAccessesAll(); // Creating rules rules_ptr.release(); - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); rules_ptr.reset(rules); // Loading file with partial wrong rules - test_smack_rules4 fd = open("/etc/smack/test_smack_rules4", O_RDONLY, 0644); - RUNNER_ASSERT_MSG_BT(fd >= 0, "Unable to open /etc/smack/test_smack_rules4"); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Unable to open /etc/smack/test_smack_rules4"); // Adding rules from file result = smack_accesses_add_from_file(rules_ptr.get(), fd); close(fd); - RUNNER_ASSERT_MSG_BT(result != 0, "Accesses were loaded from file"); + RUNNER_ASSERT_MSG(result != 0, "Accesses were loaded from file"); // Removing rules removeAccessesAll(); @@ -1142,7 +1142,7 @@ static void smack_set_another_label_for_self(void) std::string smack_label("s" + std::to_string(number)); int result = smack_set_label_for_self(smack_label.c_str()); - RUNNER_ASSERT_MSG_BT(result == 0, "smack_set_label_for_self(" << smack_label << ") failed"); + RUNNER_ASSERT_MSG(result == 0, "smack_set_label_for_self(" << smack_label << ") failed"); } static void smack_unix_sock_server(int sock) @@ -1153,14 +1153,14 @@ static void smack_unix_sock_server(int sock) alarm(2); fd = accept(sock, NULL, NULL); alarm(0); - RUNNER_ASSERT_BT(fd >= 0); + RUNNER_ASSERT_ERRNO(fd >= 0); FdUniquePtr fd_ptr(&fd); result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result >= 0, "smack_new_label_from_self() failed"); + RUNNER_ASSERT_MSG(result >= 0, "smack_new_label_from_self() failed"); CStringPtr label_ptr(label); result = write(fd, label, strlen(label)); - RUNNER_ASSERT_MSG_BT(result == (int)strlen(label), "write() failed"); + RUNNER_ASSERT_ERRNO_MSG(result == (int)strlen(label), "write() failed"); } @@ -1171,22 +1171,22 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack09_new_label_from_socket) unlink(SOCK_PATH); smack_set_another_label_for_self(); pid = fork(); - RUNNER_ASSERT_MSG_BT(pid >= 0, "Fork failed"); + RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed"); if (!pid) { /* child process, server */ int sock, result; sock = socket(AF_UNIX, SOCK_STREAM, 0); - RUNNER_ASSERT_MSG_BT(sock >= 0, "socket failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(sock >= 0, "socket failed"); SockUniquePtr sock_ptr(&sock); result = bind(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un)); - RUNNER_ASSERT_MSG_BT(result == 0, "bind failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "bind failed"); result = listen(sock, 1); - RUNNER_ASSERT_MSG_BT(result == 0, "listen failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "listen failed"); smack_unix_sock_server(sock); pid = fork(); - RUNNER_ASSERT_MSG_BT(pid >= 0, "Fork failed"); + RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed"); /* Test if socket label was unaffected by fork() */ smack_unix_sock_server(sock); if (!pid) { @@ -1204,24 +1204,24 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack09_new_label_from_socket) char *smack_label2; sock = socket(AF_UNIX, SOCK_STREAM, 0); - RUNNER_ASSERT_MSG_BT(sock >= 0, "socket failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(sock >= 0, "socket failed"); SockUniquePtr sock_ptr(&sock); result = connect(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un)); - RUNNER_ASSERT_MSG_BT(result == 0, "connect failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "connect failed"); alarm(2); result = read(sock, smack_label1, SMACK_LABEL_LEN); alarm(0); - RUNNER_ASSERT_MSG_BT(result >= 0, "read failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(result >= 0, "read failed"); smack_label1[result] = '\0'; result = smack_new_label_from_socket(sock, &smack_label2); SmackLabelPtr label2_ptr(smack_label2); - RUNNER_ASSERT_MSG_BT(result >= 0, "smack_label_from_socket failed"); + RUNNER_ASSERT_MSG(result >= 0, "smack_label_from_socket failed"); result = strcmp(smack_label1, label2_ptr.get()); if (i < 3) - RUNNER_ASSERT_MSG_BT(result == 0, "smack labels differ: '" << smack_label1 + RUNNER_ASSERT_MSG(result == 0, "smack labels differ: '" << smack_label1 << "' != '" << smack_label2 << "' i == " << i); else - RUNNER_ASSERT_MSG_BT(result != 0, "smack labels do not differ: '" << smack_label1 + RUNNER_ASSERT_MSG(result != 0, "smack labels do not differ: '" << smack_label1 << "' != '" << smack_label2 << "' i == " << i); } } @@ -1238,25 +1238,25 @@ void createFileWithLabel(const std::string &filePath, const std::string &fileLab int fd = open(filePath.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); //restore system mask umask(systemMask); - RUNNER_ASSERT_MSG_BT(fd > -1, "Unable to create file for tests: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(fd > -1, "Unable to create file for tests"); //for descriptor protection FdUniquePtr fd_ptr(&fd); //change owner and group to user APP int ret = chown(filePath.c_str(), APP_UID, APP_GID); - RUNNER_ASSERT_MSG_BT(ret == 0, "Unable to change file owner: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Unable to change file owner"); //set smack label on file ret = smack_setlabel(filePath.c_str(), fileLabel.c_str(), SMACK_LABEL_ACCESS); - RUNNER_ASSERT_MSG_BT(ret == 0, "Unable to set label for file: " << ret); + RUNNER_ASSERT_MSG(ret == 0, "Unable to set label for file: " << ret); char *label = NULL; ret = smack_getlabel(filePath.c_str(), &label, SMACK_LABEL_ACCESS); - RUNNER_ASSERT_MSG_BT(ret == 0, "Unable to get label from file"); + RUNNER_ASSERT_MSG(ret == 0, "Unable to get label from file"); std::string label_str(label ? label : ""); free(label); - RUNNER_ASSERT_MSG_BT(label_str == fileLabel, "File label not match set label"); + RUNNER_ASSERT_MSG(label_str == fileLabel, "File label not match set label"); } void prepareEnvironment(const std::string &subject, const std::string &object, const std::string &access) @@ -1283,7 +1283,7 @@ RUNNER_CHILD_TEST_SMACK(smack13_0_checking_laccess_mode_enabled_on_device) provider.apply(); int ret = smack_have_access(selfLabel.c_str(), filename.c_str(), "l"); - RUNNER_ASSERT_MSG_BT(ret == 1, "Error in adding laccess rule - l"); + RUNNER_ASSERT_MSG(ret == 1, "Error in adding laccess rule - l"); } //- Create file @@ -1305,11 +1305,11 @@ RUNNER_CHILD_TEST_SMACK(smack13_1_checking_laccess_mode) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = flock(fd, LOCK_EX | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret < 0, "Error, able to lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret < 0, "Error, able to lock file"); ret = flock(fd, LOCK_UN | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret < 0, "Error, able to lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret < 0, "Error, able to lock file"); ret = flock(fd, LOCK_SH | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret < 0, "Error, able to lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret < 0, "Error, able to lock file"); } //- Create file @@ -1331,11 +1331,11 @@ RUNNER_CHILD_TEST_SMACK(smack13_2_checking_laccess_mode_with_l_rule) prepareEnvironment(selfLabel, filename, "l"); int ret = flock(fd, LOCK_EX | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to exclusive lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to exclusive lock file"); ret = flock(fd, LOCK_UN | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to unlock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to unlock file"); ret = flock(fd, LOCK_SH | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to shared lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to shared lock file"); } //- Create file @@ -1357,11 +1357,11 @@ RUNNER_CHILD_TEST_SMACK(smack13_3_checking_laccess_mode_with_w_rule) prepareEnvironment(selfLabel, filename, "w"); int ret = flock(fd, LOCK_EX | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to exclusive lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to exclusive lock file"); ret = flock(fd, LOCK_UN | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to unlock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to unlock file"); ret = flock(fd, LOCK_SH | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to shared lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to shared lock file"); } //- Create file @@ -1383,7 +1383,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_0_checking_laccess_mode_w_rule_child) int fd = open(filePath.c_str(), O_RDWR); FdUniquePtr fd_ptr(&fd); int ret = flock(fd, LOCK_SH | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to shared lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to shared lock file"); pid_t pid = fork(); if (pid == 0) { @@ -1391,13 +1391,12 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_0_checking_laccess_mode_w_rule_child) prepareEnvironment(selfLabel, filename, "rw"); int child_fd = open(filePath.c_str(), O_RDWR); - RUNNER_ASSERT_MSG_BT(child_fd > -1, "Unable to open created file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(child_fd > -1, "Unable to open created file"); //for descriptor protection FdUniquePtr child_fd_ptr(&child_fd); ret = flock(child_fd, LOCK_SH | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to lock file with shared lock: " - << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to lock file with shared lock"); } } @@ -1420,7 +1419,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_1_checking_laccess_mode_l_rule_child) int fd = open(filePath.c_str(), O_RDWR); FdUniquePtr fd_str(&fd); int ret = flock(fd, LOCK_SH | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to shared lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to shared lock file"); pid_t pid = fork(); if (pid == 0) { @@ -1429,13 +1428,12 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_1_checking_laccess_mode_l_rule_child) prepareEnvironment(selfLabel, filename, "rl"); int child_fd = open(filePath.c_str(), O_RDONLY, 0); - RUNNER_ASSERT_MSG_BT(child_fd > -1, "Unable to open created file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(child_fd > -1, "Unable to open created file"); //for descriptor protection FdUniquePtr child_fd_ptr(&child_fd); ret = flock(child_fd, LOCK_SH | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to lock file with shared lock: " - << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to lock file with shared lock"); } } @@ -1458,7 +1456,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_2_checking_laccess_mode_w_rule_child) int fd = open(filePath.c_str(), O_RDWR); FdUniquePtr fd_ptr(&fd); int ret = flock(fd, LOCK_EX | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to exclusive lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to exclusive lock file"); pid_t pid = fork(); if (pid == 0) { @@ -1466,12 +1464,12 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_2_checking_laccess_mode_w_rule_child) prepareEnvironment(selfLabel, filename, "rw"); int child_fd = open(filePath.c_str(), O_RDWR, 0); - RUNNER_ASSERT_MSG_BT(child_fd > -1, "Unable to open created file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(child_fd > -1, "Unable to open created file"); //for descriptor protection FdUniquePtr child_fd_ptr(&child_fd); ret = flock(child_fd, LOCK_EX | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret < 0, "Error, able to lock file with exclusive lock"); + RUNNER_ASSERT_ERRNO_MSG(ret < 0, "Error, able to lock file with exclusive lock"); } } @@ -1494,7 +1492,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_3_checking_laccess_mode_l_rule_child) int fd = open(filePath.c_str(), O_RDWR, 0); FdUniquePtr fd_ptr(&fd); int ret = flock(fd, LOCK_EX | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error, unable to exclusive lock file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Error, unable to exclusive lock file"); pid_t pid = fork(); if (pid == 0) { @@ -1503,12 +1501,12 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_3_checking_laccess_mode_l_rule_child) prepareEnvironment(selfLabel, filename, "rl"); int child_fd = open(filePath.c_str(), O_RDONLY, 0); - RUNNER_ASSERT_MSG_BT(child_fd > -1, "Unable to open created file: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(child_fd > -1, "Unable to open created file"); //for descriptor protection FdUniquePtr child_fd_ptr(&child_fd); ret = flock(child_fd, LOCK_EX | LOCK_NB); - RUNNER_ASSERT_MSG_BT(ret < 0, "Error, able to lock file with eclusive lock"); + RUNNER_ASSERT_ERRNO_MSG(ret < 0, "Error, able to lock file with eclusive lock"); } } @@ -1537,49 +1535,49 @@ RUNNER_TEST_NOSMACK(smack02_aplying_rules_into_kernel_nosmack) int result; //init rules - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); //pass rules to unique_ptr SmackAccessesPtr rules_ptr(rules); //adding test rules to struct (same as SMACK version of smack02 test) result = smack_accesses_add(rules_ptr.get(), "writer", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); result = smack_accesses_add(rules_ptr.get(), "reader", "book", "r"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); result = smack_accesses_add(rules_ptr.get(), "spy", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); //applying rules to kernel (should fail) result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == -1, "Unable to apply rules into kernel"); + RUNNER_ASSERT_MSG(result == -1, "Unable to apply rules into kernel"); //calls from SMACK version of this test - all should fail because of SMACK being turned off result = smack_have_access("spy", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == -1, "smack_have_access should return error (SMACK is off)"); + RUNNER_ASSERT_MSG(result == -1, "smack_have_access should return error (SMACK is off)"); result = smack_have_access("reader", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == -1, "smack_have_access should return error (SMACK is off)"); + RUNNER_ASSERT_MSG(result == -1, "smack_have_access should return error (SMACK is off)"); result = smack_have_access("s02badsubjectlabel", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == -1, "smack_have_access should return error (SMACK is off)"); + RUNNER_ASSERT_MSG(result == -1, "smack_have_access should return error (SMACK is off)"); //testing subject revoking - should return error (no accesses applied = no subjects to revoke) result = smack_revoke_subject("s02nonexistinglabel"); - RUNNER_ASSERT_MSG_BT(result == -1, "smack_revoke_subject error - subject doesn't exist."); + RUNNER_ASSERT_MSG(result == -1, "smack_revoke_subject error - subject doesn't exist."); result = smack_revoke_subject("spy"); - RUNNER_ASSERT_MSG_BT(result == -1, "smack_revoke_subject error - subject doesn't exist."); + RUNNER_ASSERT_MSG(result == -1, "smack_revoke_subject error - subject doesn't exist."); //after revoking smack_have_access still should return error result = smack_have_access("spy", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == -1, "smack_have_access should return error (SMACK is off)."); + RUNNER_ASSERT_MSG(result == -1, "smack_have_access should return error (SMACK is off)."); result = smack_accesses_add(rules_ptr.get(), "s02subjectlabel", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to add smack rules"); + RUNNER_ASSERT_MSG(result == 0, "Unable to add smack rules"); //smack_accesses_clear should return error aswell result = smack_accesses_clear(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == -1, "Clearing rules should return error - no SMACK on system."); + RUNNER_ASSERT_MSG(result == -1, "Clearing rules should return error - no SMACK on system."); result = smack_have_access("writer", "book", "rwx"); - RUNNER_ASSERT_MSG_BT(result == -1, "smack_have_access should return error (SMACK is off)."); + RUNNER_ASSERT_MSG(result == -1, "smack_have_access should return error (SMACK is off)."); } /** @@ -1596,18 +1594,17 @@ RUNNER_TEST_NOSMACK(smack03_saving_loading_rules_nosmack) smack_accesses* tmp = NULL; - RUNNER_ASSERT_BT(smack_accesses_new(&tmp) == 0); + RUNNER_ASSERT(smack_accesses_new(&tmp) == 0); SmackAccessesPtr rules(tmp); //open file with rules fd = open("/etc/smack/test_smack_rules_full", O_RDONLY, 0644); - RUNNER_ASSERT_MSG_BT(fd >= 0, - "Unable to open /etc/smack/test_smack_rules_full. Errno: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Unable to open /etc/smack/test_smack_rules_full"); //load accesses from file result = smack_accesses_add_from_file(rules.get(), fd); close(fd); - RUNNER_ASSERT_MSG_BT(result == 0, "Error while importing accesses from file. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Error while importing accesses from file. Result: " << result); } /** @@ -1624,34 +1621,34 @@ RUNNER_TEST_NOSMACK(smack04_self_label_nosmack) //smack_new_label_from_self should fail result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result == -1, "new_label_from_self should return error (SMACK is off)."); - RUNNER_ASSERT_MSG_BT(label == NULL, "new_label_from_self shouldn't allocate memory to label."); + RUNNER_ASSERT_MSG(result == -1, "new_label_from_self should return error (SMACK is off)."); + RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory to label."); //We don't need to remember about freeing label - smack_new_label_from_self must return NULL //label if it's working properly. // /proc/self/attr/current shouldn't keep any rules inside fd = open("/proc/self/attr/current", O_RDONLY, 0644); //file exists, so it should open - RUNNER_ASSERT_MSG_BT(fd >= 0, "/proc/self/attr/current failed to open."); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "/proc/self/attr/current failed to open"); FdUniquePtr fd_ptr(&fd); result = read(fd, buff, SMACK_LABEL_LEN); //however reading it should return error - RUNNER_ASSERT_MSG_BT(result < 0, "Reading /proc/self/attr/current should return error."); + RUNNER_ASSERT_ERRNO_MSG(result < 0, "Reading /proc/self/attr/current should return error"); //setting label for self should fail result = smack_set_label_for_self("s04testlabel"); - RUNNER_ASSERT_MSG_BT(result == -1, "set_label_for_self should return error (SMACK is off)."); + RUNNER_ASSERT_MSG(result == -1, "set_label_for_self should return error (SMACK is off)."); //getting previously set label should also fail result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result == -1, "new_label_from_self should return error (SMACK is off)."); - RUNNER_ASSERT_MSG_BT(label == NULL, "new_label_from_self shouldn't allocate memory to label."); + RUNNER_ASSERT_MSG(result == -1, "new_label_from_self should return error (SMACK is off)."); + RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory to label."); // /proc/self/attr/current still shouldn't keep any rules inside result = lseek(fd, 0, SEEK_SET); //going to the file beginning - RUNNER_ASSERT_MSG_BT(result == 0, "lseek() error."); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "lseek() error"); result = read(fd, buff, SMACK_LABEL_LEN); //however it should return error - RUNNER_ASSERT_MSG_BT(result < 0, "Reading /proc/self/attr/current should return error."); + RUNNER_ASSERT_ERRNO_MSG(result < 0, "Reading /proc/self/attr/current should return error"); } /** @@ -1667,7 +1664,7 @@ RUNNER_TEST_NOSMACK(smack05_accesses_add_modify_nosmack) int result; smack_accesses* rules = NULL; - RUNNER_ASSERT_BT(smack_accesses_new(&rules) == 0); + RUNNER_ASSERT(smack_accesses_new(&rules) == 0); SmackAccessesPtr rules_ptr(rules); @@ -1675,20 +1672,20 @@ RUNNER_TEST_NOSMACK(smack05_accesses_add_modify_nosmack) //rule struct and removal of currenctly added and applied rules. clean_up() must be done only //after smack_accesses_apply(). result = smack_accesses_add_modify(rules_ptr.get(), TEST_SUBJECT, TEST_OBJECT, "rwx", ""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule. Result: " << result); result = smack_accesses_add_modify(rules_ptr.get(), TEST_SUBJECT, TEST_OBJECT, "rwx", ""); - RUNNER_ASSERT_MSG_BT(result == 0, "Unable to modify rule. Result: " << result); + RUNNER_ASSERT_MSG(result == 0, "Unable to modify rule. Result: " << result); result = smack_accesses_apply(rules_ptr.get()); - RUNNER_ASSERT_MSG_BT(result == -1, + RUNNER_ASSERT_MSG(result == -1, "smack_accesses_apply should return error (SMACK is off). Result: " << result); result = smack_have_access(TEST_SUBJECT, TEST_OBJECT, "rwx"); if(result != -1) { clean_up(); - RUNNER_ASSERT_MSG_BT(false, - "smack_have_access should return error (SMACK is off). Result: " << result); + RUNNER_FAIL_MSG("smack_have_access should return error (SMACK is off). Result: " + << result); } clean_up(); @@ -1709,29 +1706,29 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(smack09_new_label_from_socket_nosmack) char* smack_label; pid = fork(); - RUNNER_ASSERT_MSG_BT(pid >= 0, "Fork failed"); + RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed"); if (!pid) { //child (server) int sock, result; int fd; //Create new socket sock = socket(AF_UNIX, SOCK_STREAM, 0); - RUNNER_ASSERT_MSG_BT(sock >= 0, "socket failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(sock >= 0, "socket failed"); SockUniquePtr sock_ptr(&sock); //Bind it to sockaddr result = bind(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un)); - RUNNER_ASSERT_MSG_BT(result == 0, "bind failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "bind failed"); //Prepare for listening result = listen(sock, 1); - RUNNER_ASSERT_MSG_BT(result == 0, "listen failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "listen failed"); //Accept client alarm(2); fd = accept(sock, NULL, NULL); alarm(0); - RUNNER_ASSERT_MSG_BT(fd >= 0, "Failed when accepting connection from client."); + RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Failed when accepting connection from client"); FdUniquePtr fd_ptr(&fd); //wait for smack_new_label_from_socket execution @@ -1747,16 +1744,16 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(smack09_new_label_from_socket_nosmack) //Create socket sock = socket(AF_UNIX, SOCK_STREAM, 0); + RUNNER_ASSERT_ERRNO_MSG(sock >= 0, "socket failed"); SockUniquePtr sock_ptr(&sock); - RUNNER_ASSERT_MSG_BT(sock >= 0, "socket failed: " << strerror(errno)); //Connect to sockaddr result = connect(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un)); - RUNNER_ASSERT_MSG_BT(result == 0, "connect failed: " << strerror(errno)); + RUNNER_ASSERT_ERRNO_MSG(result == 0, "connect failed"); //Try getting label, should fail beacuse getsockopt won't get anything result = smack_new_label_from_socket(sock, &smack_label); - RUNNER_ASSERT_MSG_BT(result == -1, "smack_new_label_from_socket should fail."); + RUNNER_ASSERT_MSG(result == -1, "smack_new_label_from_socket should fail."); } } diff --git a/tests/security-manager-tests/common/sm_db.cpp b/tests/security-manager-tests/common/sm_db.cpp index 4bdc8bf..083b9ae 100644 --- a/tests/security-manager-tests/common/sm_db.cpp +++ b/tests/security-manager-tests/common/sm_db.cpp @@ -53,8 +53,8 @@ void TestSecurityManagerDatabase::test_db_after__app_install(const std::string & if (!m_base.is_open()) m_base.open(); - RUNNER_ASSERT_MSG_BT(!app_name.empty(), "Request is corrupted, appId is empty"); - RUNNER_ASSERT_MSG_BT(!pkg_name.empty(), "Request is corrupted, pkgId is empty"); + RUNNER_ASSERT_MSG(!app_name.empty(), "Request is corrupted, appId is empty"); + RUNNER_ASSERT_MSG(!pkg_name.empty(), "Request is corrupted, pkgId is empty"); check_app_and_pkg(app_name, pkg_name, NOT_REMOVED); @@ -80,8 +80,8 @@ void TestSecurityManagerDatabase::test_db_after__app_uninstall(const std::string if (!m_base.is_open()) m_base.open(); - RUNNER_ASSERT_MSG_BT(!app_name.empty(), "Request is corrupted, appId is empty"); - RUNNER_ASSERT_MSG_BT(!pkg_name.empty(), "Request is corrupted, pkgId is empty"); + RUNNER_ASSERT_MSG(!app_name.empty(), "Request is corrupted, appId is empty"); + RUNNER_ASSERT_MSG(!pkg_name.empty(), "Request is corrupted, pkgId is empty"); check_app_and_pkg(app_name, pkg_name, REMOVED); check_pkg(pkg_name, is_pkg_removed); @@ -97,13 +97,13 @@ void TestSecurityManagerDatabase::check_privileges(const std::string &app_name, { bool result; - RUNNER_ASSERT_MSG_BT(!app_name.empty(), "Request is corrupted, appId is empty"); - RUNNER_ASSERT_MSG_BT(!pkg_name.empty(), "Request is corrupted, pkgId is empty"); + RUNNER_ASSERT_MSG(!app_name.empty(), "Request is corrupted, appId is empty"); + RUNNER_ASSERT_MSG(!pkg_name.empty(), "Request is corrupted, pkgId is empty"); for (auto it = privileges.begin(); it != privileges.end(); ++it) { result = check_privilege(app_name, pkg_name, *it); - RUNNER_ASSERT_MSG_BT(result == true, "privilege: <" << *it << "> not added to app: <" << + RUNNER_ASSERT_MSG(result == true, "privilege: <" << *it << "> not added to app: <" << app_name << "> from pkg_id: <" << pkg_name << ">"); } } @@ -114,13 +114,13 @@ void TestSecurityManagerDatabase::check_privileges_removed(const std::string &ap { bool result; - RUNNER_ASSERT_MSG_BT(!app_name.empty(), "Request is corrupted, appId is empty"); - RUNNER_ASSERT_MSG_BT(!pkg_name.empty(), "Request is corrupted, pkgId is empty"); + RUNNER_ASSERT_MSG(!app_name.empty(), "Request is corrupted, appId is empty"); + RUNNER_ASSERT_MSG(!pkg_name.empty(), "Request is corrupted, pkgId is empty"); for (auto it = privileges.begin(); it != privileges.end(); ++it) { result = check_privilege(app_name, pkg_name, *it); - RUNNER_ASSERT_MSG_BT(result == false, "privilege: <" << *it << "> not removed for app: <" << + RUNNER_ASSERT_MSG(result == false, "privilege: <" << *it << "> not removed for app: <" << app_name << "> from pkg_id: <" << pkg_name << ">"); } } @@ -136,10 +136,10 @@ void TestSecurityManagerDatabase::check_app_and_pkg(const std::string &app_name, m_base.execute(sql.str(), result); if (is_app_removed) /* expect 0 results */ - RUNNER_ASSERT_MSG_BT(result.rows.size() == 0, "query : <" << sql.str() << + RUNNER_ASSERT_MSG(result.rows.size() == 0, "query : <" << sql.str() << "> returned [" << result.rows.size() << "] rows, expected [0]"); else /* expect exactly 1 result with 2 columns */ - RUNNER_ASSERT_MSG_BT(result.rows.size() == 1 && result.rows[0].size() == 2, "query : <" << + RUNNER_ASSERT_MSG(result.rows.size() == 1 && result.rows[0].size() == 2, "query : <" << sql.str() << "> returned [" << result.rows.size() << "] rows, expected [1]"); } @@ -153,7 +153,7 @@ void TestSecurityManagerDatabase::check_pkg(const std::string &pkg_name, " WHERE name == '" << pkg_name << "' ;"; m_base.execute(sql.str(), result); - RUNNER_ASSERT_MSG_BT(result.rows.size() == expected_rows, "query : <" << + RUNNER_ASSERT_MSG(result.rows.size() == expected_rows, "query : <" << sql.str() << "> returned [" << result.rows.size() << "] rows, expected [" << expected_rows << "] rows"); } @@ -172,7 +172,7 @@ bool TestSecurityManagerDatabase::check_privilege(const std::string &app_name, m_base.execute(sql.str(), result); /* only 0 or 1 resulting rows are alowed */ - RUNNER_ASSERT_MSG_BT(result.rows.size() == 0 || result.rows.size() == 1, "query : <" << sql.str() << "> returned [" << + RUNNER_ASSERT_MSG(result.rows.size() == 0 || result.rows.size() == 1, "query : <" << sql.str() << "> returned [" << result.rows.size() << "] rows"); return result.rows.size() == 1; diff --git a/tests/security-manager-tests/security_manager_tests.cpp b/tests/security-manager-tests/security_manager_tests.cpp index ea9a430..6b63560 100644 --- a/tests/security-manager-tests/security_manager_tests.cpp +++ b/tests/security-manager-tests/security_manager_tests.cpp @@ -66,10 +66,10 @@ static bool isLinkToExec(const char *fpath, const struct stat *sb) return false; target = realpath(fpath, NULL); - RUNNER_ASSERT_MSG_BT(target != 0, "Could not obtain real path from link."); + RUNNER_ASSERT_ERRNO_MSG(target != 0, "Could not obtain real path from link"); ret = stat(target, &buf); - RUNNER_ASSERT_MSG_BT(ret == 0, "Could not obtain real path's stat from link."); + RUNNER_ASSERT_ERRNO_MSG(ret == 0, "Could not obtain real path's stat from link"); if (buf.st_mode != (buf.st_mode | S_IXUSR | S_IFREG)) return false; @@ -87,36 +87,35 @@ static int nftw_check_sm_labels_app_dir(const char *fpath, const struct stat *sb /* ACCESS */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); labelPtr.reset(label); - RUNNER_ASSERT_MSG_BT(label != NULL, "ACCESS label on " << fpath << " is not set"); + RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set"); result = strcmp(correctLabel, label); - RUNNER_ASSERT_MSG_BT(result == 0, "ACCESS label on " << fpath << " is incorrect" + RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect" " (should be '" << correctLabel << "' and is '" << label << "')"); /* EXEC */ result = smack_lgetlabel(fpath, &label, SMACK_LABEL_EXEC); - RUNNER_ASSERT_MSG_BT(result == 0, "Could not get label for the path"); + RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path"); labelPtr.reset(label); if (S_ISREG(sb->st_mode) && (sb->st_mode & S_IXUSR) && exec_test) { - RUNNER_ASSERT_MSG_BT(label != NULL, "EXEC label on " << fpath << " is not set"); + RUNNER_ASSERT_MSG(label != NULL, "EXEC label on " << fpath << " is not set"); result = strcmp(correctLabel, label); - RUNNER_ASSERT_MSG_BT(result == 0, "Incorrect EXEC label on executable file " << fpath); + RUNNER_ASSERT_MSG(result == 0, "Incorrect EXEC label on executable file " << fpath); } else - RUNNER_ASSERT_MSG_BT(label == NULL, "EXEC label on " << fpath << " is set"); + RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set"); /* LINK TO EXEC */ if (isLinkToExec(fpath, sb) && exec_test) { char buf[SMACK_LABEL_LEN+1]; result = lgetxattr(fpath, XATTR_NAME_TIZENEXEC, buf, sizeof(buf)); - RUNNER_ASSERT_MSG_BT(result != -1, "Could not get label for the path " - << fpath << "("<st_mode) && transmute_test == true) { - RUNNER_ASSERT_MSG_BT(label != NULL, "TRANSMUTE label on " << fpath << " is not set at all"); - RUNNER_ASSERT_MSG_BT(strcmp(label,"TRUE") == 0, + RUNNER_ASSERT_MSG(label != NULL, "TRANSMUTE label on " << fpath << " is not set at all"); + RUNNER_ASSERT_MSG(strcmp(label,"TRUE") == 0, "TRANSMUTE label on " << fpath << " is not set properly: '"<= 0, + RUNNER_ASSERT_MSG(result >= 0, " Error getting current process label"); - RUNNER_ASSERT_MSG_BT(label != NULL, + RUNNER_ASSERT_MSG(label != NULL, " Process label is not set"); labelPtr.reset(label); result = strcmp(expectedLabel, label); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, " Process label is incorrect. Expected: \"" << expectedLabel << "\" Actual: \"" << label << "\""); } @@ -450,7 +449,7 @@ RUNNER_CHILD_TEST_NOSMACK(security_manager_03_set_label_from_binary_nosmack) int result; result = security_manager_set_process_label_from_binary(testBinaryPath); - RUNNER_ASSERT_MSG_BT(result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS, "security_manager_set_process_label_from_binary(" << testBinaryPath << ") failed. Result: " << result); } @@ -468,19 +467,19 @@ RUNNER_CHILD_TEST_SMACK(security_manager_04_set_label_from_appid) install_app(app_id, pkg_id); result = security_manager_set_process_label_from_appid(app_id); - RUNNER_ASSERT_MSG_BT(result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS, "security_manager_set_process_label_from_appid(" << app_id << ") failed. Result: " << result); result = smack_new_label_from_self(&label); - RUNNER_ASSERT_MSG_BT(result >= 0, + RUNNER_ASSERT_MSG(result >= 0, " Error getting current process label"); - RUNNER_ASSERT_MSG_BT(label != NULL, + RUNNER_ASSERT_MSG(label != NULL, " Process label is not set"); labelPtr.reset(label); result = strcmp(expected_label, label); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, " Process label is incorrect. Expected: \"" << expected_label << "\" Actual: \"" << label << "\""); @@ -497,7 +496,7 @@ RUNNER_CHILD_TEST_NOSMACK(security_manager_04_set_label_from_appid_nosmack) install_app(app_id, pkg_id); result = security_manager_set_process_label_from_appid(app_id); - RUNNER_ASSERT_MSG_BT(result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG(result == SECURITY_MANAGER_SUCCESS, "security_manager_set_process_label_from_appid(" << app_id << ") failed. Result: " << result); @@ -516,15 +515,15 @@ static void prepare_request(AppInstReqUniquePtr &request, request.reset(do_app_inst_req_new()); result = security_manager_app_inst_req_set_app_id(request.get(), app_id); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS, "setting app id failed. Result: " << result); result = security_manager_app_inst_req_set_pkg_id(request.get(), pkg_id); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS, "setting pkg id failed. Result: " << result); result = security_manager_app_inst_req_add_path(request.get(), path, pathType); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS, "setting allowed path failed. Result: " << result); } @@ -539,13 +538,13 @@ RUNNER_CHILD_TEST(security_manager_05_app_install_uninstall_by_uid_5000) //switch user to non-root result = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(result == 0, "drop_root_privileges failed"); + RUNNER_ASSERT_MSG(result == 0, "drop_root_privileges failed"); //install app as non-root user and try to register public path (should fail) prepare_request(request, SM_APP_ID3, SM_PKG_ID3, SECURITY_MANAGER_PATH_PUBLIC, SM_PRIVATE_PATH_FOR_USER_5000); result = security_manager_app_install(request.get()); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED, "installing app not failed. Result: " << result); //install app as non-root user @@ -553,7 +552,7 @@ RUNNER_CHILD_TEST(security_manager_05_app_install_uninstall_by_uid_5000) prepare_request(request, SM_APP_ID3, SM_PKG_ID3, SECURITY_MANAGER_PATH_PRIVATE, SM_PRIVATE_PATH); result = security_manager_app_install(request.get()); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_ERROR_AUTHENTICATION_FAILED, "installing app not failed. Result: " << result); //install app as non-root user @@ -562,12 +561,12 @@ RUNNER_CHILD_TEST(security_manager_05_app_install_uninstall_by_uid_5000) for (auto &privilege : SM_ALLOWED_PRIVILEGES) { result = security_manager_app_inst_req_add_privilege(request.get(), privilege.c_str()); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS, "setting allowed permission failed. Result: " << result); } result = security_manager_app_install(request.get()); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS, "installing app failed. Result: " << result); check_app_permissions(SM_APP_ID3, SM_PKG_ID3, user.c_str(), SM_ALLOWED_PRIVILEGES, SM_DENIED_PRIVILEGES); @@ -576,11 +575,11 @@ RUNNER_CHILD_TEST(security_manager_05_app_install_uninstall_by_uid_5000) request.reset(do_app_inst_req_new()); result = security_manager_app_inst_req_set_app_id(request.get(), SM_APP_ID3); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS, "setting app id failed. Result: " << result); result = security_manager_app_uninstall(request.get()); - RUNNER_ASSERT_MSG_BT((lib_retcode)result == SECURITY_MANAGER_SUCCESS, + RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS, "uninstalling app failed. Result: " << result); check_app_permissions(SM_APP_ID3, SM_PKG_ID3, user.c_str(), SM_NO_PRIVILEGES, SM_ALLOWED_PRIVILEGES); diff --git a/tests/security-server-tests/common/security_server_tests_common.cpp b/tests/security-server-tests/common/security_server_tests_common.cpp index 838ccb9..cd54523 100644 --- a/tests/security-server-tests/common/security_server_tests_common.cpp +++ b/tests/security-server-tests/common/security_server_tests_common.cpp @@ -28,7 +28,7 @@ const unsigned int PASSWORD_RETRY_TIMEOUT_US = 500000; Cookie getCookieFromSS() { Cookie cookie(security_server_get_cookie_size()); - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_SUCCESS == + RUNNER_ASSERT_MSG(SECURITY_SERVER_API_SUCCESS == security_server_request_cookie(cookie.data(), cookie.size()), "Error in security_server_request_cookie."); diff --git a/tests/security-server-tests/cookie_api.cpp b/tests/security-server-tests/cookie_api.cpp index cebf374..e6332d6 100644 --- a/tests/security-server-tests/cookie_api.cpp +++ b/tests/security-server-tests/cookie_api.cpp @@ -57,7 +57,7 @@ RUNNER_TEST_GROUP_INIT(COOKIE_API_TESTS) RUNNER_CHILD_TEST(tc_arguments_01_01_security_server_request_cookie) { int ret = security_server_request_cookie(NULL, KNOWN_COOKIE_SIZE); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "Error in security_server_request_cookie() argument checking: " << ret); } @@ -67,7 +67,7 @@ RUNNER_CHILD_TEST(tc_arguments_01_02_security_server_request_cookie) Cookie cookie(KNOWN_COOKIE_SIZE); int ret = security_server_request_cookie(cookie.data(), KNOWN_COOKIE_SIZE - 1); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL, "Error in security_server_request_cookie() argument checking: " << ret); } @@ -76,7 +76,7 @@ RUNNER_CHILD_TEST(tc_arguments_01_02_security_server_request_cookie) RUNNER_CHILD_TEST(tc_arguments_02_01_security_server_check_privilege) { int ret = security_server_check_privilege(NULL, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "Error in security_server_check_privilege() argument checking: " << ret); } @@ -86,7 +86,7 @@ RUNNER_CHILD_TEST(tc_arguments_03_01_security_server_check_privilege_by_cookie) { RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success"); int ret = security_server_check_privilege_by_cookie(NULL, "wiadro", "rwx"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "Error in security_server_check_privilege_by_cookie() argument checking: " << ret); } @@ -98,7 +98,7 @@ RUNNER_CHILD_TEST(tc_arguments_03_02_security_server_check_privilege_by_cookie) Cookie cookie = getCookieFromSS(); int ret = security_server_check_privilege_by_cookie(cookie.data(), NULL, "rwx"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "Error in security_server_check_privilege_by_cookie() argument checking: " << ret); } @@ -110,7 +110,7 @@ RUNNER_CHILD_TEST(tc_arguments_03_03_security_server_check_privilege_by_cookie) Cookie cookie = getCookieFromSS(); int ret = security_server_check_privilege_by_cookie(cookie.data(), "wiadro", NULL); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "Error in security_server_check_privilege_by_cookie() argument checking: " << ret); } @@ -120,7 +120,7 @@ RUNNER_CHILD_TEST(tc_arguments_03_03_security_server_check_privilege_by_cookie) RUNNER_CHILD_TEST(tc_arguments_04_01_security_server_get_cookie_pid) { int ret = security_server_get_cookie_pid(NULL); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "Error in security_server_get_cookie_pid() argument checking: " << ret); } @@ -128,7 +128,7 @@ RUNNER_CHILD_TEST(tc_arguments_04_01_security_server_get_cookie_pid) RUNNER_TEST(tc_arguments_04_02_security_server_get_cookie_pid) { const char wrong_cookie[KNOWN_COOKIE_SIZE] = {'w', 'a', 't', '?'}; - RUNNER_ASSERT_BT(security_server_get_cookie_pid(wrong_cookie) == + RUNNER_ASSERT(security_server_get_cookie_pid(wrong_cookie) == SECURITY_SERVER_API_ERROR_NO_SUCH_COOKIE); } @@ -138,7 +138,7 @@ RUNNER_CHILD_TEST(tc_arguments_05_01_security_server_get_smacklabel_cookie) { char *label = NULL; label = security_server_get_smacklabel_cookie(NULL); - RUNNER_ASSERT_MSG_BT(label == NULL, + RUNNER_ASSERT_MSG(label == NULL, "Error in security_server_get_smacklabel_cookie() argument checking"); } @@ -155,7 +155,7 @@ RUNNER_CHILD_TEST(tc_arguments_05_01_security_server_get_smacklabel_cookie) RUNNER_CHILD_TEST(tc_unit_01_01_security_server_get_cookie_size) { int ret = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(ret == KNOWN_COOKIE_SIZE, + RUNNER_ASSERT_MSG(ret == KNOWN_COOKIE_SIZE, "Error in security_server_get_cookie_size(): " << ret); } @@ -166,10 +166,10 @@ RUNNER_CHILD_TEST_NOSMACK(tc_unit_01_02_app_user_security_server_get_cookie_size int ret; ret = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(ret == 0, + RUNNER_ASSERT_MSG(ret == 0, "Failed to drop root privileges. Result: " << ret << "uid = " << getuid()); ret = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(ret == KNOWN_COOKIE_SIZE, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == KNOWN_COOKIE_SIZE, "ret = " << ret); } //--------------------------------------------------------------------------- @@ -181,11 +181,11 @@ RUNNER_CHILD_TEST_NOSMACK(tc_unit_01_03_app_user_security_server_request_cookie_ Cookie cookie(cookieSize); ret = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(ret == 0, + RUNNER_ASSERT_MSG(ret == 0, "Failed to drop root privileges. Result: " << ret << "uid = " << getuid()); ret = security_server_request_cookie(cookie.data(), KNOWN_COOKIE_SIZE); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } //--------------------------------------------------------------------------- @@ -198,11 +198,11 @@ RUNNER_CHILD_TEST_NOSMACK(tc_init_01_04_app_user_security_server_request_cookie_ Cookie cookie(cookieSize); ret = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(ret == 0, + RUNNER_ASSERT_MSG(ret == 0, "Failed to drop root privileges. Result: " << ret << "uid = " << getuid()); ret = security_server_request_cookie(cookie.data(), KNOWN_COOKIE_SIZE >> 1); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL, "ret = " << ret); } //--------------------------------------------------------------------------- @@ -213,7 +213,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_01_05_app_user_security_server_get_cookie_size) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(ret == KNOWN_COOKIE_SIZE, + RUNNER_ASSERT_MSG(ret == KNOWN_COOKIE_SIZE, "Error in security_server_get_cookie_size(): " << ret); } @@ -222,12 +222,12 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_01_05_app_user_security_server_get_cookie_size) RUNNER_CHILD_TEST(tc_unit_02_01_security_server_request_cookie) { int cookieSize = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(cookieSize == KNOWN_COOKIE_SIZE, + RUNNER_ASSERT_MSG(cookieSize == KNOWN_COOKIE_SIZE, "Error in security_server_get_cookie_size(): " << cookieSize); Cookie cookie(cookieSize); int ret = security_server_request_cookie(cookie.data(), cookie.size()); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "Error in security_server_request_cookie(): " << ret); } @@ -236,7 +236,7 @@ RUNNER_CHILD_TEST(tc_unit_02_01_security_server_request_cookie) RUNNER_CHILD_TEST_SMACK(tc_unit_02_02_app_user_security_server_request_cookie) { int cookieSize = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(cookieSize == KNOWN_COOKIE_SIZE, + RUNNER_ASSERT_MSG(cookieSize == KNOWN_COOKIE_SIZE, "Error in security_server_get_cookie_size(): " << cookieSize); SecurityServer::AccessProvider provider("selflabel_02_01"); @@ -245,7 +245,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_02_02_app_user_security_server_request_cookie) Cookie cookie(cookieSize); int ret = security_server_request_cookie(cookie.data(), cookie.size()); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "Error in security_server_request_cookie(): " << ret); } @@ -255,7 +255,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_02_02_app_user_security_server_request_cookie) RUNNER_CHILD_TEST_SMACK(tc_unit_02_03_app_user_security_server_request_cookie_too_small_buffer_size) { int cookieSize = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(cookieSize == KNOWN_COOKIE_SIZE, + RUNNER_ASSERT_MSG(cookieSize == KNOWN_COOKIE_SIZE, "Error in security_server_get_cookie_size(): " << cookieSize); cookieSize >>= 1; @@ -264,7 +264,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_02_03_app_user_security_server_request_cookie_to Cookie cookie(cookieSize); int ret = security_server_request_cookie(cookie.data(), cookie.size()); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL, "Error in security_server_request_cookie(): " << ret); } @@ -275,7 +275,7 @@ RUNNER_CHILD_TEST(tc_unit_03_01_security_server_check_privilege) Cookie cookie = getCookieFromSS(); int ret = security_server_check_privilege(cookie.data(), 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "Error in security_server_check_privilege(): " << ret); } @@ -288,7 +288,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_03_02_app_user_security_server_check_privilege) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = security_server_check_privilege(cookie.data(), 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "security_server_check_privilege() should return access denied: " << ret); } @@ -302,7 +302,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_03_03_app_user_security_server_check_privilege) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = security_server_check_privilege(cookie.data(), 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "Error in security_server_check_privilege(): " << ret); } @@ -313,13 +313,13 @@ RUNNER_CHILD_TEST(tc_unit_03_04_security_server_check_privilege_neg) Cookie cookie = getCookieFromSS(); int audio_gid = security_server_get_gid(PROC_AUDIO_GROUP_NAME); - RUNNER_ASSERT_MSG_BT(audio_gid > -1, + RUNNER_ASSERT_MSG(audio_gid > -1, "security_server_get_gid() failed. result = " << audio_gid); int ret = security_server_check_privilege(cookie.data(), audio_gid); // security_server_check_privilege fails, because the process does not belong to "audio" group - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); } // add gid @@ -329,11 +329,11 @@ RUNNER_CHILD_TEST(tc_unit_03_05_security_server_check_privilege) Cookie cookie = getCookieFromSS(); int audio_gid = security_server_get_gid(PROC_AUDIO_GROUP_NAME); - RUNNER_ASSERT_MSG_BT(audio_gid > -1, + RUNNER_ASSERT_MSG(audio_gid > -1, "security_server_get_gid() failed. result = " << audio_gid); int ret = security_server_check_privilege(cookie.data(), audio_gid); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); } // test invalid cookie name @@ -341,12 +341,12 @@ RUNNER_TEST(tc_unit_03_06_security_server_check_privilege) { // create invalid cookie int size = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(size == KNOWN_COOKIE_SIZE, "Wrong cookie size. size = " << size); + RUNNER_ASSERT_MSG(size == KNOWN_COOKIE_SIZE, "Wrong cookie size. size = " << size); Cookie cookie(size); cookie[0] = 'a'; int ret = security_server_check_privilege(cookie.data(), 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); } //--------------------------------------------------------------------------- @@ -356,10 +356,10 @@ RUNNER_CHILD_TEST(tc_unit_05_01_security_server_get_cookie_pid) Cookie cookie = getCookieFromSS(); int ret = security_server_get_cookie_pid(cookie.data()); - RUNNER_ASSERT_MSG_BT(ret > -1, "Error in security_server_get_cookie_pid(): " << ret); + RUNNER_ASSERT_MSG(ret > -1, "Error in security_server_get_cookie_pid(): " << ret); int pid = getpid(); - RUNNER_ASSERT_MSG_BT(pid == ret, "No match in PID received from cookie"); + RUNNER_ASSERT_MSG(pid == ret, "No match in PID received from cookie"); } //privileges drop and no smack rule @@ -371,7 +371,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_05_02_app_user_security_server_get_cookie_pid) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = security_server_get_cookie_pid(cookie.data()); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "security_server_get_cookie_pid() should return access denied: " << ret); } @@ -385,10 +385,10 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_05_03_app_user_security_server_get_cookie_pid) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = security_server_get_cookie_pid(cookie.data()); - RUNNER_ASSERT_MSG_BT(ret > -1, "Error in security_server_get_cookie_pid(): " << ret); + RUNNER_ASSERT_MSG(ret > -1, "Error in security_server_get_cookie_pid(): " << ret); int pid = getpid(); - RUNNER_ASSERT_MSG_BT(pid == ret, "No match in PID received from cookie"); + RUNNER_ASSERT_MSG(pid == ret, "No match in PID received from cookie"); } //--------------------------------------------------------------------------- @@ -400,7 +400,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_06_01_security_server_get_smacklabel_cookie_smac Cookie cookie = getCookieFromSS(); CStringPtr label(security_server_get_smacklabel_cookie(cookie.data())); - RUNNER_ASSERT_MSG_BT(strcmp(label.get(), "selflabel_06_01") == 0, + RUNNER_ASSERT_MSG(strcmp(label.get(), "selflabel_06_01") == 0, "No match in smack label received from cookie, received label: " << label.get()); } @@ -412,11 +412,11 @@ RUNNER_CHILD_TEST_NOSMACK(tc_unit_06_01_security_server_get_smacklabel_cookie_no Cookie cookie = getCookieFromSS(); char *receivedLabel = security_server_get_smacklabel_cookie(cookie.data()); - RUNNER_ASSERT_MSG_BT(receivedLabel != NULL, + RUNNER_ASSERT_MSG(receivedLabel != NULL, "security_server_get_smacklabel_cookie returned NULL"); std::string label(receivedLabel); free(receivedLabel); - RUNNER_ASSERT_MSG_BT(label.empty(), + RUNNER_ASSERT_MSG(label.empty(), "security_server_get_smacklabel_cookie returned: " << label); } @@ -430,7 +430,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_06_02_app_user_security_server_get_smacklabel_co provider.applyAndSwithToUser(APP_UID, APP_GID); CStringPtr label(security_server_get_smacklabel_cookie(cookie.data())); - RUNNER_ASSERT_MSG_BT(label.get() == NULL, + RUNNER_ASSERT_MSG(label.get() == NULL, "NULL should be received due to access denied, received label: " << label.get()); } @@ -445,7 +445,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_06_03_app_user_security_server_get_smacklabel_co Cookie cookie = getCookieFromSS(); CStringPtr label(security_server_get_smacklabel_cookie(cookie.data())); - RUNNER_ASSERT_MSG_BT(strcmp(label.get(), "selflabel_06_03") == 0, + RUNNER_ASSERT_MSG(strcmp(label.get(), "selflabel_06_03") == 0, "No match in smack label received from cookie, received label: " << label.get()); } @@ -463,25 +463,25 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_09_01_app_user_cookie_API_access_allow) Cookie cookie = getCookieFromSS(); int ret = security_server_get_gid(PROC_AUDIO_GROUP_NAME); - RUNNER_ASSERT_MSG_BT(ret > -1, "Failed to get \"" << PROC_AUDIO_GROUP_NAME + RUNNER_ASSERT_MSG(ret > -1, "Failed to get \"" << PROC_AUDIO_GROUP_NAME << "\" gid. Result: " << ret); ret = security_server_check_privilege(cookie.data(), ret); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); int root_gid = security_server_get_gid(ROOT_USER); - RUNNER_ASSERT_MSG_BT(root_gid > -1, "root_gid: " << root_gid); + RUNNER_ASSERT_MSG(root_gid > -1, "root_gid: " << root_gid); ret = security_server_get_cookie_pid(cookie.data()); - RUNNER_ASSERT_MSG_BT(ret == getpid(), "ret: " << ret); + RUNNER_ASSERT_MSG(ret == getpid(), "ret: " << ret); CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data())); - RUNNER_ASSERT_MSG_BT(ss_label.get() != NULL, "ss_label: " << ss_label.get()); + RUNNER_ASSERT_MSG(ss_label.get() != NULL, "ss_label: " << ss_label.get()); RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success"); ret = security_server_check_privilege_by_pid(getpid(), "_", "rx"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); } // disable access and drop privileges @@ -494,28 +494,28 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_09_02_app_user_cookie_API_access_deny) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = security_server_check_privilege(cookie.data(), DB_ALARM_GID); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "security_server_check_privilege should return access denied, " "ret: " << ret); ret = security_server_get_gid(ROOT_USER); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "security_server_get_gid should return access denied, " "ret: " << ret); ret = security_server_get_cookie_pid(cookie.data()); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "security_server_get_cookie_pid should return access denied, " "ret: " << ret); CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data())); - RUNNER_ASSERT_MSG_BT(ss_label.get() == NULL, + RUNNER_ASSERT_MSG(ss_label.get() == NULL, "access should be denied so label should be NULL: " << ss_label.get()); RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success"); ret = security_server_check_privilege_by_pid(getpid(), "_", "rx"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "security_server_check_privilege_by_pid should return access denied, " "ret: " << ret); } @@ -527,32 +527,32 @@ RUNNER_CHILD_TEST_NOSMACK(tc_unit_09_01_app_user_cookie_API_access_allow_nosmack // drop root privileges int ret = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(ret == 0, + RUNNER_ASSERT_MSG(ret == 0, "Failed to drop root privileges. Result: " << ret << "uid = " << getuid()); Cookie cookie = getCookieFromSS(); ret = security_server_get_gid(PROC_AUDIO_GROUP_NAME); - RUNNER_ASSERT_MSG_BT(ret > -1, "Failed to get \"" << PROC_AUDIO_GROUP_NAME + RUNNER_ASSERT_MSG(ret > -1, "Failed to get \"" << PROC_AUDIO_GROUP_NAME << "\" gid. Result: " << ret); ret = security_server_check_privilege(cookie.data(), ret); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "check_privilege failed. Result: " << ret); ret = security_server_get_gid(ROOT_USER); - RUNNER_ASSERT_MSG_BT(ret > -1, "Failed to get \"root\" gid. Result: " << ret); + RUNNER_ASSERT_MSG(ret > -1, "Failed to get \"root\" gid. Result: " << ret); ret = security_server_get_cookie_pid(cookie.data()); - RUNNER_ASSERT_MSG_BT(ret == getpid(), + RUNNER_ASSERT_MSG(ret == getpid(), "get_cookie_pid returned different pid than it should. Result: " << ret); CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data())); - RUNNER_ASSERT_MSG_BT(ss_label.get() != NULL, "get_smacklabel_cookie failed."); + RUNNER_ASSERT_MSG(ss_label.get() != NULL, "get_smacklabel_cookie failed."); RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success"); ret = security_server_check_privilege_by_pid(getpid(), "_", "rx"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "check_privilege_by_pid failed. Result: " << ret); } diff --git a/tests/security-server-tests/security_server_measurer_API_speed.cpp b/tests/security-server-tests/security_server_measurer_API_speed.cpp index db42e3a..9d64994 100644 --- a/tests/security-server-tests/security_server_measurer_API_speed.cpp +++ b/tests/security-server-tests/security_server_measurer_API_speed.cpp @@ -116,7 +116,8 @@ int my_pipe_read(int fd, void *buf, size_t count) { ssize_t rest = count; ssize_t s; while (rest > 0) { - RUNNER_ASSERT_MSG_BT(0 < (s = TEMP_FAILURE_RETRY(read(fd, ((char*)buf) + readf, rest))), "Error in read from pipe"); + RUNNER_ASSERT_ERRNO_MSG(0 < (s = TEMP_FAILURE_RETRY(read(fd, ((char*)buf) + readf, rest))), + "Error in read from pipe"); rest -= s; readf += s; } @@ -134,7 +135,8 @@ int my_pipe_write(int fd, void *buf, size_t count) { ssize_t rest = count; ssize_t s; while (rest > 0) { - RUNNER_ASSERT_MSG_BT(0 <= (s = TEMP_FAILURE_RETRY(write(fd, ((char*)buf) + writef, rest))), "Error in write to pipe"); + RUNNER_ASSERT_ERRNO_MSG(0 <= (s = TEMP_FAILURE_RETRY(write(fd, ((char*)buf) + writef, rest))), + "Error in write to pipe"); rest -= s; writef += s; } @@ -165,7 +167,7 @@ int communication_succeeded(int result_code) { timeval my_gettime() { timeval t; int res = gettimeofday(&t, NULL); - RUNNER_ASSERT_MSG_BT(res == 0, "gettimeofday() returned error value: " << res); + RUNNER_ASSERT_ERRNO_MSG(res == 0, "gettimeofday() returned error value: " << res); return t; } @@ -272,13 +274,13 @@ RUNNER_TEST(m000_security_server_test_the_tests) { for (int i=0; i < NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = my_nanosecsleep((long) ((i+1)*QUANTUM*1000)); - RUNNER_ASSERT_MSG_BT(ret == 0, "system sleep function returned premature wake-up; ret = " << ret); + RUNNER_ASSERT_MSG(ret == 0, "system sleep function returned premature wake-up; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "my_nanosecsleep"); - RUNNER_ASSERT_MSG_BT((stats.average_duration>expected_avarage_min) && (stats.average_duration 0, "commmunication error"); + RUNNER_ASSERT_MSG(number_of_calls > 0, "commmunication error"); stats_update(&stats, number_of_calls, duration_of_calls); } /*parent*/ @@ -381,7 +383,7 @@ RUNNER_TEST(m040_security_server_get_cookie_size) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); cookie_size = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(cookie_size > 0, "cookie_size = " << cookie_size); + RUNNER_ASSERT_MSG(cookie_size > 0, "cookie_size = " << cookie_size); end_stats_update(&stats); } finish_stats(&stats, "security_server_get_cookie_size"); @@ -404,7 +406,7 @@ RUNNER_TEST(m050_security_server_check_privilege) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_check_privilege(recved_cookie, (gid_t)call_gid); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_check_privilege"); @@ -423,7 +425,7 @@ void testSecurityServerCheckPrivilegeByCookie(bool smack) { SmackAccess smackAccess; smackAccess.add(subject_label, object_label, access_rights); smackAccess.apply(); - RUNNER_ASSERT_MSG_BT(0 == (ret = smack_set_label_for_self(subject_label)), + RUNNER_ASSERT_MSG(0 == (ret = smack_set_label_for_self(subject_label)), "Error in smack_set_label_for_self(); ret = " << ret); } @@ -443,7 +445,7 @@ void testSecurityServerCheckPrivilegeByCookie(bool smack) { object_label, access_rights_ext); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_check_privilege_by_cookie"); @@ -479,23 +481,24 @@ void testSecurityServerCheckPrivilegeBySockfd(bool smack) { } int pid = fork(); - RUNNER_ASSERT_BT(-1 != pid); + RUNNER_ASSERT_ERRNO(-1 != pid); if (0 == pid) { // child int sockfd = create_new_socket(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed"); + RUNNER_ASSERT_MSG(sockfd >= 0, "create_new_socket() failed"); SockUniquePtr sockfd_ptr(&sockfd); if (smack) - RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set"); + RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set"); - RUNNER_ASSERT_MSG_BT(listen(sockfd, 5) >= 0, "child listen failed"); + RUNNER_ASSERT_ERRNO_MSG(listen(sockfd, 5) >= 0, "child listen failed"); struct sockaddr_un client_addr; socklen_t client_len = sizeof(client_addr); int csockfd; - RUNNER_ASSERT_MSG_BT((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, "child accept failed"); + RUNNER_ASSERT_ERRNO_MSG((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, + "child accept failed"); close(csockfd); exit(EXIT_SUCCESS); @@ -504,7 +507,7 @@ void testSecurityServerCheckPrivilegeBySockfd(bool smack) { //parent sleep(2); int sockfd = connect_to_testserver(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "connect_to_testserver() failed"); + RUNNER_ASSERT_MSG(sockfd >= 0, "connect_to_testserver() failed"); SockUniquePtr sockfd_ptr(&sockfd); @@ -521,7 +524,7 @@ void testSecurityServerCheckPrivilegeBySockfd(bool smack) { sockfd, object_label, access_rights); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } @@ -552,13 +555,13 @@ RUNNER_TEST(m080_security_server_get_cookie_pid) { cookie_size = security_server_get_cookie_size(); char cookie[cookie_size]; ret = security_server_request_cookie(cookie, cookie_size); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "security_server_request_cookie failed; ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "security_server_request_cookie failed; ret = " << ret); readwrite_stats stats; initialize_stats(&stats); for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_get_cookie_pid(cookie); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_request_cookie"); @@ -575,7 +578,7 @@ RUNNER_TEST(m090_security_server_is_pwd_valid) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_is_pwd_valid"); @@ -591,7 +594,7 @@ RUNNER_TEST(m100_security_server_set_pwd) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_set_pwd("this_is_current_pwd", "this_is_new_pwd", 20, 365); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_set_pwd"); @@ -607,7 +610,7 @@ RUNNER_TEST(m110_security_server_set_pwd_validity) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_set_pwd_validity(2); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_set_pwd_validity"); @@ -623,7 +626,7 @@ RUNNER_TEST(m120_security_server_set_pwd_max_challenge) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_set_pwd_max_challenge(3); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_set_pwd_max_challenge"); @@ -639,7 +642,7 @@ RUNNER_TEST(m130_security_server_reset_pwd) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_reset_pwd("apud", 1, 2); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_reset_pwd"); @@ -656,7 +659,7 @@ RUNNER_TEST(m140_security_server_chk_pwd) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_chk_pwd("is_this_password", &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_chk_pwd"); @@ -672,7 +675,7 @@ RUNNER_TEST(m150_security_server_set_pwd_history) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_set_pwd_history(100); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_set_pwd_history"); @@ -690,7 +693,7 @@ RUNNER_TEST(m160_security_server_app_give_access) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_app_give_access(customer_label, customer_pid); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_app_give_access"); @@ -711,7 +714,7 @@ RUNNER_TEST(m170_security_server_check_privilege_by_pid) { for (int i = 1; i <= NUMBER_OF_CALLS; i++) { start_stats_update(&stats); ret = security_server_check_privilege_by_pid(pid, object, access_rights); - RUNNER_ASSERT_MSG_BT(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); + RUNNER_ASSERT_MSG(communication_succeeded(ret) == 0, "commmunication error; ret = " << ret); end_stats_update(&stats); } finish_stats(&stats, "security_server_check_privilege_by_pid"); diff --git a/tests/security-server-tests/security_server_tests_client_smack.cpp b/tests/security-server-tests/security_server_tests_client_smack.cpp index 2e3b940..4f9b1e1 100644 --- a/tests/security-server-tests/security_server_tests_client_smack.cpp +++ b/tests/security-server-tests/security_server_tests_client_smack.cpp @@ -55,10 +55,10 @@ RUNNER_CHILD_TEST_SMACK(tc04_security_server_get_gid) int ret = security_server_get_gid("abc123xyz_pysiaczek"); LogDebug("ret = " << ret); - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT == ret, "Ret: " << ret); + RUNNER_ASSERT_MSG(SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT == ret, "Ret: " << ret); ret = security_server_get_gid("root"); LogDebug("ret = " << ret); - RUNNER_ASSERT_MSG_BT(0 == ret, "Ret: " << ret); + RUNNER_ASSERT_MSG(0 == ret, "Ret: " << ret); } /* @@ -83,16 +83,16 @@ RUNNER_CHILD_TEST_SMACK(tc05_check_privilege_by_cookie) provider.addObjectRule(object_label, access_rights); provider.applyAndSwithToUser(APP_UID, APP_GID); - RUNNER_ASSERT_BT(SECURITY_SERVER_API_SUCCESS == + RUNNER_ASSERT(SECURITY_SERVER_API_SUCCESS == security_server_request_cookie(cookie,20)); - RUNNER_ASSERT_BT(SECURITY_SERVER_API_SUCCESS == + RUNNER_ASSERT(SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie( cookie, object_label, access_rights)); - RUNNER_ASSERT_BT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == + RUNNER_ASSERT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == security_server_check_privilege_by_cookie( cookie, object_label, @@ -118,45 +118,46 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc06_check_privilege_by_sockfd) int result2 = -1; smack_accesses *handle; - RUNNER_ASSERT_BT(0 == smack_accesses_new(&handle)); - RUNNER_ASSERT_BT(0 == smack_accesses_add(handle, + RUNNER_ASSERT(0 == smack_accesses_new(&handle)); + RUNNER_ASSERT(0 == smack_accesses_add(handle, subject_label, object_label, access_rights)); - RUNNER_ASSERT_BT(0 == smack_accesses_apply(handle)); + RUNNER_ASSERT(0 == smack_accesses_apply(handle)); smack_accesses_free(handle); int pid = fork(); char *label; - RUNNER_ASSERT_BT(-1 != pid); + RUNNER_ASSERT_ERRNO(-1 != pid); if (0 == pid) { // child - RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set"); + RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set"); int sockfd = create_new_socket(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed"); + RUNNER_ASSERT_MSG(sockfd >= 0, "create_new_socket() failed"); SockUniquePtr sockfd_ptr(&sockfd); label = security_server_get_smacklabel_sockfd(sockfd); - RUNNER_ASSERT_MSG_BT(label != NULL, "security_server_get_smacklabel_sockfd failed"); - RUNNER_ASSERT_MSG_BT(strcmp(label,"") == 0, "label is \"" << label << "\""); + RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed"); + RUNNER_ASSERT_MSG(strcmp(label,"") == 0, "label is \"" << label << "\""); free(label); - RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid()); + RUNNER_ASSERT_MSG(drop_root_privileges() == 0, "uid = " << getuid()); - RUNNER_ASSERT_MSG_BT(listen(sockfd, 5) >= 0, "child listen failed"); + RUNNER_ASSERT_ERRNO_MSG(listen(sockfd, 5) >= 0, "child listen failed"); label = security_server_get_smacklabel_sockfd(sockfd); - RUNNER_ASSERT_MSG_BT(label != NULL, "security_server_get_smacklabel_sockfd failed"); - RUNNER_ASSERT_MSG_BT(strcmp(label,"") == 0, "label is \"" << label << "\""); + RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed"); + RUNNER_ASSERT_MSG(strcmp(label,"") == 0, "label is \"" << label << "\""); free(label); struct sockaddr_un client_addr; socklen_t client_len = sizeof(client_addr); int csockfd; - RUNNER_ASSERT_MSG_BT((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, "child accept failed"); + RUNNER_ASSERT_ERRNO_MSG((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, + "child accept failed"); usleep(500); @@ -166,13 +167,13 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc06_check_privilege_by_sockfd) // parent sleep(1); int sockfd = connect_to_testserver(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "connect_to_testserver() failed"); + RUNNER_ASSERT_MSG(sockfd >= 0, "connect_to_testserver() failed"); SockUniquePtr sockfd_ptr(&sockfd); label = security_server_get_smacklabel_sockfd(sockfd); - RUNNER_ASSERT_MSG_BT(label != NULL, "security_server_get_smacklabel_sockfd failed"); - RUNNER_ASSERT_MSG_BT(strcmp(label,subject_label) == 0, "label is \"" << label << "\"" << ", subject_label is \"" << subject_label << "\"" ); + RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed"); + RUNNER_ASSERT_MSG(strcmp(label,subject_label) == 0, "label is \"" << label << "\"" << ", subject_label is \"" << subject_label << "\"" ); free(label); result1 = security_server_check_privilege_by_sockfd( @@ -185,8 +186,8 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc06_check_privilege_by_sockfd) access_rights_ext); } - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_SUCCESS == result1, "result = " << result1); - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == result2, "result = " << result2); + RUNNER_ASSERT_MSG(SECURITY_SERVER_API_SUCCESS == result1, "result = " << result1); + RUNNER_ASSERT_MSG(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == result2, "result = " << result2); } /* @@ -215,25 +216,25 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc07_check_privilege_by_sockfd) access.apply(); int pid = fork(); - RUNNER_ASSERT_BT(-1 != pid); + RUNNER_ASSERT_ERRNO(-1 != pid); if (0 == pid) { pid = fork(); - RUNNER_ASSERT_BT(-1 != pid); + RUNNER_ASSERT_ERRNO(-1 != pid); if (0 == pid) { // child int sockfd = create_new_socket(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed"); + RUNNER_ASSERT_MSG(sockfd >= 0, "create_new_socket() failed"); SockUniquePtr sockfd_ptr(&sockfd); - RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set"); + RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set"); - RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid()); + RUNNER_ASSERT_MSG(drop_root_privileges() == 0, "uid = " << getuid()); - RUNNER_ASSERT_MSG_BT(listen(sockfd, 5) >= 0, "child listen failed"); + RUNNER_ASSERT_ERRNO_MSG(listen(sockfd, 5) >= 0, "child listen failed"); struct sockaddr_un client_addr; socklen_t client_len = sizeof(client_addr); @@ -246,7 +247,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc07_check_privilege_by_sockfd) // parent sleep(1); int sockfd = connect_to_testserver(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "connect_to_testserver() failed"); + RUNNER_ASSERT_MSG(sockfd >= 0, "connect_to_testserver() failed"); result1 = security_server_check_privilege_by_sockfd( sockfd, @@ -259,8 +260,8 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc07_check_privilege_by_sockfd) close(sockfd); - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_SUCCESS == result1, "result1 = " << result1); - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == result2, " result2 = " << result2); + RUNNER_ASSERT_MSG(SECURITY_SERVER_API_SUCCESS == result1, "result1 = " << result1); + RUNNER_ASSERT_MSG(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == result2, " result2 = " << result2); } } } @@ -274,13 +275,13 @@ RUNNER_CHILD_TEST_NOSMACK(tc04_security_server_get_gid_nosmack) int ret; ret = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(ret == 0, + RUNNER_ASSERT_MSG(ret == 0, "Failed to drop root privileges. Result: " << ret << "uid = " << getuid()); ret = security_server_get_gid("definitely_not_existing_object"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT, "ret = " << ret); ret = security_server_get_gid("root"); - RUNNER_ASSERT_MSG_BT(ret == 0, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == 0, "ret = " << ret); } /* @@ -296,16 +297,16 @@ RUNNER_CHILD_TEST_NOSMACK(tc05_check_privilege_by_cookie_nosmack) char cookie[20]; const char* object_label = "tc05objectlabel"; - RUNNER_ASSERT_BT(security_server_request_cookie(cookie,20) == SECURITY_SERVER_API_SUCCESS); + RUNNER_ASSERT(security_server_request_cookie(cookie,20) == SECURITY_SERVER_API_SUCCESS); - RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid()); + RUNNER_ASSERT_MSG(drop_root_privileges() == 0, "uid = " << getuid()); - RUNNER_ASSERT_BT(SECURITY_SERVER_API_SUCCESS == + RUNNER_ASSERT(SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, object_label, "r")); //On NOSMACK env security server should return success on any accesses, even those that are //incorrect. - RUNNER_ASSERT_BT(SECURITY_SERVER_API_SUCCESS == + RUNNER_ASSERT(SECURITY_SERVER_API_SUCCESS == security_server_check_privilege_by_cookie(cookie, object_label, "rw")); } @@ -333,33 +334,34 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc06_check_privilege_by_sockfd_nosmack) int pid = fork(); char* label; - RUNNER_ASSERT_BT(pid >= 0); + RUNNER_ASSERT_ERRNO(pid >= 0); int ret; if (pid == 0) { //child process - server //create new socket int sockfd = create_new_socket(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed"); + RUNNER_ASSERT_MSG(sockfd >= 0, "create_new_socket() failed"); SockUniquePtr sockfd_ptr(&sockfd); //check if get_smacklabel_sockfd works correctly label = security_server_get_smacklabel_sockfd(sockfd); - RUNNER_ASSERT_MSG_BT(label != NULL, "security_server_get_smacklabel_sockfd failed"); + RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed"); ret = strcmp(label, ""); free(label); - RUNNER_ASSERT_MSG_BT(ret == 0, "label is \"" << label << "\""); + RUNNER_ASSERT_MSG(ret == 0, "label is \"" << label << "\""); - RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid()); + RUNNER_ASSERT_MSG(drop_root_privileges() == 0, "uid = " << getuid()); - RUNNER_ASSERT_MSG_BT(listen(sockfd, 5) >= 0, "child listen failed"); + RUNNER_ASSERT_ERRNO_MSG(listen(sockfd, 5) >= 0, "child listen failed"); struct sockaddr_un client_addr; socklen_t client_len = sizeof(client_addr); int csockfd; - RUNNER_ASSERT_MSG_BT((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, "child accept failed"); + RUNNER_ASSERT_ERRNO_MSG((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, + "child accept failed"); //wait a little bit for parent to do it's job usleep(200); @@ -371,22 +373,22 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc06_check_privilege_by_sockfd_nosmack) //parent sleep(1); int sockfd = connect_to_testserver(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "Failed to connect to server."); + RUNNER_ASSERT_MSG(sockfd >= 0, "Failed to connect to server."); SockUniquePtr sockfd_ptr(&sockfd); label = security_server_get_smacklabel_sockfd(sockfd); - RUNNER_ASSERT_MSG_BT(label != NULL, "get_smacklabel_sockfd failed."); + RUNNER_ASSERT_MSG(label != NULL, "get_smacklabel_sockfd failed."); ret = strcmp(label, ""); free(label); - RUNNER_ASSERT_MSG_BT(ret == 0, "label is \"" << label << "\""); + RUNNER_ASSERT_MSG(ret == 0, "label is \"" << label << "\""); result1 = security_server_check_privilege_by_sockfd(sockfd, object_label, "r"); result2 = security_server_check_privilege_by_sockfd(sockfd, object_label, "rw"); } - RUNNER_ASSERT_MSG_BT(result1 == SECURITY_SERVER_API_SUCCESS, "result = " << result1); - RUNNER_ASSERT_MSG_BT(result2 == SECURITY_SERVER_API_SUCCESS, "result = " << result2); + RUNNER_ASSERT_MSG(result1 == SECURITY_SERVER_API_SUCCESS, "result = " << result1); + RUNNER_ASSERT_MSG(result2 == SECURITY_SERVER_API_SUCCESS, "result = " << result2); } /** @@ -401,32 +403,33 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc07_check_privilege_by_sockfd_nosmack) int result2 = -1; int pid = fork(); - RUNNER_ASSERT_BT(-1 != pid); + RUNNER_ASSERT_ERRNO(-1 != pid); if (pid == 0) { pid = fork(); - RUNNER_ASSERT_BT(-1 != pid); + RUNNER_ASSERT_ERRNO(-1 != pid); if (pid == 0) { //child process //Create socket int sockfd = create_new_socket(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed"); + RUNNER_ASSERT_MSG(sockfd >= 0, "create_new_socket() failed"); SockUniquePtr sockfd_ptr(&sockfd); //Drop privileges - RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid()); + RUNNER_ASSERT_MSG(drop_root_privileges() == 0, "uid = " << getuid()); //Prepare for accepting - RUNNER_ASSERT_MSG_BT(listen(sockfd, 5) >= 0, "child listen failed"); + RUNNER_ASSERT_ERRNO_MSG(listen(sockfd, 5) >= 0, "child listen failed"); struct sockaddr_un client_addr; socklen_t client_len = sizeof(client_addr); //Accept connections int csockfd; - RUNNER_ASSERT_MSG_BT((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, "child accept failed"); + RUNNER_ASSERT_ERRNO_MSG((csockfd = accept(sockfd,(struct sockaddr*)&client_addr, &client_len)) > 0, + "child accept failed"); //wait a little bit for parent to do it's job usleep(200); @@ -436,14 +439,14 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc07_check_privilege_by_sockfd_nosmack) exit(0); } else { //parent process //Drop root privileges - RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid()); + RUNNER_ASSERT_MSG(drop_root_privileges() == 0, "uid = " << getuid()); //Wait for server to set up sleep(1); //Connect and check privileges int sockfd = connect_to_testserver(); - RUNNER_ASSERT_MSG_BT(sockfd >= 0, "Failed to create socket fd."); + RUNNER_ASSERT_MSG(sockfd >= 0, "Failed to create socket fd."); result1 = security_server_check_privilege_by_sockfd(sockfd, object_label, "r"); result2 = security_server_check_privilege_by_sockfd(sockfd, object_label, "rw"); @@ -451,8 +454,8 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc07_check_privilege_by_sockfd_nosmack) close(sockfd); //Both results (just like in the previous test case) should return success. - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_SUCCESS == result1, "result1 = " << result1); - RUNNER_ASSERT_MSG_BT(SECURITY_SERVER_API_SUCCESS == result2, "result2 = " << result2); + RUNNER_ASSERT_MSG(SECURITY_SERVER_API_SUCCESS == result1, "result1 = " << result1); + RUNNER_ASSERT_MSG(SECURITY_SERVER_API_SUCCESS == result2, "result2 = " << result2); } } } @@ -465,20 +468,20 @@ RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) { char *cookie = NULL; int cookie_size = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(PROPER_COOKIE_SIZE == cookie_size, "Wrong cookie size from security-server"); + RUNNER_ASSERT_MSG(PROPER_COOKIE_SIZE == cookie_size, "Wrong cookie size from security-server"); cookie = (char*) calloc(cookie_size, 1); - RUNNER_ASSERT_MSG_BT(NULL != cookie, "Memory allocation error"); + RUNNER_ASSERT_MSG(NULL != cookie, "Memory allocation error"); res = security_server_request_cookie(cookie, cookie_size); if (res != SECURITY_SERVER_API_SUCCESS) { free(cookie); - RUNNER_ASSERT_MSG_BT(res == SECURITY_SERVER_API_SUCCESS, "Error in requesting cookie from security-server"); + RUNNER_ASSERT_MSG(res == SECURITY_SERVER_API_SUCCESS, "Error in requesting cookie from security-server"); } label_ss = security_server_get_smacklabel_cookie(cookie); free(cookie); - RUNNER_ASSERT_MSG_BT(label_ss != NULL, "Error in getting label by cookie"); + RUNNER_ASSERT_MSG(label_ss != NULL, "Error in getting label by cookie"); std::string label_cookie(label_ss); @@ -487,12 +490,12 @@ RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) { res = smack_new_label_from_self(&label_smack); if (res < 0) { free(label_smack); - RUNNER_ASSERT_MSG_BT(res == 0, "Error in getting self SMACK label"); + RUNNER_ASSERT_MSG(res == 0, "Error in getting self SMACK label"); } std::string label_self(label_smack ? label_smack : ""); free(label_smack); - RUNNER_ASSERT_MSG_BT(label_self == label_cookie, "No match in SMACK labels"); + RUNNER_ASSERT_MSG(label_self == label_cookie, "No match in SMACK labels"); //TODO: here could be label change using SMACK API and checking if it @@ -514,25 +517,25 @@ RUNNER_TEST_NOSMACK(tc18_security_server_get_smacklabel_cookie_nosmack) { char* cookie = NULL; int cookie_size = security_server_get_cookie_size(); - RUNNER_ASSERT_MSG_BT(PROPER_COOKIE_SIZE == cookie_size, + RUNNER_ASSERT_MSG(PROPER_COOKIE_SIZE == cookie_size, "Wrong cookie size from security-server. Size: " << cookie_size); cookie = (char*) calloc(cookie_size, sizeof(char)); - RUNNER_ASSERT_MSG_BT(NULL != cookie, "Memory allocation error"); + RUNNER_ASSERT_MSG(NULL != cookie, "Memory allocation error"); //Request cookie from SS res = security_server_request_cookie(cookie, cookie_size); CookieUniquePtr cookie_ptr(cookie); cookie = NULL; - RUNNER_ASSERT_MSG_BT(res == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(res == SECURITY_SERVER_API_SUCCESS, "Error in requesting cookie from security-server. Result: " << res); label_ss = security_server_get_smacklabel_cookie(cookie_ptr.get()); - RUNNER_ASSERT_MSG_BT(label_ss != NULL, "Error in getting label by cookie"); + RUNNER_ASSERT_MSG(label_ss != NULL, "Error in getting label by cookie"); std::string label(label_ss); free(label_ss); - RUNNER_ASSERT_MSG_BT(label.empty(), "label_ss is not an empty string."); + RUNNER_ASSERT_MSG(label.empty(), "label_ss is not an empty string."); } diff --git a/tests/security-server-tests/security_server_tests_dbus.cpp b/tests/security-server-tests/security_server_tests_dbus.cpp index 52fdb09..04b6024 100644 --- a/tests/security-server-tests/security_server_tests_dbus.cpp +++ b/tests/security-server-tests/security_server_tests_dbus.cpp @@ -37,12 +37,12 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus) char *smack_context = NULL; pid_t pid = fork(); - RUNNER_ASSERT_MSG_BT(-1 != pid, "fork() failed"); + RUNNER_ASSERT_ERRNO_MSG(-1 != pid, "fork() failed"); if (pid == 0) { // child ret = smack_set_label_for_self(subject_child); - RUNNER_ASSERT_MSG_BT(ret == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "smack_set__label_for_self() failed, ret: " << ret); // initialize the errors @@ -53,14 +53,14 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus) ret = dbus_error_is_set(&err); if (1 == ret) { dbus_error_free(&err); - RUNNER_ASSERT_MSG_BT(0 == ret, "dbus_bus_get() failed, ret: " << ret); + RUNNER_ASSERT_MSG(0 == ret, "dbus_bus_get() failed, ret: " << ret); } // request our name on the bus ret = dbus_bus_request_name(conn, DBUS_CALLER_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { dbus_error_free(&err); - RUNNER_ASSERT_MSG_BT(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret, + RUNNER_ASSERT_MSG(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret, "dbus_bus_request_name() failed, ret: " << ret); } @@ -70,13 +70,13 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus) DBUS_SMACK_INTERFACE, DBUS_SMACK_METHOD); - RUNNER_ASSERT_MSG_BT(NULL != msg, + RUNNER_ASSERT_MSG(NULL != msg, "dbus_message_new_method_call() failed, ret: " << ret); // append arguments, we need SMACK context for our parent process "test.method.server" dbus_message_iter_init_append(msg, &args); ret = dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &dbus_server_name); - RUNNER_ASSERT_MSG_BT(1 == ret, "Out of memory"); + RUNNER_ASSERT_MSG(1 == ret, "Out of memory"); // wait for parent to connect to DBus sleep(3); @@ -84,8 +84,8 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus) // send message and get a handle for a reply // -1 is default timeout ret = dbus_connection_send_with_reply (conn, msg, &pending, -1); - RUNNER_ASSERT_MSG_BT(1 == ret, "Out of memory"); - RUNNER_ASSERT_MSG_BT(NULL != pending, "Pending call null"); + RUNNER_ASSERT_MSG(1 == ret, "Out of memory"); + RUNNER_ASSERT_MSG(NULL != pending, "Pending call null"); dbus_connection_flush(conn); @@ -97,13 +97,13 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus) // get the reply msg = dbus_pending_call_steal_reply(pending); - RUNNER_ASSERT_MSG_BT(NULL != msg, "Reply null"); + RUNNER_ASSERT_MSG(NULL != msg, "Reply null"); // free message handle dbus_pending_call_unref(pending); ret = dbus_message_iter_init(msg, &iter); - RUNNER_ASSERT_MSG_BT(0 != ret, "Message has no arguments"); + RUNNER_ASSERT_MSG(0 != ret, "Message has no arguments"); dbus_message_iter_recurse(&iter, &var); @@ -127,9 +127,9 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus) dbus_message_unref(msg); dbus_connection_unref(conn); - RUNNER_ASSERT_BT(smack_context != NULL); + RUNNER_ASSERT(smack_context != NULL); ret = strcmp(smack_context, subject_parent); - RUNNER_ASSERT_MSG_BT(0 == ret, + RUNNER_ASSERT_MSG(0 == ret, "Context mismatch! context from dbus: " << smack_context); exit(0); @@ -137,7 +137,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus) } else { // parent ret = smack_set_label_for_self(subject_parent); - RUNNER_ASSERT_MSG_BT(ret == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(ret == PC_OPERATION_SUCCESS, "smack_set_label_for_self() failed, ret: " << ret); // initialise the error @@ -148,14 +148,14 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus) ret = dbus_error_is_set(&err); if (1 == ret) { dbus_error_free(&err); - RUNNER_ASSERT_MSG_BT(0 == ret, "dbus_bus_get() failed, ret: " << ret); + RUNNER_ASSERT_MSG(0 == ret, "dbus_bus_get() failed, ret: " << ret); } // request our name on the bus and check for errors ret = dbus_bus_request_name(conn, DBUS_SERVER_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { dbus_error_free(&err); - RUNNER_ASSERT_MSG_BT(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret, + RUNNER_ASSERT_MSG(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret, "dbus_bus_request_name() failed, ret: " << ret); } @@ -188,7 +188,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack) char *smack_context = NULL; pid_t pid = fork(); - RUNNER_ASSERT_MSG_BT(-1 != pid, "fork() failed"); + RUNNER_ASSERT_ERRNO_MSG(-1 != pid, "fork() failed"); if (pid == 0) { // child @@ -201,14 +201,14 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack) ret = dbus_error_is_set(&err); if (1 == ret) { dbus_error_free(&err); - RUNNER_ASSERT_MSG_BT(false, "Failed to connect to system bus. Ret " << ret); + RUNNER_FAIL_MSG("Failed to connect to system bus. Ret " << ret); } // request our name on the bus; failure = exit with result 2 ret = dbus_bus_request_name(conn, DBUS_CALLER_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { dbus_error_free(&err); - RUNNER_ASSERT_MSG_BT(false, "Failed to request name on the bus. Ret " << ret); + RUNNER_FAIL_MSG("Failed to request name on the bus. Ret " << ret); } // crate a new method call for checking SMACK context from DBus interface @@ -217,12 +217,12 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack) DBUS_SMACK_INTERFACE, DBUS_SMACK_METHOD); - RUNNER_ASSERT_MSG_BT(msg != NULL, "dbus_message_new_method_call() failed."); + RUNNER_ASSERT_MSG(msg != NULL, "dbus_message_new_method_call() failed."); // append arguments, we need SMACK context for our parent process "test.method.server" dbus_message_iter_init_append(msg, &args); ret = dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &dbus_server_name); - RUNNER_ASSERT_MSG_BT(ret == 1, "Out of memory. Ret " << ret); + RUNNER_ASSERT_MSG(ret == 1, "Out of memory. Ret " << ret); // wait for parent to connect to DBus sleep(3); @@ -230,8 +230,8 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack) // send message and get a handle for a reply // -1 is default timeout ret = dbus_connection_send_with_reply (conn, msg, &pending, -1); - RUNNER_ASSERT_MSG_BT(ret == 1, "Out of memory. Ret " << ret); - RUNNER_ASSERT_MSG_BT(pending != NULL, "Pending call is NULL."); + RUNNER_ASSERT_MSG(ret == 1, "Out of memory. Ret " << ret); + RUNNER_ASSERT_MSG(pending != NULL, "Pending call is NULL."); dbus_connection_flush(conn); @@ -243,13 +243,13 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack) // get the reply msg = dbus_pending_call_steal_reply(pending); - RUNNER_ASSERT_MSG_BT(msg != NULL, "Failed to get the reply from bus."); + RUNNER_ASSERT_MSG(msg != NULL, "Failed to get the reply from bus."); // free message handle dbus_pending_call_unref(pending); ret = dbus_message_iter_init(msg, &iter); - RUNNER_ASSERT_MSG_BT(ret != 0, "DBus message has no arguments. Ret " << ret); + RUNNER_ASSERT_MSG(ret != 0, "DBus message has no arguments. Ret " << ret); dbus_message_iter_recurse(&iter, &var); while (dbus_message_iter_get_arg_type(&var) != DBUS_TYPE_INVALID) { @@ -272,9 +272,9 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack) dbus_message_unref(msg); dbus_connection_unref(conn); - RUNNER_ASSERT_BT(smack_context != NULL); + RUNNER_ASSERT(smack_context != NULL); ret = strcmp(smack_context, subject_parent); - RUNNER_ASSERT_MSG_BT(ret == 0, "Context mismatch. Context " << smack_context); + RUNNER_ASSERT_MSG(ret == 0, "Context mismatch. Context " << smack_context); exit(0); @@ -289,14 +289,14 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack) ret = dbus_error_is_set(&err); if (1 == ret) { dbus_error_free(&err); - RUNNER_ASSERT_MSG_BT(0 == ret, "dbus_bus_get() failed, ret: " << ret); + RUNNER_ASSERT_MSG(0 == ret, "dbus_bus_get() failed, ret: " << ret); } // request our name on the bus and check for errors ret = dbus_bus_request_name(conn, DBUS_SERVER_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING , &err); if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { dbus_error_free(&err); - RUNNER_ASSERT_MSG_BT(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret, + RUNNER_ASSERT_MSG(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret, "dbus_bus_request_name() failed, ret: " << ret); } diff --git a/tests/security-server-tests/security_server_tests_password.cpp b/tests/security-server-tests/security_server_tests_password.cpp index 7c95cfe..6f358f5 100644 --- a/tests/security-server-tests/security_server_tests_password.cpp +++ b/tests/security-server-tests/security_server_tests_password.cpp @@ -63,7 +63,7 @@ struct SystemClock { void shift(time_t sft) { m_shift += sft; time_t shifted = m_original + m_shift; - RUNNER_ASSERT_BT(0 == stime(&shifted)); + RUNNER_ASSERT_ERRNO(0 == stime(&shifted)); } ~SystemClock() { @@ -72,7 +72,7 @@ struct SystemClock { return; } - RUNNER_ASSERT_BT(0 == stime(&m_original)); + RUNNER_ASSERT_ERRNO(0 == stime(&m_original)); } private: time_t m_original; @@ -94,10 +94,10 @@ RUNNER_TEST(tc01_clear_environment) ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(expire_sec == 0, "expire_sec = " << expire_sec); - RUNNER_ASSERT_MSG_BT(max_attempt == 0, "max_attempt = " << max_attempt); - RUNNER_ASSERT_MSG_BT(attempt == 0, "attempt = " << attempt); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); + RUNNER_ASSERT_MSG(expire_sec == 0, "expire_sec = " << expire_sec); + RUNNER_ASSERT_MSG(max_attempt == 0, "max_attempt = " << max_attempt); + RUNNER_ASSERT_MSG(attempt == 0, "attempt = " << attempt); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); } else { @@ -121,20 +121,20 @@ RUNNER_TEST(tc02_security_server_set_pwd_validity) // TESTS: // WITHOUT password ret = security_server_set_pwd_validity(10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); ret = security_server_set_pwd_validity(11); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); // WITH password ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_validity(10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_validity(11); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -150,20 +150,20 @@ RUNNER_TEST(tc03_security_server_set_pwd_max_challenge) // TESTS: // WITHOUT password ret = security_server_set_pwd_max_challenge(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); ret = security_server_set_pwd_max_challenge(6); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); // WITH password ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_max_challenge(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_max_challenge(6); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -176,7 +176,7 @@ RUNNER_TEST(tc04_security_server_chk_pwd_too_long_password_case) // 33 char password ret = security_server_chk_pwd("abcdefghijklmnopqrstuvwxyz0123456", &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /** @@ -188,16 +188,16 @@ RUNNER_TEST(tc05_security_server_chk_pwd_null_input_case) unsigned int attempt, max_attempt, expire_sec; ret = security_server_chk_pwd(NULL, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_chk_pwd("password", NULL, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_chk_pwd("password", &attempt, NULL, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_chk_pwd("password", &attempt, &max_attempt, NULL); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /** @@ -214,9 +214,9 @@ RUNNER_TEST(tc06_security_server_chk_pwd_no_password_case) // TEST ret = security_server_chk_pwd("isthisempty", &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(expire_sec == 0, expire_sec); - RUNNER_ASSERT_MSG_BT(max_attempt == 0, max_attempt); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); + RUNNER_ASSERT_MSG(expire_sec == 0, expire_sec); + RUNNER_ASSERT_MSG(max_attempt == 0, max_attempt); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret); } /** @@ -231,7 +231,7 @@ RUNNER_TEST(tc07_security_server_set_pwd_null_input_case) // TEST ret = security_server_set_pwd(NULL, NULL, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /** @@ -247,7 +247,7 @@ RUNNER_TEST(tc08_security_server_set_pwd_too_long_input_param) // TEST // 33 char password ret = security_server_set_pwd("abcdefghijklmnopqrstuvwxyz0123456", "abcdefghijklmnopqrstuvwxyz0123456", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /** @@ -262,7 +262,7 @@ RUNNER_TEST(tc09_security_server_set_pwd_current_pwd_empty) // TEST ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -274,19 +274,19 @@ RUNNER_TEST(tc10_security_server_set_pwd_current_pwd_max_valid_period_in_days) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); // UINT_MAX will cause api error, it is to big value ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, UINT_MAX); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); // calculate max applicable valid days that will not be rejected by ss // ensure, that after conversion from days to seconds in ss there will be no uint overflow unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1; ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, valid_days); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -298,12 +298,12 @@ RUNNER_TEST(tc11_security_server_set_pwd_current_pwd_max_max_challenge) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, UINT_MAX, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -315,12 +315,12 @@ RUNNER_TEST(tc12_security_server_set_pwd_current_pwd_nonempty2zero) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, "", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /** @@ -332,13 +332,13 @@ RUNNER_TEST(tc14_security_server_set_pwd_current_pwd_too_long_input_param) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); std::string lng_pwd(5000, 'A'); ret = security_server_set_pwd(TEST_PASSWORD,lng_pwd.c_str(), 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /** @@ -352,12 +352,12 @@ RUNNER_TEST(tc15_security_server_chk_pwd_empty_password) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd("", &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /** @@ -369,21 +369,21 @@ RUNNER_TEST(tc16_security_server_set_pwd_validity) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST ret = security_server_set_pwd_validity(0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_validity(1); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //When trying to set UINT_MAX we should get error. ret = security_server_set_pwd_validity(UINT_MAX); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_set_pwd_validity(2); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -397,12 +397,12 @@ RUNNER_TEST(tc17_security_server_is_pwd_valid) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 2); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST: ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); - RUNNER_ASSERT_MSG_BT((expire_sec > 172795) && (expire_sec < 172805), "expire_sec = " << expire_sec); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG((expire_sec > 172795) && (expire_sec < 172805), "expire_sec = " << expire_sec); } /** @@ -417,20 +417,20 @@ RUNNER_TEST(tc18_security_server_set_pwd_max_challenge) // ensure, that after conversion from days to seconds in ss there will be no uint overflow unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1; ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, valid_days); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TESTS ret = security_server_set_pwd_max_challenge(0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_max_challenge(UINT_MAX); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_max_challenge(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_max_challenge(6); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } @@ -444,15 +444,15 @@ RUNNER_TEST(tc19_security_server_is_pwd_valid) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_max_challenge(6); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); - RUNNER_ASSERT_MSG_BT(max_attempt == 6, "max_attempt = " << max_attempt); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG(max_attempt == 6, "max_attempt = " << max_attempt); } /** @@ -466,15 +466,15 @@ RUNNER_TEST(tc20_security_server_chk_pwd) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, ret); ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); } /** @@ -488,12 +488,12 @@ RUNNER_TEST(tc21_security_server_chk_incorrect_pwd) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //TEST usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); } /** @@ -506,12 +506,12 @@ RUNNER_TEST(tc22_security_server_set_pwd_incorrect_current) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(SECOND_TEST_PASSWORD, THIRD_TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); } /** @@ -524,12 +524,12 @@ RUNNER_TEST(tc23_security_server_set_pwd_correct_current) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -543,26 +543,26 @@ RUNNER_TEST(tc24_security_server_attempt_exceeding) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST printf("5 subtests started..."); for (i = 1; i <= 5; i++) { usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); - RUNNER_ASSERT_MSG_BT(attempt == i, "attempt = " << attempt << ", expected " << i); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); + RUNNER_ASSERT_MSG(attempt == i, "attempt = " << attempt << ", expected " << i); } printf("DONE\n"); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); - RUNNER_ASSERT_MSG_BT(attempt == 0, "ret = " << ret); - RUNNER_ASSERT_MSG_BT(max_attempt == 10, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG(attempt == 0, "ret = " << ret); + RUNNER_ASSERT_MSG(max_attempt == 10, "ret = " << ret); } /** @@ -576,26 +576,26 @@ RUNNER_TEST(tc25_security_server_attempt_exceeding) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 1); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST printf("10 subtests started..."); for (i = 1; i <= 10; i++) { usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); - RUNNER_ASSERT_MSG_BT(attempt == i, "attempt = " << attempt << ", expected " << i); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); + RUNNER_ASSERT_MSG(attempt == i, "attempt = " << attempt << ", expected " << i); } // The check, that exceeds max number usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED, "ret = " << ret); printf("DONE\n"); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MAX_ATTEMPTS_EXCEEDED, "ret = " << ret); } /** @@ -608,11 +608,11 @@ RUNNER_TEST(tc26_security_server_reset_pwd) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST ret = security_server_reset_pwd(TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -625,12 +625,12 @@ RUNNER_TEST(tc27_security_server_chk_pwd_too_long_password) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST std::string lng_pwd(5000, 'A'); ret = security_server_chk_pwd(lng_pwd.c_str(), &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /** @@ -644,12 +644,12 @@ RUNNER_TEST(tc28_security_server_check_expiration) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 1); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); - RUNNER_ASSERT_MSG_BT((expire_sec < 86402) && (expire_sec > 86396), "expire_sec = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG((expire_sec < 86402) && (expire_sec > 86396), "expire_sec = " << ret); } /** @@ -662,32 +662,32 @@ RUNNER_TEST(tc29_security_server_set_pwd_history) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 1); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TESTS ret = security_server_set_pwd_history(100); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_set_pwd_history(51); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_set_pwd_history(-5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_set_pwd_history(50); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_history(0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_history(INT_MAX); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_set_pwd_history(INT_MIN); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); ret = security_server_set_pwd_history(10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } @@ -732,10 +732,10 @@ RUNNER_TEST(tc30_security_server_check_history) clean_password_dir(); ret = security_server_set_pwd_history(9); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_reset_pwd("history0", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); printf("11 subtests started..."); for (i = 0; i < 11; i++) { @@ -744,21 +744,21 @@ RUNNER_TEST(tc30_security_server_check_history) usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(buf1, buf2, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } printf("DONE\n"); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd("history11", "history1", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd("history1", "history8", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd("history1", "history12", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); printf("48 subtests started..."); for (i = 12; i < 60; i++) { @@ -768,7 +768,7 @@ RUNNER_TEST(tc30_security_server_check_history) sprintf(buf2, "history%d", i + 1); ret = security_server_set_pwd(buf1, buf2, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } printf("DONE\n"); @@ -794,7 +794,7 @@ RUNNER_TEST(tc31_security_server_replay_attack) usleep(i); } - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); } /** @@ -809,27 +809,27 @@ RUNNER_TEST(tc32_security_server_challenge_on_expired_password) // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 4, 1); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = gettimeofday(&cur_time, NULL); - RUNNER_ASSERT_MSG_BT(ret > -1, ret); + RUNNER_ASSERT_ERRNO(ret != -1); cur_time.tv_sec += (expire_sec + 1); ret = settimeofday(&cur_time, NULL); - RUNNER_ASSERT_MSG_BT(ret > -1, ret); + RUNNER_ASSERT_ERRNO(ret != -1); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXPIRED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXPIRED, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_MISMATCH, "ret = " << ret); } /** @@ -844,7 +844,7 @@ RUNNER_TEST(tc33_security_server_reset_by_null_pwd) // TEST ret = security_server_reset_pwd(NULL, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret); } /* @@ -868,21 +868,21 @@ void verify_chk_pwd ( int ret = security_server_chk_pwd(challenge, &attempt, &max_attempt, &expire_sec); // validate returned value - RUNNER_ASSERT_MSG_BT(ret == expected_result, + RUNNER_ASSERT_MSG(ret == expected_result, info << "security_server_chk_pwd returned " << ret << " (expected: " << expected_result << ")"); // validate current attempts value - RUNNER_ASSERT_MSG_BT(attempt == expected_current_attempt, + RUNNER_ASSERT_MSG(attempt == expected_current_attempt, info << "security_server_chk_pwd returned attempt = " << attempt << " (expected: " << expected_current_attempt << ")"); // validate max attempt value - RUNNER_ASSERT_MSG_BT(max_attempt == expected_max_attempt, + RUNNER_ASSERT_MSG(max_attempt == expected_max_attempt, info << "security_server_chk_pwd returned max_attempt = " << max_attempt << " (expected: " << expected_max_attempt << ")"); - RUNNER_ASSERT_MSG_BT(expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME, + RUNNER_ASSERT_MSG(expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME, info << "security_server_chk_pwd returned expire_sec = " << expire_sec << " (expected: " << PASSWORD_INFINITE_EXPIRATION_TIME << ")"); } @@ -896,7 +896,7 @@ RUNNER_TEST(tc34_security_server_max_attempts) reset_security_server(); int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // change max attempts number few times std::vector max_challenge_tab = {1, 4, 2}; @@ -905,7 +905,7 @@ RUNNER_TEST(tc34_security_server_max_attempts) unsigned int max_challenges = max_challenge_tab[pass]; ret = security_server_set_pwd_max_challenge(max_challenges); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // max_challenges-1 wrong password attempts for (unsigned int attempt_nr = 1; attempt_nr < max_challenges; ++attempt_nr) @@ -934,7 +934,7 @@ RUNNER_TEST(tc35_security_server_decrease_max_attempts) reset_security_server(); int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge_more, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // missed attempts for (unsigned int attempt = 1; attempt <= max_challenge_more; ++attempt) @@ -946,14 +946,14 @@ RUNNER_TEST(tc35_security_server_decrease_max_attempts) // lower max_challenge ret = security_server_set_pwd_max_challenge(max_challenge_less); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // try valid password - should pass (curr attempts is reset) verify_chk_pwd(TEST_PASSWORD, SECURITY_SERVER_API_SUCCESS, 1, max_challenge_less); // remove max attempts limit ret = security_server_set_pwd_max_challenge(0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // try valid password again - should pass verify_chk_pwd(TEST_PASSWORD, SECURITY_SERVER_API_SUCCESS, 1, 0); @@ -961,7 +961,7 @@ RUNNER_TEST(tc35_security_server_decrease_max_attempts) // try to change the password - should pass usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // validate new password verify_chk_pwd(SECOND_TEST_PASSWORD, SECURITY_SERVER_API_SUCCESS, 1, 0); @@ -981,10 +981,10 @@ RUNNER_TEST(tc36_security_server_challenge_previous_passwords) reset_security_server(); int ret = security_server_set_pwd_history(history_depth); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_reset_pwd(TEST_PASSWORD, max_challenge, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); for (int depth = 0; depth < history_depth; ++depth) { prev_pass = new_pass; @@ -994,7 +994,7 @@ RUNNER_TEST(tc36_security_server_challenge_previous_passwords) usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(prev_pass.c_str(), new_pass.c_str(), max_challenge, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // challenge initial password verify_chk_pwd( @@ -1026,7 +1026,7 @@ RUNNER_TEST(tc37_security_server_challenge_mixed) const unsigned int max_challenge = 2; int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // 2x correct pwd - verify that 'cuurrent attempt' isn't increased for (unsigned int i = 0; i < max_challenge; ++i) @@ -1091,55 +1091,55 @@ RUNNER_TEST(tc38_security_server_history_depth_change) reset_security_server(); ret = security_server_set_pwd_history(initial_history_depth); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(SECOND_TEST_PASSWORD, THIRD_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST_PASSWORD, 2nd and 3rd remembered => 1st should be refused usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(THIRD_TEST_PASSWORD, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); /* * Lower history depth. At this point SS should treat THIRD_TEST_PASSWORD as current pwd, * and SECOND_TEST_PASSWORD as a part of history. */ ret = security_server_set_pwd_history(decreased_history_depth); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(THIRD_TEST_PASSWORD, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, THIRD_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); /* * Increase history depth to 3. At this point SS should remember TEST_PASSWORD * and THIRD_TEST_PASSWORD only. */ ret = security_server_set_pwd_history(increased_history_depth); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // 3rd and TEST_PASSWORD remembered => 2nd should be accepted usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // TEST_PASSWORD, 2nd and 3rd remembered => 3rd should be refused usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(SECOND_TEST_PASSWORD, THIRD_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); } /** @@ -1155,7 +1155,7 @@ RUNNER_TEST(tc39_security_server_attempts_num_check_after_reset) reset_security_server(); int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // missed attempts for (unsigned int attempt = 1; attempt <= invalid_attempts_num; ++attempt) @@ -1167,10 +1167,10 @@ RUNNER_TEST(tc39_security_server_attempts_num_check_after_reset) attempt = max_attempt = expire_sec = UINT_MAX; ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); - RUNNER_ASSERT_MSG_BT(max_attempt == max_challenge, "max_attempt = " << max_attempt); - RUNNER_ASSERT_MSG_BT(attempt == invalid_attempts_num, "attempt = " << attempt); - RUNNER_ASSERT_MSG_BT(expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME, "expire_sec = " << + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG(max_attempt == max_challenge, "max_attempt = " << max_attempt); + RUNNER_ASSERT_MSG(attempt == invalid_attempts_num, "attempt = " << attempt); + RUNNER_ASSERT_MSG(expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME, "expire_sec = " << expire_sec); // restart server - triggers loading password data from file @@ -1202,22 +1202,22 @@ RUNNER_TEST(tc40_security_server_history_check_after_reset) reset_security_server(); int ret = security_server_set_pwd_history(history_depth); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(SECOND_TEST_PASSWORD, THIRD_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(THIRD_TEST_PASSWORD, FOURTH_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); // restart server - triggers loading password data from file restart_security_server(); @@ -1225,15 +1225,15 @@ RUNNER_TEST(tc40_security_server_history_check_after_reset) // try to reuse history passwords usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(FOURTH_TEST_PASSWORD, THIRD_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(FOURTH_TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(FOURTH_TEST_PASSWORD, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } /** @@ -1249,32 +1249,32 @@ RUNNER_TEST(tc41_security_server_empty_history_check) //set new history count int ret = security_server_set_pwd_history(history_depth); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //set new password and fill history ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(SECOND_TEST_PASSWORD, THIRD_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //make sure, that everything went OK - try setting something that would cause reuse error usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(THIRD_TEST_PASSWORD, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(THIRD_TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_REUSED, "ret = " << ret); //reset history limit to no history at all ret = security_server_set_pwd_history(empty_history_depth); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //make sure, that current password still exists in memory //expected attempt 3 because our previous tries increased attempt counter @@ -1287,16 +1287,16 @@ RUNNER_TEST(tc41_security_server_empty_history_check) //make sure that it's possible to reuse old password once history limit is set to 0 usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(THIRD_TEST_PASSWORD, THIRD_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //once again try setting earlier used passwords - now API should return success usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(THIRD_TEST_PASSWORD, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } RUNNER_TEST(tc42_security_server_set_new_pwd_with_current_empty) @@ -1306,12 +1306,12 @@ RUNNER_TEST(tc42_security_server_set_new_pwd_with_current_empty) //set a password int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //try setting different password and giving NULL as current once again usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(NULL, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); } RUNNER_TEST(tc43_security_server_no_retry_timeout_is_pwd_valid) @@ -1321,14 +1321,14 @@ RUNNER_TEST(tc43_security_server_no_retry_timeout_is_pwd_valid) //set a password int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //do test unsigned int attempt, max_attempt, expire_sec; ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); } RUNNER_TEST(tc44_security_server_retry_timeout_chk_pwd) @@ -1338,14 +1338,14 @@ RUNNER_TEST(tc44_security_server_retry_timeout_chk_pwd) //set a password int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //do test unsigned int attempt, max_attempt, expire_sec; ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER, "ret = " << ret); ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER, "ret = " << ret); } RUNNER_TEST(tc45_security_server_retry_timeout_set_pwd) @@ -1355,13 +1355,13 @@ RUNNER_TEST(tc45_security_server_retry_timeout_set_pwd) //set a password int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //do test ret = security_server_set_pwd(TEST_PASSWORD, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER, "ret = " << ret); ret = security_server_set_pwd(TEST_PASSWORD, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_RETRY_TIMER, "ret = " << ret); } RUNNER_TEST(tc46_security_server_no_retry_timeout_set_pwd_validity) @@ -1371,13 +1371,13 @@ RUNNER_TEST(tc46_security_server_no_retry_timeout_set_pwd_validity) //set a password int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //do test ret = security_server_set_pwd_validity(11); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_validity(11); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } RUNNER_TEST(tc47_security_server_no_retry_timeout_reset_pwd) @@ -1387,13 +1387,13 @@ RUNNER_TEST(tc47_security_server_no_retry_timeout_reset_pwd) //set a password int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //do test ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_reset_pwd(TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } RUNNER_TEST(tc48_security_server_no_retry_timeout_pwd_history) @@ -1403,13 +1403,13 @@ RUNNER_TEST(tc48_security_server_no_retry_timeout_pwd_history) //set a password int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //do test ret = security_server_set_pwd_history(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_history(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } RUNNER_TEST(tc49_security_server_no_retry_timeout_set_pwd_max_challenge) @@ -1419,13 +1419,13 @@ RUNNER_TEST(tc49_security_server_no_retry_timeout_set_pwd_max_challenge) //set a password int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); //do test ret = security_server_set_pwd_max_challenge(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); ret = security_server_set_pwd_max_challenge(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); } RUNNER_TEST(tc50_security_server_set_pwd_current_pwd_with_infinite_expiration_time) @@ -1436,17 +1436,17 @@ RUNNER_TEST(tc50_security_server_set_pwd_current_pwd_with_infinite_expiration_ti // Prepare environment reset_security_server(); ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); // Assert security server sets infinite expiration time ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd(SECOND_TEST_PASSWORD, &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); - RUNNER_ASSERT_MSG_BT(expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(expire_sec == PASSWORD_INFINITE_EXPIRATION_TIME, "invalid expiration time " << expire_sec); clean_password_dir(); @@ -1457,20 +1457,20 @@ RUNNER_TEST(tc51_security_server_is_pwd_valid) reset_security_server(); int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 1); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); unsigned int attempt, maxAttempt, validSec; attempt = maxAttempt = validSec = 0; ret = security_server_is_pwd_valid(&attempt, &maxAttempt, &validSec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret << + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret << " atempt=" << attempt << " maxAttempt=" << maxAttempt << " validSec=" << validSec); SystemClock clock(60*60*24*2); ret = security_server_is_pwd_valid(&attempt, &maxAttempt, &validSec); - RUNNER_ASSERT_MSG_BT((ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST) && (validSec == 0), + RUNNER_ASSERT_MSG((ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST) && (validSec == 0), "ret = " << ret << " atempt=" << attempt << " maxAttempt=" << maxAttempt << " validSec=" << validSec); } @@ -1480,13 +1480,13 @@ RUNNER_TEST(tc52_security_server_is_pwd_valid) reset_security_server(); int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); unsigned int attempt, maxAttempt, validSec; attempt = maxAttempt = validSec = 0; ret = security_server_is_pwd_valid(&attempt, &maxAttempt, &validSec); - RUNNER_ASSERT_MSG_BT((ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST) && (validSec == 0xffffffff), "ret = " << ret << + RUNNER_ASSERT_MSG((ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST) && (validSec == 0xffffffff), "ret = " << ret << " atempt=" << attempt << " maxAttempt=" << maxAttempt << " validSec=" << validSec); } @@ -1495,30 +1495,30 @@ RUNNER_TEST(tc53_security_server_is_pwd_valid) reset_security_server(); int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 3); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret); unsigned int attempt, maxAttempt, validSec; attempt = maxAttempt = validSec = 0; // password shoudl be valid for 3 days == (60*60*24*3) 259200 seconds ret = security_server_is_pwd_valid(&attempt, &maxAttempt, &validSec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); - RUNNER_ASSERT_MSG_BT((validSec > 259000) && (validSec < 260000), "validSec = " << validSec); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG((validSec > 259000) && (validSec < 260000), "validSec = " << validSec); SystemClock clock; clock.shift(-60*60*24); // one day back // password should be valid for 4 days == (60*60*24*4) 345600 seconds ret = security_server_is_pwd_valid(&attempt, &maxAttempt, &validSec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); - RUNNER_ASSERT_MSG_BT((validSec > 345000) && (validSec < 346000), "validSec = " << validSec); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG((validSec > 345000) && (validSec < 346000), "validSec = " << validSec); clock.shift(-60*60*24*2); // 3 days back // password shoudl be valid for 6 days == (60*60*24*6) 518400 seconds ret = security_server_is_pwd_valid(&attempt, &maxAttempt, &validSec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); - RUNNER_ASSERT_MSG_BT((validSec > 518000) && (validSec < 519000), "validSec = " << validSec); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret); + RUNNER_ASSERT_MSG((validSec > 518000) && (validSec < 519000), "validSec = " << validSec); } int main(int argc, char *argv[]) diff --git a/tests/security-server-tests/security_server_tests_privilege.cpp b/tests/security-server-tests/security_server_tests_privilege.cpp index c65e4c9..f93136a 100644 --- a/tests/security-server-tests/security_server_tests_privilege.cpp +++ b/tests/security-server-tests/security_server_tests_privilege.cpp @@ -34,10 +34,10 @@ void check_security_server_app_has_privilege(const char *app_label, int is_enabled; result = security_server_app_has_privilege(app_label, APP_TYPE_WGT, permission, &is_enabled); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error calling security_server_app_has_privilege. Result: " << result); - RUNNER_ASSERT_MSG_BT(is_enabled == is_enabled_expected, + RUNNER_ASSERT_MSG(is_enabled == is_enabled_expected, "Result of security_server_app_has_privilege should be: " << is_enabled_expected); } @@ -50,15 +50,15 @@ RUNNER_TEST(sstp_01_security_server_app_has_privilege) DB_BEGIN result = perm_app_uninstall(SSTP_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error uninstalling app. Result" << result); result = perm_app_install(SSTP_APP_ID); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error installing app. Result" << result); result = perm_app_disable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app r and no r permissions. Result: " << result); DB_END @@ -71,7 +71,7 @@ RUNNER_TEST(sstp_01_security_server_app_has_privilege) DB_BEGIN result = perm_app_enable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS1, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error registering app r permissions. Result: " << result); DB_END @@ -84,7 +84,7 @@ RUNNER_TEST(sstp_01_security_server_app_has_privilege) DB_BEGIN result = perm_app_enable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS2, false); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error registering app r permissions. Result: " << result); DB_END @@ -97,7 +97,7 @@ RUNNER_TEST(sstp_01_security_server_app_has_privilege) DB_BEGIN result = perm_app_disable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS1); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app r and no r permissions. Result: " << result); DB_END @@ -110,7 +110,7 @@ RUNNER_TEST(sstp_01_security_server_app_has_privilege) DB_BEGIN result = perm_app_disable_permissions(SSTP_APP_ID, APP_TYPE_WGT, SSTP_PERMS2); - RUNNER_ASSERT_MSG_BT(result == PC_OPERATION_SUCCESS, + RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "Error disabling app r and no r permissions. Result: " << result); DB_END diff --git a/tests/security-server-tests/security_server_tests_stress.cpp b/tests/security-server-tests/security_server_tests_stress.cpp index ae73ead..330fb0f 100644 --- a/tests/security-server-tests/security_server_tests_stress.cpp +++ b/tests/security-server-tests/security_server_tests_stress.cpp @@ -137,16 +137,16 @@ void testFunction(bool isSmack) if (isSmack) { //preapre environment int ret = smack_set_label_for_self(g_subject.data()); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in smack_set_label_for_self()"); + RUNNER_ASSERT_MSG(ret == 0, "Error in smack_set_label_for_self()"); struct smack_accesses *rulesRaw = NULL; ret = smack_accesses_new(&rulesRaw); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in smack_accesses_new()"); + RUNNER_ASSERT_MSG(ret == 0, "Error in smack_accesses_new()"); SmackAccessesPtr rules(rulesRaw); ret = smack_accesses_add(rules.get(), g_subject.data(), g_object.data(), g_rule.data()); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in smack_accesses_add()"); + RUNNER_ASSERT_MSG(ret == 0, "Error in smack_accesses_add()"); ret = smack_accesses_apply(rules.get()); - RUNNER_ASSERT_MSG_BT(ret == 0, "Error in smack_accesses_apply()"); + RUNNER_ASSERT_MSG(ret == 0, "Error in smack_accesses_apply()"); } //spawning threads @@ -165,7 +165,7 @@ RUNNER_CHILD_TEST_SMACK(tc_stress_cookie_api_smack) { testFunction(true); - RUNNER_ASSERT_MSG_BT(g_successes == g_threadsNumber, + RUNNER_ASSERT_MSG(g_successes == g_threadsNumber, "Not all threads exit with success: " << g_successes << "/ " << g_threadsNumber << std::endl << "Errors:" << std::endl << g_errors); @@ -175,7 +175,7 @@ RUNNER_CHILD_TEST_NOSMACK(tc_stress_cookie_api_no_smack) { testFunction(false); - RUNNER_ASSERT_MSG_BT(g_successes == g_threadsNumber, + RUNNER_ASSERT_MSG(g_successes == g_threadsNumber, "Not all threads exit with success: " << g_successes << "/ " << g_threadsNumber << std::endl << "Errors:" << std::endl << g_errors); diff --git a/tests/security-server-tests/server.cpp b/tests/security-server-tests/server.cpp index 7c90047..b837a34 100644 --- a/tests/security-server-tests/server.cpp +++ b/tests/security-server-tests/server.cpp @@ -50,10 +50,10 @@ void clear_password() attempt = max_attempt = expire_sec = UINT_MAX; ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret); - RUNNER_ASSERT_BT(expire_sec == 0); - RUNNER_ASSERT_BT(max_attempt == 0); - RUNNER_ASSERT_BT(attempt == 0); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret); + RUNNER_ASSERT(expire_sec == 0); + RUNNER_ASSERT(max_attempt == 0); + RUNNER_ASSERT(attempt == 0); sleep(1); } @@ -71,40 +71,40 @@ void check_API_passwd(bool smack) { SecurityServer::AccessProvider privider(TEST04_SUBJECT); privider.applyAndSwithToUser(APP_UID, APP_GID); } else { - RUNNER_ASSERT_MSG_BT((ret = drop_root_privileges()) == 0, + RUNNER_ASSERT_MSG((ret = drop_root_privileges()) == 0, "Failed to drop root privileges. Result: " << ret << "uid = " << getuid()); } ret = security_server_set_pwd_validity(APP_UID); - RUNNER_ASSERT_MSG_BT(ret == err, + RUNNER_ASSERT_MSG(ret == err, "security_server_set_pwd_validity has failed," " ret: " << ret); ret = security_server_set_pwd_max_challenge(5); - RUNNER_ASSERT_MSG_BT(ret == err, + RUNNER_ASSERT_MSG(ret == err, "security_server_set_pwd_max_challenge has failed," " ret: " << ret); ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == err_is_pwd_valid, + RUNNER_ASSERT_MSG(ret == err_is_pwd_valid, "security_server_is_pwd_valid should return password exist," " ret: " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd("12345", "12346", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == err, + RUNNER_ASSERT_MSG(ret == err, "security_server_set_pwd has failed, ret: " << ret); ret = security_server_reset_pwd("12346",0, 0); - RUNNER_ASSERT_MSG_BT(ret == err, + RUNNER_ASSERT_MSG(ret == err, "security_server_reset_pwd has failed, ret: " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd("12346", &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == err, + RUNNER_ASSERT_MSG(ret == err, "security_server_chk_pwd has failed, ret: " << ret); ret = security_server_set_pwd_history(10); - RUNNER_ASSERT_MSG_BT(ret == err, + RUNNER_ASSERT_MSG(ret == err, "security_server_set_pwd_history has failed, ret: " << ret); } @@ -112,17 +112,17 @@ RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_TESTS_SERVER); RUNNER_TEST(tc_security_server_get_gid_normal_case_trying_to_get_gid_of_tel_gprs) { - RUNNER_ASSERT_BT(security_server_get_gid("tel_gprs") >= 0); + RUNNER_ASSERT(security_server_get_gid("tel_gprs") >= 0); } RUNNER_TEST(tc_security_server_get_gid_empty_object_name) { - RUNNER_ASSERT_BT(security_server_get_gid("") == SECURITY_SERVER_API_ERROR_INPUT_PARAM); + RUNNER_ASSERT(security_server_get_gid("") == SECURITY_SERVER_API_ERROR_INPUT_PARAM); } RUNNER_TEST(tc_security_server_get_gid_wrong_object_name_teltel) { - RUNNER_ASSERT_BT(security_server_get_gid("teltel") == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT); + RUNNER_ASSERT(security_server_get_gid("teltel") == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT); } RUNNER_CHILD_TEST_SMACK(tc01a_security_server_app_give_access) @@ -136,7 +136,7 @@ RUNNER_CHILD_TEST_SMACK(tc01a_security_server_app_give_access) security_server_app_give_access(subject, getpid()); - RUNNER_ASSERT_BT(1 == smack_have_access(subject, object, "rwxat")); + RUNNER_ASSERT(1 == smack_have_access(subject, object, "rwxat")); } /* @@ -153,11 +153,11 @@ RUNNER_CHILD_TEST_SMACK(tc01a_security_server_app_give_access) // time. sleep(1); - RUNNER_ASSERT_BT(0 == smack_have_access(subject, object, "r----")); - RUNNER_ASSERT_BT(0 == smack_have_access(subject, object, "-w---")); - RUNNER_ASSERT_BT(0 == smack_have_access(subject, object, "--x--")); - RUNNER_ASSERT_BT(0 == smack_have_access(subject, object, "---a-")); - RUNNER_ASSERT_BT(0 == smack_have_access(subject, object, "----t")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "r----")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "-w---")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "--x--")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "---a-")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "----t")); }*/ RUNNER_CHILD_TEST_SMACK(tc01c_security_server_app_give_access_no_access) @@ -169,14 +169,14 @@ RUNNER_CHILD_TEST_SMACK(tc01c_security_server_app_give_access_no_access) smack.add(subject, object, "-----"); smack.apply(); - RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(object), "Error in smack_label_for_self"); + RUNNER_ASSERT_MSG(0 == smack_set_label_for_self(object), "Error in smack_label_for_self"); - RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid()); + RUNNER_ASSERT_MSG(drop_root_privileges() == 0, "uid = " << getuid()); - RUNNER_ASSERT_BT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == + RUNNER_ASSERT(SECURITY_SERVER_API_ERROR_ACCESS_DENIED == security_server_app_give_access(subject, getpid())); - RUNNER_ASSERT_BT(0 == smack_have_access(subject, object, "r")); + RUNNER_ASSERT(0 == smack_have_access(subject, object, "r")); } RUNNER_TEST_SMACK(tc02_check_privilege_by_pid) @@ -189,11 +189,11 @@ RUNNER_TEST_SMACK(tc02_check_privilege_by_pid) //we checking existing rule, it should return positive ret = security_server_check_privilege_by_pid(pid, "_", "rx"); - RUNNER_ASSERT_BT(ret == SECURITY_SERVER_API_SUCCESS); + RUNNER_ASSERT(ret == SECURITY_SERVER_API_SUCCESS); //we checking rule with label that not exist ret = security_server_check_privilege_by_pid(pid, "thislabelisnotreal", "rwxat"); - RUNNER_ASSERT_BT(ret != SECURITY_SERVER_API_SUCCESS); + RUNNER_ASSERT(ret != SECURITY_SERVER_API_SUCCESS); } RUNNER_CHILD_TEST_SMACK(tc03_check_API_passwd_allow) @@ -210,27 +210,27 @@ RUNNER_CHILD_TEST_SMACK(tc03_check_API_passwd_allow) provider.applyAndSwithToUser(APP_UID, APP_GID); ret = security_server_set_pwd_validity(10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret); ret = security_server_set_pwd_max_challenge(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret); ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(NULL, "12345", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); ret = security_server_reset_pwd("12345",0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd("12345", &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); ret = security_server_set_pwd_history(10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); } RUNNER_CHILD_TEST_SMACK(tc04_check_API_passwd_denied) @@ -250,7 +250,7 @@ RUNNER_CHILD_TEST_SMACK(tc07_check_API_data_share_allow) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = security_server_app_give_access(TEST07_SUBJECT, getpid()); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); } RUNNER_CHILD_TEST_SMACK(tc08_check_API_data_share_denied) @@ -259,7 +259,7 @@ RUNNER_CHILD_TEST_SMACK(tc08_check_API_data_share_denied) provider.applyAndSwithToUser(APP_UID, APP_GID); int ret = security_server_app_give_access(TEST08_SUBJECT, getpid()); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "security_server_app_give_access should return access denied," " ret: " << ret); } @@ -286,15 +286,15 @@ RUNNER_CHILD_TEST_NOSMACK(tc01_security_server_app_give_access_nosmack) int result = 0; result = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(result == 0, + RUNNER_ASSERT_MSG(result == 0, "Failed to drop root privileges. Result: " << result << "uid = " << getuid()); result = security_server_app_give_access(subject, getpid()); - RUNNER_ASSERT_MSG_BT(result == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(result == SECURITY_SERVER_API_SUCCESS, "Error in security_server_app_give_access. Result: " << result); result = smack_have_access(subject, object, "rwxat"); - RUNNER_ASSERT_MSG_BT(result == -1, + RUNNER_ASSERT_MSG(result == -1, "smack_have_access should return error when SMACK is off. Result: " << result); } @@ -314,12 +314,12 @@ RUNNER_TEST_NOSMACK(tc02_check_privilege_by_pid_nosmack) //we checking existing rule, it should return positive ret = security_server_check_privilege_by_pid(pid, "_", "rx"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "check_privilege_by_pid for existing label failed. Result: " << ret); //we checking rule with label that not exist ret = security_server_check_privilege_by_pid(pid, "thislabelisnotreal", "rwxat"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "check_privilege_by_pid for nonexisting label failed. Result: " << ret); } @@ -339,11 +339,11 @@ int clear_password_nosmack() attempt = max_attempt = expire_sec = UINT_MAX; ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "is_pwd_faild should return no password error. Result: " << ret); - RUNNER_ASSERT_MSG_BT(expire_sec == 0, "expire_sec = " << expire_sec << ", should be 0."); - RUNNER_ASSERT_MSG_BT(max_attempt == 0, "max_attempt = " << max_attempt << ", should be 0."); - RUNNER_ASSERT_MSG_BT(attempt == 0, "attempt = " << attempt << ", should be 0."); + RUNNER_ASSERT_MSG(expire_sec == 0, "expire_sec = " << expire_sec << ", should be 0."); + RUNNER_ASSERT_MSG(max_attempt == 0, "max_attempt = " << max_attempt << ", should be 0."); + RUNNER_ASSERT_MSG(attempt == 0, "attempt = " << attempt << ", should be 0."); return 0; } @@ -369,37 +369,37 @@ RUNNER_CHILD_TEST_NOSMACK(tc03_check_API_passwd_allow_nosmack) // drop root privileges ret = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(ret == 0, + RUNNER_ASSERT_MSG(ret == 0, "Failed to drop root privileges. Result: " << ret << "uid = " << getuid()); ret = security_server_set_pwd_validity(10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "set_pwd_validity should return no password error. Result: " << ret); ret = security_server_set_pwd_max_challenge(5); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "set_pwd_max_challenge should return no password error. Result: " << ret); ret = security_server_is_pwd_valid(&attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "is_pwd_valid should return no password error. Result: " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_set_pwd(NULL, "12345", 0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "set_pwd failed. Result: " << ret); ret = security_server_reset_pwd("12345",0, 0); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "reset_pwd failed. Result: " << ret); usleep(PASSWORD_RETRY_TIMEOUT_US); ret = security_server_chk_pwd("12345", &attempt, &max_attempt, &expire_sec); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "chk_pwd failed. Result: " << ret); ret = security_server_set_pwd_history(10); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "set_pwd_history failed. Result: " << ret); } @@ -416,11 +416,11 @@ RUNNER_CHILD_TEST_NOSMACK(tc07_check_API_data_share_allow_nosmack) // drop root privileges ret = drop_root_privileges(); - RUNNER_ASSERT_MSG_BT(ret == 0, + RUNNER_ASSERT_MSG(ret == 0, "Failed to drop root privileges. Result: " << ret << "uid = " << getuid()); ret = security_server_app_give_access(TEST07_SUBJECT, getpid()); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "app_give_access failed. Result: " << ret); } diff --git a/tests/security-server-tests/weird_arguments.cpp b/tests/security-server-tests/weird_arguments.cpp index 46df994..fbf86db 100644 --- a/tests/security-server-tests/weird_arguments.cpp +++ b/tests/security-server-tests/weird_arguments.cpp @@ -22,27 +22,27 @@ RUNNER_TEST(tc01_security_server_get_gid_weird_input_case) /* normal param case */ ret = security_server_get_gid("tel_sim"); - RUNNER_ASSERT_MSG_BT(ret > -1, "ret: " << ret); + RUNNER_ASSERT_MSG(ret > -1, "ret: " << ret); /* wrong param case */ ret = security_server_get_gid("elephony_akecall"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT, "ret: " << ret); /* weird param case */ ret = security_server_get_gid(weird); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT, "ret: " << ret); /* null param case */ ret = security_server_get_gid(NULL); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); /* param too long case */ ret = security_server_get_gid("abcdefghijklmnopqrstuvwxyz01234"); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); /* empty param case */ ret = security_server_get_gid(""); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); } /* from security_server_tests_server.cpp */ @@ -56,14 +56,14 @@ RUNNER_TEST(tc03_security_server_request_cookie_weird_input_case) char *cookie = NULL; ret = security_server_request_cookie(cookie, cookie_size); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); /* buffer size too small case */ cookie_size = 19; char cookie2[cookie_size]; ret = security_server_request_cookie(cookie2, cookie_size); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_BUFFER_TOO_SMALL, "ret: " << ret); } RUNNER_TEST(tc04_security_server_check_privilege_weird_input_case) @@ -76,18 +76,18 @@ RUNNER_TEST(tc04_security_server_check_privilege_weird_input_case) char *cookie = NULL; ret = security_server_check_privilege(cookie, gid); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); char cookie2[cookie_size]; ret = security_server_request_cookie(cookie2, cookie_size); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); /* big gid case */ gid = 70666; ret = security_server_check_privilege(cookie2, gid); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED, "ret: " << ret); } RUNNER_TEST(tc05_security_server_check_privilege_by_cookie_weird_input_case) { @@ -100,22 +100,22 @@ RUNNER_TEST(tc05_security_server_check_privilege_by_cookie_weird_input_case) /* null cookie case */ char *cookie = NULL; ret = security_server_check_privilege_by_cookie(cookie, object, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); /* null object case */ char *object2 = NULL; char cookie2[cookie_size]; ret = security_server_request_cookie(cookie2, cookie_size); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret); ret = security_server_check_privilege_by_cookie(cookie2, object2, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); /* null access rights case */ access_rights = NULL; ret = security_server_check_privilege_by_cookie(cookie2, object, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); } RUNNER_TEST_SMACK(tc06_security_server_check_privilege_by_sockfd_weird_input_case) @@ -128,18 +128,18 @@ RUNNER_TEST_SMACK(tc06_security_server_check_privilege_by_sockfd_weird_input_cas /* invalid sockfd case */ ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); sockfd = 0; /* null object case */ char *object2 = NULL; ret = security_server_check_privilege_by_sockfd(sockfd, object2, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); /* null access rights case */ access_rights = NULL; ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret); } RUNNER_TEST(tc07_security_server_get_cookie_pid_weird_input_case) @@ -148,7 +148,7 @@ RUNNER_TEST(tc07_security_server_get_cookie_pid_weird_input_case) char *cookie = NULL; ret = security_server_get_cookie_pid(cookie); - RUNNER_ASSERT_BT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM); + RUNNER_ASSERT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM); } /////////////////////////// @@ -173,20 +173,20 @@ RUNNER_TEST_NOSMACK(tc06_security_server_check_privilege_by_sockfd_weird_input_c //invalid sockfd case ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "check_privilege_by_sockfd failed. Result: " << ret); sockfd = 0; //null object case char *object2 = NULL; ret = security_server_check_privilege_by_sockfd(sockfd, object2, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "check_privilege_by_sockfd failed. Result: " << ret); //null access rights case access_rights = NULL; ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights); - RUNNER_ASSERT_MSG_BT(ret == SECURITY_SERVER_API_SUCCESS, + RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "check_privilege_by_sockfd failed. Result: " << ret); } -- 2.7.4