1cc_test_library {
2    name: "libnetd_test_resolv_utils",
3    defaults: ["netd_defaults", "resolv_test_defaults"],
4    srcs: [
5        "resolv_test_utils.cpp",
6    ],
7    header_libs: [
8        "libnetd_resolv_headers",
9    ],
10    shared_libs: [
11        "libutils",
12    ],
13    static_libs: [
14        "netd_aidl_interface-ndk_platform",
15        "libnetd_test_dnsresponder_ndk",
16        "libnetdutils",
17        "libgmock",
18    ],
19}
20
21cc_library_host_static {
22    name: "golddata_proto_host",
23    proto: {
24        export_proto_headers: true,
25        type: "full",
26    },
27    srcs: [
28        "golddata.proto",
29    ],
30}
31
32cc_binary_host {
33    name: "resolv_gold_test_pbtxt2pb_host",
34    cflags: [
35        "-Wall",
36        "-Werror",
37    ],
38    srcs: ["pbtxt2pb_converter_host.cpp"],
39    static_libs: [
40        "golddata_proto_host",
41        "libc++fs",
42        "libprotobuf-cpp-full",
43    ],
44}
45
46genrule {
47    name: "resolv_gold_test_pbtxt2pb",
48    tools: [
49        "resolv_gold_test_pbtxt2pb_host",
50        "soong_zip",
51    ],
52    srcs: ["testdata/*.pbtxt"],
53    // convert .pbtxt to .pb files; zip them as a single pb.zip.
54    cmd: "mkdir $(genDir)/pb && for fname in $(in); " +
55         "do $(location resolv_gold_test_pbtxt2pb_host) --in_file=$$fname " +
56         "--out_dir=$(genDir)/pb; done && " +
57         "$(location soong_zip) -o $(out) -C $(genDir)/pb -D $(genDir)/pb",
58    out: ["testdata/pb.zip"],
59}
60
61cc_library_static {
62    name: "golddata_proto",
63    defaults: ["netd_defaults"],
64    proto: {
65        export_proto_headers: true,
66        type: "lite",
67    },
68    srcs: [
69        "golddata.proto",
70    ],
71    tidy: false,
72}
73
74cc_test {
75    name: "resolv_gold_test",
76    test_suites: ["general-tests", "mts"],
77    require_root: true,
78    // b/151392634, this is a workaround because MTS
79    // can not handle the test with testdata correctly.
80    // TODO: Remove the xml after MTS fixing the problem.
81    test_config: "resolv_gold_test_config.xml",
82    defaults: ["netd_defaults", "resolv_test_defaults"],
83    data: [":resolv_gold_test_pbtxt2pb"],
84    srcs: [
85        "resolv_gold_test.cpp",
86    ],
87    header_libs: [
88        "libnetd_client_headers",
89    ],
90    shared_libs: [
91        "libcrypto",
92        "libbinder_ndk",
93        "libssl",
94    ],
95    static_libs: [
96        "dnsresolver_aidl_interface-unstable-ndk_platform",
97        "golddata_proto",
98        "libgmock",
99        "libnetd_resolv",
100        "libnetd_test_dnsresponder_ndk",
101        "libnetd_test_resolv_utils",
102        "libnetdutils",
103        "libprotobuf-cpp-lite",
104        "netd_aidl_interface-ndk_platform",
105        "netd_event_listener_interface-ndk_platform",
106        "server_configurable_flags",
107        "stats_proto",
108    ],
109    // MTS test binary can't be built under compile_multilib = "both" and having test data.
110    // However, MTS coverage requires 32 bit test binary to run.
111    compile_multilib: "32",
112}
113
114cc_test {
115    name: "resolv_stress_test",
116    test_suites: ["general-tests", "mts"],
117    // This won't work with test_config
118    // require_root: true,
119    // TODO: Remove resolv_test_mts_coverage_defaults after mts coverage switched to 64-bit device.
120    defaults: ["netd_defaults", "resolv_test_defaults", "resolv_test_mts_coverage_defaults"],
121    srcs: [
122        "resolv_stress_test.cpp",
123    ],
124    header_libs: [
125        "libnetd_resolv_headers",
126    ],
127    shared_libs: [
128        "libbinder_ndk",
129        "libnetd_client",
130    ],
131    static_libs: [
132        "dnsresolver_aidl_interface-ndk_platform",
133        "libgmock",
134        "libnetd_test_dnsresponder_ndk",
135        "libnetd_test_resolv_utils",
136        "libnetdutils",
137        "libutils",
138        "netd_event_listener_interface-ndk_platform",
139        "netd_aidl_interface-ndk_platform",
140    ],
141}
142
143cc_test {
144    name: "resolv_integration_test",
145    test_suites: ["general-tests", "mts"],
146    require_root: true,
147    test_config_template: ":resolv_test_config_template",
148    defaults: ["netd_defaults", "resolv_test_defaults"],
149    tidy: false, // cuts test build time by > 1m30s
150    srcs: [
151        "dns_responder/dns_responder.cpp",
152        "dnsresolver_binder_test.cpp",
153        "resolv_integration_test.cpp",
154    ],
155    header_libs: [
156        "dnsproxyd_protocol_headers",
157        "libnetd_resolv_headers",
158    ],
159    // TODO: make static link libc++ work.
160    //stl: "libc++_static",
161    shared_libs: [
162        "libbinder_ndk",
163        "libnetd_client",
164    ],
165    static_libs: [
166        "dnsresolver_aidl_interface-unstable-ndk_platform",
167        "libbpf_android",
168        "libcrypto_static",
169        "libgmock",
170        "libnetd_test_dnsresponder_ndk",
171        "libnetd_test_metrics_listener",
172        "libnetd_test_resolv_utils",
173        "libnetd_test_tun_interface",
174        "libnetd_test_utils",
175        "libnetdutils",
176        "libssl",
177        "libutils",
178        "netd_aidl_interface-ndk_platform",
179        "netd_event_listener_interface-ndk_platform",
180    ],
181    // This test talks to the DnsResolver module over a binary protocol on a socket, so keep it as
182    // multilib setting is worth because we might be able to get some coverage for the case where
183    // 32bit apps talk to 64bit resolvers.
184    compile_multilib: "both",
185    multilib: {
186        lib32: {
187            suffix: "32",
188        },
189        lib64: {
190            suffix: "64",
191        },
192    },
193}
194
195cc_test_library {
196    name: "resolv_stats_test_utils",
197    srcs: [
198        "resolv_stats_test_utils.cpp"
199    ],
200    defaults: ["netd_defaults", "resolv_test_defaults"],
201    export_include_dirs: ["."],
202    static_libs: [
203        "libgmock",
204        "libnetdutils",
205        "libprotobuf-cpp-lite",
206        "stats_proto",
207    ],
208}
209
210cc_test {
211    name: "resolv_stats_test_utils_test",
212    srcs: [
213        "resolv_stats_test_utils_test.cpp",
214    ],
215    defaults: ["netd_defaults", "resolv_test_defaults"],
216    test_suites: ["general-tests"],
217    test_mainline_modules: ["CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex"],
218    static_libs: [
219        "libgmock",
220        "libprotobuf-cpp-lite",
221        "resolv_stats_test_utils",
222        "stats_proto",
223    ],
224}
225