diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp index 8c41e638..b827c85c 100644 --- a/tests/daemon/mgmt/face-manager-create-face.t.cpp +++ b/tests/daemon/mgmt/face-manager-create-face.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /** - * Copyright (c) 2014-2015, Regents of the University of California, + * Copyright (c) 2014-2016, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -62,6 +62,11 @@ public: " udp\n" " {\n" " port " + port + "\n" + " mcast no\n" + " }\n" + " ether\n" + " {\n" + " mcast no\n" " }\n" "}\n" "authorizations\n" @@ -457,5 +462,5 @@ BOOST_AUTO_TEST_SUITE_END() // CreateFace BOOST_AUTO_TEST_SUITE_END() // TestFaceManager BOOST_AUTO_TEST_SUITE_END() // Mgmt -} // tests -} // nfd +} // namespace tests +} // namespace nfd diff --git a/tests/daemon/mgmt/face-manager-process-config.t.cpp b/tests/daemon/mgmt/face-manager-process-config.t.cpp index 0b1a1565..6296fc85 100644 --- a/tests/daemon/mgmt/face-manager-process-config.t.cpp +++ b/tests/daemon/mgmt/face-manager-process-config.t.cpp @@ -157,6 +157,8 @@ BOOST_AUTO_TEST_CASE(ProcessSectionTcpUnknownOption) BOOST_AUTO_TEST_CASE(ProcessSectionUdp) { + SKIP_IF_NOT_SUPERUSER(); + const std::string CONFIG = "face_system\n" "{\n" @@ -294,6 +296,8 @@ BOOST_AUTO_TEST_CASE(ProcessSectionUdpUnknownOption) BOOST_AUTO_TEST_CASE(ProcessSectionUdpMulticastReinit) { + SKIP_IF_NOT_SUPERUSER(); + const std::string CONFIG_WITH_MCAST = "face_system\n" "{\n" diff --git a/tests/daemon/mgmt/general-config-section.t.cpp b/tests/daemon/mgmt/general-config-section.t.cpp index debd2b88..d3af3669 100644 --- a/tests/daemon/mgmt/general-config-section.t.cpp +++ b/tests/daemon/mgmt/general-config-section.t.cpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /** - * Copyright (c) 2014-2015, Regents of the University of California, + * Copyright (c) 2014-2016, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -66,6 +66,8 @@ BOOST_AUTO_TEST_CASE(DefaultConfig) BOOST_AUTO_TEST_CASE(UserAndGroupConfig) { + SKIP_IF_NOT_SUPERUSER(); + const std::string CONFIG = "general\n" "{\n" @@ -81,6 +83,8 @@ BOOST_AUTO_TEST_CASE(UserAndGroupConfig) BOOST_AUTO_TEST_CASE(NoUserConfig) { + SKIP_IF_NOT_SUPERUSER(); + const std::string CONFIG = "general\n" "{\n" diff --git a/tests/test-common.hpp b/tests/test-common.hpp index 7c9c60d9..fea503b8 100644 --- a/tests/test-common.hpp +++ b/tests/test-common.hpp @@ -1,6 +1,6 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /** - * Copyright (c) 2014-2015, Regents of the University of California, + * Copyright (c) 2014-2016, Regents of the University of California, * Arizona Board of Regents, * Colorado State University, * University Pierre & Marie Curie, Sorbonne University, @@ -34,6 +34,19 @@ #include #include +#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE +#include +#define SKIP_IF_NOT_SUPERUSER() \ + do { \ + if (::geteuid() != 0) { \ + BOOST_TEST_MESSAGE("This test case needs to be run as superuser, skipping"); \ + return; \ + } \ + } while (false) +#else +#define SKIP_IF_NOT_SUPERUSER() +#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE + namespace nfd { namespace tests { diff --git a/wscript b/wscript index d169a5a3..f1743422 100644 --- a/wscript +++ b/wscript @@ -97,6 +97,9 @@ main(int, char**) int ret = setegid(grp.gr_gid); ret = seteuid(pwd.pw_uid); (void)(ret); + + getegid(); + geteuid(); return 0; } '''):