]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3493] Automatically run tests that require root privileges with sudo
authorAndrei Pavel <andrei@isc.org>
Wed, 28 May 2025 06:26:46 +0000 (09:26 +0300)
committerAndrei Pavel <andrei@isc.org>
Tue, 17 Jun 2025 18:34:44 +0000 (21:34 +0300)
If user already has root privileges or if passwordless sudo is set up,
to avoid false failures caused by non-working sudo.

meson.build
src/hooks/dhcp/ping_check/tests/icmp_socket_unittests.cc
src/hooks/dhcp/ping_check/tests/meson.build
src/hooks/dhcp/ping_check/tests/ping_channel_unittests.cc
src/hooks/dhcp/ping_check/tests/ping_check_mgr_unittests.cc
src/lib/dhcp/tests/meson.build
src/lib/dhcp/tests/pkt_filter_bpf_unittest.cc
src/lib/dhcp/tests/pkt_filter_lpf_unittest.cc

index 4e0ec39f9fb575fbfa17c2b72b6ebb90b19d5be9..a7d577e8ca58f69ee1f6a3f6e15ae2d658e5c777 100644 (file)
@@ -121,6 +121,7 @@ PIP_COMPILE = find_program('pip-compile', required: false)
 PLANTUML = find_program('plantuml', required: false)
 PYTHON = find_program('python3', 'python', required: true)
 SPHINX = find_program('sphinx-build', 'sphinx-build-3', required: false)
+SUDO = find_program('sudo', required: false)
 XMLLINT = find_program('xmllint', required: false)
 
 CD_AND_RUN = find_program(TOP_SOURCE_DIR / 'scripts/cd-and-run.sh')
@@ -567,6 +568,14 @@ else
 endif
 conf_data.set('PACKAGE_VERSION_TYPE', f'"@package_version_type@"')
 
+PASSWORDLESS_SUDO_SET_UP = false
+if SUDO.found()
+    result = run_command(SUDO, '-n', 'true', check: false)
+    if result.returncode() == 0
+        PASSWORDLESS_SUDO_SET_UP = true
+    endif
+endif
+
 #### Compiler
 
 compile_args = []
index 2394b360ca0d0b5e0e54b9943086a058ba1b57e9..747d970da0259f622afb17123803702ad6a9a834 100644 (file)
@@ -250,9 +250,11 @@ public:
     std::vector<uint8_t> input_buf_;
 };
 
+// Test fixture used to distinguish tests that require root privileges.
+struct RootICMPSocketTest : ICMPSocketTest {};
 
 // Verifies that an ICMP socket can be opened and closed.
