tests: fix running with non-root user

Refs: #3418

Change-Id: If7f5c05baaff0cf748c87c77057517928539df0d
This commit is contained in:
Weiwei Liu
2016-03-19 07:00:42 +00:00
parent 2879779804
commit f5aee94f15
5 changed files with 34 additions and 5 deletions
@@ -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
@@ -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"
@@ -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"
+14 -1
View File
@@ -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 {
+3
View File
@@ -97,6 +97,9 @@ main(int, char**)
int ret = setegid(grp.gr_gid);
ret = seteuid(pwd.pw_uid);
(void)(ret);
getegid();
geteuid();
return 0;
}
'''):