ci: stop adding capabilities before running unit tests
This ensures that all tests pass (or are automatically skipped)
when run as an unprivileged user.
Change-Id: If8b66fd6555de455648576565b1c6cbd02695d1b
Refs: #3418
diff --git a/tests/daemon/mgmt/general-config-section.t.cpp b/tests/daemon/mgmt/general-config-section.t.cpp
index d3af366..26e87ea 100644
--- a/tests/daemon/mgmt/general-config-section.t.cpp
+++ b/tests/daemon/mgmt/general-config-section.t.cpp
@@ -28,6 +28,8 @@
#include "tests/test-common.hpp"
+#include <cstring>
+
namespace nfd {
namespace general {
namespace tests {
@@ -37,17 +39,18 @@
class GeneralConfigSectionFixture : public BaseFixture
{
public:
+#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
~GeneralConfigSectionFixture()
{
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
// revert changes to s_normalUid/s_normalGid, if any
PrivilegeHelper::s_normalUid = ::geteuid();
PrivilegeHelper::s_normalGid = ::getegid();
-#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
}
+#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
};
-BOOST_FIXTURE_TEST_SUITE(MgmtGeneralConfigSection, GeneralConfigSectionFixture)
+BOOST_AUTO_TEST_SUITE(Mgmt)
+BOOST_FIXTURE_TEST_SUITE(TestGeneralConfigSection, GeneralConfigSectionFixture)
BOOST_AUTO_TEST_CASE(DefaultConfig)
{
@@ -113,12 +116,6 @@
#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
-static bool
-checkExceptionMessage(const ConfigFile::Error& error, const std::string& expected)
-{
- return error.what() == expected;
-}
-
BOOST_AUTO_TEST_CASE(InvalidUserConfig)
{
const std::string CONFIG =
@@ -130,10 +127,12 @@
ConfigFile configFile;
general::setConfigFile(configFile);
- const std::string expected = "Invalid value for \"user\" in \"general\" section";
- BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
- ConfigFile::Error,
- bind(&checkExceptionMessage, _1, expected));
+ BOOST_CHECK_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
+ ConfigFile::Error,
+ [] (const ConfigFile::Error& e) {
+ return std::strcmp(e.what(),
+ "Invalid value for \"user\" in \"general\" section") == 0;
+ });
}
BOOST_AUTO_TEST_CASE(InvalidGroupConfig)
@@ -147,13 +146,16 @@
ConfigFile configFile;
general::setConfigFile(configFile);
- const std::string expected = "Invalid value for \"group\" in \"general\" section";
- BOOST_REQUIRE_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
- ConfigFile::Error,
- bind(&checkExceptionMessage, _1, expected));
+ BOOST_CHECK_EXCEPTION(configFile.parse(CONFIG, true, "test-general-config-section"),
+ ConfigFile::Error,
+ [] (const ConfigFile::Error& e) {
+ return std::strcmp(e.what(),
+ "Invalid value for \"group\" in \"general\" section") == 0;
+ });
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestGeneralConfigSection
+BOOST_AUTO_TEST_SUITE_END() // Mgmt
} // namespace tests
} // namespace general