-TEST_F(ICMPSocketTest, openClose) {
+TEST_F(RootICMPSocketTest, openClose) {
     SKIP_IF(notRoot());
 
     // For open the endpoint is only used to determine protocol, the address is irrelevant.
@@ -286,7 +288,7 @@ TEST_F(ICMPSocketTest, openClose) {
 }
 
 // Verifies that an ICMP socket can send and receive ICMP messages.
-TEST_F(ICMPSocketTest, sendReceive) {
+TEST_F(RootICMPSocketTest, sendReceive) {
     SKIP_IF(notRoot());
 
     PingSocket socket(io_service_);
index 8beca7813e184e0489d30db094fa44f8bd0e4f8e..9cad2dc223c8a98931b2f95a7a0da1aabd9ed1f1 100644 (file)
@@ -18,4 +18,26 @@ dhcp_ping_check_tests = executable(
     include_directories: [include_directories('.'), include_directories('..')] + INCLUDES,
     link_with: [dhcp_ping_check_archive] + LIBS_BUILT_SO_FAR,
 )
-test('dhcp-ping-check-tests', dhcp_ping_check_tests, protocol: 'gtest')
+
+root_tests = 'RootICMPSocketTest.*:RootPingChannelTest.*:RootPingCheckMgr.*:RootPingCheckMgrTest.*'
+
+test(
+    'dhcp-ping-check-tests',
+    dhcp_ping_check_tests,
+    args: [f'--gtest_filter=-@root_tests@'],
+    protocol: 'gtest',
+    is_parallel: false,
+    priority: -1,
+)
+
+if PASSWORDLESS_SUDO_SET_UP
+    test(
+        'sudo-dhcp-ping-check-tests',
+        SUDO,
+        args: [dhcp_ping_check_tests, f'--gtest_filter=@root_tests@'],
+        protocol: 'gtest',
+        is_parallel: false,
+        priority: -1,
+        suite: 'sudo-tests',
+    )
+endif
index 505bf71c43b75a4b34599cc57815d27471124370..65e98a7228f458040944937a477e9c194a57755a 100644 (file)
@@ -284,6 +284,9 @@ public:
     bool stopped_;
 };
 
+// Test fixture used to distinguish tests that require root privileges.
+struct RootPingChannelTest : PingChannelTest {};
+
 void
 PingChannelTest::sendReceiveTest(size_t num_threads, size_t num_targets /* = 25 */,
                                  const std::function<void()>& set_error_trigger) {
@@ -516,7 +519,7 @@ PingChannelTest::ioErrorTest(const std::function<void()>& set_error_trigger,
 }
 
 // Verifies PingChannel open and close operations.
-TEST_F(PingChannelTest, openCloseST) {
+TEST_F(RootPingChannelTest, openCloseST) {
     SKIP_IF(notRoot());
 
     // Create the channel instance.
@@ -580,7 +583,7 @@ TEST_F(PingChannelTest, openCloseST) {
 }
 
 // Verifies PingChannel open and close operations.
-TEST_F(PingChannelTest, openCloseMT) {
+TEST_F(RootPingChannelTest, openCloseMT) {
     SKIP_IF(notRoot());
     MultiThreadingTest mt;
 
@@ -629,20 +632,20 @@ TEST_F(PingChannelTest, openCloseMT) {
 
 // Verifies that a PingChannel can perpetuate sending requests and receiving
 // replies when driven by a single-threaded IOService.
-TEST_F(PingChannelTest, sendReceiveST) {
+TEST_F(RootPingChannelTest, sendReceiveST) {
     sendReceiveTest(0);
 }
 
 // Verifies that a PingChannel can perpetuate sending requests and receiving
 // replies when driven by a multi-threaded IOServiceThreadPool 3 threads
-TEST_F(PingChannelTest, sendReceiveMT) {
+TEST_F(RootPingChannelTest, sendReceiveMT) {
     // Use a thread pool with 3 threads.
     sendReceiveTest(3);
 }
 
 // Verifies that an exception throw from asyncRead triggers graceful channel
 // shutdown and that operations can be resumed with a single-threaded channel.
-TEST_F(PingChannelTest, readExceptionErrorST) {
+TEST_F(RootPingChannelTest, readExceptionErrorST) {
     ioErrorTest(
         [this]() {
             channel_->throw_on_read_number_ = 5;
@@ -651,7 +654,7 @@ TEST_F(PingChannelTest, readExceptionErrorST) {
 
 // Verifies that an exception throw from asyncRead triggers graceful channel
 // shutdown and that operations can be resumed with a multi-threaded channel.
-TEST_F(PingChannelTest, readExceptionErrorMT) {
+TEST_F(RootPingChannelTest, readExceptionErrorMT) {
     // Use a thread pool with 3 threads.
     ioErrorTest(
         [this]() {
@@ -661,7 +664,7 @@ TEST_F(PingChannelTest, readExceptionErrorMT) {
 
 // Verifies that a fatal error code passed into socketReadCallback triggers graceful channel
 // shutdown and that operations can be resumed with a single-threaded channel.
-TEST_F(PingChannelTest, readFatalErrorST) {
+TEST_F(RootPingChannelTest, readFatalErrorST) {
     ioErrorTest(
         [this]() {
             channel_->ec_on_read_number_ = 3;
@@ -672,7 +675,7 @@ TEST_F(PingChannelTest, readFatalErrorST) {
 
 // Verifies that a fatal error code passed into socketReadCallback triggers graceful channel
 // shutdown and that operations can be resumed with a single-threaded channel.
-TEST_F(PingChannelTest, readFatalErrorMT) {
+TEST_F(RootPingChannelTest, readFatalErrorMT) {
     ioErrorTest(
         [this]() {
             channel_->ec_on_read_number_ = 3;
@@ -683,7 +686,7 @@ TEST_F(PingChannelTest, readFatalErrorMT) {
 
 // Verifies that a non-fatal, EWOULDBLOCK error passed into socketReadCallback does
 // not disrupt reading for a single-threaded channel.
-TEST_F(PingChannelTest, readAgainErrorST) {
+TEST_F(RootPingChannelTest, readAgainErrorST) {
     sendReceiveTest(0, 10,
         [this]() {
             channel_->ec_on_read_number_ = 4;
@@ -694,7 +697,7 @@ TEST_F(PingChannelTest, readAgainErrorST) {
 
 // Verifies that a non-fatal, EWOULDBLOCK error passed into socketReadCallback does
 // not disrupt reading for a multi-threaded channel.
-TEST_F(PingChannelTest, readAgainErrorMT) {
+TEST_F(RootPingChannelTest, readAgainErrorMT) {
     sendReceiveTest(3, 10,
         [this]() {
             channel_->ec_on_read_number_ = 4;
@@ -705,7 +708,7 @@ TEST_F(PingChannelTest, readAgainErrorMT) {
 
 // Verifies that an exception throw from asyncRead triggers graceful channel
 // shutdown and that operations can be resumed with a single-threaded channel.
-TEST_F(PingChannelTest, writeExceptionErrorST) {
+TEST_F(RootPingChannelTest, writeExceptionErrorST) {
     ioErrorTest(
         [this]() {
             channel_->throw_on_write_number_ = 5;
@@ -714,7 +717,7 @@ TEST_F(PingChannelTest, writeExceptionErrorST) {
 
 // Verifies that an exception throw from asyncRead triggers graceful channel
 // shutdown and that operations can be resumed with a multi-threaded channel.
-TEST_F(PingChannelTest, writeExceptionErrorMT) {
+TEST_F(RootPingChannelTest, writeExceptionErrorMT) {
     // Use a thread pool with 3 threads.
     ioErrorTest(
         [this]() {
@@ -724,7 +727,7 @@ TEST_F(PingChannelTest, writeExceptionErrorMT) {
 
 // Verifies that a fatal error code passed into socketReadCallback triggers graceful channel
 // shutdown and that operations can be resumed with a single-threaded channel.
-TEST_F(PingChannelTest, writeFatalErrorST) {
+TEST_F(RootPingChannelTest, writeFatalErrorST) {
     ioErrorTest(
         [this]() {
             channel_->ec_on_write_number_ = 3;
@@ -735,7 +738,7 @@ TEST_F(PingChannelTest, writeFatalErrorST) {
 
 // Verifies that a fatal error code passed into socketReadCallback triggers graceful channel
 // shutdown and that operations can be resumed with a single-threaded channel.
-TEST_F(PingChannelTest, writeFatalErrorMT) {
+TEST_F(RootPingChannelTest, writeFatalErrorMT) {
     ioErrorTest(
         [this]() {
             channel_->ec_on_write_number_ = 3;
@@ -746,7 +749,7 @@ TEST_F(PingChannelTest, writeFatalErrorMT) {
 
 // Verifies that a non-fatal, EWOULDBLOCK error passed into socketWriteCallback does
 // not disrupt writing for a single-threaded channel.
-TEST_F(PingChannelTest, writeAgainErrorST) {
+TEST_F(RootPingChannelTest, writeAgainErrorST) {
     sendReceiveTest(0, 10,
         [this]() {
             channel_->ec_on_write_number_ = 6;
@@ -757,7 +760,7 @@ TEST_F(PingChannelTest, writeAgainErrorST) {
 
 // Verifies that a non-fatal, EWOULDBLOCK error passed into socketWriteCallback
 // does not disrupt writing for a multi-threaded channel.
-TEST_F(PingChannelTest, writeAgainErrorMT) {
+TEST_F(RootPingChannelTest, writeAgainErrorMT) {
     sendReceiveTest(3, 10,
         [this]() {
             channel_->ec_on_write_number_ = 6;
@@ -768,7 +771,7 @@ TEST_F(PingChannelTest, writeAgainErrorMT) {
 
 // Verify the recoverable write errors do not disrupt writing for a
 // single-threaded channel.
-TEST_F(PingChannelTest, writeSendFailedErrorST) {
+TEST_F(RootPingChannelTest, writeSendFailedErrorST) {
     SKIP_IF(notRoot());
 
     std::list<boost::asio::error::basic_errors> errors = {
@@ -794,7 +797,7 @@ TEST_F(PingChannelTest, writeSendFailedErrorST) {
 
 // Verify the recoverable write errors do not disrupt writing for a
 // multi-threaded channel.
-TEST_F(PingChannelTest, writeSendFailedErrorMT) {
+TEST_F(RootPingChannelTest, writeSendFailedErrorMT) {
     SKIP_IF(notRoot());
 
     std::list<boost::asio::error::basic_errors> errors = {
index e885dfcb9a32fbb28d00c0dd2a7e8dfd1291f4b3..8685597057233ddc961103de30a2d59159b78398 100644 (file)
@@ -38,8 +38,11 @@ namespace ph = std::placeholders;
 
 namespace {
 
+// Test fixture used to distinguish tests that require root privileges.
+struct RootPingCheckMgr : PingCheckMgr {};
+
 // Sanity check the basics for production class, PingCheckMgr, single-threaded mode.
-TEST(PingCheckMgr, basicsST) {
+TEST(RootPingCheckMgr, basicsST) {
     SKIP_IF(IOServiceTest::notRoot());
     MultiThreadingMgr::instance().setMode(false);
 
@@ -112,7 +115,7 @@ TEST(PingCheckMgr, basicsST) {
 
 // Sanity check the basics for production class, PingCheckMgr. Bulk of testing
 // is done with test derivation, TestPingCheckMgr.
-TEST(PingCheckMgr, basicsMT) {
+TEST(RootPingCheckMgr, basicsMT) {
     SKIP_IF(IOServiceTest::notRoot());
     MultiThreadingTest mt;
 
@@ -1777,110 +1780,114 @@ public:
     LeaseQueryPairs frees_;
 };
 
-TEST_F(PingCheckMgrTest, operationalBasicsST) {
+// Test fixture used to distinguish tests that require root privileges.
+struct RootPingCheckMgrTest : PingCheckMgrTest {};
+
+
+TEST_F(RootPingCheckMgrTest, operationalBasicsST) {
     testOperationalBasics(0);
 }
 
-TEST_F(PingCheckMgrTest, operationalBasicsMT) {
+TEST_F(RootPingCheckMgrTest, operationalBasicsMT) {
     MultiThreadingTest mt;
     testOperationalBasics(3);
 }
 
-TEST_F(PingCheckMgrTest, startPingST) {
+TEST_F(RootPingCheckMgrTest, startPingST) {
     testStartPing();
 }
 
-TEST_F(PingCheckMgrTest, startPingMT) {
+TEST_F(RootPingCheckMgrTest, startPingMT) {
     MultiThreadingTest mt;
     testStartPing();
 }
 
-TEST_F(PingCheckMgrTest, nextToSendST) {
+TEST_F(RootPingCheckMgrTest, nextToSendST) {
     testNextToSend();
 }
 
-TEST_F(PingCheckMgrTest, nextToSendMT) {
+TEST_F(RootPingCheckMgrTest, nextToSendMT) {
     MultiThreadingTest mt;
     testNextToSend();
 }
 
-TEST_F(PingCheckMgrTest, setNextExpirationST) {
+TEST_F(RootPingCheckMgrTest, setNextExpirationST) {
     testSetNextExpiration();
 }
 
-TEST_F(PingCheckMgrTest, setNextExpirationMT) {
+TEST_F(RootPingCheckMgrTest, setNextExpirationMT) {
     MultiThreadingTest mt;
     testSetNextExpiration();
 }
 
-TEST_F(PingCheckMgrTest, sendCompletedST) {
+TEST_F(RootPingCheckMgrTest, sendCompletedST) {
     testSendCompleted();
 }
 
-TEST_F(PingCheckMgrTest, sendCompletedMT) {
+TEST_F(RootPingCheckMgrTest, sendCompletedMT) {
     MultiThreadingTest mt;
     testSendCompleted();
 }
 
-TEST_F(PingCheckMgrTest, replyReceivedForEchoReplyST) {
+TEST_F(RootPingCheckMgrTest, replyReceivedForEchoReplyST) {
     testReplyReceivedForEchoReply();
 }
 
-TEST_F(PingCheckMgrTest, replyReceivedForEchoReplyMT) {
+TEST_F(RootPingCheckMgrTest, replyReceivedForEchoReplyMT) {
     MultiThreadingTest mt;
     testReplyReceivedForEchoReply();
 }
 
-TEST_F(PingCheckMgrTest, replyReceivedForTargetUnreachableST) {
+TEST_F(RootPingCheckMgrTest, replyReceivedForTargetUnreachableST) {
     testReplyReceivedForTargetUnreachable();
 }
 
-TEST_F(PingCheckMgrTest, replyReceivedForTargetUnreachableMT) {
+TEST_F(RootPingCheckMgrTest, replyReceivedForTargetUnreachableMT) {
     MultiThreadingTest mt;
     testReplyReceivedForTargetUnreachable();
 }
 
-TEST_F(PingCheckMgrTest, expirationProcessingST) {
+TEST_F(RootPingCheckMgrTest, expirationProcessingST) {
     testExpirationProcessing();
 }
 
-TEST_F(PingCheckMgrTest, expirationProcessingMT) {
+TEST_F(RootPingCheckMgrTest, expirationProcessingMT) {
     MultiThreadingTest mt;
     testExpirationProcessing();
 }
 
-TEST_F(PingCheckMgrTest, multiplePingsWithReplyST) {
+TEST_F(RootPingCheckMgrTest, multiplePingsWithReplyST) {
     testMultiplePingsWithReply();
 }
 
-TEST_F(PingCheckMgrTest, multiplePingsWithReplyMT) {
+TEST_F(RootPingCheckMgrTest, multiplePingsWithReplyMT) {
     MultiThreadingTest mt;
     testMultiplePingsWithReply();
 }
 
-TEST_F(PingCheckMgrTest, multiplePingsWithReplyAndPauseST) {
+TEST_F(RootPingCheckMgrTest, multiplePingsWithReplyAndPauseST) {
     testMultiplePingsWithReplyAndPause();
 }
 
-TEST_F(PingCheckMgrTest, multiplePingsWithReplyAndPauseMT) {
+TEST_F(RootPingCheckMgrTest, multiplePingsWithReplyAndPauseMT) {
     MultiThreadingTest mt;
     testMultiplePingsWithReplyAndPause();
 }
 
-TEST_F(PingCheckMgrTest, sendCompletedSendFailedST) {
+TEST_F(RootPingCheckMgrTest, sendCompletedSendFailedST) {
     testSendCompletedSendFailed();
 }
 
-TEST_F(PingCheckMgrTest, sendCompletedSendFailedMT) {
+TEST_F(RootPingCheckMgrTest, sendCompletedSendFailedMT) {
     MultiThreadingTest mt;
     testSendCompletedSendFailed();
 }
 
-TEST_F(PingCheckMgrTest, shouldPingST) {
+TEST_F(RootPingCheckMgrTest, shouldPingST) {
     testShouldPingTest();
 }
 
-TEST_F(PingCheckMgrTest, shouldPingMT) {
+TEST_F(RootPingCheckMgrTest, shouldPingMT) {
     MultiThreadingTest mt;
     testShouldPingTest();
 }
@@ -1894,11 +1901,11 @@ TEST_F(PingCheckMgrTest, getScopedConfigMT) {
     testGetScopedConfig();
 }
 
-TEST_F(PingCheckMgrTest, checkSuspendedST) {
+TEST_F(RootPingCheckMgrTest, checkSuspendedST) {
     testCheckSuspended();
 }
 
-TEST_F(PingCheckMgrTest, checkSuspendedMT) {
+TEST_F(RootPingCheckMgrTest, checkSuspendedMT) {
     MultiThreadingTest mt;
     testCheckSuspended();
 }
index bbf125eef50e831bfecef9b96c33475d0def33eb..333a730cb4d86261a74febd77c80d9f2ce7a4b43 100644 (file)
@@ -66,10 +66,26 @@ kea_dhcp_tests = executable(
     include_directories: [include_directories('.')] + INCLUDES,
     link_with: [kea_util_unittests_lib, libs_testutils] + LIBS_BUILT_SO_FAR,
 )
+
+root_tests = 'RootPktFilterBPFTest.*:RootPktFilterLPFTest.*'
+
 test(
     'kea-dhcp-tests',
     kea_dhcp_tests,
+    args: [f'--gtest_filter=-@root_tests@'],
     protocol: 'gtest',
     is_parallel: false,
     priority: -1,
 )
+
+if PASSWORDLESS_SUDO_SET_UP
+    test(
+        'sudo-kea-dhcp-tests',
+        SUDO,
+        args: [kea_dhcp_tests, f'--gtest_filter=@root_tests@'],
+        protocol: 'gtest',
+        is_parallel: false,
+        priority: -1,
+        suite: 'sudo-tests',
+    )
+endif
index 05c683396d2432bb96fd02a69e2ab10e802cd66f..cfc093607df9aeb95d9f1dd3d5cb3314e7008597 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014-2025 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -38,6 +38,9 @@ public:
     }
 };
 
+// Test fixture used to distinguish tests that require root privileges.
+struct RootPktFilterBPFTest : PktFilterBPFTest {};
+
 // This test verifies that the PktFilterBPF class reports its capability
 // to send packets to the host having no IP address assigned.
 TEST_F(PktFilterBPFTest, isDirectResponseSupported) {
@@ -60,7 +63,7 @@ TEST_F(PktFilterBPFTest, isSocketReceivedTimeSupported) {
 
 // This test verifies that the raw AF_PACKET family socket can
 // be opened and bound to the specific interface.
-TEST_F(PktFilterBPFTest, openSocket) {
+TEST_F(RootPktFilterBPFTest, openSocket) {
     SKIP_IF(notRoot());
 
     // Create object representing loopback interface.
@@ -90,7 +93,7 @@ TEST_F(PktFilterBPFTest, openSocket) {
 // test over the real interface but since we don't know what interfaces
 // are present in the particular system we have to stick to local loopback
 // interface as this one is almost always present.
-TEST_F(PktFilterBPFTest, send) {
+TEST_F(RootPktFilterBPFTest, send) {
     SKIP_IF(notRoot());
 
     // Packet will be sent over loopback interface.
@@ -172,7 +175,7 @@ TEST_F(PktFilterBPFTest, send) {
 
 // This test verifies correctness of reception of the DHCP packet over
 // raw socket, whereby all IP stack headers are hand-crafted.
-TEST_F(PktFilterBPFTest, receive) {
+TEST_F(RootPktFilterBPFTest, receive) {
     SKIP_IF(notRoot());
 
     // Packet will be received over loopback interface.
@@ -211,7 +214,7 @@ TEST_F(PktFilterBPFTest, receive) {
 // This test verifies that if the packet is received over the raw
 // socket and its destination address doesn't match the address
 // to which the socket is "bound", the packet is dropped.
-TEST_F(PktFilterBPFTest, filterOutUnicast) {
+TEST_F(RootPktFilterBPFTest, filterOutUnicast) {
     SKIP_IF(notRoot());
 
     // Packet will be received over loopback interface.
index f5952c0e77c8d304eadadc2687eceb681916d943..928699e2d7ac8a695e3e938806a922989483a007 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2024 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2025 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -38,6 +38,9 @@ public:
     }
 };
 
+// Test fixture used to distinguish tests that require root privileges.
+struct RootPktFilterLPFTest : PktFilterLPFTest {};
+
 // This test verifies that the PktFilterLPF class reports its capability
 // to send packets to the host having no IP address assigned.
 TEST_F(PktFilterLPFTest, isDirectResponseSupported) {
@@ -64,7 +67,7 @@ TEST_F(PktFilterLPFTest, isSocketReceivedTimeSupported) {
 
 // This test verifies that the raw AF_PACKET family socket can
 // be opened and bound to the specific interface.
-TEST_F(PktFilterLPFTest, openSocket) {
+TEST_F(RootPktFilterLPFTest, openSocket) {
     SKIP_IF(notRoot());
 
     // Create object representing loopback interface.
@@ -102,7 +105,7 @@ TEST_F(PktFilterLPFTest, openSocket) {
 
 // This test verifies correctness of sending DHCP packet through the raw
 // socket, whereby all IP stack headers are hand-crafted.
-TEST_F(PktFilterLPFTest, send) {
+TEST_F(RootPktFilterLPFTest, send) {
     SKIP_IF(notRoot());
 
     // Packet will be sent over loopback interface.
@@ -165,7 +168,7 @@ TEST_F(PktFilterLPFTest, send) {
 
 // This test verifies correctness of reception of the DHCP packet over
 // raw socket, whereby all IP stack headers are hand-crafted.
-TEST_F(PktFilterLPFTest, receive) {
+TEST_F(RootPktFilterLPFTest, receive) {
     SKIP_IF(notRoot());
 
     // Packet will be received over loopback interface.
@@ -202,7 +205,7 @@ TEST_F(PktFilterLPFTest, receive) {
 // This test verifies that if the packet is received over the raw
 // socket and its destination address doesn't match the address
 // to which the socket is "bound", the packet is dropped.
-TEST_F(PktFilterLPFTest, filterOutUnicast) {
+TEST_F(RootPktFilterLPFTest, filterOutUnicast) {
     SKIP_IF(notRoot());
 
     // Packet will be received over loopback interface.