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

Commit 55e4f2c9 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6291259 from 6405f3e7 to rvc-release

Change-Id: I5ab20189a1afd80f64391975e6920f72de885bf3
parents fe25ab80 6405f3e7
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -23,6 +23,11 @@ aidl_interface {
        "netd_event_listener_interface",
    ],
    backend: {
        java: {
            apex_available: [
                "com.android.wifi",
            ],
        },
        ndk: {
            gen_log: true,
        },
@@ -80,7 +85,6 @@ cc_library {
        "libbase",
        "libcutils",
        "libjsoncpp",
        "liblog", //Used by libstatslog_resolv
        "libnetdutils",
        "libprotobuf-cpp-lite",
        "libstatslog_resolv",
@@ -95,9 +99,15 @@ cc_library {
    // integrity check (against a checksum) that is not supported for static
    // libs. See http://b/141248879
    // We're also adding libssl here to treat it consistently.
    // liblog is added as a shared library because it provides stable C API
    // from the platform; we don't need to include it in this module by
    // statically linking to it. Doing so is even dangerous because the socket
    // protocol to logd implemented in the library isn't guaranteed to be
    // stable. See b/151051671
    shared_libs: [
        "libbinder_ndk",
        "libcrypto",
        "liblog", //Used by libstatslog_resolv
        "libssl",
    ],
    header_libs: [
@@ -173,6 +183,7 @@ cc_test {
    name: "resolv_unit_test",
    test_suites: ["device-tests", "mts"],
    require_root: true,
    test_config: "resolv_unit_test_config.xml",
    //TODO:  drop root privileges and make it be an real unit test.
    defaults: ["netd_defaults"],
    srcs: [
+31 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<configuration description="Configuration for resolv unit tests">
   <option name="test-suite-tag" value="mts" />
   <target_preparer class="com.android.compatibility.common.tradefed.targetprep.FilePusher">
       <option name="cleanup" value="true" />
       <option name="push" value="resolv_unit_test->/data/local/tmp/resolv_unit_test" />
       <option name="append-bitness" value="true" />
   </target_preparer>
   <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
   <test class="com.android.tradefed.testtype.GTest" >
       <option name="native-test-device-path" value="/data/local/tmp" />
       <option name="module-name" value="resolv_unit_test" />
       <option name="runtime-hint" value="10m" />
       <!-- test-timeout unit is ms, value = 10 min -->
       <option name="native-test-timeout" value="600000" />
   </test>
</configuration>
+3 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ cc_library_static {
    defaults: ["netd_defaults"],
    proto: {
        export_proto_headers: true,
        type: "full",
        type: "lite",
    },
    srcs: [
        "golddata.proto",
@@ -34,7 +34,7 @@ cc_test {
    test_suites: ["device-tests", "mts"],
    require_root: true,
    defaults: ["netd_defaults"],
    data: ["testdata/*.pbtxt"],
    data: ["testdata/pb/*.pb"],
    srcs: [
        "resolv_gold_test.cpp",
    ],
@@ -44,7 +44,6 @@ cc_test {
    shared_libs: [
        "libbinder_ndk",
        "libcrypto",
        "libprotobuf-cpp-full",
        "libssl",
    ],
    static_libs: [
@@ -57,6 +56,7 @@ cc_test {
        "libnetd_test_dnsresponder_ndk",
        "libnetd_test_resolv_utils",
        "libnetdutils",
        "libprotobuf-cpp-lite",
        "netd_aidl_interface-ndk_platform",
        "netd_event_listener_interface-ndk_platform",
        "server_configurable_flags",
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

syntax = "proto3";
package android.net;
option optimize_for = LITE_RUNTIME;

// Used to indicate which call is invoked to send DNS lookups.
enum CallType {
+27 −18
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@
#include <Fwmark.h>
#include <android-base/chrono_utils.h>
#include <android-base/file.h>
#include <android-base/result.h>
#include <android-base/stringprintf.h>
#include <gmock/gmock-matchers.h>
#include <google/protobuf/text_format.h>
#include <gtest/gtest.h>

#include "PrivateDnsConfiguration.h"
@@ -38,6 +38,7 @@

namespace android::net {

using android::base::Result;
using android::base::StringPrintf;
using android::netdutils::ScopedAddrinfo;
using std::chrono::milliseconds;
@@ -48,17 +49,19 @@ enum class DnsProtocol { CLEARTEXT, TLS };
// TODO: Consider moving to packages/modules/DnsResolver/tests/resolv_test_utils.h.
constexpr unsigned int MAXPACKET = 8 * 1024;

const std::string kTestDataPath = android::base::GetExecutableDirectory() + "/testdata/";
// The testdata/pb/*.pb are generated from testdata/*.pbtext.
// TODO: Generate .pb files via precompiler.
const std::string kTestDataPath = android::base::GetExecutableDirectory() + "/testdata/pb/";
const std::vector<std::string> kGoldFilesGetAddrInfo = {
        "getaddrinfo.topsite.google.pbtxt",    "getaddrinfo.topsite.youtube.pbtxt",
        "getaddrinfo.topsite.amazon.pbtxt",    "getaddrinfo.topsite.yahoo.pbtxt",
        "getaddrinfo.topsite.facebook.pbtxt",  "getaddrinfo.topsite.reddit.pbtxt",
        "getaddrinfo.topsite.wikipedia.pbtxt", "getaddrinfo.topsite.ebay.pbtxt",
        "getaddrinfo.topsite.netflix.pbtxt",   "getaddrinfo.topsite.bing.pbtxt"};
const std::vector<std::string> kGoldFilesGetAddrInfoTls = {"getaddrinfo.tls.topsite.google.pbtxt"};
const std::vector<std::string> kGoldFilesGetHostByName = {"gethostbyname.topsite.youtube.pbtxt"};
        "getaddrinfo.topsite.google.pb",    "getaddrinfo.topsite.youtube.pb",
        "getaddrinfo.topsite.amazon.pb",    "getaddrinfo.topsite.yahoo.pb",
        "getaddrinfo.topsite.facebook.pb",  "getaddrinfo.topsite.reddit.pb",
        "getaddrinfo.topsite.wikipedia.pb", "getaddrinfo.topsite.ebay.pb",
        "getaddrinfo.topsite.netflix.pb",   "getaddrinfo.topsite.bing.pb"};
const std::vector<std::string> kGoldFilesGetAddrInfoTls = {"getaddrinfo.tls.topsite.google.pb"};
const std::vector<std::string> kGoldFilesGetHostByName = {"gethostbyname.topsite.youtube.pb"};
const std::vector<std::string> kGoldFilesGetHostByNameTls = {
        "gethostbyname.tls.topsite.youtube.pbtxt"};
        "gethostbyname.tls.topsite.youtube.pb"};

// Fixture test class definition.
class TestBase : public ::testing::Test {
@@ -123,14 +126,18 @@ class TestBase : public ::testing::Test {
        return false;
    }

    GoldTest ToProto(const std::string& file) {
        // Convert the testing configuration from .pbtxt file to proto.
        std::string file_content;
        const std::string file_name = kTestDataPath + file;
        EXPECT_TRUE(android::base::ReadFileToString(file_name, &file_content))
                << "Failed to read " << file_name << ": " << strerror(errno);
    Result<GoldTest> ToProto(const std::string& filename) {
        // Convert the testing configuration from binary .pb file to proto.
        std::string content;
        const std::string path = kTestDataPath + filename;

        bool ret = android::base::ReadFileToString(path, &content);
        if (!ret) return Errorf("Read {} failed: {}", path, strerror(errno));

        android::net::GoldTest goldtest;
        EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(file_content, &goldtest));
        ret = goldtest.ParseFromString(content);
        if (!ret) return Errorf("Parse {} failed", path);

        return goldtest;
    }

@@ -417,7 +424,9 @@ TEST_P(ResolvGoldTest, GoldData) {
    }

    // Read test configuration from proto text file to proto.
    const auto goldtest = ToProto(file);
    const Result<GoldTest> result = ToProto(file);
    ASSERT_TRUE(result.ok()) << result.error().message();
    const GoldTest& goldtest = result.value();

    // Register packet mappings (query, response) from proto.
    SetupMappings(goldtest, dns);
Loading