Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ecf6adc2 authored by Bernie Innocenti's avatar Bernie Innocenti Committed by Luke Huang
Browse files

Explicitly require root privs for tests requiring it

These tests currently require root privs to interact with netd:
  resolv_integration_test
  libnetdbpf_test
  netd_unit_test
  netd_integration_test

Bug: 134891412
Bug: 136633978
Test: atest

Merged-In: Ib7387d83d0da5dde0ee43a164ee01989a458ae8a
(cherry picked from commit 4d89d8bda75c3e9dd05da494c284ec791545f64e)

Change-Id: I7c61ab2d68437c31339a5950f308b33cd2f1d8d6
parent 54b29fd0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ cc_library_static {
cc_test {
    name: "resolv_integration_test",
    test_suites: ["device-tests"],
    require_root: true,
    defaults: ["netd_defaults"],
    srcs: [
        "dns_responder/dns_responder.cpp",
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "dns_responder_client"
#include "dns_responder_client.h"

#include <android-base/logging.h>
#include <android-base/stringprintf.h>
#include <utils/Log.h>

@@ -152,6 +153,9 @@ void DnsResponderClient::SetUp() {
    // binder setup
    auto binder = android::defaultServiceManager()->getService(android::String16("netd"));
    mNetdSrv = android::interface_cast<android::net::INetd>(binder);
    if (mNetdSrv == nullptr) {
        LOG(FATAL) << "Can't connect to service 'netd'. Missing root privileges? uid=" << getuid();
    }

    auto resolvBinder =
            android::defaultServiceManager()->getService(android::String16("dnsresolver"));
+1 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ class DnsResolverBinderTest : public ::testing::Test {
        if (binder != nullptr) {
            mDnsResolver = android::interface_cast<IDnsResolver>(binder);
        }
        // This could happen when the test isn't running as root, or if netd isn't running.
        assert(nullptr != mDnsResolver.get());
        // Create cache for test
        mDnsResolver->createNetworkCache(TEST_NETID);