tests: fix running with non-root user

Refs: #3418

Change-Id: If7f5c05baaff0cf748c87c77057517928539df0d
diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp
index 8c41e63..b827c85 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 @@
       "  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() // 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 0b1a156..6296fc8 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(ProcessSectionUdp)
 {
+  SKIP_IF_NOT_SUPERUSER();
+
   const std::string CONFIG =
     "face_system\n"
     "{\n"
@@ -294,6 +296,8 @@
 
 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 debd2b8..d3af366 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(UserAndGroupConfig)
 {
+  SKIP_IF_NOT_SUPERUSER();
+
   const std::string CONFIG =
     "general\n"
     "{\n"
@@ -81,6 +83,8 @@
 
 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 7c9c60d..fea503b 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 <ndn-cxx/util/time-unit-test-clock.hpp>
 #include <ndn-cxx/security/key-chain.hpp>
 
+#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#include <unistd.h>
+#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 {